From d53d93c87311e2fd1975a6a2de219b633cf24aea Mon Sep 17 00:00:00 2001 From: Alarig Le Lay Date: Fri, 19 Jul 2024 10:45:21 +0200 Subject: [PATCH] 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 --- check_domain_expiration_rdap.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/check_domain_expiration_rdap.py b/check_domain_expiration_rdap.py index 352b38c..5213a79 100755 --- a/check_domain_expiration_rdap.py +++ b/check_domain_expiration_rdap.py @@ -15,21 +15,21 @@ import requests_cache _log = logging.getLogger('nagiosplugin') -list2dict = [] - -session = requests_cache.CachedSession( - '/tmp/iana_rdap_cache', - cache_control=True -) -req = session.get('https://data.iana.org/rdap/dns.json') -for list_of_list in req.json()['services']: - k,v = list_of_list - for x in k: - list2dict.append({'name':x, 'url':v[0]}) - -df = pandas.DataFrame(list2dict) - def expiration(domain): + list2dict = [] + + session = requests_cache.CachedSession( + '/tmp/iana_rdap_cache', + cache_control=True + ) + req = session.get('https://data.iana.org/rdap/dns.json') + for list_of_list in req.json()['services']: + k,v = list_of_list + for x in k: + list2dict.append({'name':x, 'url':v[0]}) + + df = pandas.DataFrame(list2dict) + domain = pyunycode.convert(domain) tld = domain.split('.')[-1] try: