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

39
zabbix-whois-discovery.py Normal file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env python3
# read domains from a json array
# and feed them into zabbix
import sys
import os
import json
from pyzabbix import ZabbixMetric, ZabbixSender
wwwhost = sys.argv[1]
asdf = ''
idx = 0
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 idx, thing in enumerate(domains['domains']):
if idx == 0:
asdf += '{"{#WHOISDOMAIN}":"'+thing+'"}'
else:
asdf += ',{"{#WHOISDOMAIN}":"'+thing+'"}'
done = '{"data":['+asdf+']}'
packet = ZabbixMetric(wwwhost, 'domain.expiry.item', done),
result = ZabbixSender(use_config=True).send(packet)
## some tests
#print(done)
#print(packet)
#print(result)
## another test
#f = open('/tmp/zabbix-whois.txt', 'w')
#f.write(done)
#f.close()