Web and Unmanaged
1753834 Members
8206 Online
108806 Solutions
New Discussion юеВ

Re: HPE OfficeConnect Switch 1820 8G J9979A : get CPU and memory utilization from SNMP 1

 
SOLVED
Go to solution
---HMN---
Occasional Advisor

HPE OfficeConnect Switch 1820 8G J9979A : get CPU and memory utilization from SNMP 1

Hi!

I have a switch with model and version firmware: HPE OfficeConnect Switch 1820 8G J9979A, PT.02.05, Linux 3.6.5, U-Boot 2012.10-00116.

I get statistics on interfaces by snmp. How do I get the snmp load of cpu and memory usage from snmp? Via the web this information is available.

6 REPLIES 6
SantoshPG
HPE Pro

Re: HPE OfficeConnect Switch 1820 8G J9979A : get CPU and memory utilization from SNMP 1

Hi,

From the management and config guide of this switch.

Link :- http://h20564.www2.hpe.com/portal/site/hpsc/public/kb/docDisplay/?docId=c04622710

The switch supports the following MIB only.

The switch supports the following MIBs: тАв BRIDGE-MIB (IEEE 802.1Q) тАв LLDP-MIB (IEEE 802.3AB) тАв EtherLike-MIB тАв IF-MIB тАв RFC1213-MIB тАв RMON-MIB (RMON History as in v1) тАв Power Ethernet MIB (RFC3621), only on switches that support PoE+. (No SNMP information is available on configured PoE schedules.)

Thank you,
I am an HPE employee
-------------------------------------------------------------------------
Was the post useful? Click on Kudos Thumb below
---HMN---
Occasional Advisor
Solution

Re: HPE OfficeConnect Switch 1820 8G J9979A : get CPU and memory utilization from SNMP 1

Thank you for your information. I saw that mibs didn't have cpu and memory utilization. I was resolved this issue by script get data from web console.
Sorry for my bad English
VargasDoug
New Member

Re: HPE OfficeConnect Switch 1820 8G J9979A : get CPU and memory utilization from SNMP 1

I'm having the same problem with the 1920s model, how would this script get data from web console?
---HMN---
Occasional Advisor

Re: HPE OfficeConnect Switch 1820 8G J9979A : get CPU and memory utilization from SNMP 1

This is my script to get CPU and Memory on web console. It's written by python language. So you must install it on your monitor server.

Please could you send me your email through a private message by clicking here . I will send file script to you.

Note:

My script use with 1820 model. I don't sure with 1920s, it can login web console with same url in script

Because the script use browser to get data, It's get more performance of your monitor server. If you have many switch 1920s, you will lost many RAM and CPU for it.

------------------------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/env
import requests, json, sys
#import compago
#app = compago.Application()

session = requests.Session()
session.trust_env = False
url = "http://" + sys.argv[1]
urlLogin = "/htdocs/login/login.lua"
urlData = "/htdocs/pages/base/support.lsp"
urlLogout = "/htdocs/pages/main/logout.lsp"
username = sys.argv[3]
password = sys.argv[4]
#@app.command
def getCPU():
if login()==0:
print "login failed"
else:
responseData = login()
html = responseData.text
noFindCPUStr = html.find('id="cpu_util_prog_bar_val">')
noCPUStr = len('id="cpu_util_prog_bar_val">')
cpu = responseData.text[noFindCPUStr + noCPUStr:(noFindCPUStr + noCPUStr + 2)]
print cpu
logout()
#@app.command
def getMem():
if login()==0:
print "login failed"
else:
responseData = login()
html = responseData.text
noFindMEMStr = html.find('id="mem_util_prog_bar_val">')
noMEMStr = len('id="mem_util_prog_bar_val">')
memory = responseData.text[noFindMEMStr + noMEMStr:(noFindMEMStr + noMEMStr + 2)]
print memory
logout()
def login():

data = {'username':username,'password':password}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
responseLogin = session.post(url + urlLogin, data, headers)
#print responseLogin.status_code
if responseLogin.status_code == 200:
#Logincookies = responseLogin.cookies
#responseData = session.post(url + urlData, cookies = Logincookies)
responseData = session.post(url + urlData)
#html = responseData.text
#print html
return responseData
else:
return 0

def logout():
session.post(url + urlLogout)
#print logout.status_code
session.close()

if __name__ == "__main__":
#app.run()
if sys.argv[2] == "getCPU":
getCPU()
elif sys.argv[2] == "getMem":
getMem()
else:
print "Invalid argument! (script.py ip function)"

 

ъ╣Аы▓╜ьг╝
Senior Member

Re: HPE OfficeConnect Switch 1820 8G J9979A : get CPU and memory utilization from SNMP 1

I have the same problem as you.

I am also using the HPE 1820-24G switch.

I found that CPU/MEMORY can't be found in MIB, so I can only collect it with your script.

Can you e-mail me your complete script?

I couldn't run the code above because I don't know python.

I want to get your .py file.

I would be very grateful if you could provide it.

Thank you.

 

bjkim@nalintech.co.kr

---HMN---
Occasional Advisor

Re: HPE OfficeConnect Switch 1820 8G J9979A : get CPU and memory utilization from SNMP 1

https://mega.nz/file/qpAUhQDT#OyMMr_oqyBr19rJEiQTvpNR_5WKQv0yHin9nh6ucafk

https://mega.nz/file/zoQGTaRQ#rgG3IKexUH9dVe5YbceCh6Wq9E7-LLLH8sU_uCmiG_Y

This is my python script and bash script sample called python script. The $1 $2 $3 $4 is argument. 

This is sample when you need get memory used percent:

"/usr/bin/python /usr/lib/zabbix/externalscripts/HPSwitch.py ip_switch getMem username_webconsole_Switch password_webconsole_Switch"

"/usr/bin/python /usr/lib/zabbix/externalscripts/HPSwitch.py 192.168.1.245 getMem admin 123456"

for getCPU

"/usr/bin/python /usr/lib/zabbix/externalscripts/HPSwitch.py 192.168.1.245 getCPU admin 123456"

You need to setup python on server and install "requests, json, sys" library. I writen this script long time ago. I can't remember exactly. May be the library ready existing in python when you install it.

The last, Your monitor system must be support extenal or internal script like zabbix.  And you will create extenal or internal script item.

Please talk me detail your problem. I will support you. (your monitor system, url your hp switch web console)

The url web console must to same url bellow:

url = "http://" + sys.argv[1]     (http://192.168.1.245)
urlLogin = "/htdocs/login/login.lua"   (http://192.168.1.245/htdocs/login/login.lua    -     login url web console)
urlData = "/htdocs/pages/base/support.lsp"    (http://192.168.1.245/htdocs/pages/base/support.lsp - have cpu and memory info in here)
urlLogout = "/htdocs/pages/main/logout.lsp"     (http://192.168.1.245/htdocs/pages/main/logout.lsp  -  logout url web console)

Sorry for my bad English!