From 3980730150d71b8eb9a084f6a0795a8866a911f7 Mon Sep 17 00:00:00 2001 From: Nicolargo Date: Fri, 27 Jun 2014 20:41:05 +0200 Subject: [PATCH] First try for ESXi --- glances/core/glances_stats.py | 5 +++-- glances/plugins/glances_cpu.py | 7 ++++--- glances/plugins/glances_mem.py | 15 ++++++++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/glances/core/glances_stats.py b/glances/core/glances_stats.py index 9ae35a87..e785a02b 100644 --- a/glances/core/glances_stats.py +++ b/glances/core/glances_stats.py @@ -28,10 +28,11 @@ from glances.core.glances_globals import plugins_path, sys_path # SNMP OID regexp pattern to short system name dict oid_to_short_system_name = {'.*Linux.*': 'linux', - '.*BSD.*': 'bsd', '.*Darwin.*': 'mac', + '.*BSD.*': 'bsd', '.*Windows.*': 'windows', - '.*Cisco.*': 'cisco'} + '.*Cisco.*': 'cisco', + '.*VMware ESXi.*': 'esxi'} class GlancesStats(object): diff --git a/glances/plugins/glances_cpu.py b/glances/plugins/glances_cpu.py index 8ca12648..58d7f686 100644 --- a/glances/plugins/glances_cpu.py +++ b/glances/plugins/glances_cpu.py @@ -30,7 +30,8 @@ import psutil snmp_oid = {'default': {'user': '1.3.6.1.4.1.2021.11.9.0', 'system': '1.3.6.1.4.1.2021.11.10.0', 'idle': '1.3.6.1.4.1.2021.11.11.0'}, - 'windows': {'percent': '1.3.6.1.2.1.25.3.3.1.2'}} + 'windows': {'percent': '1.3.6.1.2.1.25.3.3.1.2'}, + 'esxi': {'percent': '1.3.6.1.2.1.25.3.3.1.2'}} class Plugin(GlancesPlugin): @@ -92,8 +93,8 @@ class Plugin(GlancesPlugin): elif self.get_input() == 'snmp': # Update stats using SNMP - if self.get_short_system_name() == 'windows': - # Windows + if self.get_short_system_name() in ('windows', 'esxi'): + # Windows or VMWare ESXi # You can find the CPU utilization of windows system by querying the oid # Give also the number of core (number of element in the table) # print snmp_oid[self.get_short_system_name()] diff --git a/glances/plugins/glances_mem.py b/glances/plugins/glances_mem.py index 1983e3a1..aebe3d7f 100644 --- a/glances/plugins/glances_mem.py +++ b/glances/plugins/glances_mem.py @@ -39,7 +39,11 @@ snmp_oid = {'default': {'total': '1.3.6.1.4.1.2021.4.5.0', 'windows': {'mnt_point': '1.3.6.1.2.1.25.2.3.1.3', 'alloc_unit': '1.3.6.1.2.1.25.2.3.1.4', 'size': '1.3.6.1.2.1.25.2.3.1.5', - 'used': '1.3.6.1.2.1.25.2.3.1.6'}} + 'used': '1.3.6.1.2.1.25.2.3.1.6'}, + 'esxi': {'mnt_point': '1.3.6.1.2.1.25.2.3.1.3', + 'alloc_unit': '1.3.6.1.2.1.25.2.3.1.4', + 'size': '1.3.6.1.2.1.25.2.3.1.5', + 'used': '1.3.6.1.2.1.25.2.3.1.6'}} class Plugin(GlancesPlugin): @@ -109,8 +113,8 @@ class Plugin(GlancesPlugin): self.stats['used'] = self.stats['total'] - self.stats['free'] elif self.get_input() == 'snmp': # Update stats using SNMP - if self.get_short_system_name() == 'windows': - # Mem stats for Windows OS are stored in the FS table + if self.get_short_system_name() in ('windows', 'esxi'): + # Mem stats for Windows|Vmware Esxi are stored in the FS table try: fs_stat = self.set_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()], bulk=True) @@ -118,8 +122,9 @@ class Plugin(GlancesPlugin): self.reset() else: for fs in fs_stat: - # The Physical Memory gives statistics on RAM usage and availability. - if fs == 'Physical Memory': + # The Physical Memory (Windows) or Real Memory (VmWare) + # gives statistics on RAM usage and availability. + if fs in ('Physical Memory', 'Real Memory'): self.stats['total'] = int(fs_stat[fs]['size']) * int(fs_stat[fs]['alloc_unit']) self.stats['used'] = int(fs_stat[fs]['used']) * int(fs_stat[fs]['alloc_unit']) self.stats['percent'] = float(self.stats['used'] * 100 / self.stats['total']) -- GitLab