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

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

Issue 29459594: Noissue - Add missing parameter for getmacaddress function (Closed)
Patch Set: Created June 8, 2017, 3:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import os, re, subprocess, sys, socket, struct, fcntl 3 import os, re, subprocess, sys, socket, struct, fcntl
4 4
5 INTERVAL = 5 5 INTERVAL = 5
6 6
7 def format_bandwidth(bits): 7 def format_bandwidth(bits):
8 if bits >= 1000000: 8 if bits >= 1000000:
9 return "%.2f Mbit/s" % (bits / 1000000) 9 return "%.2f Mbit/s" % (bits / 1000000)
10 elif bits >= 1000: 10 elif bits >= 1000:
(...skipping 16 matching lines...) Expand all
27 sys.exit(0) 27 sys.exit(0)
28 28
29 (warn, crit) = sys.argv[1:3] 29 (warn, crit) = sys.argv[1:3]
30 warn = int(sys.argv[1]) 30 warn = int(sys.argv[1])
31 crit = int(sys.argv[2]) 31 crit = int(sys.argv[2])
32 nic = str(sys.argv[3]) 32 nic = str(sys.argv[3])
33 33
34 process = subprocess.Popen( 34 process = subprocess.Popen(
35 ["sudo", "tcpdump", "-q", "-s", "64", "-G", str(INTERVAL), "-W", "1", "-w", "-"], 35 ["sudo", "tcpdump", "-q", "-s", "64", "-G", str(INTERVAL), "-W", "1", "-w", "-"],
36 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 36 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
37 mac = getmacaddress() 37 mac = getmacaddress(nic)
38 38
39 total = {"rx": 0, "tx": 0} 39 total = {"rx": 0, "tx": 0}
40 http = {"rx": 0, "tx": 0} 40 http = {"rx": 0, "tx": 0}
41 https = {"rx": 0, "tx": 0} 41 https = {"rx": 0, "tx": 0}
42 ssh = {"rx": 0, "tx": 0} 42 ssh = {"rx": 0, "tx": 0}
43 dns = {"rx": 0, "tx": 0} 43 dns = {"rx": 0, "tx": 0}
44 other = {"rx": 0, "tx": 0} 44 other = {"rx": 0, "tx": 0}
45 other_detailed = {} 45 other_detailed = {}
46 46
47 # See http://wiki.wireshark.org/Development/LibpcapFileFormat for libpcap form at description 47 # See http://wiki.wireshark.org/Development/LibpcapFileFormat for libpcap form at description
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 if total["rx"] >= crit or total["tx"] >= crit: 133 if total["rx"] >= crit or total["tx"] >= crit:
134 print "CRITICAL - " + output 134 print "CRITICAL - " + output
135 sys.exit(2) 135 sys.exit(2)
136 136
137 if total["rx"] >= warn or total["tx"] >= warn: 137 if total["rx"] >= warn or total["tx"] >= warn:
138 print "WARNING - " + output 138 print "WARNING - " + output
139 sys.exit(1) 139 sys.exit(1)
140 140
141 print "OK - " + output 141 print "OK - " + output
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld