Skip to content
Snippets Groups Projects
Commit 6a6fdaf8 authored by lazydog's avatar lazydog
Browse files

shodan query credits now the right api-endpoint

parent ff38153b
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ execute $check_plugin -h ...@@ -19,7 +19,7 @@ execute $check_plugin -h
- check_selenium - extract runtime/status-values from selenium-tests - check_selenium - extract runtime/status-values from selenium-tests
- check_redis - checks and monitors values on a redis_server - check_redis - checks and monitors values on a redis_server
- check_shodan_credits - checks how many credits available on a certain account - 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
......
...@@ -82,7 +82,7 @@ ERROR you need to give all values (k,c,m,u) ...@@ -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) shodan_answer = requests.get(url)
...@@ -93,7 +93,7 @@ if shodan_answer.status_code != 200: ...@@ -93,7 +93,7 @@ if shodan_answer.status_code != 200:
sys.exit(2) sys.exit(2)
sj = json.loads(shodan_answer.text) sj = json.loads(shodan_answer.text)
creditz = sj["credits"] creditz = sj["query_credits"]
url = "%s/api/v1/metrics/%s/points" % (u, m) url = "%s/api/v1/metrics/%s/points" % (u, m)
headers = { headers = {
......
...@@ -10,6 +10,34 @@ ...@@ -10,6 +10,34 @@
# - python-requests, python-simplejson # - 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 ...@@ -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) shodan_answer = requests.get(url)
if shodan_answer.status_code != 200: if shodan_answer.status_code != 200:
...@@ -111,23 +139,23 @@ if shodan_answer.status_code != 200: ...@@ -111,23 +139,23 @@ if shodan_answer.status_code != 200:
return_exit(return_d) return_exit(return_d)
sj = json.loads(shodan_answer.text) sj = json.loads(shodan_answer.text)
if sj["credits"] < c: if sj["query_credits"] < c:
return_d["status"]="Critical" return_d["status"]="Critical"
return_d["exit"]=2 return_d["exit"]=2
return_d["text"]="Critical, Credits: %s" % sj["credits"] return_d["text"]="Critical, Credits: %s" % sj["query_credits"]
return_d["perfdata"]="| credits: %s;" % sj["credits"] return_d["perfdata"]="| credits: %s;" % sj["query_credits"]
elif sj["credits"] < w: elif sj["query_credits"] < w:
return_d["status"]="Warning" return_d["status"]="Warning"
return_d["exit"]=1 return_d["exit"]=1
return_d["text"]="Warning, Credits: %s" % sj["credits"] return_d["text"]="Warning, Credits: %s" % sj["query_credits"]
return_d["perfdata"]="| credits: %s;" % sj["credits"] return_d["perfdata"]="| credits: %s;" % sj["query_credits"]
else: else:
return_d["status"]="Ok" return_d["status"]="Ok"
return_d["exit"]=0 return_d["exit"]=0
return_d["text"]="All OK, Credits: %s" % sj["credits"] return_d["text"]="All OK, Credits: %s" % sj["query_credits"]
return_d["perfdata"]="| credits: %s;" % sj["credits"] return_d["perfdata"]="| credits: %s;" % sj["query_credits"]
return_exit(return_d) return_exit(return_d)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment