[HOWTO] From snmptable to Graphs (Data Query walkthrough)

If you figure out how to do something interesting/cool in Cacti and want to share it with the community, please post your experience here.

Moderators: Developers, Moderators

paulbeard206
Cacti User
Posts: 150
Joined: Sat Jul 30, 2005 2:15 pm

Anyone want to try my handiwork?

Post by paulbeard206 »

I have created a set of templates for disk read/writes and disk load average ( for systems that support it).
Attachments
cacti-DiskIO.zip
This zip file has all the templates.
(14.8 KiB) Downloaded 3495 times
graph_image-1.php.png
graph_image-1.php.png (39.52 KiB) Viewed 28696 times
graph_image.php.png
graph_image.php.png (30.83 KiB) Viewed 28696 times
User avatar
TFC
Cacti Pro User
Posts: 739
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

Post by TFC »

In order to Document ı create a xml file. But I didnt find index oid. I have only these OIDs:
I have these OIDs:
.1.3.6.1.4.1.6213.2.4.1.1.1
.1.3.6.1.4.1.6213.2.4.1.1.2
.1.3.6.1.4.1.6213.2.4.1.2.1
.1.3.6.1.4.1.6213.2.4.1.2.2
.1.3.6.1.4.1.6213.2.4.1.3.1
.1.3.6.1.4.1.6213.2.4.1.3.2
.1.3.6.1.4.1.6213.2.4.1.4.5
.1.3.6.1.4.1.6213.2.4.1.4.6
.1.3.6.1.4.1.6213.2.4.1.4.7
.1.3.6.1.4.1.6213.2.4.1.4.8
.1.3.6.1.4.1.6213.2.4.1.4.9
.1.3.6.1.4.1.6213.2.4.1.4.10
.1.3.6.1.4.1.6213.2.4.1.4.2
.1.3.6.1.4.1.6213.2.4.1.4.3
.1.3.6.1.4.1.6213.2.4.1.4.4
But I cant find the index oid
How can I write a XML file for these oids?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

This is hard to guess without the MIB or an snmpwalk output with the textual representation of the OIDs
Reinhard
User avatar
TFC
Cacti Pro User
Posts: 739
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

Post by TFC »

lvm wrote:This is hard to guess without the MIB or an snmpwalk output with the textual representation of the OIDs
Reinhard
here is the MIB file
and textual representation:
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.sessions.sessActive .1.3.6.1.4.1.6213.2.4.1.1.1 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.sessions.sessTotal .1.3.6.1.4.1.6213.2.4.1.1.2 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.requests.reqActive .1.3.6.1.4.1.6213.2.4.1.2.1 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.requests.reqTotal .1.3.6.1.4.1.6213.2.4.1.2.2 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.bytes.bytesIn .1.3.6.1.4.1.6213.2.4.1.3.1 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.bytes.bytesOut .1.3.6.1.4.1.6213.2.4.1.3.2 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.devicePerformance.bytesSaved .1.3.6.1.4.1.6213.2.4.1.4.5 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.devicePerformance.avgConnectionsPerDay .1.3.6.1.4.1.6213.2.4.1.4.6 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.devicePerformance.avgRequestsPerDay .1.3.6.1.4.1.6213.2.4.1.4.7 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.devicePerformance.avgBytesSavedPerDay .1.3.6.1.4.1.6213.2.4.1.4.8 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.devicePerformance.avgCPUUsed .1.3.6.1.4.1.6213.2.4.1.4.9 int32
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.devicePerformance.avgMemoryUsed .1.3.6.1.4.1.6213.2.4.1.4.10 int32
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.devicePerformance.connectionsAccepted .1.3.6.1.4.1.6213.2.4.1.4.2 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.devicePerformance.connectionsRefused .1.3.6.1.4.1.6213.2.4.1.4.3 counter64
.iso.org.dod.internet.private.enterprises.juniperDX.dx.dxStats.systemStats.devicePerformance.requestsProcessed .1.3.6.1.4.1.6213.2.4.1.4.4 counter64
Attachments
DX-STATS.zip
(13.38 KiB) Downloaded 3423 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

That does not look like an snmptable. These are "only" multiple, but single, OIDs. So you may copy the "SNMP - Generic OID Template" once for each OID are write a wrapper script that queries all those OIDs and spits them out in one single line (a Data Input Method)
Reinhard
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Typo?

Post by gandalf »

/usr/local/dick wrote:Very nice walkthrough, but there appear to be some typo's, unfortunately also in the code examples.
Sometimes you refer to hrStoragetable and sometime to hrStoragedTable (note the d).
Thank you for pointing this out. I won't correct this issue here, as a new development system will "soon" be available. This HowTo was ported, too.
Reinhard
fozzy
Cacti User
Posts: 54
Joined: Mon Jan 09, 2006 11:33 am
Location: SE of LIML
Contact:

