Пример #1
0
def loadstat(agent,ip,key,port):
	'''
	#loadstat 负载
	#fifteen : 15分钟的负载平均值
	#five : 5分钟的负载平均值
	#one : 1分钟的负载平均值
	#return {"loadstat":{"fifteen":"fifteen","five":"five","one":"one"}}
	'''
	load_one_oid=ObjectName('.1.3.6.1.4.1.2021.10.1.3.1')
	load_five_oid=ObjectName('.1.3.6.1.4.1.2021.10.1.3.2')
	load_fifteen_oid=ObjectName('.1.3.6.1.4.1.2021.10.1.3.3')
	load_one =ger_snmp_get(agent,ip,key,port,load_one_oid)
	load_five =ger_snmp_get(agent,ip,key,port,load_five_oid)
	load_fifteen =ger_snmp_get(agent,ip,key,port,load_fifteen_oid)
	return {'loadstat':{'fifteen':str(load_fifteen[0][1]),'five':str(load_five[0][1]),'one':str(load_one[0][1])}}
Пример #2
0
def user_login(agent,ip,key,port):
	'''
	#login 登录用户数量
	#return {"user_login":"******"} 
	'''
	login_oid=ObjectName('.1.3.6.1.2.1.25.1.5.0')
	user_login =ger_snmp_get(agent,ip,key,port,login_oid)
	return {'user_login':str(user_login[0][1])}
Пример #3
0
def process_num(agent,ip,key,port):
	'''
	#process_num : 进程数量
	#return {"process_num":"process_num"}
	'''
	process_oid=ObjectName('.1.3.6.1.2.1.25.1.6.0')
	process_num =ger_snmp_get(agent,ip,key,port,process_oid)
	return {'process_num':str(process_num[0][1])}
Пример #4
0
def cpu_usage_test(agent,ip,key,port):
        '''
        @获取cpu的使用率
        @user用户模式cpu使用率
        @kernel内核模式cpu使用率
        @low-priority低优先级模式cpu使用率
        '''

        user_oid=ObjectName('.1.3.6.1.4.1.2021.11.9.0')
        kernel_oid=ObjectName('.1.3.6.1.4.1.2021.11.10.0')
        low_oid=ObjectName('.1.3.6.1.4.1.2021.11.11.0')
        user_get=ger_snmp_get(agent,ip,key,port,user_oid)
        kernel_get=ger_snmp_get(agent,ip,key,port,kernel_oid)
        low_get=ger_snmp_get(agent,ip,key,port,low_oid)
        #total = user_get[0][1]+kernel_get[0][1]+low_get[0][1]
        user_usage=float(user_get[0][1])
        kernel_usage=float(kernel_get[0][1])
        low_usage=float(low_get[0][1])
        return {'cpu':{'user':user_usage,'kernel':kernel_usage,'low':low_usage}}