Example #1
0
 def get_ip_address(self):
     INTERFACE = ['eth0', 'eth1']
     ifaces = network.ifaces().values()
     for i in INTERFACE:
         for j in ifaces:
             if j.name == i and j.link:
                 return j.ipaddr
Example #2
0
 def __init__(self):
     self._samples = deque(maxlen=1024)
     self._read_mbytes = 0
     self._write_mbytes = 0
     self._timestamp = time.time()
     self._fs_read_bytes = 0
     self._fs_write_bytes = 0
     self._network_rbytes = 0
     self._network_wbytes = 0
     self._cache_tbytes = 0
     self._cache_ubytes = 0
     self._vol_rbytes = 0
     self._vol_wbytes = 0
     self._ifaces = network.ifaces().values()
Example #3
0
 def _GET(self):
     ifaces = []
     for info in network.ifaces().values():
         o = {'id'     : info.name,
              'iface'  : info.name,
              'ipaddr' : info.ipaddr,
              'netmask': info.netmask,
              'slaves' : info.slaves,
              'master' : info.master,
              'type'   : info.type,
              'link'   : info.link}
         if info.type == 'bond-master':
             bond = network.Bond(info.name)
             o['mode'] = bond.mode
         ifaces.append(o)
     return error.success(ifaces)
Example #4
0
from store import *
from load import *
import logging
import network
import socket

logging.basicConfig()
logger = logging.getLogger('nsq')
fh = logging.FileHandler('/var/log/nsq.log')
logger.setLevel(logging.INFO)
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
logger.addHandler(fh)

iface = [info.ipaddr for info in network.ifaces().values() if info.link]
aim = config.zoofs.ip + ':' + str(config.zoofs.consumer_port)
if len(iface) < 0:
    logger.error("no useful ip")
    exit()
print aim


def handler(message):
    try:
        manage(json.loads(message.body))
        return True
    except Exception, ex:
        print ex
        return False
Example #5
0
 def GET(self):
     return error.success([str(info.ipaddr) for info in network.ifaces().values() if info.link])
Example #6
0
 def _getIfaces(self):
     return [info.ipaddr for info in network.ifaces().values() if info.link]