Problem with script ( custom mib )

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

Moderators: Developers, Moderators

Post Reply
iescoura
Posts: 5
Joined: Tue Dec 30, 2014 7:17 am

Problem with script ( custom mib )

Post by iescoura »

I'm having some trouble with creating script to graph an UPS with custom mib, i'm trying with this script:

# cat /usr/local/share/cacti/scripts/nobreakcp.sh
#!/usr/local/bin/bash
result=$(snmpwalk -m /usr/local/nobreakcp/mibcp.my -v 1 -c ******* X.X.X.X cpUpsInputCurrent | awk '{ print $4*0.1 }')
printf "$result"

When i run it manually, the result was:

# /usr/local/share/cacti/scripts/nobreakcp.sh
14.9

But running from cacti:

12/29/2014 10:55:04 AM - CMDPHP: Poller[0] Host[0] DS[5562] CMD: /usr/local/share/cacti/scripts/nobreakcp.sh, output: U
12/29/2014 10:59:01 AM - CMDPHP: Poller[0] Host[0] DS[5562] CMD: /usr/local/share/cacti/scripts/nobreakcp.sh, output: U

If i run a random script, using perl, it return an value


Any ideas?

Thanks!
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Problem with script ( custom mib )

Post by BSOD2600 »

I'd strongly recommend you make a copy of the 'SNMP - Generic OID Template' data template and use the numeric OID. What you're doing will not scale well at all.
iescoura
Posts: 5
Joined: Tue Dec 30, 2014 7:17 am

Re: Problem with script ( custom mib )

Post by iescoura »

I´ve tryed to use only snmp , but failed again:

01/05/2015 11:15:47 AM - POLLER: Poller[0] CACTI2RRD: /usr/local/bin/rrdtool update /usr/local/share/cacti/rra/nobreak_a_snmp_oid_5563.rrd --template snmp_oid 1420463746:U
01/05/2015 11:15:47 AM - POLLER: Poller[0] CACTI2RRD: /usr/local/bin/rrdtool update /usr/local/share/cacti/rra/nobreak_a_snmp_oid_5564.rrd --template snmp_oid 1420463746:U
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Problem with script ( custom mib )

Post by BSOD2600 »

Post an snmpwalk of the numeric OID from the cacti server to the device in question.
iescoura
Posts: 5
Joined: Tue Dec 30, 2014 7:17 am

Re: Problem with script ( custom mib )

Post by iescoura »

(root@stats)# snmpwalk -v 1 -c t3mp0r4r14 10.0.10.41 1.3.6.1.4.1.3778.1.2.3.0
SNMPv2-SMI::enterprises.3778.1.2.3.0 = INTEGER: 15
(root@stats)# snmpwalk -v 1 -c t3mp0r4r14 10.0.10.41 .1.3.6.1.4.1.3778.1.3.5.1.2
SNMPv2-SMI::enterprises.3778.1.3.5.1.2.1 = INTEGER: 2007
(root@stats)# snmpwalk -m /usr/local/nobreakcp/mibcp.my -v 1 -c t3mp0r4r14 10.0.10.41 1.3.6.1.4.1.3778.1.2.3.0
CP-UPS-MIB::cpUpsEstimatedMinutesRemaining.0 = INTEGER: 15 minutes
(root@stats)# snmpwalk -m /usr/local/nobreakcp/mibcp.my -v 1 -c t3mp0r4r14 10.0.10.41 .1.3.6.1.4.1.3778.1.3.5.1.2
CP-UPS-MIB::cpUpsInputVoltage.1 = INTEGER: 1995 0.1 RMS Volts
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Problem with script ( custom mib )

Post by BSOD2600 »

What OID did you use in the 'SNMP - Generic OID Template'? Do you see that in the poller cache for that device? What about in cacti.log once you increase the logging level?
iescoura
Posts: 5
Joined: Tue Dec 30, 2014 7:17 am

Re: Problem with script ( custom mib )

Post by iescoura »

I used the oid .1.3.6.1.4.1.3778.1.3.5.1.3 , tryed others like .1.3.6.1.4.1.3778.1.3.5.1.2 and .1.3.6.1.4.1.3778.1.3.5.1.0, but no success

The error:

01/07/2015 08:19:28 AM - CMDPHP: Poller[0] Host[439] DS[5563] WARNING: Result from SNMP not valid. Partial Result: U
01/07/2015 08:19:28 AM - CMDPHP: Poller[0] Host[439] DS[5563] SNMP: v1: 10.0.10.41, dsname: snmp_oid, oid: .1.3.6.1.4.1.3778.1.3.5.1.3, output: U
01/07/2015 08:19:28 AM - POLLER: Poller[0] CACTI2RRD: /usr/local/bin/rrdtool update /usr/local/share/cacti/rra/nobreak_a_snmp_oid_5563.rrd --template snmp_oid 1420625968:U


(root@stats)# snmpwalk -v 1 -c t3mp0r4r14 10.0.10.41 .1.3.6.1.4.1.3778.1.3.5.1.3
SNMPv2-SMI::enterprises.3778.1.3.5.1.3.1 = INTEGER: 187

Any idea?
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Problem with script ( custom mib )

Post by BSOD2600 »

You're not specifying a valid OID. Pay close attention to the OID returned by the snmpwalk vs what you're using -- they dont match.

Try the following in cacti: .1.3.6.1.4.1.3778.1.3.5.1.3.1
iescoura
Posts: 5
Joined: Tue Dec 30, 2014 7:17 am

Re: Problem with script ( custom mib )

Post by iescoura »

BSOD2600, thanks for your help

The snmp is working perfectly now.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests