Exemplo n.º 1
0
def main():
  # setup logging
  if '--quiet' in sys.argv:
    logging.basicConfig(level=logging.ERROR)
    #logging.basicConfig(filename='/tmp/metricfire.log', level=logging.DEBUG)
    #logging.debug(time.ctime())
  else:
    logging.basicConfig(level=logging.DEBUG)

  # Make sure, a digitemp configfile exists
  check_create_config_file()
  # Initialize metrifire API
  logging.debug("Initializing Metricfire API.")
  metricfire.init(config['api-key'], try_adns=config.get('metricfire_try_adns', False))
  while True:
    before = time.time()
    send_receive()
    now = time.time()

    if '--once' in sys.argv:
      logging.debug("Exiting")
      break

    if now - before > config['interval']:
      logging.info("Interval exceeded.")
    else:
      time.sleep(config['interval'] - (now - before))
Exemplo n.º 2
0
#
# FRLinux - [email protected]
# Thanks to John Hamill for the help on Python :)
#
# you need psutil v0.4 or above - http://code.google.com/p/psutil/
#
# v0.1 - 13/12/11 - basic metrics feeding to metricfire
# v0.2 - 14/12/11 - more metrics gathering based on psutil

import time
import psutil
import metricfire

# send key to server
# add key here in the form of /key
metricfire.init("")

# cpu
cputimes = psutil.cpu_times()
#print type(cputimes),dir(cputimes)
cpus = ['user', 'nice', 'system', 'idle', 'iowait', 'irq', 'softirq']

for cpu in cpus:
    metric = getattr(cputimes, cpu)
    metricfire.send("cpu." + cpu, str(metric))

# memory
phymemusage = psutil.phymem_usage()
virtmemusage = psutil.virtmem_usage()
mems = ['total', 'used', 'free', 'percent']
Exemplo n.º 3
0
#
# FRLinux - [email protected]
# Thanks to John Hamill for the help on Python :)
#
# you need psutil v0.4 or above - http://code.google.com/p/psutil/
#
# v0.1 - 13/12/11 - basic metrics feeding to metricfire
# v0.2 - 14/12/11 - more metrics gathering based on psutil

import time
import psutil
import metricfire

# send key to server
# add key here in the form of /key
metricfire.init("")

# cpu
cputimes =  psutil.cpu_times()
#print type(cputimes),dir(cputimes)
cpus= ['user', 'nice', 'system', 'idle', 'iowait', 'irq', 'softirq']

for cpu in cpus:
	metric = getattr(cputimes,cpu)
   	metricfire.send("cpu." + cpu, str(metric))
	
# memory
phymemusage = psutil.phymem_usage()
virtmemusage = psutil.virtmem_usage()
mems = ['total', 'used', 'free', 'percent' ]
Exemplo n.º 4
0
 def __init__(self, api_key, app_id):
   self._api_key = api_key
   self._app_id = app_id
   metricfire.init(self._api_key, application=self._app_id)