Hi Akshay,

I'm sure careful study of the source code would reveal exactly the
circumstances when the program will exit with a non-zero return value.
Maybe one of the developers will chime in, if you're lucky, but
unfortunately I have no time for such study at present.
However, I know of at least one more circumstance where it returns 1. That
being if you give the program faulty command line arguments, whereupon it
will print a help text and exit with status 1.
If you'll permit me to guess, it seems reasonable that snmpget would also
return 1 in other failure modes. For example, if snmpget fails to execute
because the system has too many active processes and cannot allocate a new
PID, I'll bet it doesn't return 0. Likewise if the process receives a kill
signal before finishing. But again, this is just speculation.

BR,
Joel


On Fri, Mar 14, 2014 at 12:35 PM, Ballarpure, Akshay (EXT-Tata Consultancy
Ser - IN/Hyderabad) <akshay.ballarpure....@nsn.com> wrote:

>  Thanks Joel for quick response.
>
>
>
> We can get snmp-get response = 1 only in case of timeout or there are any
> other scenarios  where we can get it as "1" ?
>
>
>
> --
>
> With regards,
>
> Akshay
>
>
>
> *From:* ext Joel Hansell [mailto:joel.hans...@gmail.com]
> *Sent:* Thursday, March 13, 2014 3:48 PM
> *To:* Ballarpure, Akshay (EXT-Tata Consultancy Ser - IN/Hyderabad)
> *Cc:* net-snmp-users@lists.sourceforge.net
> *Subject:* Re: SNMP get response result
>
>
>
> Hi Akshay,
>
> I'm not part of the dev team, but I can give an educated guess as to why
> it behaves like that.
>
> As you know, the Unix convention for return status is that if the command
> exits normally, it should return 0. It should only return some other number
> if the command failed to execute as expected, and in other words the output
> will not be complete.
>
> In the case of the timeout, that's a failure to reach the Agent (for
> whatever reason), and thus the command is not delivering the requested data
> to the user. So it exits with status 1, to indicate that it failed to
> provide the requested information.
>
> The other failure you posted (No Such Object), however, is a different
> story. Here, there was a response from the Agent, where the Agent is saying
> that the requested OID is not available in its MIB view. The snmpget
> command prints the response and exits, which is considered normal operation.
>
> So, I think there is a certain logic to it. If there is a response, print
> the response and exit with status 0. If there is no response, for some
> reason, exit with error status. It doesn't consider what the content of the
> response is.
>
> If you need to find out if an error was returned from the Agent, then
> you'll have to parse the printed output.
>
>
>
> Best regards,
> Joel Hansell
>
>
>
> On Thu, Mar 13, 2014 at 7:04 AM, Ballarpure, Akshay (EXT-Tata Consultancy
> Ser - IN/Hyderabad) <akshay.ballarpure....@nsn.com> wrote:
>
> Hello,
>
> I would like to know the response of snmp get in case of failure. We are
> getting zero in most of the success cases.
>
> If we can get 1 in case of timeout, shall we use value of "$?" as snmp
> success and failure (0 and 1 respectively) on Solaris box ? please reply
> asap. Thanks
>
>
>
>
>
> TCSH02-fm-1# /opt/MOTcagt/bin/snmpget -v3 -u admin -a SHA -A
> 09618538758384384367 -x AES -X 86095694849620176636 -l authPriv
> 27.182.4.222 1.3.6.1.2.1.1.5.0
>
> SNMPv2-MIB::sysName.0 = STRING: NESIM-60001-ENodeB980
>
> TCSH02-fm-1# echo $?
>
> 0
>
> TCSH02-fm-1# /opt/MOTcagt/bin/snmpget -v3 -u admin -a SHA -A
> 09618538758384384367 -x AES -X 86095694849620176636 -l authPriv
> 27.182.4.222 1.3.6.1.2.1.1.5.01
>
> SNMPv2-MIB::sysName.1 = No Such Object available on this agent at this OID
>
> TCSH02-fm-1# echo $?
>
> 0
>
> TCSH02-fm-1# /opt/MOTcagt/bin/snmpget -v3 -u admin -a SHA -A
> 09618538758384384367 -x AES -X 86095694849620176636 -l authPriv
> 27.182.18.51 1.3.6.1.2.1.1.5.0
>
> SNMPv2-MIB::sysName.0 = STRING: TCSH02-fm-sb
>
> TCSH02-fm-1# /opt/MOTcagt/bin/snmpget -v3 -u admin -a SHA -A
> 09618538758384384367 -x AES -X 86095694849620176636 -l authPriv
> 27.182.18.51 1.3.6.1.2.1.1.5.0
>
> SNMPv2-MIB::sysName.0 = STRING: TCSH02-fm-sb
>
> TCSH02-fm-1# /opt/MOTcagt/bin/snmpget -v3 -u admin -a SHA -A
> 09618538758384384367 -x AES -X 86095694849620176636 -l authPriv
> 27.182.18.48 1.3.6.1.2.1.1.5.0
>
> snmpget: Timeout
>
> TCSH02-fm-1#  echo $?
>
> 1
>
>
>
> --
>
> With regards,
>
> Akshay
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Net-snmp-users mailing list
> Net-snmp-users@lists.sourceforge.net
> Please see the following page to unsubscribe or change other options:
> https://lists.sourceforge.net/lists/listinfo/net-snmp-users
>
>
>
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
  • SNMP get resp... Ballarpure, Akshay (EXT-Tata Consultancy Ser - IN/Hyderabad)
    • Re: SNMP... Joel Hansell
      • RE: ... Ballarpure, Akshay (EXT-Tata Consultancy Ser - IN/Hyderabad)
        • ... Joel Hansell

Reply via email to