This repository was archived by the owner on Apr 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathcheck_graylog2_server
More file actions
executable file
·52 lines (44 loc) · 1.48 KB
/
check_graylog2_server
File metadata and controls
executable file
·52 lines (44 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
"""check_graylog2_server
Usage:
check_graylog2_server -U <url> [ -i <inputs> ]
check_graylog2_server -h | --help
Options:
-h --help Show this screen.
-U --url Graylog2 API URL, including basic auth.
"""
from docopt import docopt
import requests, json, sys
def main():
args = docopt(__doc__)
try:
url = '%s/count/total' % ( args['<url>'] )
graylog_request = requests.get( url )
graylog_results = json.loads( graylog_request.content )
total_events = int(graylog_results['events'])
except:
e = sys.exc_info()
print "CRITICAL error querying Graylog2 for count/total: %s" % e
exit(2)
try:
url = '%s/system/inputs' % ( args['<url>'] )
graylog_request = requests.get( url )
graylog_results = json.loads( graylog_request.content )
total_inputs = int(graylog_results['total'])
except:
e = sys.exc_info()
print "CRITICAL error querying Graylog2 for system/inputs: %s" % e
exit(2)
try:
url = '%s/system/throughput' % ( args['<url>'] )
graylog_request = requests.get( url )
graylog_results = json.loads( graylog_request.content )
throughput = int(graylog_results['throughput'])
except:
e = sys.exc_info()
print "CRITICAL error querying Graylog2 for system/throughput: %s" % e
exit(2)
print "OK Graylog2 server is healthy: %d events/sec|total_events=%d,inputs=%d,throughput=%d" % ( throughput, total_events, total_inputs, throughput )
exit(0)
if __name__ == "__main__":
main()