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

Unified Diff: modules/nagios/files/check_bandwidth

Issue 29458590: Noissue - Use parameter for network interface in the check_bandwidth nagios plugin (Closed)
Patch Set: For comment 2 Created June 8, 2017, 1:13 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | modules/nagios/templates/nrpe.cfg.erb » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/nagios/files/check_bandwidth
===================================================================
--- a/modules/nagios/files/check_bandwidth
+++ b/modules/nagios/files/check_bandwidth
@@ -12,23 +12,24 @@
else:
return "%.2f bit/s" % bits
-def getmacaddress():
+def getmacaddress(nic="eth0"):
# See man netdevice for the request structure: it has to start with 16 bytes
# containing the interface name, the OS will write 8 bytes after that (2 bytes
# family name and 6 bytes actual MAC address).
s = socket.socket()
SIOCGIFHWADDR = 0x8927 # see man ioctl_list
- return fcntl.ioctl(s.fileno(), SIOCGIFHWADDR, struct.pack("24s", "eth0"))[18:24]
+ return fcntl.ioctl(s.fileno(), SIOCGIFHWADDR, struct.pack("24s", nic))[18:24]
if __name__ == "__main__":
- if len(sys.argv) != 3:
+ if len(sys.argv) != 4:
script_name = os.path.basename(sys.argv[0])
- print "Usage: %s WARN CRIT" % script_name
+ print "Usage: %s WARN CRIT NIC" % script_name
sys.exit(0)
(warn, crit) = sys.argv[1:3]
warn = int(sys.argv[1])
crit = int(sys.argv[2])
+ nic = str(sys.argv[3])
process = subprocess.Popen(
["sudo", "tcpdump", "-q", "-s", "64", "-G", str(INTERVAL), "-W", "1", "-w", "-"],
« no previous file with comments | « no previous file | modules/nagios/templates/nrpe.cfg.erb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld