Move initial JSON fetching into the expiration check function
It will avoid fetching it just to print the help Signed-off-by: Alarig Le Lay <alarig@swordarmor.fr>
This commit is contained in:
parent
9ff18d29a8
commit
d53d93c873
|
@ -15,21 +15,21 @@ import requests_cache
|
||||||
|
|
||||||
_log = logging.getLogger('nagiosplugin')
|
_log = logging.getLogger('nagiosplugin')
|
||||||
|
|
||||||
list2dict = []
|
def expiration(domain):
|
||||||
|
list2dict = []
|
||||||
|
|
||||||
session = requests_cache.CachedSession(
|
session = requests_cache.CachedSession(
|
||||||
'/tmp/iana_rdap_cache',
|
'/tmp/iana_rdap_cache',
|
||||||
cache_control=True
|
cache_control=True
|
||||||
)
|
)
|
||||||
req = session.get('https://data.iana.org/rdap/dns.json')
|
req = session.get('https://data.iana.org/rdap/dns.json')
|
||||||
for list_of_list in req.json()['services']:
|
for list_of_list in req.json()['services']:
|
||||||
k,v = list_of_list
|
k,v = list_of_list
|
||||||
for x in k:
|
for x in k:
|
||||||
list2dict.append({'name':x, 'url':v[0]})
|
list2dict.append({'name':x, 'url':v[0]})
|
||||||
|
|
||||||
df = pandas.DataFrame(list2dict)
|
df = pandas.DataFrame(list2dict)
|
||||||
|
|
||||||
def expiration(domain):
|
|
||||||
domain = pyunycode.convert(domain)
|
domain = pyunycode.convert(domain)
|
||||||
tld = domain.split('.')[-1]
|
tld = domain.split('.')[-1]
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue