Is it possible to have SNMP string in notes?

Support questions about the Network Weather Map plugin

Moderators: Developers, Moderators

Post Reply
philipz
Cacti User
Posts: 100
Joined: Tue Sep 22, 2009 7:46 am

Is it possible to have SNMP string in notes?

Post by philipz »

I could not find an answer in the forum so here I go...

I am using up/down snmp interface statistics to color code the label for my switchports, so I have a TARGET already. Now I want to see the interface description in the Notes when I mouseover that label (or the icon if there is any).
Is that possible at all?

Thanks,

Phil
dionvdc
Posts: 46
Joined: Tue Feb 16, 2010 3:54 pm

Post by dionvdc »

Perhaps http://forums.cacti.net/viewtopic.php?t=38326 could help you, more specific the links within that thread.
philipz
Cacti User
Posts: 100
Joined: Tue Sep 22, 2009 7:46 am

Post by philipz »

dionvdc wrote:Perhaps http://forums.cacti.net/viewtopic.php?t=38326 could help you, more specific the links within that thread.
Hmm this is about PHP/overlib, not really about SNMP info in Notes unles I miss something...
Isn't it possible to put an SNMP GET string into a variable and use that variable as a Note (displayed at a Mouseover)?
dionvdc
Posts: 46
Joined: Tue Feb 16, 2010 3:54 pm

Post by dionvdc »

philipz wrote:
dionvdc wrote:Perhaps http://forums.cacti.net/viewtopic.php?t=38326 could help you, more specific the links within that thread.
Hmm this is about PHP/overlib, not really about SNMP info in Notes unles I miss something...
Isn't it possible to put an SNMP GET string into a variable and use that variable as a Note (displayed at a Mouseover)?
Yes it is about php/overlib.
But one of the threads mentioned has the title "Popup with snmp device info in weathermap", isn't that what you wanted?
For the SNMP GET bit, try it.
philipz
Cacti User
Posts: 100
Joined: Tue Sep 22, 2009 7:46 am

Post by philipz »

dionvdc wrote: Yes it is about php/overlib.
But one of the threads mentioned has the title "Popup with snmp device info in weathermap", isn't that what you wanted?
For the SNMP GET bit, try it.
The popup thread is about Java and PHP adaptation and the lot... Not my cup of tea :(

Here's my try:

Code: Select all

# check interface status and color label accordingly
TARGET snmp:{map:community}:{node:this:ip}:.1.3.6.1.2.1.2.2.1.8.{node:this:interface}:-
# get interface description
NOTES snmp:{map:community}:{node:this:ip}:.1.3.6.1.4.1.9.2.2.1.1.28.{node:this:interface}:-
The string replacements happen, but it doesn't do an SNMP query :(
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

It is possible. Check the manual for the SNMP datasource - there's a variable defined called something like snmp_raw_in which contains the actual returned data from SNMP, even if it is a string (the target will return 0 in that case).
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
philipz
Cacti User
Posts: 100
Joined: Tue Sep 22, 2009 7:46 am

Post by philipz »

Howie wrote:It is possible. Check the manual for the SNMP datasource - there's a variable defined called something like snmp_raw_in which contains the actual returned data from SNMP, even if it is a string (the target will return 0 in that case).
There's indeed a section like that in the manual (http://www.network-weathermap.com/manua ... .html#snmp), but does it work for a Note instead of a target? I'm not sure how to code this; I have already a target defined for that node.
There's no example in that part of the manual; any help would be greatly appreciated

tx,

Phil
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

It's in two stages. You have a node or link with a TARGET. That makes Weathermap speak SNMP to the device. After that it defines some variables that you can use most places there can be a string.

So...

Code: Select all

SET community public

NODE sdfsdf
    SET ip 10.1.1.22
    SET interface 2
    TARGET snmp:{map:community}:{node:this:ip}:.1.3.6.1.2.1.2.2.1.8.{node:this:interface}:.1.3.6.1.2.1.2.2.1.2.{node:this:interface}
    POSITION 100 100
    NOTES This interface is called {node:this:snmp_out_raw}
uses the 'in' value from the TARGET to colour the node (the OID is for ifOperStatus) and the 'out' value to collect the interface description.

If you need to do this for a link, where both in and out values are used for the link itself, you'll need to add an additional node to collect the extra information. You can position it off the side of the screen and refer to it from the notes of the link still:

NODE hidden1
TARGET etc etc

LINK visiblelink
NOTES My interface name is {node:hidden1:snmp_in_raw}
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
philipz
Cacti User
Posts: 100
Joined: Tue Sep 22, 2009 7:46 am

Post by philipz »

[quote="Howie"]

Code: Select all

SET community public

NODE sdfsdf
    SET ip 10.1.1.22
    SET interface 2
    TARGET snmp:{map:community}:{node:this:ip}:.1.3.6.1.2.1.2.2.1.8.{node:this:interface}:.1.3.6.1.2.1.2.2.1.2.{node:this:interface}
    POSITION 100 100
    NOTES This interface is called {node:this:snmp_out_raw}
When I applied this I get the following error:
07/01/2010 04:13:17 PM - WEATHERMAP: Poller[0] WARNING: [Map 12] MySite-LAN.conf: ReadData: NODE MyNode, target: snmp:MyCommunity:10.10.10.10:.1.3.6.1.2.1.2.2.1.8.11104:.1.3.6.1.4.1.9.2.2.1.1.28.11104 on config line 46 of /usr/local/share/cacti-0.8.7g-beta2/plugins/weathermap/configs/LAN.conf had no valid data, according to WeatherMapDataSource_snmp

It is quite strange though; for some nodes it works but definitely not for all.
Some don't have a description (empty string); would that make it fail?
It turns all my interfaces down in the map so no luck so far...

Update: not all interfaces are shown down but most of them are. It doesn't seem like the empty description is the source of the problem either. Some ports with an empty description show as "up" and have a description "unknown" (which is fine).
philipz
Cacti User
Posts: 100
Joined: Tue Sep 22, 2009 7:46 am

Post by philipz »

Fixed! I had "SET snmp_abort count" defined, which prevented Weathermap from getting all the interface descriptions. Not sure why, but removing that statement fixed the issue.

Thanks Howie and Dionvdc, I have a perfectly looking overview of my LAN now. The mouseover to give switch description/information is a killer feature :)

One more happy customer.

Phil
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

philipz wrote:Fixed! I had "SET snmp_abort count" defined, which prevented Weathermap from getting all the interface descriptions. Not sure why, but removing that statement fixed the issue.
The reason is that the current code can't tell the difference between an empty string and a failed request, so it treats an empty description as a 'failure'. snmp_abort_count tells weathermap to stop trying to talk to an SNMP host after it has had 'n' failures. This reduces the impact on poller runtime when you lose contact with your 800-port VSS chassis - you get 5*timeout seconds of delay instead of 800*timeout.

If you'd like to try it, I've made a couple of small changes for 0.98. They are:

in lib/datasources/WeatherMapDataSource_snmp.php, look for the two lines like:
if ($out_result) {
and
if ($in_result) {
near the bottom of the file.

and change them to
if ($out_result !== FALSE) {
and
if ($in_result !== FALSE) {

respectively. Then add that snmp_abort_count back in and you should still get your labels. I hope :-)
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests