File: //usr/lib/python2.7/site-packages/lap/virtuallo.py
#!/usr/bin/python
import socket
import fcntl
import struct
import yaml
def __run__(params):
try:
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])
if get_ip_address(params.get('iface')) == params.get('ip'):
return [0, 'OK - Server in route']
else:
return [0, 'CRITICAL - Server out of route']
except Exception,e:
return [0, 'CRITICAL - %s' % e]