Post by fozzy »

JJX wrote:When i try to load the xml of the example ("Chapter I: Building raw XML file") i get these errors:
Notice: Undefined index: arg_index in /var/www/cacti/lib/data_query.php on line 98

Notice: Undefined index: script_path in /var/www/cacti/lib/data_query.php on line 98

Notice: Undefined index: arg_query in /var/www/cacti/lib/data_query.php on line 109

Notice: Undefined index: query_name in /var/www/cacti/lib/data_query.php on line 109

Notice: Undefined index: script_path in /var/www/cacti/lib/data_query.php on line 109

Warning: Cannot modify header information - headers already sent by (output started at /var/www/cacti/lib/data_query.php:98) in /var/www/cacti/host.php on line 129

any idea?

got this fixed by adding

error_reporting(E_ERROR);

as the first line of data_query.php

Luca
fury
Posts: 13
Joined: Sun Dec 31, 2006 6:57 am

Post by fury »

hi *,

i created a graph for SNMP CPU load according to this howto, but i
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please repeat your question and do not use "strange" characters, phpBB does not like them
Reinhard
fury
Posts: 13
Joined: Sun Dec 31, 2006 6:57 am

Post by fury »

i went through this howto for getting the cpu load of an win server by snmp and got an error making the graph. here is the errormessage:

Code: Select all

RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="fit-w2ks-amd - CPU Load" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
DEF:a="/usr/local/cacti/rra/fitw2ksamd_cpu_load_windows_30.rrd":CPU_Load_Windows:AVERAGE \
LINE1:a#FF0000:"Procent" 

RRDTool Says:

ERROR: opening '/usr/local/cacti/rra/fitw2ksamd_cpu_load_windows_30.rrd': No such file or directory
here is my xml file:

Code: Select all

<interface>
        <name>Get Windows CPU Load</name>
        <description>Get SNMP based Partition Information out of hrStorageTable</description>
        <index_order_type>numeric</index_order_type>
        <oid_index>1.3.6.1.2.1.25.3.3.1</oid_index>

        <fields>
                <hrProcessorLoad>
                        <name>Index</name>
                        <method>walk</method>
                        <source>value</source>
                        <direction>input</direction>
                        <oid>1.3.6.1.2.1.25.3.3.1.2</oid>
                </hrProcessorLoad>
        </fields>
</interface>
where is my mistake?

thx 4 help and happy new year!

Andre
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please run from command line

Code: Select all

snmpwalk -c <community> -v 1 <host> 1.3.6.1.2.1.25.3.3.1
to check, if the host is responding. Please prepend your OIDs in the XML file with a leading . (dot).
Reinhard
fury
Posts: 13
Joined: Sun Dec 31, 2006 6:57 am

Post by fury »

thx.

now it is working. i restarted the snmp deamon and it worked.

Andre
finn
Posts: 13
Joined: Thu Dec 06, 2007 7:58 pm

Re: Chapter II: Insert all descriptive table columns

Post by finn »

e.g. the first Description will be fetched from OID = .1.3.6.1.2.1.25.2.3.1.3.1 (that is base OID = .1.3.6.1.2.1.25.2.3.1.3 together with the appended index .1 will form the complete OID .1.3.6.1.2.1.25.2.3.1.3.1.
Just trying to understand the behavour of this :)

From what I can see a "walk" on input will not have the index appended, but for output it will?

As when I was trying to get the descriptions for various CPU 5 min averages from a router for which there are multiple CPUs, the descriptions were stored amongst descriptions for other stuff. Therefore a walk would return a whole pile of unrelevant descriptions (meaning the index value was not appended to the OID)and was of no use to me. I had to use method "get" to ensure I only received the descriptions I was after based on the index values.

But if direction set to output a walk willl have index values appended?

Is this intentional?

I have a case where for the descriptions I need to retreive them based on the index value (which for input works with get), but for the actual data I do not want this, I simply want t o walk to get them:

Procedure for Devices with Multiple CPUs
http://www.cisco.com/warp/public/477/SN ... l#multiple

So I have this;

Code: Select all

<interface>
        <name>Cisco EnvMon CPU</name>
        <description>Get Cisco Environmental CPU Data</description>
        <oid_index>.1.3.6.1.4.1.9.9.109.1.1.1.1.2</oid_index>
        <fields>
               <CPUStatusDescr>
                        <name>CPU Description</name>
                        <method>get</method>
                        <source>value</source>
                        <direction>input</direction>
                        <oid>.1.3.6.1.2.1.47.1.1.1.1.7</oid>
               </CPUStatusDescr>
                <CPUStatus>
                        <name>CPU Status</name>
                        <method>walk</method>
                        <source>value</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.4.1.9.9.109.1.1.1.1.5</oid>
                </CPUStatus>

        </fields>


