OID Tree, Branch Counter

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

Moderators: Moderators, Developers

Post Reply
Author
Message
User avatar
mojiro
Cacti User
Posts: 121
Joined: Sun Jul 24, 2005 12:20 pm
Location: Ireland, Dublin

OID Tree, Branch Counter

#1 Post by mojiro » Sat Jan 19, 2008 3:42 pm

How it works:

You provide an OID that, via snmpwalk will return other OID's, then they will be counted and given to cacti poller to graph them...

ex.
Under 1.3.6.1.2.1.4.22.1.4 there is information about ARP Table, but there is no OID to provide the number of records, so you have to count them somehow...

Code: Select all

~# snmpwalk -v 1 -c public 10.86.87.110 1.3.6.1.2.1.4.22.1.4
IP-MIB::ipNetToMediaType.2.10.86.87.129 = INTEGER: dynamic(3)
IP-MIB::ipNetToMediaType.2.10.86.89.130 = INTEGER: dynamic(3)
IP-MIB::ipNetToMediaType.2.10.86.89.131 = INTEGER: dynamic(3)
IP-MIB::ipNetToMediaType.2.10.86.89.133 = INTEGER: dynamic(3)
IP-MIB::ipNetToMediaType.3.10.86.87.109 = INTEGER: dynamic(3)

~# snmpwalk -v 1 -c public 10.86.87.110 1.3.6.1.2.1.4.22.1.4 | wc -l | awk '{printf$0}'

5~#

Note: This is a very usable template has it been posted again ?
Attachments
cacti_graph_template_unix_-_oid_counter.xml
(9.84 KiB) Downloaded 1028 times
[i]Born to be online![/i]

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

#2 Post by gandalf » Sun Jan 20, 2008 5:02 pm

Thank you for your contribution.
I would recommend, placing /full/path/to/everything for external command into your shell script. In general, cactiuser has not necessarily the same $PATH settings!
Reinhard

User avatar
mojiro
Cacti User
Posts: 121
Joined: Sun Jul 24, 2005 12:20 pm
Location: Ireland, Dublin

#3 Post by mojiro » Sun Jan 20, 2008 5:08 pm

this is a bit problem... :-?

I used not to prefer full paths because, I use custom compiled tools (ex php, net-snmp) and in my system are.. /usr/local/php/bin/php

... and at other systems /usr/sbin/php

I will try to fix all of my work :)
[i]Born to be online![/i]

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

#4 Post by gandalf » Sun Jan 20, 2008 5:13 pm

mojiro wrote:this is a bit problem... :-?
Confirmed. You may simply provide a README that tells the user what to do. And perhaps make the script stop if nothing is configured.
Reinhard

User avatar
mojiro
Cacti User
Posts: 121
Joined: Sun Jul 24, 2005 12:20 pm
Location: Ireland, Dublin

#5 Post by mojiro » Wed Jan 23, 2008 4:35 am

I think... that using variable:|path_php_binary|

in my scripts/templates is better..., isn't it ? :)

edit:

I think there is one for snmpwalk, or I am wrong ?
[i]Born to be online![/i]

User avatar
juliangomezr
Posts: 32
Joined: Tue Jun 30, 2009 11:26 am

Re: OID Tree, Branch Counter

#6 Post by juliangomezr » Mon Mar 27, 2017 3:22 pm

Hi, I am trying to use the script, but the graph always shows 0.

I tried with the oid 1.3.6.1.2.1.4.22.1.4 and 1.3.6.1.2.1.4.22.1.2, but there is no difference.

what coudl be wrong, I did not found the system paths, that you were talking about, on the xml files...
Attachments
data source.PNG
data source.PNG (32.7 KiB) Viewed 1379 times
data input.PNG
data input.PNG (25.91 KiB) Viewed 1379 times

User avatar
mojiro
Cacti User
Posts: 121
Joined: Sun Jul 24, 2005 12:20 pm
Location: Ireland, Dublin

Re: OID Tree, Branch Counter

#7 Post by mojiro » Mon Mar 27, 2017 3:58 pm

are you sure that this OID gives results?
[i]Born to be online![/i]

User avatar
juliangomezr
Posts: 32
Joined: Tue Jun 30, 2009 11:26 am

Re: OID Tree, Branch Counter

#8 Post by juliangomezr » Mon Mar 27, 2017 6:20 pm

Yes, even I exceuted the script in a console and I got a result.

see the images.
Attachments
oid 2.png
oid 2.png (2.55 KiB) Viewed 1357 times
oid 1.png
oid 1.png (4.77 KiB) Viewed 1357 times

User avatar
mojiro
Cacti User
Posts: 121
Joined: Sun Jul 24, 2005 12:20 pm
Location: Ireland, Dublin

Re: OID Tree, Branch Counter

#9 Post by mojiro » Tue Mar 28, 2017 4:47 pm

do they following test:
- give temporary ssh/terminal access to www-data/apache/nginx user + password
- login as www-data/apache/nginx user
- execute

I think it fails because some of the apps (snmpwalk, wc, awk) are either only in sbin either are not in that user's $PATH.

If it is $PATH issue, do:

Code: Select all

# whereis awk
awk: /usr/bin/awk /usr/share/awk /usr/share/man/man1/awk.1.gz
... and replace awk with /usr/bin/awk

do the same for snmpwalk and wc.

In any other case... post here and we will check it :)
[i]Born to be online![/i]

Post Reply