Ejemplo n.º 1
0
    def __update__(self):
        """
		Update the stats
		"""

        # Get informations from libstatgrab and others...
        self.host = statgrab.sg_get_host_info()
        # TODO: platform.platform(True) instead of statgrab.sg_get_host_info()
        self.system = statgrab.sg_get_host_info()
        self.cpu = statgrab.sg_get_cpu_percents()
        self.load = statgrab.sg_get_load_stats()
        self.mem = statgrab.sg_get_mem_stats()
        self.memswap = statgrab.sg_get_swap_stats()
        self.networkinterface = statgrab.sg_get_network_iface_stats()
        self.network = statgrab.sg_get_network_io_stats_diff()
        self.diskio = statgrab.sg_get_disk_io_stats_diff()
        # Replace the bugged self.fs = statgrab.sg_get_fs_stats()
        self.fs = self.glancesgrabfs.get()
        self.processcount = statgrab.sg_get_process_count()
        self.process = statgrab.sg_get_process_stats()
        self.now = datetime.datetime.now()

        # Get the number of core (CPU)
        # Used to display load alerts
        self.core_number = multiprocessing.cpu_count()
Ejemplo n.º 2
0
	def __update__(self):
		"""
		Update the stats
		"""

		# Get informations from libstatgrab and others...
		self.host = statgrab.sg_get_host_info()
		# TODO: platform.platform(True) instead of statgrab.sg_get_host_info()
		self.system = statgrab.sg_get_host_info()
		self.cpu = statgrab.sg_get_cpu_percents()
		self.load = statgrab.sg_get_load_stats()
		self.mem = statgrab.sg_get_mem_stats()
		self.memswap = statgrab.sg_get_swap_stats()
		self.networkinterface = statgrab.sg_get_network_iface_stats()
		self.network = statgrab.sg_get_network_io_stats_diff()
		self.diskio = statgrab.sg_get_disk_io_stats_diff()
		# Replace the bugged self.fs = statgrab.sg_get_fs_stats()
		self.fs = self.glancesgrabfs.get()
		self.processcount = statgrab.sg_get_process_count()
		self.process = statgrab.sg_get_process_stats()
		self.now = datetime.datetime.now()
				
		# Get the number of core (CPU)
		# Used to display load alerts
		self.core_number = multiprocessing.cpu_count()
Ejemplo n.º 3
0
def get_all_values():
	cpu  = statgrab.sg_get_cpu_percents()
	mem  = statgrab.sg_get_mem_stats()
	load = statgrab.sg_get_load_stats()
	swap = statgrab.sg_get_swap_stats()

	my_stats = {
		"cpu": {
			"kernel": cpu.kernel,
			"user": cpu.user,
			"iowait": cpu.iowait,
			"nice": cpu.nice,
			"swap": cpu.swap,
			"idle": cpu.idle,
		},
		"load": {
			"min1": load.min1,
			"min5": load.min5,
			"min15": load.min15,
		},
		"mem": {
			"used": mem.used,
			"cache": mem.cache,
			"free": mem.free,
			"total": mem.total,
		},
		"swap": {
			"used": swap.used,
			"free": swap.free,
			"total": swap.total,
		},
	}

	return my_stats
Ejemplo n.º 4
0
def get_all_values():
    cpu = statgrab.sg_get_cpu_percents()
    mem = statgrab.sg_get_mem_stats()
    load = statgrab.sg_get_load_stats()
    swap = statgrab.sg_get_swap_stats()

    my_stats = {
        "cpu": {
            "kernel": cpu.kernel,
            "user": cpu.user,
            "iowait": cpu.iowait,
            "nice": cpu.nice,
            "swap": cpu.swap,
            "idle": cpu.idle,
        },
        "load": {
            "min1": load.min1,
            "min5": load.min5,
            "min15": load.min15,
        },
        "mem": {
            "used": mem.used,
            "cache": mem.cache,
            "free": mem.free,
            "total": mem.total,
        },
        "swap": {
            "used": swap.used,
            "free": swap.free,
            "total": swap.total,
        },
    }

    return my_stats
Ejemplo n.º 5
0
	def __update__(self):
		"""
		Update the stats
		"""

		# Get informations from libstatgrab and others...
		self.host = statgrab.sg_get_host_info()
		self.system = statgrab.sg_get_host_info()
		self.cpu = statgrab.sg_get_cpu_percents()
		self.load = statgrab.sg_get_load_stats()
		self.mem = statgrab.sg_get_mem_stats()
		self.memswap = statgrab.sg_get_swap_stats()
		self.network = statgrab.sg_get_network_io_stats_diff()
		self.processcount = statgrab.sg_get_process_count()
		self.process = statgrab.sg_get_process_stats()
		# BUG: https://bugs.launchpad.net/ubuntu/+source/libstatgrab/+bug/886783
		# TODO: self.fs = statgrab.sg_get_fs_stats()
		self.now = datetime.datetime.now()		