</interface>

This works fine for the descriptions, but for the output it's appending the index and it breaks..for the output I merely want to walk that oid!

(as in the index is only valid for fetching the descriptions, using the index for the output breaks it!)

So given the multicpu oid setup as described by the Cisco document I have linked to (where the description index is different tothat of the actual value index), is what I'm trying to accomplish possible?

Given this is my first attempt at doing an indexed SNMP data query I'm not sure if what I'm attempting is going to work or if I'm going to ahve to resort to excluding descriptions and rely on a human to enter them manually at point of graph creation?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please post snmpwalks of the OIDs used so I can understand better
Reinhard
finn
Posts: 13
Joined: Thu Dec 06, 2007 7:58 pm

Post by finn »

gandalf wrote:Please post snmpwalks of the OIDs used so I can understand better
Reinhard
Sure.

Ok to grab the actual CPU 5 min averages I can walk this:

Code: Select all

snmpwalk -v 2c -c public x.x.x.x 1.3.6.1.4.1.9.9.109.1.1.1.1.5
SNMPv2-SMI::enterprises.9.9.109.1.1.1.1.5.1 = Gauge32: 10
SNMPv2-SMI::enterprises.9.9.109.1.1.1.1.5.2 = Gauge32: 6
SNMPv2-SMI::enterprises.9.9.109.1.1.1.1.5.3 = Gauge32: 1
Ok, so this device returned results for three CPU's. Now, to quote the Cisco document "identify the physical entity to which these values correspond" I must walk the following:

Code: Select all

snmpwalk -v 2c -c public x.x.x.x .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: 3017
SNMPv2-SMI::enterprises.9.9.109.1.1.1.1.2.2 = INTEGER: 3001
SNMPv2-SMI::enterprises.9.9.109.1.1.1.1.2.3 = INTEGER: 1009
Ok, so now given the values 3017, 3001 and 1009 I can now retreive the descriptions for these three CPU's, by using oid .1.3.6.1.2.1.47.1.1.1.1.7 and appending the 3017,3001 and 1009 values:

Code: Select all

snmpget -v 2c -c public x.x.x.x .1.3.6.1.2.1.47.1.1.1.1.7.3017
SNMPv2-SMI::mib-2.47.1.1.1.1.7.3017 = STRING: "CPU of Routing Processor 5"

Code: Select all

 snmpget -v 2c -c public x.x.x.x .1.3.6.1.2.1.47.1.1.1.1.7.3001
SNMPv2-SMI::mib-2.47.1.1.1.1.7.3001 = STRING: "CPU of Switching Processor 5"

Code: Select all

 snmpget -v 2c -c public x.x.x.x .1.3.6.1.2.1.47.1.1.1.1.7.1009
SNMPv2-SMI::mib-2.47.1.1.1.1.7.1009 = STRING: "CPU of Sub-Module 1 CFC Card"

SO that's the problem. I can get the descriptions working by using .1.3.6.1.4.1.9.9.109.1.1.1.1.2 for the index. But then I can't fetch the CPU values. So as seen in my xml file, the descriptions arn't the problem.

So, when the index value is appended to the oid I want to walk to get the CPU values, it of course breaks (as that index is only valid for retreiving the descriptions). That's when I discovered that there appears to be different behaviour for get and walk in the xml interface depending on direction. For input if I do a walk it does not append index. As i if I did a walk for descriptions oid then it would retrive the whole list of everything. If I changed method to get then it did what I want. But for the output section, a walk does have the index value appended. And if using the index used to fetch the descriptions, it will break.

Hope that makes sense.

And cheers for any help, even if it's a " can't be done due ot the way they have implemented this on the 76s". At least then I know and wont worry about it any longer :)


Oh, and yeah if you just walk 1.3.6.1.2.1.47.1.1.1.1.7 (the oid used to get descriptions) then you get descriptions for all kinds of stuff:

Code: Select all

 snmpwalk -v 2c -c public x.x.x.x .1.3.6.1.2.1.47.1.1.1.1.7
SNMPv2-SMI::mib-2.47.1.1.1.1.7.1 = STRING: "CISCO7606-S"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.2 = STRING: "Physical Slot 1"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.3 = STRING: "Physical Slot 2"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.4 = STRING: "Physical Slot 3"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.5 = STRING: "Physical Slot 4"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.6 = STRING: "Physical Slot 5"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.7 = STRING: "Physical Slot 6"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.8 = STRING: "Backplane"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.9 = STRING: "fan-tray 1 fan-fail Sensor"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.10 = STRING: "Container of Fan FRU 1"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.11 = STRING: "FAN-MOD-6SHS 1"
SNMPv2-SMI::mib-2.47.1.1.1.1.7.12 = STRING: "Container of Container of Power Supply"
Rest of output deleted, as there's quite a bit of stuff in there!
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests