This commit is contained in:
2018-06-07 16:30:31 +02:00
parent 0d2665bac5
commit d67283a560
4 changed files with 208 additions and 0 deletions

31
zabbix-whois-check.py Normal file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env python3
# checks when a domain is going to expire
# and sends the time to zabbix
# new version that reads from a json file
import sys
import os
import json
import whois
from pyzabbix import ZabbixMetric, ZabbixSender
wwwhost = sys.argv[1]
dir_path = os.path.dirname(os.path.realpath(__file__))
with open(dir_path+'/whois/'+wwwhost+'.json', 'r') as read_file:
domains = json.load(read_file)
for domain in domains['domains']:
w = whois.whois(domain)
if isinstance(w.expiration_date, list):
packet = ZabbixMetric(wwwhost, 'domain.expiry['+domain+']', w.expiration_date[0].timestamp()),
else:
packet = ZabbixMetric(wwwhost, 'domain.expiry['+domain+']', w.expiration_date.timestamp()),
result = ZabbixSender(use_config=True).send(packet)
## some tests
#print(w)
#print(w.domain_name, w.expiration_date)
#print(packet)
#print(result)