Ejemplo n.º 6
0
Archivo: utils.py Proyecto: nyimbi/Domo
def node_info(pid):
    #pid = os.getpid()
    for proc in sg.sg_get_process_stats():
        if pid == proc.pid:
            break
    load_stat = sg.sg_get_load_stats()
    mem_stats = sg.sg_get_mem_stats()
    swap_stats = sg.sg_get_swap_stats()

    return {
        'pid': pid,
        'loadavg': {
            'min1': load_stat.min1
        },
        'cpu_usage': proc.cpu_percent,
        'mem_usage': proc.proc_resident,
        'node_mem_usage': mem_stats,
        'node_swap_usage': swap_stats,
    }
Ejemplo n.º 7
0
	def __update__(self):
		"""
		Update the stats
		"""

		# Get informations from libstatgrab and others...
		self.host = statgrab.sg_get_host_info()
		# TODO: platform.platform(True) instead of statgrab.sg_get_host_info()
		self.system = statgrab.sg_get_host_info()
		self.cpu = statgrab.sg_get_cpu_percents()
		self.load = statgrab.sg_get_load_stats()
		self.mem = statgrab.sg_get_mem_stats()
		self.memswap = statgrab.sg_get_swap_stats()
		self.network = statgrab.sg_get_network_io_stats_diff()
		self.diskio = statgrab.sg_get_disk_io_stats_diff()
		# Replace the bugged self.fs = statgrab.sg_get_fs_stats()
		self.fs = self.glancesgrabfs.get()
		self.processcount = statgrab.sg_get_process_count()
		self.process = statgrab.sg_get_process_stats()
		self.now = datetime.datetime.now()		
Ejemplo n.º 8
0
'''

res = stg.sg_get_host_info()
for (k,v) in ast.literal_eval(str(res)).items():
  print k,": ",v
'''
uptime :  11135
os_name :  Linux
os_version :  #1 SMP Fri Apr 6 05:01:55 UTC 2012
hostname :  Cyborg
platform :  x86_64
os_release :  3.2.0-2-amd64
'''

print "Memory (RAM)"
res = stg.sg_get_mem_stats()
for (k,v) in ast.literal_eval(str(res)).items():
  print k, v / 1000000,"MB"
'''
total 8372 MB
cache 1769 MB
used 4549 MB
free 3822 MB
'''
#This is exactly the same with swap, and user but not with cache attribute

for iface in stg.sg_get_network_iface_stats():
  print iface['interface_name']+":", "up" if iface["up"] == 1 else "down"
'''
lo: up
wlan0: up
Ejemplo n.º 9
0
#what
import statgrab
print("Machine Resource Agent deploying...")

#data are displayed in bytes I think
#RAM and CPU stats
print(statgrab.sg_get_cpu_stats())

#HD Space
print(statgrab.sg_get_mem_stats())

#still need to work on parsing

Ejemplo n.º 10
0
def _reportMEM():
    memStat = statgrab.sg_get_mem_stats()
    memLoad = (memStat['used'] * 100) / memStat['total']
    return memLoad
Ejemplo n.º 11
0
import time
import logging
import statgrab

from status.models import *

kb = 1024
mb = kb * kb

while True:
    ### Host data ###

    cpu = statgrab.sg_get_cpu_percents()
    load = statgrab.sg_get_load_stats()
    host = statgrab.sg_get_host_info()
    mem = statgrab.sg_get_mem_stats()
    hs = HostStats(hostname=host['hostname'],
                   uptime=host['uptime'],
                   arch=host['platform'],
                   min1=str(load['min1']),
                   min5=str(load['min5']),
                   min15=str(load['min15']),
                   mem_total=mem['total'] / mb,
                   mem_free=(mem['cache'] + mem['free']) / mb,
                   mem_used=mem['used'] / mb)
    hs.save()
    ### FS data ###

    filesystems = statgrab.sg_get_fs_stats()
    for fs in filesystems:
        fs_stat = FilesystemStats(
Ejemplo n.º 12
0
import time
import logging
import statgrab

from status.models import *

kb = 1024
mb = kb * kb

while True:
    ### Host data ###

    cpu = statgrab.sg_get_cpu_percents()
    load = statgrab.sg_get_load_stats()
    host = statgrab.sg_get_host_info()
    mem = statgrab.sg_get_mem_stats()
    hs = HostStats(hostname = host['hostname'], uptime = host['uptime'], arch = host['platform'], min1 = str(load['min1']), min5 = str(load['min5']), min15 = str(load['min15']), mem_total = mem['total'] / mb, mem_free = (mem['cache'] + mem['free']) / mb, mem_used = mem['used'] / mb)
    hs.save()
    ### FS data ###

    filesystems = statgrab.sg_get_fs_stats()
    for fs in filesystems:
        fs_stat = FilesystemStats(device = fs['device_name'], used_perc = str(float(fs['used']) / float(fs['size']) * 100.0), size = fs['size'] / mb, used = fs['used'] / mb,  avail = fs['avail'] / mb, fs_type = fs['fs_type'])
        fs_stat.save()
    ### Network data ###
    statgrab.sg_get_network_io_stats()
    time.sleep(1) # Collect data over 1 second
    diff = statgrab.sg_get_network_io_stats_diff()
    netstats = statgrab.sg_get_network_iface_stats()
    for iface in diff:
        for netstat in netstats: