Nikulski.net
SNMP query tool
1. Introduction

This tool execute SNMP GET / GET-NEXT / GET-BULK / WALK. The definition of OIDs are stored in a simple XML file.
            
    Usage: snmpQuery.pl -h <ip/file> -c <comunity> [options]

    Parameter:
        -h <ip/file>    IP or file (a listof IPs) of ERS IP address
        -c <comunity>   SNMPv2 read comunity

    Option:
        -m <file>       MIB file
        -debug

    Examples:
        snmpQuery.pl -h 192.168.1.8 -c public
        snmpQuery.pl -h ip_hosts.txt -c public -m mibQuery.xml
        snmpQuery.pl -h ip_hosts.txt -c public -debug
            
        
2. XML file to configure SNMP queries

To be able to process very flexible SNMP command, a XML file is given to formulate what you want to do. The content looks like this:
            

    &lt;?xml version='1.0'?&gt;
    <opt>
        <About>
            <Info>MIB OID file for snmp.pl</Info>
            <Type>OIDs</Type>
            <Version>1</Version>
        </About>
        <query>
            <!-- ipForwarding -->
            <oid>1.3.6.1.2.1.4.1.0</oid>         <!-- OID(s) -->
            <oid>1.3.6.1.2.1.5.1.0</oid>
            <methode>get_request</methode>       <!-- get_request / get_next_request / get_bulk_request / walk_request -->
        </query>
        <query>
            <!--interface description -->
            <oid>1.3.6.1.2.1.2.2.1.2.0</oid>
            <methode>get_next_request</methode>
            <delay>1700</delay>                  <!-- delay the query in milliseconds (is optional) -->
        </query>
        <query>
            <!--interface alias -->
            <oid>1.3.6.1.2.1.31.1.1.1.18</oid>
            <methode>get_bulk_request</methode>
            <repetitions>20</repetitions>        <!-- 1 - 30 (default 10) (is optional) -->
        </query>
        <query>
            <!--Synomptics chassis description -->
            <oid>1.3.6.1.4.1.45.1.6.3.3.1.1.5</oid>
            <methode>walk_request</methode>
            <repetitions>10</repetitions>
        </query>
    </opt>
                
            
        
3. Example output

here a example how the display output looks like.
            
    C:\Perl64\scripts\SNMP>snmpQuery.pl -h 192.168.1.8 -c public -m mibQuery.xml
    [**.**.**.**] run query 1 as get_request
    [**.**.**.**] OIDs: 1.3.6.1.2.1.4.1.0
                        1.3.6.1.2.1.5.1.0
    [192.168.1.8] response  = '2'
    [192.168.1.8] response  = '0'
    [**.**.**.**] query 1 processed in  0.040 seconds
    [**.**.**.**] delay query 2 for 1.700 seconds
    [**.**.**.**] run query 2 as get_next_request
    [**.**.**.**] OID: '1.3.6.1.2.1.2.2.1.2.0'
    [192.168.1.8] response  = 'Avaya Ethernet Routing Switch 4550T PWR Module - Port 1  '
    [**.**.**.**] query 2 processed in  2.028 seconds
    [**.**.**.**] run query 3 as get_bulk_request
    [**.**.**.**] OID: '1.3.6.1.2.1.31.1.1.1.18'
    [192.168.1.8] response .1 = 'NAC'
    [192.168.1.8] response .2 = 'NAC'
    [192.168.1.8] response .3 = 'NAC'
    [192.168.1.8] response .4 = 'NAC'
    [192.168.1.8] response .5 = 'NAC'
    [192.168.1.8] response .6 = 'NAC'
    [192.168.1.8] response .7 = 'NAC'
    [192.168.1.8] response .8 = 'NAC'
    [192.168.1.8] response .9 = 'NAC'
    [192.168.1.8] response .10 = 'NAC'
    [192.168.1.8] response .11 = 'NAC'
    [192.168.1.8] response .12 = 'NAC'
    [192.168.1.8] response .13 = ''
    [192.168.1.8] response .14 = ''
    [192.168.1.8] response .15 = ''
    [192.168.1.8] response .16 = ''
    [192.168.1.8] response .17 = ''
    [192.168.1.8] response .18 = ''
    [192.168.1.8] response .19 = ''
    [192.168.1.8] response .20 = ''
    [**.**.**.**] query 3 processed in  0.023 seconds
    [**.**.**.**] run query 4 as walk_request
    [**.**.**.**] OID: '1.3.6.1.4.1.45.1.6.3.3.1.1.5'
    [192.168.1.8] response .3.10.0 = '50 ports 10/100BaseT with PoE plus 2 10/100/1000/SFP combo ports'
    [192.168.1.8] response .3.10.1 = ''
    [192.168.1.8] response .3.10.2 = ''
    [192.168.1.8] response .3.10.3 = ''
    [192.168.1.8] response .4.10.0 = 'Primary Power Supply'
    [192.168.1.8] response .4.11.0 = 'Redundant Power Supply'
    [192.168.1.8] response .5.10.0 = 'Temperature Sensor'
    [192.168.1.8] response .6.10.0 = 'Internal Fan 1'
    [192.168.1.8] response .6.11.0 = 'Internal Fan 2'
    [192.168.1.8] response .6.12.0 = 'Internal Fan 3'
    [192.168.1.8] response .4.10.0 = 'Primary Power Supply'
    [192.168.1.8] response .4.11.0 = 'Redundant Power Supply'
    [192.168.1.8] response .5.10.0 = 'Temperature Sensor'
    [192.168.1.8] response .6.10.0 = 'Internal Fan 1'
    [192.168.1.8] response .6.11.0 = 'Internal Fan 2'
    [192.168.1.8] response .6.12.0 = 'Internal Fan 3'
    [192.168.1.8] response .6.13.0 = 'Internal Fan 4'
    [192.168.1.8] response .8.1.0 = '50 ports 10/100BaseT with PoE plus 2 10/100/1000/SFP combo ports'
    [**.**.**.**] query 4 processed in  0.425 seconds
    [main] processed in  2.519 seconds