Ad Widget

Collapse

Help please script use NET::SNMP perl to monitor zabbix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DB601
    Member
    • Jun 2010
    • 30

    #1

    Help please script use NET::SNMP perl to monitor zabbix

    hello,

    i'm searching a way to use NET::SNMP in a script to return the name of each OID of NBAR protocols like SNMPwalk does

    I read the perldoc, it's not very clear for me because i don't control very well objects in perl.


    i found this:


    use strict;

    ## Validate the version of Perl

    BEGIN
    {
    die('Perl version 5.6.0 or greater is required') if ($] < 5.006);
    }

    ## Version of the Net::SNMP module

    our $VERSION = v5.2.0;

    ## Load our modules

    use Net::SNMP:ispatcher();
    use Net::SNMP::PDU qw( :ALL );
    use Net::SNMP::Security();
    use Net::SNMP::Transport qw( orts );
    ## Handle importing/exporting of symbols

    use Exporter();

    our @ISA = qw( Exporter );

    our @EXPORT = qw(
    INTEGER INTEGER32 OCTET_STRING OBJECT_IDENTIFIER IPADDRESS COUNTER
    COUNTER32 GAUGE GAUGE32 UNSIGNED32 TIMETICKS OPAQUE COUNTER64 NOSUCHOBJECT
    NOSUCHINSTANCE ENDOFMIBVIEW snmp_dispatcher
    );

    our @EXPORT_OK = qw( snmp_event_loop oid_context_match );

    our %EXPORT_TAGS = (
    asn1 => [
    qw( INTEGER INTEGER32 OCTET_STRING NULL OBJECT_IDENTIFIER SEQUENCE
    IPADDRESS COUNTER COUNTER32 GAUGE GAUGE32 UNSIGNED32 TIMETICKS
    OPAQUE COUNTER64 NOSUCHOBJECT NOSUCHINSTANCE ENDOFMIBVIEW
    GET_REQUEST GET_NEXT_REQUEST GET_RESPONSE SET_REQUEST TRAP
    GET_BULK_REQUEST INFORM_REQUEST SNMPV2_TRAP REPORT )
    ],
    debug => [
    qw( DEBUG_ALL DEBUG_NONE DEBUG_MESSAGE DEBUG_TRANSPORT DEBUG_DISPATCHER
    DEBUG_PROCESSING DEBUG_SECURITY snmp_debug )
    ],
    generictrap => [
    qw( COLD_START WARM_START LINK_DOWN LINK_UP AUTHENTICATION_FAILURE
    EGP_NEIGHBOR_LOSS ENTERPRISE_SPECIFIC )
    ],
    snmp => [
    qw( SNMP_VERSION_1 SNMP_VERSION_2C SNMP_VERSION_3 SNMP_PORT
    SNMP_TRAP_PORT snmp_debug snmp_dispatcher snmp_dispatch_once
    snmp_type_ntop oid_base_match oid_lex_sort ticks_to_time )
    ],
    translate => [
    qw( TRANSLATE_NONE TRANSLATE_OCTET_STRING TRANSLATE_NULL
    TRANSLATE_TIMETICKS TRANSLATE_OPAQUE TRANSLATE_NOSUCHOBJECT
    TRANSLATE_NOSUCHINSTANCE TRANSLATE_ENDOFMIBVIEW TRANSLATE_UNSIGNED
    TRANSLATE_ALL )
    ]
    );

    Exporter::export_ok_tags( qw( asn1 debug generictrap snmp translate ) );

    $EXPORT_TAGS{ALL} = [ @EXPORT_OK ];

    ## Debugging bit masks

    sub DEBUG_ALL() { 0xff } # All
    sub DEBUG_NONE() { 0x00 } # None
    sub DEBUG_MESSAGE() { 0x02 } # Message/PDU encoding/decoding
    sub DEBUG_TRANSPORT() { 0x04 } # Transport Layer
    sub DEBUG_DISPATCHER() { 0x08 } # Dispatcher
    sub DEBUG_PROCESSING() { 0x10 } # Message Processing
    sub DEBUG_SECURITY() { 0x20 } # Security

    ## Package variables

    our $DEBUG = DEBUG_NONE; # Debug mask

    our $DISPATCHER; # Dispatcher instance

    our $BLOCKING = 0; # Count of blocking objects

    our $NONBLOCKING = 0; # Count of non-blocking objects

    BEGIN
    {
    # Validate the creation of the Dispatcher object.

    if (!defined($DISPATCHER = Net::SNMP:ispatcher->instance)) {
    die('FATAL: Failed to create Dispatcher instance');
    }
    }



    How may i use it to have the name of my protocol ??
Working...