pysnmp

Sending SNMP Traps containing custom data

孤人 提交于 2019-12-01 19:50:37
A client has requested that instead of email alerts that we send SNMP Traps to their Nagios server instead. The only thing I knew about SNMP before yesterday was that it sounded like an acronym, so please excuse (and correct me on) any misconceptions about it that I may have. The only information that needs to be sent in the trap pertains to data about the event we are alerting our client about, which is just a couple of values pulled from our database. Needless to say these aren't in any sort of MIB, nor do they have any OIDs, and this is where I'm having trouble finding answers. I can't

How can I check the data transfer on a network interface in python?

大憨熊 提交于 2019-11-30 08:44:10
问题 There is a socket method for getting the IP of a given network interface: import socket import fcntl import struct def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24]) Which returns the following: >>> get_ip_address('lo') '127.0.0.1' >>> get_ip_address('eth0') '38.113.228.130' Is there a similar method to return the network transfer of that interface? I

How can I check the data transfer on a network interface in python?

你说的曾经没有我的故事 提交于 2019-11-29 07:28:49
There is a socket method for getting the IP of a given network interface: import socket import fcntl import struct def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24]) Which returns the following: >>> get_ip_address('lo') '127.0.0.1' >>> get_ip_address('eth0') '38.113.228.130' Is there a similar method to return the network transfer of that interface? I know I can read /proc/net/dev but I'd love a socket method. Mike Pennington The best way to poll