[aklug] Re: Exit status of scripts

From: Royce Williams <royce@alaska.net>
Date: Fri Jun 05 2009 - 14:27:56 AKDT

Are you at liberty to show your config, or a similar one?

The syntax I'm talking about is as simple as

# snmpd.conf
extend my.branch "echo blah"

... and you should see

$ snmpwalk -v 1 -c redacted 192.168.42.42 NET-SNMP-EXTEND-MIB::nsExtendObjects | grep my.branch
NET-SNMP-EXTEND-MIB::nsExtendCommand."my.branch" = STRING: echo blah
NET-SNMP-EXTEND-MIB::nsExtendArgs."my.branch" = STRING:
NET-SNMP-EXTEND-MIB::nsExtendInput."my.branch" = STRING:
NET-SNMP-EXTEND-MIB::nsExtendCacheTime."my.branch" = INTEGER: 5
NET-SNMP-EXTEND-MIB::nsExtendExecType."my.branch" = INTEGER: exec(1)
NET-SNMP-EXTEND-MIB::nsExtendRunType."my.branch" = INTEGER: run-on-read(1)
NET-SNMP-EXTEND-MIB::nsExtendStorage."my.branch" = INTEGER: permanent(4)
NET-SNMP-EXTEND-MIB::nsExtendStatus."my.branch" = INTEGER: active(1)
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."my.branch" = STRING: blah
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."my.branch" = STRING: blah
NET-SNMP-EXTEND-MIB::nsExtendOutNumLines."my.branch" = INTEGER: 1
NET-SNMP-EXTEND-MIB::nsExtendResult."my.branch" = INTEGER: 0
NET-SNMP-EXTEND-MIB::nsExtendOutLine."my.branch".1 = STRING: blah

... or something pretty close to that, I'm playing a little fast and loose with the redacting.

Royce

James Zuelow wrote, on 6/5/2009 2:06 PM:
> Yes.
>
> But if I just print a value to sdtout or stderr, I don't get that same value back with snmpwalk (or OpenNMS, which is where I'm really going with this).
>
> For example:
>
> - /bin/bash
> - i=99
> - echo $i
>
> Will print out 99 to the shell, but snmpd sees a null value.
>
> James Zuelow....................CBJ MIS (907)586-0236
> Network Specialist...Registered Linux User No. 186591
>
>> -----Original Message-----
>> From: aklug-bounce@aklug.org [mailto:aklug-bounce@aklug.org]
>> On Behalf Of Royce Williams
>> Sent: Friday, 05 June, 2009 13:54
>> To: aklug@aklug.org
>> Subject: [aklug] Re: Exit status of scripts
>>
>> James Zuelow wrote, on 6/5/2009 1:46 PM:
>>> I can extend the net-snmp daemon by having it run scripts.
>>>
>>> Net-snmpd can use the exit value of the script, so for example:
>>>
>>> - /bin/bash
>>> - i=3D120
>>> - exit $i
>>>
>>> Would return "120" to snmpd when it ran the script. (When
>> it was queried fo=
>>> r that OID.)
>>>
>>> The problem is that exit values are limited to 255, and I
>> can see where you=
>>> could need values that exceed 255 returned to snmpd.
>> There's got to be a =
>>> way to have a script return larger values to snmpd, but I'm
>> not finding it =
>>> today.
>> Are you using NET-SNMP-EXTEND-MIB::nsExtendCommand? If so, the output
>> itself is what gets stuff into the OID, IIRC.
>>
>> Royce
>>
>> ---------
>> To unsubscribe, send email to <aklug-request@aklug.org>
>> with 'unsubscribe' in the message body.
>>

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Fri Jun 5 14:28:07 2009

This archive was generated by hypermail 2.1.8 : Fri Jun 05 2009 - 14:28:07 AKDT