Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Improved Cisco CPU Utilization Script Query
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
_CL



Joined: 25 Feb 2008
Posts: 38
Location: USA

PostPosted: Wed Jun 04, 2008 3:56 pm    Post subject: Improved Cisco CPU Utilization Script Query Reply with quote

I've written a new script query to retrieve the CPU stats from the CISCO-PROCESS-MIB. The script is indexed off the CPU name, therefore, it is immune to changes in the CPU index. The script will continue to correctly track CPU utilization based off the CPU name even though the CPU index may change due to reloading the Cisco device, processor failovers, linecard OIR, etc.

Problem: A traditional approach to gathering CPU stats would use the CPU index (cpmCPUTotalIndex) in the CPU table (cpmCPUTotalTable). The downfall with this approach is that the CISCO-PROCESS-MIB states that "This index is assigned arbitrarily by the engine and is not saved over reboots." In practice, it can also be affected by other hardware changes in the device, e.g., processor failovers.

cpmCPUTotalTable
..cpmCPUTotalEntry
....cpmCPUTotalIndex (1) <== CPU index
....cpmCPUTotalPhysicalIndex (2)
....cpmCPUTotal5secRev (6) <== CPU stats
....cpmCPUTotal1minRev (7) <==
....cpmCPUTotal5minRev (8) <==

Solution: The name of each CPU is static, at least within a particular IOS version, so we can use it as an index. The CPU name is tied to each CPU index by way of cpmCPUTotalPhysicalIndex which is the same value as entPhysicalIndex in the ENTITY-MIB. Hence, we can use the cpmCPUTotalPhysicalIndex to index into the entPhysicalEntry and retrieve the CPU name.

entPhysicalTable
..entPhysicalEntry
....entPhysicalIndex (1)
....entPhysicalName (7)

Benefits:

(1) Once a data source and graph are created for a CPU, Cacti will continue to track the CPU utilization even if the underlying CPU index changes.

(2) Cacti will track active and redundant CPUs and keep track of failovers. Some Cisco devices only place the active CPU in the CPU table. If the device fails over to the standby CPU, then Cacti will no longer be able to track the utilization on the original CPU, however, if the device fails back over to the original CPU, it will automatically pick up the change and begin tracking the CPU again. Further, after the initial failover, if you create a data source and graph for the second CPU, you will have all data sources and graphs in place to track CPU utilization no matter which CPU is active.

Example: The attached file, cpu-utilization-7600.pdf, has a detailed example of the script in action.



cacti_cisco_cpu_util.zip
 Description:

Download
 Filename:  cacti_cisco_cpu_util.zip
 Filesize:  5.67 KB
 Downloaded:  250 Time(s)


cpu-utilization-7600.pdf
 Description:

Download
 Filename:  cpu-utilization-7600.pdf
 Filesize:  642.52 KB
 Downloaded:  279 Time(s)

Back to top
_CL



Joined: 25 Feb 2008
Posts: 38
Location: USA

PostPosted: Wed Jun 04, 2008 4:05 pm    Post subject: Dependencies Reply with quote

I forgot to mention that my Cacti installation runs the following using the latest Synaptic packages

* Ubuntu 8.04
* Cacti 0.8.7b
* RRDtool 1.2.19
* Net-SNMP 5.4.1
* Apache 2.28
* PHP 5.2.4
* MySQL 5.0.51a
Back to top
_CL



Joined: 25 Feb 2008
Posts: 38
Location: USA

PostPosted: Wed Jun 04, 2008 6:40 pm    Post subject: Sample graphs Reply with quote

The example below is from the same Cisco 7600 in the detailed example file attached to the original post.

For image below, I manually forced a Supervisor failover at 17:10:44. You can see where the graphs for the formerly active Supervisor in slot 5 stopped (as expected) and the newly active Supervisor in slot 6 started. You can also see the continuous graphs for the CPUs on the linecards in slots 2 and 7.

The CPU indeces during the failover are changing for the Supervisors and the linecards, but because the script indexes off the CPU name, the graphs are not affected.



cisco-cpu-util-example.png
 Description:
 Filesize:  179.08 KB
 Viewed:  3394 Time(s)

cisco-cpu-util-example.png


Back to top
zivley



Joined: 13 Nov 2007
Posts: 46

PostPosted: Thu Jun 05, 2008 1:49 am    Post subject: Reply with quote

Well, those graphs look cool.
I'd appreciate a short explanation of how to install, I can try to figure out but I prefer the "official" way, so there won't be problems...

Here's how I assume it should be, let me know if I'm right:

1. Copy cisco_cpu_util.php tp <path_cacti>/scripts/
2. Copy cisco_cpu_util.xml to <path_cacti>/resource/script_queries/
3. Import cacti_data_query_cisco_-_cpu_utilization.xml to cacti

Thanks!
Ziv
Back to top
_CL



