Cisco IOS-XR RSP and LC CPU monitoring: script and templates

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
acivciss
Posts: 4
Joined: Mon Aug 19, 2013 1:12 pm

Cisco IOS-XR RSP and LC CPU monitoring: script and templates

Post by acivciss »

Script is written in python and tested on python 2.7.3.
Created for Cisco IOS-XR CRS-3 and ASR9010.
Tested on cacti 0.8.7i.
For snmp queries you need snmpwalk and snmpget installed.
By default snmp v2c is used.

- unzip cisco_iosxr_cpu_stats.zip
- copy script_query_get_iosxr_cpu_stats.xml into CACTI_HOME/resource/script_queries/
- copy script_get_iosxr_cpu_stats.py into CACTI_HOME/scripts/
- through cacti web interface import templates: graph_data_template_cisco_iosxr_cpu_stats.xml and data_query_template_cisco_iosxr_cpu_stats.xml
Attachments
cisco_iosxr_cpu_stats.zip
(6.61 KiB) Downloaded 336 times
havok1977
Posts: 49
Joined: Fri Apr 08, 2005 1:41 pm

Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ

Post by havok1977 »

Thanks for posting this, seems like its what we currently need

However Im getting this when I try to create the graph:

This data query returned 0 rows, perhaps there was a problem executing this data query. You can run this data query in debug mode to get more information.


Our debug info
+ Running data query [20].
+ Found type = '4' [Script Query].
+ Found data query XML file at '/usr/share/cacti/resource/script_queries/script_query_get_cisco_iosxr_cpu_stats.xml'
+ XML file parsed ok.
+ Executing script for num of indexes '/usr/bin/env python /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community num_indexes'
+ Executing script for list of indexes '/usr/bin/env python /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community index' Index Count: 0
+ Executing script query '/usr/bin/env python /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community query index'
+ Executing script query '/usr/bin/env python /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community query query'

What could be the problem here?
Last edited by havok1977 on Thu Aug 14, 2014 10:08 am, edited 1 time in total.
acivciss
Posts: 4
Joined: Mon Aug 19, 2013 1:12 pm

Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ

Post by acivciss »

Please check if the script is working correctly from the cli. Just run it from cli using correct IP address and community:
/usr/bin/env python /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community num_indexes
/usr/bin/env python /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community index
The output should be something like that, depends on how many cpus you have:
/usr/bin/env python /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py 192.168.111.111 public num_indexes
6
/usr/bin/env python /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py 192.168.111.111 public index
66
82
2050
16777282
16777298
16779266
If you will have problems with the output from the script, you need to check that snmpwalk and snmpget utilities are correctly installed and the script can find them using system path.
Run that command using your router IP and community:
snmpwalk -v2c -c public 192.168.111.111 .1.3.6.1.4.1.9.9.109.1.1.1.1.2

iso.3.6.1.4.1.9.9.109.1.1.1.1.2.66 = INTEGER: 38557239
iso.3.6.1.4.1.9.9.109.1.1.1.1.2.82 = INTEGER: 56744940
iso.3.6.1.4.1.9.9.109.1.1.1.1.2.2050 = INTEGER: 16203662
iso.3.6.1.4.1.9.9.109.1.1.1.1.2.16777282 = INTEGER: 168504586
iso.3.6.1.4.1.9.9.109.1.1.1.1.2.16777298 = INTEGER: 159516845
iso.3.6.1.4.1.9.9.109.1.1.1.1.2.16779266 = INTEGER: 176960415
If it is not in the system path the simple solution is to copy snmpget and snmpwalk to the directory where the script is located.
havok1977
Posts: 49
Joined: Fri Apr 08, 2005 1:41 pm

Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ

Post by havok1977 »

Thanks for your reply

I get these errors when invoking the script via CLI
[root@NMU-SRV-MRTG ~]# /usr/bin/env python /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community num_indexes
Traceback (most recent call last):
File "/usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py", line 73, in <module>
print get_cpu_index()
File "/usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py", line 21, in get_cpu_index
out = subprocess.check_output(IDX_OID, shell=True)
AttributeError: 'module' object has no attribute 'check_output'
[root@NMU-SRV-MRTG ~]# /usr/bin/env python /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community index
Traceback (most recent call last):
File "/usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py", line 75, in <module>
get_cpu_index()
File "/usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py", line 21, in get_cpu_index
out = subprocess.check_output(IDX_OID, shell=True)
AttributeError: 'module' object has no attribute 'check_output'
Our server runs CentOS 6, which includes python ver 2.6.6 - would the lower version be the issue here?
acivciss
Posts: 4
Joined: Mon Aug 19, 2013 1:12 pm

Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ

Post by acivciss »

Yes, the problem is with the python version.
Please replace your script_get_cisco_iosxr_cpu_stats.py with the new one. I've changed it to support python < 2.7.
I hope this time it will work. :)
Attachments
script_get_cisco_iosxr_cpu_stats.py.zip
changed to support python < 2.7
(1.19 KiB) Downloaded 161 times
havok1977
Posts: 49
Joined: Fri Apr 08, 2005 1:41 pm

Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ

Post by havok1977 »

Yeah, the Python version was the issue; in case anyone has the same OS this is how you install the newer version in parallel to avoid clashes:

http://toomuchdata.com/2014/02/16/how-t ... on-centos/


[root@NMU-SRV-MRTG script_queries]# /usr/local/bin/python2.7 /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community num_indexes
4
[root@NMU-SRV-MRTG script_queries]# /usr/local/bin/python2.7 /usr/share/cacti/scripts/script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community index
2
18
2082
2098
havok1977
Posts: 49
Joined: Fri Apr 08, 2005 1:41 pm

Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ

Post by havok1977 »

acivciss wrote:Yes, the problem is with the python version.
Please replace your script_get_cisco_iosxr_cpu_stats.py with the new one. I've changed it to support python < 2.7.
I hope this time it will work. :)

Heh, we worked on it at the same time :) I'll test this version and let you know how it goes
havok1977
Posts: 49
Joined: Fri Apr 08, 2005 1:41 pm

Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ

Post by havok1977 »

acivciss wrote:Yes, the problem is with the python version.
Please replace your script_get_cisco_iosxr_cpu_stats.py with the new one. I've changed it to support python < 2.7.
I hope this time it will work. :)

Works perfectly, thanks again!
[root@NMU-SRV-MRTG tmp]$ /usr/bin/env python ./script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community num_indexes
2
[root@NMU-SRV-MRTG tmp]$ /usr/bin/env python ./script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community index
2
2082
acivciss
Posts: 4
Joined: Mon Aug 19, 2013 1:12 pm

Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ

Post by acivciss »

You're welcome!

Hope graphs are OK too. :)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest