Beispiel #1
0
# ping a list of hosts
def ping(hosts):
  for host in hosts:
    pipe = subprocess.Popen([ping_executable, '-c', str(packets), host],
                            stdout=subprocess.PIPE)
    response = pipe.communicate()[0].splitlines()[-1] # last line
    yield (host, parse_ping_response(response))

# collect data
def collect(hosts):
  if ping_method == 'fping':
    responses = fping(hosts)
  else:
    responses = ping(hosts)

  for (host, delay) in responses:
    add_value(host, delay)
    log('collecting host ' + host + ': delay ' + delay, 1)

if __name__ == "__main__":
  from lib.get_hosts import get_hosts

  log('Collect started', 1)

  tstart = time.time()
  collect(get_hosts())
  tend = time.time() - tstart

  log('Collect finished and ran for ' + str(tend), 1)
Beispiel #2
0
#!/usr/bin/env python

#
# gen_graph.py : generate a graph an return an absolute path to it
#

import rrd

def gen_graph(host, start = '', end = ''):
  return rrd.render(host, start, end)

if __name__ == "__main__":
  from lib.get_hosts import get_hosts

  for host in get_hosts():
    gen_graph(host, '', '');