← Back to team overview

nagios-charmers team mailing list archive

[Bug 1882302] [NEW] Enable sending snmp traps funcionality

 

Public bug reported:

This is an enhancement request.

Currently nagios charm does not have the functionality of sending snmp
traps. It's relatively simple to implement this functionality.

This has been implemented and tested in the field and proved to work
well. It sould be further improved (like for example creating a charm
option for the IP address of the server to send traps to and turning
extraconfig and scripts into templates).

This is the way it is working today:

------------------------------>8======================================

1) Configure Juju:

juju config nagios contactgroup-members="root,managementstation"

juju config nagios extraconfig='
#
# this file was automaticaly generated by the nagios charm, do not edit it

define command{
        command_name send-service-trap
        command_line /usr/local/bin/send-service-trap 10.129.162.181 public "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$"
}

define command{
        command_name send-host-trap
        command_line /usr/local/bin/send-host-trap 10.129.162.181 public "$HOSTNAME$" $HOSTSTATEID$ "$HOSTOUTPUT$"
}

define contact{
        contact_name                    managementstation
        alias                           Management Station
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r,f,s
        host_notification_options       d,u,r,f,s
        service_notification_commands   send-service-trap
        host_notification_commands      send-host-trap
}

2) on the nagios/0 (or more if HA) machine, download some MIBs:

wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/nagios-plugins/nagios-mib/master/MIB/NAGIOS-ROOT-MIB
wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/nagios-plugins/nagios-mib/master/MIB/NAGIOS-NOTIFY-MIB
wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/hardaker/net-snmp/master/mibs/SNMPv2-SMI.txt
wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/hardaker/net-snmp/master/mibs/SNMPv2-MIB.txt
wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/hardaker/net-snmp/master/mibs/SNMPv2-TC.txt

3) Also on the nagios/0 (or more if HA) machine, create two scripts:

cat >/usr/local/bin/send-service-trap <<EOF
#!/bin/bash

# Arguments:
# $1 = Management Station
# $2 = Community String
# $3 = host_name
# $4 = service_description (Description of the service)
# $5 = return_code (An integer that determines the state
#       of the service check, 0=OK, 1=WARNING, 2=CRITICAL,
#       3=UNKNOWN).
# $6 = plugin_output (A text string that should be used
#       as the plugin output for the service check)
#
/usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "$3" nSvcDesc s "$4" nSvcStateID i $5 nSvcOutput s "$6"
EOF

cat >/usr/local/bin/send-host-trap <<EOF
#!/bin/bash

# Arguments:
# $1 = Management Station
# $2 = Community String
# $3 = host_name
# $4 = HostStatID A number that corresponds to the current state of the host: 0=UP, 1=DOWN, 2=UNREACHABLE.
# $5 = HOSTOUTPUT The first line of text output from the last host check (i.e. "Ping OK").
#
/usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nHostEvent nHostname s "$3" nHostStateID i $4 nHostOutput s "$5"
EOF

chmod +x /usr/local/bin/send-service-trap /usr/local/bin/send-host-trap

------------------------------>8======================================


This bug is open to track the implementation of these changes on the charm.

** Affects: charm-nagios
     Importance: Undecided
     Assignee: Andre Ruiz (andre-ruiz)
         Status: New

** Changed in: charm-nagios
     Assignee: (unassigned) => Andre Ruiz (andre-ruiz)

** Description changed:

- 
  This is an enhancement request.
  
  Currently nagios charm does not have the functionality of sending snmp
  traps. It's relatively simple to implement this functionality.
  
  This has been implemented and tested in the field and proved to work
  well. It sould be further improved (like for example creating a charm
  option for the IP address of the server to send traps to and turning
  extraconfig and scripts into templates).
  
  This is the way it is working today:
  
  ------------------------------>8======================================
  
  1) Configure Juju:
  
  juju config nagios contactgroup-members="root,managementstation"
  
  juju config nagios extraconfig='
  #
  # this file was automaticaly generated by the nagios charm, do not edit it
  
  define command{
-         command_name send-service-trap
-         command_line /usr/local/bin/send-service-trap 10.129.162.181 public "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$"
+         command_name send-service-trap
+         command_line /usr/local/bin/send-service-trap 10.129.162.181 public "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$"
  }
  
  define command{
-         command_name send-host-trap
-         command_line /usr/local/bin/send-host-trap 10.129.162.181 public "$HOSTNAME$" $HOSTSTATEID$ "$HOSTOUTPUT$"
+         command_name send-host-trap
+         command_line /usr/local/bin/send-host-trap 10.129.162.181 public "$HOSTNAME$" $HOSTSTATEID$ "$HOSTOUTPUT$"
  }
  
  define contact{
-         contact_name                    managementstation
-         alias                           Management Station
-         service_notification_period     24x7
-         host_notification_period        24x7
-         service_notification_options    w,u,c,r,f,s
-         host_notification_options       d,u,r,f,s
-         service_notification_commands   send-service-trap
-         host_notification_commands      send-host-trap
+         contact_name                    managementstation
+         alias                           Management Station
+         service_notification_period     24x7
+         host_notification_period        24x7
+         service_notification_options    w,u,c,r,f,s
+         host_notification_options       d,u,r,f,s
+         service_notification_commands   send-service-trap
+         host_notification_commands      send-host-trap
  }
  
  2) on the nagios/0 (or more if HA) machine, download some MIBs:
  
  wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/nagios-plugins/nagios-mib/master/MIB/NAGIOS-ROOT-MIB
  wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/nagios-plugins/nagios-mib/master/MIB/NAGIOS-NOTIFY-MIB
  wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/hardaker/net-snmp/master/mibs/SNMPv2-SMI.txt
  wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/hardaker/net-snmp/master/mibs/SNMPv2-MIB.txt
  wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/hardaker/net-snmp/master/mibs/SNMPv2-TC.txt
  
  3) Also on the nagios/0 (or more if HA) machine, create two scripts:
  
  cat >/usr/local/bin/send-service-trap <<EOF
  #!/bin/bash
  
  # Arguments:
  # $1 = Management Station
  # $2 = Community String
  # $3 = host_name
  # $4 = service_description (Description of the service)
  # $5 = return_code (An integer that determines the state
  #       of the service check, 0=OK, 1=WARNING, 2=CRITICAL,
  #       3=UNKNOWN).
  # $6 = plugin_output (A text string that should be used
  #       as the plugin output for the service check)
  #
  /usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "$3" nSvcDesc s "$4" nSvcStateID i $5 nSvcOutput s "$6"
  EOF
  
  cat >/usr/local/bin/send-host-trap <<EOF
  #!/bin/bash
  
  # Arguments:
  # $1 = Management Station
  # $2 = Community String
  # $3 = host_name
  # $4 = HostStatID A number that corresponds to the current state of the host: 0=UP, 1=DOWN, 2=UNREACHABLE.
  # $5 = HOSTOUTPUT The first line of text output from the last host check (i.e. "Ping OK").
  #
  /usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nHostEvent nHostname s "$3" nHostStateID i $4 nHostOutput s "$5"
  EOF
  
  chmod +x /usr/local/bin/send-service-trap /usr/local/bin/send-host-trap
  
