Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
check_nginx_status
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Perun
deployment
ProxyIdP
check_nginx_status
Commits
ff38153b
Commit
ff38153b
authored
6 years ago
by
lazydog
Browse files
Options
Downloads
Patches
Plain Diff
cachet_shodan_credits
parent
80d9e41c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Readme.md
+7
-2
7 additions, 2 deletions
Readme.md
cachet_shodan_credits
+133
-0
133 additions, 0 deletions
cachet_shodan_credits
check_shodan_credits
+147
-0
147 additions, 0 deletions
check_shodan_credits
with
287 additions
and
2 deletions
Readme.md
+
7
−
2
View file @
ff38153b
# Dogtown-Nagios-Plugins
(c) copyright 2008-201
7
dogtown@mare-system.de
(c) copyright 2008-201
8
dogtown@mare-system.de
these plugins are developed and tested using Debian, SLES
these plugins are developed and tested using FreeBSD, Debian, SLES
and RedHat but should work on any modern Unix.
for help see $check_plugin.Readme, if available, or
...
...
@@ -17,6 +18,10 @@ execute $check_plugin -h
-
check_mdstat - check status on linux softraid, also alerts on autmated rebuilds
-
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
## obsolete / not maintained anymore
...
...
This diff is collapsed.
Click to expand it.
cachet_shodan_credits
0 → 100755
+
133
−
0
View file @
ff38153b
#!/usr/bin/env python
# (c) copyright 2018 dogtown@mare-system.de
#
# License: GPL v2
#
# dload: https://bitbucket.org/maresystem/dogtown-nagios-plugins
#
#
# requirements:
# - python-requests, python-simplejson
#
#
version
=
"
0.0.5.r2 - alpha - 2018-05-20
"
import
getopt
,
sys
,
time
,
os
,
string
import
requests
import
simplejson
as
json
import
re
def
check_shodan_help
():
print
"""
# usage: $0 -k YOUR_SHODAN_API_KEY -c YOUR_CACHET_KEY -m YOUR_CACHET_METRIC -u YOU_CACHET_URL
"""
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"
D:k:w:c:m:u:h
"
,
[
"
help
"
,
"
script
"
,
"
debug
"
])
except
getopt
.
GetoptError
,
err
:
# print help information and exit:
print
str
(
err
)
# will print something like "option -a not recognized"
check_shodan_help
()
sys
.
exit
(
2
)
k
=
c
=
m
=
u
=
0
for
o
,
a
in
opts
:
#print "o :: " + o + " <--> a: " + a
if
o
in
(
"
-h
"
,
"
--help
"
):
check_shodan_help
()
sys
.
exit
()
elif
o
in
(
"
-k
"
,
"
--key
"
):
k
=
a
elif
o
in
(
"
-c
"
,
"
--critical
"
):
c
=
a
elif
o
in
(
"
-m
"
,
"
--metric
"
):
m
=
a
elif
o
in
(
"
-u
"
,
"
--cachet_url
"
):
u
=
a
else
:
check_shodan_help
()
sys
.
exit
(
2
)
if
k
==
0
or
c
==
0
or
m
==
0
or
u
==
0
:
print
(
"""
ERROR you need to give all values (k,c,m,u)
"""
)
check_shodan_help
()
sys
.
exit
(
2
)
url
=
"
https://api.shodan.io/account/profile?key=%s
"
%
k
shodan_answer
=
requests
.
get
(
url
)
if
shodan_answer
.
status_code
!=
200
:
print
"
ERROR. cannot load shodan-status
"
print
"
status-code: %s
"
%
shodan_answer
.
status_code
print
"
text: %s
"
%
shodan_answer
.
text
sys
.
exit
(
2
)
sj
=
json
.
loads
(
shodan_answer
.
text
)
creditz
=
sj
[
"
credits
"
]
url
=
"
%s/api/v1/metrics/%s/points
"
%
(
u
,
m
)
headers
=
{
"
X-Cachet-Token
"
:
c
,
"
Content-Type
"
:
"
application/json;
"
}
data
=
{
"
value
"
:
creditz
}
r
=
requests
.
post
(
url
,
headers
=
headers
,
json
=
data
)
if
r
.
status_code
!=
200
:
print
(
"
CachetOutput Error (status: %s)
"
%
r
.
status_code
)
print
(
r
.
text
)
sys
.
exit
(
2
)
else
:
# log here
pass
This diff is collapsed.
Click to expand it.
check_shodan_credits
0 → 100755
+
147
−
0
View file @
ff38153b
#!/usr/bin/env python
# (c) copyright 2018 dogtown@mare-system.de
#
# License: GPL v2
#
# dload: https://bitbucket.org/maresystem/dogtown-nagios-plugins
#
#
# requirements:
# - python-requests, python-simplejson
#
#
version
=
"
0.0.5.r2 - alpha - 2018-05-20
"
import
getopt
,
sys
,
time
,
os
,
string
import
requests
import
simplejson
as
json
import
re
# run-defaults
debug
=
"
no
"
ctype
=
"
status
"
# return-defaults
return_d
=
{}
return_d
[
"
status
"
]
=
"
UNKNOWN
"
return_d
[
"
exit
"
]
=
3
return_d
[
"
text
"
]
=
"
no return (default)
"
return_d
[
"
perfdata
"
]
=
"
none
"
def
return_exit
(
rd
):
print
"
ShodanCredits %s %s %s %s
"
%
(
D
,
rd
[
"
status
"
],
rd
[
"
text
"
],
rd
[
"
perfdata
"
])
sys
.
exit
(
rd
[
"
exit
"
])
def
check_shodan_help
():
print
"""
# usage: $0 -k YOUR_API_KEY -d Description [ -w INT [ -c INT ]]
"""
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"
D:k:w:c:h
"
,
[
"
help
"
,
"
script
"
,
"
debug
"
])
except
getopt
.
GetoptError
,
err
:
# print help information and exit:
print
str
(
err
)
# will print something like "option -a not recognized"
check_shodan_help
()
sys
.
exit
(
2
)
w
=
10
c
=
2
k
=
0
D
=
""
for
o
,
a
in
opts
:
#print "o :: " + o + " <--> a: " + a
if
o
in
(
"
-h
"
,
"
--help
"
):
check_shodan_help
()
sys
.
exit
()
elif
o
in
(
"
-k
"
,
"
--key
"
):
k
=
a
elif
o
in
(
"
-w
"
,
"
--warning
"
):
w
=
int
(
a
)
elif
o
in
(
"
-c
"
,
"
--critical
"
):
c
=
int
(
a
)
elif
o
in
(
"
-D
"
,
"
--Description
"
):
D
=
a
else
:
check_shodan_help
()
sys
.
exit
(
2
)
if
k
==
0
:
print
(
"""
ERROR you need to give an API-key
"""
)
check_shodan_help
()
sys
.
exit
(
2
)
url
=
"
https://api.shodan.io/account/profile?key=%s
"
%
k
shodan_answer
=
requests
.
get
(
url
)
if
shodan_answer
.
status_code
!=
200
:
return_d
[
"
status
"
]
=
"
Error
"
return_d
[
"
exit
"
]
=
3
return_d
[
"
text
"
]
=
"
Error in API-Call, HTTPstatus: %s
"
%
shodan_answer
.
status_code
return_d
[
"
perfdata
"
]
=
shodan_answer
.
text
return_exit
(
return_d
)
sj
=
json
.
loads
(
shodan_answer
.
text
)
if
sj
[
"
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
"
]
elif
sj
[
"
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
"
]
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_exit
(
return_d
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment