RE: String to Integer - SNMP

This is a discussion on RE: String to Integer - SNMP ; > From: Clement Sciammas [mailto:csciammas@goodmailsystems.com] > Sent: Friday, October 10, 2008 10:47 AM > We are using net-snmp 5.3.0.1-25.25 and.doing an extend query > that is returning a string but we would like it to return an > integer because ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: RE: String to Integer

  1. RE: String to Integer

    > From: Clement Sciammas [mailto:csciammas@goodmailsystems.com]
    > Sent: Friday, October 10, 2008 10:47 AM


    > We are using net-snmp 5.3.0.1-25.25 and.doing an extend query
    > that is returning a string but we would like it to return an
    > integer because it is used by another application that will
    > only accept integer input. Here is the output from snmpget:


    The extend command only returns strings. You will need to parse the output line into an integer type in whatever scripting language or adapter you are using to process the output.


    HTH,

    Mike

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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/...net-snmp-users


  2. Re: String to Integer

    2008/10/13 Mike Ayers :
    >> From: Clement Sciammas [mailto:csciammas@goodmailsystems.com]


    >> We are using net-snmp 5.3.0.1-25.25 and.doing an extend query
    >> that is returning a string but we would like it to return an
    >> integer because it is used by another application that will
    >> only accept integer input.

    >
    > The extend command only returns strings.


    That's actually a slight over-simplification.
    The extend command actually returns two values:

    - the output of the command (a string), and
    - the exit value of the command (an integer)

    This latter value can be retrieved using the OID

    .1.3.6.1.4.1.8072.1.3.2.3.1.4."index"

    Unfortunately, this return code is limited to the
    range 0-255 (being the values handled by _exit(2))
    So that probably doesn't help you with this
    particular problem.

    Mike's suggestion of having the client side convert
    from string to integer is probably the best approach.

    Dave

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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/...net-snmp-users


  3. RE: String to Integer

    Mike/Dave,

    Thanks for the help.

    Unfortunately, the device making the query is a 3rd party load balancer that
    we do not have the ability to modify. Is there a way other than extend to
    get integer output of a local shell script?

    Thanks
    Clement

    -----Original Message-----
    From: Mike Ayers [mailto:mike_ayers@tvworks.com]
    Sent: Monday, October 13, 2008 11:25 AM
    To: Clement Sciammas; net-snmp-users@lists.sourceforge.net
    Subject: RE: String to Integer

    > From: Clement Sciammas [mailto:csciammas@goodmailsystems.com]
    > Sent: Friday, October 10, 2008 10:47 AM


    > We are using net-snmp 5.3.0.1-25.25 and.doing an extend query
    > that is returning a string but we would like it to return an
    > integer because it is used by another application that will
    > only accept integer input. Here is the output from snmpget:


    The extend command only returns strings. You will need to parse the
    output line into an integer type in whatever scripting language or adapter
    you are using to process the output.


    HTH,

    Mike


    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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/...net-snmp-users


  4. Re: String to Integer

    2008/10/13 Clement Sciammas :
    > Unfortunately, the device making the query is a 3rd party load balancer that
    > we do not have the ability to modify. Is there a way other than extend to
    > get integer output of a local shell script?


    There are basically two ways to extend the agent.

    One way is use a fixed-format MIB output, which is the approach
    used by the "extend" (and similar) directives. The advantage is
    that the agent script doesn't have to do anything special, and can
    be ignorant of SNMP completely. The disadvantage is that the
    client side has be a little more flexible, and adapt to this fixes format.

    The alternative is to have a specific MIB, more tightly focused on
    the precise requirements of the client side. That makes things
    simpler for the client, but does mean that the agent has to do a
    bit more work to match this MIB.

    It does sound as if that's the way you'll need to go.
    That doesn't mean you have to descend into the murky
    depths of writing a fully-fledged C module. Have a look
    at the "pass" directive - that ought to be sufficient.

    Dave

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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/...net-snmp-users


+ Reply to Thread