Extended UCD/Net CPU Usage

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

Moderators: Developers, Moderators

Post Reply
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Extended UCD/Net CPU Usage

Post by divagater »

Hey all. This CPU usage template and script works with any number of CPU's and cores always displaying roughly 100% total usage. The perl script that does the collections looks at the delta in cpu time over elapsed time to ajust all the values to a 100% scale. The results should closely match what is seen in top or sar.

This template is loosely based on the templates found here: http://code.google.com/p/mysql-cacti-te ... xTemplates. Mostly I am just copying the look and feel as those templates use ssh to cat /proc/cpu info and I am working only over snmp.

The perl script requires the SNMP package. The export was done on Cacti 0.8.7d and requires that SNMP return the following counters:

[root@exlap600 npc]# snmpwalk -c m0n1t0rm3 -v 2c exlap606 .1.3.6.1.4.1.2021.11 | grep ssCpuRaw
UCD-SNMP-MIB::ssCpuRawUser.0 = Counter32: 2806463526
UCD-SNMP-MIB::ssCpuRawNice.0 = Counter32: 10078058
UCD-SNMP-MIB::ssCpuRawSystem.0 = Counter32: 493131292
UCD-SNMP-MIB::ssCpuRawIdle.0 = Counter32: 3841599494
UCD-SNMP-MIB::ssCpuRawWait.0 = Counter32: 1312103365
UCD-SNMP-MIB::ssCpuRawKernel.0 = Counter32: 491410448
UCD-SNMP-MIB::ssCpuRawInterrupt.0 = Counter32: 1720844
UCD-SNMP-MIB::ssCpuRawSoftIRQ.0 = Counter32: 0

Cheers,
Billy
Attachments
Sample graph image
Sample graph image
extended_cpu.jpg (47.5 KiB) Viewed 4669 times
extended_cpu_graph.zip
The template and script
(5.79 KiB) Downloaded 312 times
Last edited by divagater on Thu Jun 25, 2009 6:01 am, edited 1 time in total.
[url=http://forums.cacti.net/viewtopic.php?t=26540][b]NPC 2.0.4[/b][/url]
[url=http://trac2.assembla.com/npc][size=75]Trac[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=defect][size=75]Bugs[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=enhancement][size=75]Requests[/size][/url]
codemann
Posts: 5
Joined: Mon Dec 08, 2008 3:31 pm

Post by codemann »

Works good on a recent Dual/Quad Core CPU, but doesn't work on an older Xeon 3Ghz with Hyperthreading.

The reason is that that CPU doesn't return the $irq value, giving this error :
Can't call method "val" on an undefined value at extended_cpu.pl line 71.

[edit]
This seems to be because of the older NET-SNMP version, I think you need 5.3 at least for this, and the older server still has 5.0.9. I'm going to update it and I'll let you know if it works.
[/edit]
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

codemann wrote:Works good on a recent Dual/Quad Core CPU, but doesn't work on an older Xeon 3Ghz with Hyperthreading.

The reason is that that CPU doesn't return the $irq value, giving this error :
Can't call method "val" on an undefined value at extended_cpu.pl line 71.

[edit]
This seems to be because of the older NET-SNMP version, I think you need 5.3 at least for this, and the older server still has 5.0.9. I'm going to update it and I'll let you know if it works.
[/edit]
Just uploaded a new version that should take care of that issue. You only need to replace the script. The template is unchanged.

Cheers,
Billy
[url=http://forums.cacti.net/viewtopic.php?t=26540][b]NPC 2.0.4[/b][/url]
[url=http://trac2.assembla.com/npc][size=75]Trac[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=defect][size=75]Bugs[/size][/url] | [url=http://trac2.assembla.com/npc/newticket?type=enhancement][size=75]Requests[/size][/url]
codemann
Posts: 5
Joined: Mon Dec 08, 2008 3:31 pm

Post by codemann »

I updated the script, but we're also planning on updating the NET-SNMP.
codemann
Posts: 5
Joined: Mon Dec 08, 2008 3:31 pm

Post by codemann »

Update: it doesn't really work with the updated script on the older server. I'm going to update the NET-SNMP probably next week, I'm very busy at the moment with other issues.
Attachments
extended.png
extended.png (48.12 KiB) Viewed 4370 times
User avatar
sumsum
Cacti User
Posts: 68
Joined: Mon Apr 26, 2004 7:18 am
Location: Switzerland
Contact:

Re: Extended UCD/Net CPU Usage

Post by sumsum »

hello

If I start the perl script manual, sometimes i get errors :

Code: Select all

vmonster:/usr/share/cacti-0.8.7g/scripts# perl extended_cpu.pl -C cacti -v 2 -p 161 -H localhost
Illegal division by zero at extended_cpu.pl line 99.
I guess it is because the CPU Nice Value is sometimes 0.

I'm running Debian Lenny 64bit in a Quadcore i7 CPU 860 @ 2.80GHz with NET-SNMP version: 5.4.1
I think there seams to be something not right. Has anyone a suggestion, where I need to look into ?

The graph it self looks like this after a while.
Attachments
graph_image.php.png
graph_image.php.png (27.32 KiB) Viewed 2399 times
http://www.lounge-radio.com/
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest