|query_ifSpeed| returns the wrong value

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

jas0420
Cacti User
Posts: 91
Joined: Thu Jan 13, 2005 3:58 pm
Location: College Station, TX - USA

|query_ifSpeed| returns the wrong value

Post by jas0420 »

I've got a weird one... May just be my misunderstanding of query_ifSpeed, but........

I've been graphing % utilization on my WAN circuits by running a CDEF against the tunnel interfaces. Works great. I had to do the rrd.php update by KC (midway down on this link: http://forums.cacti.net/viewtopic.php?t=3030) to get the query_ifSpeed functionality. (At least I think I had to... If I back out the changes, all of my working utilization graphs fail.)

I've found that if I try this on a server NIC though that it returns the Index value of the interface rather than the speed of the interface. I'm using the same CDEF (same graph template, actually).

Here's a snippet from the graph debug that shows cdef's "b" and "g" using a value of 65539. This is what query_ifSpeed filled in from the CDEF string.

Code: Select all

DEF:a="C\:\cacti/rra/server_ratl0sm02_10_80_2_65_traffic_in_1059.rrd":traffic_in:LAST \
DEF:b="C\:\cacti/rra/server_ratl0sm02_10_80_2_65_traffic_in_1059.rrd":traffic_out:LAST \
CDEF:cdefb=a,65539,/,100,*,8,* \
CDEF:cdefg=b,65539,/,100,*,8,* \

Here's a look at the SNMP Interface details from the device view of the server. The second NIC is the one I was working on. Note the Index is 65539.

Code: Select all

Index  Status  Description                          Type    Speed    
1      1       MS TCP Loopback interface            24      10000000  
65539  1       Broadcom NetXtreme Gigabit Ethernet  6       1000000000   
So, it's clearly grabbing that rather than the 1000000000. Skews my numbers quite a bit... Although 29,000% utilization would be cool... :)

Thanks for any input,
Jason
User avatar
stevew
Posts: 26
Joined: Tue Aug 17, 2004 12:39 pm
Location: London
Contact:

Post by stevew »

Can you try a verbose query on the "snmp - interface statistics" from the device page for that router. Here's a snippet from my output:

Code: Select all

+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.5'
+ Found item [ifSpeed='100000000'] index: 1 [from value]
+ Found item [ifSpeed='100000000'] index: 2 [from value]
[url=http://www.welham.net/]Steve W[/url]
jas0420
Cacti User
Posts: 91
Joined: Thu Jan 13, 2005 3:58 pm
Location: College Station, TX - USA

Post by jas0420 »

It seemed to pick up on it correctly when doing that.....

Snippet:

Code: Select all

+ Found item [ifSpeed='10000000'] index: 1 [from value]
+ Found item [ifSpeed='1000000000'] index: 65539 [from value]

Whole output:

Code: Select all

+ Running data query [1].
+ Found type = '3' [snmp query].
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ XML file parsed ok.
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.2.1.2.2.1.1'
+ Located input field 'ifIndex' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.1'
+ Found item [ifIndex='1'] index: 1 [from value]
+ Found item [ifIndex='65539'] index: 65539 [from value]
+ Located input field 'ifOperStatus' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.8'
+ Found item [ifOperStatus='1'] index: 1 [from value]
+ Found item [ifOperStatus='1'] index: 65539 [from value]
+ Located input field 'ifDescr' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.2'
+ Found item [ifDescr='MS TCP Loopback interface'] index: 1 [from value]
+ Found item [ifDescr='Broadcom NetXtreme Gigabit Ethernet'] index: 65539 [from value]
+ Located input field 'ifName' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.31.1.1.1.1'
+ Located input field 'ifAlias' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.31.1.1.1.18'
+ Located input field 'ifType' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.3'
+ Found item [ifType='24'] index: 1 [from value]
+ Found item [ifType='6'] index: 65539 [from value]
+ Located input field 'ifSpeed' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.5'
+ Found item [ifSpeed='10000000'] index: 1 [from value]
+ Found item [ifSpeed='1000000000'] index: 65539 [from value]
+ Located input field 'ifHwAddr' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.6'
+ Found item [ifHwAddr=''] index: 1 [from value]
+ Found item [ifHwAddr='00:06:5B:F3:2E:32'] index: 65539 [from value]
+ Located input field 'ifIP' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.4.20.1.2'
+ Found item [ifIP='10.80.2.65'] index: 65539 [from regexp oid parse]
+ Found item [ifIP='127.0.0.1'] index: 1 [from regexp oid parse]
jas0420
Cacti User
Posts: 91
Joined: Thu Jan 13, 2005 3:58 pm
Location: College Station, TX - USA

Post by jas0420 »

Can't explain it, but this started working sometime tonight. I don't know what I did to fix it either because I wasn't trying to this evening!

I know that I did not change the CDEF, the graph, or the graph template.

I know that I removed and re-applied (only by /*commenting*/ out so the actual code never changed) KC's modifications to the rrd.php file for query_ifSpeed. I know that commenting out the changes broke all of my other working utilization graphs so I removed the comment flags to get them going again. Never bothered to check if it changed the graph in question because there was no reason for it to!

I also did the verbose query for Steve above. Again, didn't check to see if anything changed... No reason to expect it to.

The only other out of the norm thing I did was reboot the Cacti server...

Strange. Definitely working though.

Code: Select all

CDEF:cdefb=a,1000000000,/,100,*,8,* \
CDEF:cdefg=b,1000000000,/,100,*,8,* \
Jason
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

jas0420,

Please post your modified lib/rrd.php file.

Thanx,

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
jas0420
Cacti User
Posts: 91
Joined: Thu Jan 13, 2005 3:58 pm
Location: College Station, TX - USA

Post by jas0420 »

Here ya go... Renamed from rrd.php to rrd.txt so that it would attach here.

-jas
Attachments
rrd.txt
rrd.php modified to account for query_ifSpeed as per instructions by "KC"
(45.72 KiB) Downloaded 564 times
jas0420
Cacti User
Posts: 91
Joined: Thu Jan 13, 2005 3:58 pm
Location: College Station, TX - USA

Post by jas0420 »

For what it is worth, I have added the graph mentioned above to several more servers (pre-existing in Cacti).

In each case, query_ifSpeed returned the index # of the NIC rather than the speed of the NIC and threw the CDEF math wayyyy off. I narrowed down what fixed it above to Steve's suggestion of doing a Verbose Query on the SNMP Interface.

The simple act of doing that resolved the issue every time. Once I did that, I would refresh the web browser where I was viewing the incorrect #'s and when it reloaded the page, everything was correct.

So.... Thanks Steve for the inquiry! You wound up fixing it! (Or at least giving me a workaround!)

Jason
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

There are three reindex methods in Cacti:

Uptime Goes Backwards,
Number of Indexes Change,
Verify Always

The First and Second are fairly good, the last is more poller intensive, but will keep you indexes in line.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
jas0420
Cacti User
Posts: 91
Joined: Thu Jan 13, 2005 3:58 pm
Location: College Station, TX - USA

Post by jas0420 »

Point noted.

If it looks like the changes aren't sticking for some reason, I'll bug ya for some more details on that. So far, so good though!

Thanks,
Jason
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

I have sent to Cacti author for some comment and thoughts.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
jas0420
Cacti User
Posts: 91
Joined: Thu Jan 13, 2005 3:58 pm
Location: College Station, TX - USA

Post by jas0420 »

I went through a couple of reboots on the Cacti server today (hung tping processes that you saw in the other thread!)... Just wanted to pass along that all of the correct interface values survived the reboots, so it looks like the verbose snmp scan modified the db and it stuck correctly.

jas
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

I created a patch that will allow you to substitute data query variables (such as ifSpeed) directly into CDEF strings. Luckily Cacti already has support for this in the graph legend, so adding CDEF support was straightforward. Just like the above modification, just apply the patch and create a custom CDEF item that contains '|query_ifSpeed|'. This patch however works with any data query input field, rather than just ifSpeed.

Let me know if anyone has any questions.

-Ian
Attachments
cdef_data_query_variables.patch
Patch for data query variables in CDEF strings
(1.63 KiB) Downloaded 442 times
jas0420
Cacti User
Posts: 91
Joined: Thu Jan 13, 2005 3:58 pm
Location: College Station, TX - USA

Post by jas0420 »

Hi Ian. It's Monday morning and I didn't get enough coffee today, so I'm probably just not understanding what you are saying, but...

I failed to post my CDEF string in the original message, but I was already using |query_ifSpeed| in the CDEF. My CDEF has always read:

Code: Select all

cdef=CURRENT_DATA_SOURCE,|query_ifSpeed|,/,100,*,8,*

(take either traffic_in or traffic out depenting on the DS I'm linked to, divide it by the interface speed, multiply it by 100 for percentage, and multipy by 8 to change it from bytes to bits. I then stacked the _in and _out results to get a total % utilized.)

That is the CDEF that was polling and grabbing the wrong value for interface speed as demonstrated in the the two graph template lines from my first message (and would work once I did the verbose SNMP query).

Code: Select all

CDEF:cdefb=a,65539,/,100,*,8,* \ 
CDEF:cdefg=b,65539,/,100,*,8,* \
Sorry that I didn't specify the CDEF string in the first message. Apologies too if I didn't grasp what you were suggesting.

Thanks,
Jason
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

Sorry, I did misunderstand your post a bit. The problem you are describing here is that the ifIndex value is ending up where the ifSpeed should be. Can you execute the following SQL query against your Cacti database and return the results?

Code: Select all

select field_name,field_value,snmp_index from host_snmp_cache where host_id = HOST_ID and snmp_query_id = 1 order by snmp_index;
Be sure to substitute 'HOST_ID' with the ID of the device you are dealing with.

-Ian
jas0420
Cacti User
Posts: 91
Joined: Thu Jan 13, 2005 3:58 pm
Location: College Station, TX - USA

Post by jas0420 »

I made a new Cacti device by adding a new server. I immediately ran the SQL query you asked for against it. Results were:

Image

I let it go for a few poller cycles and found that it demonstrated the same behavior as mentioned above... From my CDEF

Code: Select all

cdef=CURRENT_DATA_SOURCE,|query_ifSpeed|,/,100,*,8,* 
it replaced query_ifSpeed with the index number of the NIC as you can see here in the graph debug:

Code: Select all

CDEF:cdefa=a,65539,/,100,*,8,* \
CDEF:cdefb=b,65539,/,100,*,8,* \
I then did the Verbose SNMP Query "workaround" above from the device view of the new server. It yielded the following results:



Code: Select all

+ Running data query [1].
+ Found type = '3' [snmp query].
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ XML file parsed ok.
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.2.1.2.2.1.1'
+ Located input field 'ifIndex' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.1'
+ Found item [ifIndex='1'] index: 1 [from value]
+ Found item [ifIndex='65539'] index: 65539 [from value]
+ Found item [ifIndex='65540'] index: 65540 [from value]
+ Found item [ifIndex='131077'] index: 131077 [from value]
+ Located input field 'ifOperStatus' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.8'
+ Found item [ifOperStatus='1'] index: 1 [from value]
+ Found item [ifOperStatus='1'] index: 65539 [from value]
+ Found item [ifOperStatus='1'] index: 65540 [from value]
+ Found item [ifOperStatus='1'] index: 131077 [from value]
+ Located input field 'ifDescr' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.2'
+ Found item [ifDescr='MS TCP Loopback interface'] index: 1 [from value]
+ Found item [ifDescr='Broadcom NetXtreme Gigabit Ethernet'] index: 65539 [from value]
+ Found item [ifDescr='Broadcom NetXtreme Gigabit Ethernet #2'] index: 65540 [from value]
+ Found item [ifDescr='WAN (PPP/SLIP) Interface'] index: 131077 [from value]
+ Located input field 'ifName' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.31.1.1.1.1'
+ Located input field 'ifAlias' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.31.1.1.1.18'
+ Located input field 'ifType' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.3'
+ Found item [ifType='24'] index: 1 [from value]
+ Found item [ifType='6'] index: 65539 [from value]
+ Found item [ifType='6'] index: 65540 [from value]
+ Found item [ifType='23'] index: 131077 [from value]
+ Located input field 'ifSpeed' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.5'
+ Found item [ifSpeed='10000000'] index: 1 [from value]
+ Found item [ifSpeed='1000000000'] index: 65539 [from value]
+ Found item [ifSpeed='1000000000'] index: 65540 [from value]
+ Found item [ifSpeed='19200'] index: 131077 [from value]
+ Located input field 'ifHwAddr' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.6'
+ Found item [ifHwAddr=''] index: 1 [from value]
+ Found item [ifHwAddr='00:0B:DB:E2:96:D8'] index: 65539 [from value]
+ Found item [ifHwAddr='00:0B:DB:E2:96:D9'] index: 65540 [from value]
+ Found item [ifHwAddr='00:53:45:00:00:00'] index: 131077 [from value]
+ Located input field 'ifIP' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.2.1.4.20.1.2'
+ Found item [ifIP='10.80.100.14'] index: 65539 [from regexp oid parse]
+ Found item [ifIP='127.0.0.1'] index: 1 [from regexp oid parse]
+ Found item [ifIP='192.168.0.60'] index: 65540 [from regexp oid parse]
+ Found item [ifIP='192.168.234.235'] index: 131077 [from regexp oid parse]
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
+ Found data query XML file at 'C:\apachefriends\xampp\cacti/resource/snmp_queries/interface.xml'
I refreshed my browser that had been displaying the graph with the 72,000% utilization and found it had dropped down to a more reasonable 4% and the graph debug showed that the CDEF had found the right number this time:

Code: Select all

CDEF:cdefa=a,1000000000,/,100,*,8,* \
CDEF:cdefb=b,1000000000,/,100,*,8,* \
So I went back and re-ran the SQL queries I did at the first of the thread and wasn't too surprised to find it identical as it was before the "Verbose SNMP Query" since everything seemed in order the first time around.

Weird, huh??
Jason
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests