Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Thu Feb 21, 2019 11:59 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Cisco IOS-XR RSP and LC CPU monitoring: script and templates
PostPosted: Mon Aug 19, 2013 1:24 pm 
Offline

Joined: Mon Aug 19, 2013 1:12 pm
Posts: 4
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 260 times
Top
 Profile  
 
 Post subject: Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ
PostPosted: Wed Aug 13, 2014 5:57 pm 
Offline

Joined: Fri Apr 08, 2005 1:41 pm
Posts: 49
Thanks for posting this, seems like its what we currently need

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

Quote:

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

Quote:
+ 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.

Top
 Profile  
 
 Post subject: Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ
PostPosted: Thu Aug 14, 2014 3:25 am 
Offline

Joined: Mon Aug 19, 2013 1:12 pm
Posts: 4
Please check if the script is working correctly from the cli. Just run it from cli using correct IP address and community:
Quote:
/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:
Quote:
/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:
Quote:
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.


Top
 Profile  
 
 Post subject: Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ
PostPosted: Thu Aug 14, 2014 9:58 am 
Offline

Joined: Fri Apr 08, 2005 1:41 pm
Posts: 49
Thanks for your reply

I get these errors when invoking the script via CLI

Quote:
[[email protected] ~]# /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'
[[email protected] ~]# /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?


Top
 Profile  
 
 Post subject: Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ
PostPosted: Thu Aug 14, 2014 10:48 am 
Offline

Joined: Mon Aug 19, 2013 1:12 pm
Posts: 4
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:
File comment: changed to support python < 2.7
script_get_cisco_iosxr_cpu_stats.py.zip [1.19 KiB]
Downloaded 88 times
Top
 Profile  
 
 Post subject: Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ
PostPosted: Thu Aug 14, 2014 10:55 am 
Offline

Joined: Fri Apr 08, 2005 1:41 pm
Posts: 49
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-to-install-python-on-centos/



Quote:
[[email protected] 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
[[email protected] 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


Top
 Profile  
 
 Post subject: Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ
PostPosted: Thu Aug 14, 2014 10:56 am 
Offline

Joined: Fri Apr 08, 2005 1:41 pm
Posts: 49
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


Top
 Profile  
 
 Post subject: Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ
PostPosted: Thu Aug 14, 2014 11:28 am 
Offline

Joined: Fri Apr 08, 2005 1:41 pm
Posts: 49
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!

Quote:
[[email protected] tmp]$ /usr/bin/env python ./script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community num_indexes
2
[[email protected] tmp]$ /usr/bin/env python ./script_get_cisco_iosxr_cpu_stats.py XXX.XXX.XXX.XXX community index
2
2082


Top
 Profile  
 
 Post subject: Re: Cisco IOS-XR RSP and LC CPU monitoring: script and templ
PostPosted: Thu Aug 14, 2014 11:46 am 
Offline

Joined: Mon Aug 19, 2013 1:12 pm
Posts: 4
You're welcome!

Hope graphs are OK too. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group