Joined: 25 Feb 2008
Posts: 38
Location: USA

PostPosted: Thu Jun 05, 2008 12:23 pm    Post subject: Reply with quote

zivley wrote:
Well, those graphs look cool.
I'd appreciate a short explanation of how to install, I can try to figure out but I prefer the "official" way, so there won't be problems...

Here's how I assume it should be, let me know if I'm right:

1. Copy cisco_cpu_util.php tp <path_cacti>/scripts/
2. Copy cisco_cpu_util.xml to <path_cacti>/resource/script_queries/
3. Import cacti_data_query_cisco_-_cpu_utilization.xml to cacti

Thanks!
Ziv


Your assumption is correct for most installations. One gotcha I know of is....I have two Cacti installations (production, test). The latter is an Ubuntu package install. The Ubuntu package puts the scripts in <path_cacti>/site/scripts.
Back to top
zivley



Joined: 13 Nov 2007
Posts: 46

PostPosted: Sun Jun 08, 2008 12:25 am    Post subject: Reply with quote

_CL wrote:
zivley wrote:
Well, those graphs look cool.
I'd appreciate a short explanation of how to install, I can try to figure out but I prefer the "official" way, so there won't be problems...

Here's how I assume it should be, let me know if I'm right:

1. Copy cisco_cpu_util.php tp <path_cacti>/scripts/
2. Copy cisco_cpu_util.xml to <path_cacti>/resource/script_queries/
3. Import cacti_data_query_cisco_-_cpu_utilization.xml to cacti

Thanks!
Ziv


Your assumption is correct for most installations. One gotcha I know of is....I have two Cacti installations (production, test). The latter is an Ubuntu package install. The Ubuntu package puts the scripts in <path_cacti>/site/scripts.


Actually, the Ubuntu package builds the cacti on /usr/share/cacti/ as a base dir where the value <path_cacti> refers to /usr/share/cacti/site/ already, so it's not totally correct to say <path_cacti>/site.
Ziv
Back to top
_CL



Joined: 25 Feb 2008
Posts: 38
Location: USA

PostPosted: Tue Jun 10, 2008 12:58 pm    Post subject: Improving the improvement Reply with quote

The graphs look better if you change the graph template by putting the 5 min area as item 1, the 1 min line as item 5, and the 5 sec line as item 9. A simple 3 clicks on the up and down arrows in the graph template will accomplish this, so I am not reposting the template.


rp6-new.png
 Description:
 Filesize:  56.07 KB
 Viewed:  3077 Time(s)

rp6-new.png


Back to top
zivley



Joined: 13 Nov 2007
Posts: 46

PostPosted: Wed Jun 11, 2008 3:02 am    Post subject: Reply with quote

You're right, the graphs look better this way, I was also amused to find out that in this cacti version, when you move up or down an item, all the related GPRINTS move with it! It saves you a lot of clicks and mess.
Anwyay, I have a curiosity in a few Cisco 2800 routers that all of their graphs look like this (see attached image), it's not an error, they're actually working fine for a long time, all with this kind of cpu load due to a very speciffic work they do (a lot of serial interfaces). This routers are beasts! If you telnet them and try to do whatever you want, you won't even feel they're working at this cpu load.
Anyway, in this case, your graph template doesn't make them look so fancy, it looks actually boring, but that's not your fault.
All other routers cpu graphs are looking very cool and useful!
Thanks a lot!
Ziv



cpu-util.png
 Description:
Cisco2800 CPU Utilization
 Filesize:  68.42 KB
 Viewed:  3041 Time(s)

cpu-util.png


Back to top
_CL



Joined: 25 Feb 2008
Posts: 38
Location: USA

PostPosted: Wed Jun 11, 2008 8:48 am    Post subject: Reply with quote

zivley wrote:
You're right, the graphs look better this way, I was also amused to find out that in this cacti version, when you move up or down an item, all the related GPRINTS move with it! It saves you a lot of clicks and mess.
Anwyay, I have a curiosity in a few Cisco 2800 routers that all of their graphs look like this (see attached image), it's not an error, they're actually working fine for a long time, all with this kind of cpu load due to a very speciffic work they do (a lot of serial interfaces). This routers are beasts! If you telnet them and try to do whatever you want, you won't even feel they're working at this cpu load.
Anyway, in this case, your graph template doesn't make them look so fancy, it looks actually boring, but that's not your fault.
All other routers cpu graphs are looking very cool and useful!
Thanks a lot!
Ziv


I suspect you know this, but just in case - you can change the autoscale options in the graph template so that the lower limit is not fixed at 0.
Back to top
_CL



Joined: 25 Feb 2008
Posts: 38
Location: USA

PostPosted: Wed Jun 11, 2008 9:01 am    Post subject: Script server versions Reply with quote

Here's a version of the CPU utilization template that can be used by the script server. This is my first attempt at using the script server, but everything seems to be working ok. (If you haven't done script server before, read chapter 14 in the Cacti manual before using this template.)

I changed the file names of the files I had to change to work with script server

cisco_cpu_util.xml => ss_cisco_cpu_util.xml (put this file in <path_cacti>/resource/script_server/)

cisco_cpu_util.php => ss_cisco_cpu_util.php (put this file in <path_cacti>/scripts/)

I changed the data query and data template names

Cisco - CPU Utilization => Cisco - CPU Utilization (ss)

The graph template didn't change. Well, it did, but not due to the script server. I changed the order of the lines in the graph as I mentioned a few posts back. If you import this template the new graph template will overwrite the original graph template, but the data query and data template will not overwrite the originals because I changed their names.



ss_cisco_cpu_util.zip
 Description:

Download
 Filename:  ss_cisco_cpu_util.zip
 Filesize:  5.75 KB
 Downloaded:  88 Time(s)

Back to top
_CL



Joined: 25 Feb 2008
Posts: 38
Location: USA

PostPosted: Thu Jun 12, 2008 9:28 am    Post subject: Re: Script server versions Reply with quote

_CL wrote:
If you import this template the new graph template will overwrite the original graph template, but the data query and data template will not overwrite the originals because I changed their names.


Looks like I was wrong with the above statement. I started a new Cacti install today. I imported the ss version after the original version - this did overwrite the original data query and data template. Don't know why. There must be some value with the template other than the title that identifies the template.
Back to top
Gorbachov



Joined: 04 May 2008
Posts: 14

PostPosted: Tue Jun 17, 2008 7:06 pm    Post subject: Reply with quote

Someone any luck on using this graphs for an ASA 5510?
Back to top
_CL



Joined: 25 Feb 2008
Posts: 38
Location: USA

PostPosted: Tue Jun 17, 2008 7:43 pm    Post subject: Reply with quote

Gorbachov wrote:
Someone any luck on using this graphs for an ASA 5510?


Here are the OIDs used by the script. Are you able to walk these values?

Code:

.1.3.6.1.4.1.9.9.109.1.1.1.1.2  # cpmCPUTotalPhysicalIndex
.1.3.6.1.2.1.47.1.1.1.1.7       # entPhysicalName
.1.3.6.1.4.1.9.9.109.1.1.1.1.6  # cpmCPUTotal5secRev
.1.3.6.1.4.1.9.9.109.1.1.1.1.7  # cpmCPUTotal1minRev
.1.3.6.1.4.1.9.9.109.1.1.1.1.8  # cpmCPUTotal5minRev


They should work. I checked ftp://ftp-sj.cisco.com/pub/mibs/supportlists/asa/asa-supportlist.html and both the ENTITY-MIB and CISCO-PROCESS-MIB are supported by the ASA.
Back to top
Gorbachov



Joined: 04 May 2008
Posts: 14

PostPosted: Wed Jun 18, 2008 5:37 pm    Post subject: Reply with quote

Code:
furgona:~# snmpwalk -v 2c -c Cacti 192.168.1.1 .1.3.6.1.4.1.9.9.109.1.1.1.1.2
SNMPv2-SMI::enterprises.9.9.109.1.1.1.1.2.1 = INTEGER: 1
furgona:~# snmpwalk -v 2c -c Cacti 192.168.1.1 .1.3.6.1.2.1.47.1.1.1.1.7
SNMPv2-SMI::mib-2.47.1.1.1.1.7.1 = STRING: "Chassis"
furgona:~# snmpwalk -v 2c -c Cacti 192.168.1.1 .1.3.6.1.4.1.9.9.109.1.1.1.1.6
SNMPv2-SMI::enterprises.9.9.109.1.1.1.1.6 = No Such Object available on this age                  nt at this OID
furgona:~# snmpwalk -v 2c -c Cacti 192.168.1.1 .1.3.6.1.4.1.9.9.109.1.1.1.1.7
SNMPv2-SMI::enterprises.9.9.109.1.1.1.1.7 = No Such Object available on this agent at this OID
furgona:~# snmpwalk -v 2c -c Cacti 192.168.1.1 .1.3.6.1.4.1.9.9.109.1.1.1.1.8
SNMPv2-SMI::enterprises.9.9.109.1.1.1.1.8 = No Such Object available on this agent at this OID
furgona:~#



May by my ASA does not support them
Back to top
bunyas



Joined: 11 May 2006
Posts: 9

PostPosted: Wed Sep 03, 2008 3:44 pm    Post subject: Work on Windows install? Reply with quote

I've tried getting your script_server script to work on a Windows install of Cacti (0.8.7b) and am not having any success. Everything looks like it loaded properly, but I'm not generating any graphs.

Any help from anyone would be greatly appreciated.

Scott
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 



Powered by phpBB © 2001, 2005 phpBB Group