Improved Cisco CPU Utilization Script Query
Moderators: Developers, Moderators
Improved Cisco CPU Utilization Script Query
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.
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.
- Attachments
-
- cpu-utilization-7600.pdf
- (642.52 KiB) Downloaded 1609 times
-
- cacti_cisco_cpu_util.zip
- (5.67 KiB) Downloaded 1313 times
CL
Dependencies
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
* 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
CL
Sample graphs
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.
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.
- Attachments
-
- cisco-cpu-util-example.png (179.08 KiB) Viewed 20184 times
CL
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
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.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
CL
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._CL wrote: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.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
Ziv
Improving the improvement
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.
- Attachments
-
- rp6-new.png (56.07 KiB) Viewed 19867 times
CL
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
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
- Attachments
-
- Cisco2800 CPU Utilization
- cpu-util.png (68.42 KiB) Viewed 19831 times
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.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
CL
Script server versions
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.
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.
- Attachments
-
- ss_cisco_cpu_util.zip
- (5.75 KiB) Downloaded 554 times
CL
Re: Script server versions
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._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.
CL
Here are the OIDs used by the script. Are you able to walk these values?Gorbachov wrote:Someone any luck on using this graphs for an ASA 5510?
Code: Select all
.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
CL
Code: Select all
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
Work on Windows install?
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
Any help from anyone would be greatly appreciated.
Scott
Who is online
Users browsing this forum: No registered users and 0 guests