Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/nagios/files/check_connections

Issue 11773028: Added connections and memory monitoring (Closed)
Patch Set: Created Sept. 20, 2013, 10:25 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
3 import subprocess
4
5 if __name__ == "__main__":
6 process_output = subprocess.check_output(["netstat", "-nt"])
7
8 established = 0
9 opening = 0
10 closing = 0
11 for line in process_output.splitlines():
12 data = line.split()
13 if len(data) < 6:
14 continue
15
16 status = data[5]
17 if status == "ESTABLISHED":
18 established += 1
19 elif status == "SYN_RECV":
20 opening += 1
21 elif status in ("FIN_WAIT1", "FIN_WAIT2", "CLOSE_WAIT", "LAST_ACK", "CLOSING "):
22 closing += 1
23
24 status = "established %i opening %i closing %i" % (established, opening, closi ng)
25
26 perfdata = "established=%i opening=%i closing=%i" % (established, opening, clo sing)
27
28 output = "%s|%s" % (status, perfdata)
29
30 print "OK - " + output
OLDNEW

Powered by Google App Engine
This is Rietveld