コード例 #1
0
ファイル: glances.py プロジェクト: metal3d/glances
	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()
コード例 #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()
コード例 #3
0
ファイル: glances.py プロジェクト: Lazymonkey/glances
	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()		
コード例 #4
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()		
コード例 #5
0
#OR you can convert Result class to dictionnary
import ast
dic = ast.literal_eval(str(res))

for (k,v) in dic.items():
  print k,": ",v,"%"
  
  
for disk in stg.sg_get_disk_io_stats():
  print disk['disk_name'],"\tRead: ",disk['read_bytes']/1000,"KB\t\tWrite: ",disk['write_bytes']/1000,"KB"
'''
sda 	Read:  814150 KB		Write:  1347350 KB
sdb 	Read:  11636 KB		Write:  0 KB
'''

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"
コード例 #6
0
 def test_results(self):
     # Most of the sg_ functions are properly tested above, but check one of
     # them exists with the right name...
     host = statgrab.sg_get_host_info()
     self.assertTrue(isinstance(host, statgrab.Result))
コード例 #7
0
ファイル: test.py プロジェクト: i-scream/pystatgrab
 def test_results(self):
     # Most of the sg_ functions are properly tested above, but check one of
     # them exists with the right name...
     host = statgrab.sg_get_host_info()
     self.assertTrue(isinstance(host, statgrab.Result))
コード例 #8
0
setup_environ(settings)
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:
コード例 #9
0
setup_environ(settings)
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: