????

Your IP : 3.144.40.238


Current Path : /lib/python3.6/site-packages/glances/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/glances/__pycache__/stats_client_snmp.cpython-36.pyc

3

Eo�c�@sXdZddlZddlmZddlmZddlmZdddd	d
ddd
�ZGdd�de�Z	dS)zThe stats manager.�N)�GlancesStats)�	iteritems)�logger�linuxZmacZbsdZwindowsZciscoZesxiZnetapp)z	.*Linux.*z
.*Darwin.*z.*BSD.*z.*Windows.*z	.*Cisco.*z.*VMware ESXi.*z
.*NetApp.*cs:eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Z�ZS)�GlancesStatsClientSNMPz?This class stores, updates and gives stats for the SNMP client.Ncs0tt|�j�||_||_d|_|j|j�dS)N)�superr�__init__�config�argsZos_nameZload_modules)�selfr	r
)�	__class__��'/usr/lib/python3.6/stats_client_snmp.pyr"s
zGlancesStatsClientSNMP.__init__cCs�ddlm}||jj|jj|jj|jj|jj|jjd�}|j	d�ik}|r�|j	d�}y&|j
|d�|_tj
dj|j��Wn$tk
r�d|_tjd�YnX|S)	z)Check if SNMP is available on the server.r)�GlancesSNMPClient)�hostZport�versionZ	community�userZauthz1.3.6.1.2.1.1.5.0z1.3.6.1.2.1.1.1.0zSNMP system name detected: {}NzCannot detect SNMP system name)Zglances.snmprr
ZclientZ	snmp_portZsnmp_versionZsnmp_communityZ	snmp_userZ	snmp_authZ
get_by_oid�get_system_name�system_namer�info�format�KeyErrorZwarning)rrZsnmp_client�retZoid_os_namer
r
r�
check_snmp1s$
z!GlancesStatsClientSNMP.check_snmpcCs<d}|dkr|Sx&tt�D]\}}tj||�r|}PqW|S)z2Get the short os name from the OS name OID string.N�)r�oid_to_short_system_name�re�search)rZoid_system_name�short_system_name�r�vr
r
rrNsz&GlancesStatsClientSNMP.get_system_namecCs�x�|jD]�}|j|j�rqd|j|_|j|j|_y|j|j�Wn4tk
r|}ztjdj	||��WYdd}~XqX|j|j
�|j|j�qWdS)zUpdate the stats using SNMP.ZsnmpzUpdate {} failed: {}N)Z_pluginsZis_disabledZinput_methodrr�update�	Exceptionr�errorrZupdate_stats_historyZupdate_views)r�p�er
r
rr!]s$zGlancesStatsClientSNMP.update)NN)	�__name__�
__module__�__qualname__�__doc__rrrr!�
__classcell__r
r
)rrrs
r)
r)rZ
glances.statsrZglances.compatrZglances.loggerrrrr
r
r
r�<module>
s