Exemple #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()
Exemple #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()
Exemple #3
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()		
Exemple #4
0
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,
    }
Exemple #5
0
 def get_cpu_memory_stat(self):
     proc_list = []
     for i in statgrab.sg_get_process_stats():
         if self._stop:
             self.running = False
             return proc_list
         # If len(i['process_name']) > 15, then the string is truncated by
         # statgrab module, so in re.search use i['process_name'] as search
         # criteria
         proctitle = str(i['proctitle'])
         if not proctitle:
             # For some of the process proctitle is ''
             # in that case let us use process_name
             proctitle = str(i['process_name'])
         if not re.search(self._appname, proctitle, re.U | re.L):
             # If process name doesn't match, continue
             continue
         proc_list.append([i, self._appname])
     return proc_list
Exemple #6
0
 def get_cpu_memory_stat(self):
     proc_list = []
     for i in statgrab.sg_get_process_stats():
         if self._stop:
             self.running = False
             return proc_list
         # If len(i['process_name']) > 15, then the string is truncated by
         # statgrab module, so in re.search use i['process_name'] as search
         # criteria
         proctitle = str(i['proctitle'])
         if not proctitle:
             # For some of the process proctitle is ''
             # in that case let us use process_name
             proctitle = str(i['process_name'])
         if not re.search(self._appname, proctitle,
                          re.U | re.L):
             # If process name doesn't match, continue
             continue
         proc_list.append([i, self._appname])
     return proc_list
Exemple #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()		
Exemple #8
0
 def execute(self, quals, columns):
     # statgrab already returns its data in a format suitable
     # for Multicorn: a list (iterable) of dicts.
     # `quals` is ignored, PostgreSQL will do the filtering itself.
     return statgrab.sg_get_process_stats()
lo: Input: 0 Kb	Output: 0 Kb
wlan0: Input: 794 Kb	Output: 554 Kb
eth0: Input: 0 Kb	Output: 0 Kb
'''

res = stg.sg_get_process_count()
for (k,v) in ast.literal_eval(str(res)).items():
  print k,v
'''
zombie 0
running 2
total 175
stopped 1
sleeping 172
'''

res = stg.sg_get_process_stats()
print "Number Processes:",len(res)
print "CPU\tUID\tGID\tPID\tName"
for p in res:
  print round(p['cpu_percent'],2),"\t",p['uid'],"\t",p['gid'],'\t',p['pid'],'\t',p['process_name']
'''
CPU	UID	GID	PID	Name 
0.01 	0 	0 	1 	init
0.0 	0 	0 	2 	kthreadd
0.0 	0 	0 	3 	ksoftirqd/0
0.0 	0 	0 	6 	migration/0
0.0 	0 	0 	7 	watchdog/0
0.0 	0 	0 	8 	migration/1
...
'''
Exemple #10
0
 def execute(self, quals, columns):
     # statgrab already returns its data in a format suitable
     # for Multicorn: a list (iterable) of dicts.
     # `quals` is ignored, PostgreSQL will do the filtering itself.
     return statgrab.sg_get_process_stats()