diff --git a/Readme.md b/Readme.md index c3df0aff8a372d18a07f52e43098590404ccf3bb..c6dc0aa8cb288803916fbb054c26caa9b5d13d11 100644 --- a/Readme.md +++ b/Readme.md @@ -19,7 +19,7 @@ execute $check_plugin -h - check_selenium - extract runtime/status-values from selenium-tests - check_redis - checks and monitors values on a redis_server - check_shodan_credits - checks how many credits available on a certain account -- cachet_shodan_credits - sends status-report to cahcet-metric +- cachet_shodan_credits - sends status-report to cachet-metric diff --git a/cachet_shodan_credits b/cachet_shodan_credits index bd86d379802e8a5c52a1b0e109aed39fc764c0ee..db306b1b2d2c3e63aa98cf710ba4a79e1ad76c21 100755 --- a/cachet_shodan_credits +++ b/cachet_shodan_credits @@ -82,7 +82,7 @@ ERROR you need to give all values (k,c,m,u) -url = "https://api.shodan.io/account/profile?key=%s" % k +url = "https://api.shodan.io/api-info?key=%s" % k shodan_answer = requests.get(url) @@ -93,7 +93,7 @@ if shodan_answer.status_code != 200: sys.exit(2) sj = json.loads(shodan_answer.text) -creditz = sj["credits"] +creditz = sj["query_credits"] url = "%s/api/v1/metrics/%s/points" % (u, m) headers = { diff --git a/check_shodan_credits b/check_shodan_credits index d76b1d1cea9afc94669577cc1b812a1aaca2a085..2647f435dc42f7751dbcd04527b99997ad7e951c 100755 --- a/check_shodan_credits +++ b/check_shodan_credits @@ -10,6 +10,34 @@ # - python-requests, python-simplejson # # +# +# checkcommands.cfg +# +# +# +#~ define command { + + #~ command_name check_shodan_credits + #~ command_line $USER1$/check_shodan_credits -k $ARG1$ -D $ARG2$ -w $ARG3$ -c $ARG4$ + +#~ } + + +#~ services.cfg +#~ # +#~ # +#~ define service { + #~ hostname EXTERNAL_API + #~ service_description check_shodan_credits_dev + #~ check_command check_shodan_credits!DEV!SHODAN_API_KEY!10!2 + #~ use cysmo-service + #~ register 1 + #~ notifications_enabled 1 + #~ normal_check_interval 10 + #~ retry_check_interval 5 + #~ max_check_attempts 3 + +#~ } @@ -100,7 +128,7 @@ ERROR you need to give an API-key -url = "https://api.shodan.io/account/profile?key=%s" % k +url = "https://api.shodan.io/api-info?key=%s" % k shodan_answer = requests.get(url) if shodan_answer.status_code != 200: @@ -111,23 +139,23 @@ if shodan_answer.status_code != 200: return_exit(return_d) sj = json.loads(shodan_answer.text) -if sj["credits"] < c: +if sj["query_credits"] < c: return_d["status"]="Critical" return_d["exit"]=2 - return_d["text"]="Critical, Credits: %s" % sj["credits"] - return_d["perfdata"]="| credits: %s;" % sj["credits"] + return_d["text"]="Critical, Credits: %s" % sj["query_credits"] + return_d["perfdata"]="| credits: %s;" % sj["query_credits"] -elif sj["credits"] < w: +elif sj["query_credits"] < w: return_d["status"]="Warning" return_d["exit"]=1 - return_d["text"]="Warning, Credits: %s" % sj["credits"] - return_d["perfdata"]="| credits: %s;" % sj["credits"] + return_d["text"]="Warning, Credits: %s" % sj["query_credits"] + return_d["perfdata"]="| credits: %s;" % sj["query_credits"] else: return_d["status"]="Ok" return_d["exit"]=0 - return_d["text"]="All OK, Credits: %s" % sj["credits"] - return_d["perfdata"]="| credits: %s;" % sj["credits"] + return_d["text"]="All OK, Credits: %s" % sj["query_credits"] + return_d["perfdata"]="| credits: %s;" % sj["query_credits"] return_exit(return_d)