Domanda

I have the nagios with two host. one is localhost(10.10.62.5) and another one is ubuntu(10.10.62.10). i set up nagios monitor on localhost.

host configuration files are below

localhost.cfg:

define host{
    use                     linux-server           
    host_name               localhost
    alias                   localhost
    address                 10.10.62.5
    }

define service{ 
host_name       localhost   
service_description WSN_COUNT   
is_volatile     1   
check_command       check-host-alive    
max_check_attempts  1
normal_check_interval   1
retry_check_interval    1
active_checks_enabled   0   
passive_checks_enabled  1   
check_period        24x7    
notification_interval   31536000    
notification_period 24x7    
notification_options    w,u,c   
notifications_enabled   1
 }

ubuntu.cfg:

define host{
  use    linux-server
  host_name ubuntu
  alias  ubuntu
  address    10.10.62.10
}
define service{ 
host_name    localhost  
service_description WSN_COUNT   
is_volatile  1  
check_command    check-host-alive   
max_check_attempts  1
normal_check_interval   1
retry_check_interval    1
active_checks_enabled   0   
passive_checks_enabled  1   
check_period     24x7   
notification_interval   31536000    
notification_period 24x7    
notification_options    w,u,c   
notifications_enabled   1
}

MIBfile:

NAGIOS-TRAP-TEST-MIB DEFINITIONS ::= BEGIN
IMPORTS enterprises FROM SNMPv2-SMI;

nagiostests OBJECT IDENTIFIER ::= { enterprises 0 }
nagiostraps OBJECT IDENTIFIER ::= { nagiostests 1 }
nagiosnotifs OBJECT IDENTIFIER ::= { nagiostests 2 }

WSNcount NOTIFICATION-TYPE
        OBJECTS { sysLocation }
        STATUS current
        DESCRIPTION "SNMPv2c notification"
        ::= { nagiosnotifs 9 }
END

I used snmptt(net-snmp) to integrate the traps with nagios. configuration files are

snmptt.conf.local:

    EVENT WSNcount .1.3.6.1.4.1.0.2.1 "Status Events" Normal
FORMAT SNMPv2c notification $*
EXEC /usr/local/nagios/libexec/eventhandlers/submit_check_result localhost WSN_COUNT 1 "SNMPv2c notification $*"
SDESC
SNMPv2c notification
Variables:
  1: sysLocation
EDESC

snmptt.conf.local:

    EVENT WSNcount .1.3.6.1.4.1.0.2.1 "Status Events" Normal
FORMAT SNMPv2c notification $*
EXEC /usr/local/nagios/libexec/eventhandlers/submit_check_result ubuntu WSN_COUNT 1 "SNMPv2c notification $*"
SDESC
SNMPv2c notification
Variables:
   1: sysLocation
EDESC

When i sending trap from ubuntu(10.10.62.10) machine using following command, trap sending to both hosts in nagios.

    snmptrap -v 2c -c private 10.10.62.5 "" NAGIOS-TRAP-TEST-MIB::RFIDcount SNMPv2-MIB::sysLocation.0 s "snmptest trap"

PLEASE help me with send trap to particular host.. how it is possible...

È stato utile?

Soluzione

I think you misinterpreted what a SNMP-trap is. A SNMP-trap is a SNMP message sent to your monitoring system/service from a network device such as a router, switch, blade, cluster, ..

I guess the thing you want to do is search the MIB-file for the particular network device you want to monitor and search the OID that matches the information you want the gather from that specific device.

The device you want to monitor through SNMP has to have SNMP enabled in it's configuration (webbased or something..).

You can do a SNMPwalk to this device to see all available OIDs :

snmpwalk -v 2c -c public <ip address network device>

-c stands for 'community' and by default this is 'public', you can edit this in the configuration of your network device.

-v stands for the version of SNMP you want to use.

When you find the OID which provides you the device's information you wore looking for you can do the following command (or put this in a perl or bash script) :

snmpwalk -v 2c -c public <ip address network device> <OID>

When you made this script you can define a command for this script in commands.cfg :

#'check_lefthand' command definition
define command{        
    command_name    check_lefthand  
    command_line    $USER1$/lefthands.pl $ARG1$ $ARG2$
    }

You can now use this check_ in your service definitions of Nagios.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top