+ ------------------------------>8======================================
  
- This bug is open to track the implementation of these changes on the
- charm.
+ 
+ This bug is open to track the implementation of these changes on the charm.

-- 
You received this bug notification because you are a member of Nagios
Charm developers, which is subscribed to Nagios Charm.
https://bugs.launchpad.net/bugs/1882302

Title:
  Enable sending snmp traps funcionality

Status in Nagios Charm:
  New

Bug description:
  This is an enhancement request.

  Currently nagios charm does not have the functionality of sending snmp
  traps. It's relatively simple to implement this functionality.

  This has been implemented and tested in the field and proved to work
  well. It sould be further improved (like for example creating a charm
  option for the IP address of the server to send traps to and turning
  extraconfig and scripts into templates).

  This is the way it is working today:

  ------------------------------>8======================================

  1) Configure Juju:

  juju config nagios contactgroup-members="root,managementstation"

  juju config nagios extraconfig='
  #
  # this file was automaticaly generated by the nagios charm, do not edit it

  define command{
          command_name send-service-trap
          command_line /usr/local/bin/send-service-trap 10.129.162.181 public "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$"
  }

  define command{
          command_name send-host-trap
          command_line /usr/local/bin/send-host-trap 10.129.162.181 public "$HOSTNAME$" $HOSTSTATEID$ "$HOSTOUTPUT$"
  }

  define contact{
          contact_name                    managementstation
          alias                           Management Station
          service_notification_period     24x7
          host_notification_period        24x7
          service_notification_options    w,u,c,r,f,s
          host_notification_options       d,u,r,f,s
          service_notification_commands   send-service-trap
          host_notification_commands      send-host-trap
  }

  2) on the nagios/0 (or more if HA) machine, download some MIBs:

  wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/nagios-plugins/nagios-mib/master/MIB/NAGIOS-ROOT-MIB
  wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/nagios-plugins/nagios-mib/master/MIB/NAGIOS-NOTIFY-MIB
  wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/hardaker/net-snmp/master/mibs/SNMPv2-SMI.txt
  wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/hardaker/net-snmp/master/mibs/SNMPv2-MIB.txt
  wget -P /usr/share/snmp/mibs/ https://raw.githubusercontent.com/hardaker/net-snmp/master/mibs/SNMPv2-TC.txt

  3) Also on the nagios/0 (or more if HA) machine, create two scripts:

  cat >/usr/local/bin/send-service-trap <<EOF
  #!/bin/bash

  # Arguments:
  # $1 = Management Station
  # $2 = Community String
  # $3 = host_name
  # $4 = service_description (Description of the service)
  # $5 = return_code (An integer that determines the state
  #       of the service check, 0=OK, 1=WARNING, 2=CRITICAL,
  #       3=UNKNOWN).
  # $6 = plugin_output (A text string that should be used
  #       as the plugin output for the service check)
  #
  /usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "$3" nSvcDesc s "$4" nSvcStateID i $5 nSvcOutput s "$6"
  EOF

  cat >/usr/local/bin/send-host-trap <<EOF
  #!/bin/bash

  # Arguments:
  # $1 = Management Station
  # $2 = Community String
  # $3 = host_name
  # $4 = HostStatID A number that corresponds to the current state of the host: 0=UP, 1=DOWN, 2=UNREACHABLE.
  # $5 = HOSTOUTPUT The first line of text output from the last host check (i.e. "Ping OK").
  #
  /usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nHostEvent nHostname s "$3" nHostStateID i $4 nHostOutput s "$5"
  EOF

  chmod +x /usr/local/bin/send-service-trap /usr/local/bin/send-host-
  trap

  ------------------------------>8======================================

  
  This bug is open to track the implementation of these changes on the charm.

To manage notifications about this bug go to:
https://bugs.launchpad.net/charm-nagios/+bug/1882302/+subscriptions


Follow ups