Recieving SNMP Traps

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
ahoward12
Posts: 137
Joined: Thu Jan 05, 2017 10:24 am

Re: Recieving SNMP Traps

Post by ahoward12 »

I consolidated all of the files as you said, and removed the 3 entries from the snmptt.ini file. I changed the lines around on all of the entries so the EXEC line is above the FORMAT, however I am still getting nowhere with having it being translated incorrectly for lack of better phrase.

Here is my new, consolidated snmptt.conf:

Code: Select all

#
#
#
EVENT coldStart .1.3.6.1.6.3.1.1.5.1 "Status Events" Normal
FORMAT Device reinitialized (coldStart)
#EXEC qpage -f TRAP notifygroup1 "Device reinitialized (coldStart)"
SDESC
A coldStart trap signifies that the SNMPv2 entity, acting
in an agent role, is reinitializing itself and that its
configuration may have been altered.
EDESC
#
#
#
EVENT warmStart .1.3.6.1.6.3.1.1.5.2 "Status Events" Normal
FORMAT Device reinitialized (warmStart)
#EXEC qpage -f TRAP notifygroup1 "Device reinitialized (warmStart)"
SDESC
A warmStart trap signifies that the SNMPv2 entity, acting
in an agent role, is reinitializing itself such that its
configuration is unaltered.
EDESC
#
#
#
EVENT linkDown .1.3.6.1.6.3.1.1.5.3 "Status Events" Normal
FORMAT Link down on interface $1.  Admin state: $2.  Operational state: $3
#EXEC qpage -f TRAP notifygroup1 "Link down on interface $1.  Admin state: $2.  Operational state: $3"
SDESC
A linkDown trap signifies that the SNMP entity, acting in
an agent role, has detected that the ifOperStatus object for
one of its communication links is about to enter the down
state from some other state (but not from the notPresent
state).  This other state is indicated by the included value
of ifOperStatus.
EDESC
#
#
#
EVENT linkUp .1.3.6.1.6.3.1.1.5.4 "Status Events" Normal
FORMAT Link up on interface $1.  Admin state: $2.  Operational state: $3
#EXEC qpage -f TRAP notifygroup1 "Link up on interface $1.  Admin state: $2.  Operational state: $3"
SDESC
A linkUp trap signifies that the SNMP entity, acting in an
agent role, has detected that the ifOperStatus object for
one of its communication links left the down state and
transitioned into some other state (but not into the
notPresent state).  This other state is indicated by the
included value of ifOperStatus.
EDESC
#
#
#
EVENT authenticationFailure .1.3.6.1.6.3.1.1.5.5 "Status Events" Normal
FORMAT SNMP athentication failure
#EXEC qpage -f TRAP notifygroup1 "SNMP authentication failure"
SDESC
An authenticationFailure trap signifies that the SNMPv2
entity, acting in an agent role, has received a protocol
message that is not properly authenticated.  While all
implementations of the SNMPv2 must be capable of generating
this trap, the snmpEnableAuthenTraps object indicates
whether this trap will be generated.
EDESC
#
#
#
#
MIB: LIEBERT-GP-AGENT-MIB (file:/usr/share/snmp/mibs/LIEBERT_GP_AGENT.MIB) converted on Tue Oct 17 11:27:45 2017 using snmpttconvertmib v1.4beta2
#
#
#
EVENT lgpAgentDeviceCommunicationLost .1.3.6.1.4.1.476.1.42.2.3.0.1 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The agent has lost communications with a managed device. $*
SDESC
The agent has lost communications with a managed device.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentFirmwareUpdateSuccessful .1.3.6.1.4.1.476.1.42.2.3.0.5 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The firmware update to the agent card has completed successfully. $*
SDESC
The firmware update to the agent card has completed successfully.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentFirmwareCorrupt .1.3.6.1.4.1.476.1.42.2.3.0.6 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The firmware update to the agent card has failed and the firmware is $*
SDESC
The firmware update to the agent card has failed and the firmware is
now corrupt.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentHeartbeat .1.3.6.1.4.1.476.1.42.2.3.0.7 "Status Events" Critical
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The agent card is alive. $*
SDESC
The agent card is alive.
Variables:
  1: sysUpTime
  2: lgpConditionsPresent
  3: lgpAgentConnectedDeviceCount
EDESC
#
#
#
EVENT lgpAgentDnsLookupFailure .1.3.6.1.4.1.476.1.42.2.3.0.8 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT A Domain Name System (DNS) lookup of a network name failed to $*
SDESC
A Domain Name System (DNS) lookup of a network name failed to
resolve.  This may result in one or more of the following:
1. failure to notify a target address of an important condition
2. failure allow access for monitoring purposes
This issue should be resolved as soon as possible with a
network or system administrator.
Variables:
  1: sysUpTime
  2: lgpNetworkName
EDESC
#
#
#
EVENT lgpAgentDeviceCommunicationLostLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.1 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The agent has lost communications with a managed device. $*
SDESC
The agent has lost communications with a managed device.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentFirmwareUpdateSuccessfulLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.5 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The firmware update to the agent card has completed successfully. $*
SDESC
The firmware update to the agent card has completed successfully.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentFirmwareCorruptLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.6 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The firmware update to the agent card has failed and the firmware is $*
SDESC
The firmware update to the agent card has failed and the firmware is
now corrupt.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentHeartbeatLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.7 "Status Events" Critical
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT Well this is bullshit.
SDESC The agent card is alive.
EDESC
#
#
#
EVENT lgpAgentDnsLookupFailureLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.8 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT A Domain Name System (DNS) lookup of a network name failed to $*
SDESC
A Domain Name System (DNS) lookup of a network name failed to
resolve.  This may result in one or more of the following:
1. failure to notify a target address of an important condition
2. failure allow access for monitoring purposes
This issue should be resolved as soon as possible with a
network or system administrator.
Variables:
  1: sysUpTime
  2: lgpNetworkName
EDESC
#
#
#
#
MIB: LIEBERT-GP-SYSTEM-MIB (file:/usr/share/snmp/mibs/LIEBERT_GP_SYSTEM.MIB) converted on Tue Oct 17 18:23:51 2017 using snmpttconvertmib v1.4beta2
#
#
#
EVENT lgpSysNotification .1.3.6.1.4.1.476.1.42.3.7.8.1 "Status Events" Critical
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT This notification is a generic notification intended for direct user $*
SDESC
This notification is a generic notification intended for direct user
visibility.  The user event description identifies the system
condition that has occurred.  This text will be prefixed with either
'Active:', 'Cleared:', or 'Message:' depending on the state of the
event.  Note: That a prefix of 'Message:' identifies a stateless event
and as such there will be no corresponding 'Cleared:' trap sent.
Variables:
  1: sysUpTime
  2: lgpSysEventDescription
EDESC
#
#
#
EVENT lgpSysCritical .1.3.6.1.4.1.476.1.42.3.7.8.2 "Status Events" Critical
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The system has returned to a Critical operating state. This implies $*
SDESC
The system has returned to a Critical operating state. This implies
prior to the generation of this event the system was operating in a
state where one or more alarm or warning conditions were present.
All of those alarms or conditions have now cleared.
NOTE: This notification may be generated after a short delay during a
cold boot of the system -- if no alarms or conditions are present in the
monitored device(s) at that time.
Variables:
  1: sysUpTime
  2: lgpAgentConnectedDeviceCount
EDESC
#
#
#
#
MIB: UPS-MIB (file:/usr/share/snmp/mibs/RFC1628_UPS_MIB.MIB) converted on Thu Oct 19 13:51:06 2017 using snmpttconvertmib v1.4beta2
#
#
#
EVENT upsTrapOnBattery .1.3.6.1.2.1.33.2.1 "Status Events" Critical
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The UPS is operating on battery power.  This trap is $*
SDESC
The UPS is operating on battery power.  This trap is
persistent and is resent at one minute intervals until
the UPS either turns off or is no longer running on
battery.
Variables:
  1: upsEstimatedMinutesRemaining
  2: upsSecondsOnBattery
  3: upsConfigLowBattTime
EDESC
#
#
#
EVENT upsTrapTestCompleted .1.3.6.1.2.1.33.2.2 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT This trap is sent upon completion of a UPS diagnostic $*
SDESC
This trap is sent upon completion of a UPS diagnostic
test.
Variables:
  1: upsTestId
  2: upsTestSpinLock
  3: upsTestResultsSummary
  4: upsTestResultsDetail
  5: upsTestStartTime
  6: upsTestElapsedTime
EDESC
#
#
#
EVENT upsTrapAlarmEntryAdded .1.3.6.1.2.1.33.2.3 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT This trap is sent each time an alarm is inserted into $*
SDESC
This trap is sent each time an alarm is inserted into
to the alarm table.  It is sent on the insertion of
all alarms except for upsAlarmOnBattery and
upsAlarmTestInProgress.
Variables:
  1: upsAlarmId
  2: upsAlarmDescr
EDESC
#
#
#
EVENT upsTrapAlarmEntryRemoved .1.3.6.1.2.1.33.2.4 "Status Events" Normal
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT This trap is sent each time an alarm is removed from $*
SDESC
This trap is sent each time an alarm is removed from
the alarm table.  It is sent on the removal of all
alarms except for upsAlarmTestInProgress.
Variables:
  1: upsAlarmId
  2: upsAlarmDescr
EDESC
This is the one I am focusing on for the time being:

Code: Select all

EVENT lgpAgentHeartbeatLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.7 "Status Events" Critical
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The agent card is alive.
SDESC The agent card is alive.
EDESC
My snmptt.log shows this still:

Code: Select all

Wed Nov  1 17:05:55 2017 .1.3.6.1.4.1.476.1.42.2.3.0.0.7 Critical "Status Events" 10.10.99.245 - The agent card is alive. 12:2:53:24.90 0 1
While event viewer and, in-turn, my text messages are this:

Code: Select all

SERVICE ALERT: Core UPS Rack 3 .245;SNMP Traps;CRITICAL;HARD;1;12:2:53:24.90 0 1 / sysUpTime (TICKS):12:2:53:24.90 lgpConditionsPresent (GAUGE):0 lgpAgentConnectedDeviceCount (UNSIGNED32):1
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Recieving SNMP Traps

Post by tgriep »

Change that trap from

Code: Select all

EVENT lgpAgentHeartbeatLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.7 "Status Events" Critical
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
FORMAT The agent card is alive.
SDESC The agent card is alive.
EDESC
to

Code: Select all

EVENT lgpAgentHeartbeatLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.7 "Status Events" Critical
FORMAT The agent card is alive.
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC The agent card is alive.
EDESC
The EXEC line has to be under the FORMAT line.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ahoward12
Posts: 137
Joined: Thu Jan 05, 2017 10:24 am

Re: Recieving SNMP Traps

Post by ahoward12 »

I had that changed already, I apologize I just pasted the *old* snmptt.conf in the code box. Either way it makes no difference as far as formatting, whether the FORMAT line is above or below the EXEC line, the outcome is still the same.

Here is my current snmptt.conf:

Code: Select all

#
#
#
EVENT coldStart .1.3.6.1.6.3.1.1.5.1 "Status Events" Normal
FORMAT Device reinitialized (coldStart)
#EXEC qpage -f TRAP notifygroup1 "Device reinitialized (coldStart)"
SDESC
A coldStart trap signifies that the SNMPv2 entity, acting
in an agent role, is reinitializing itself and that its
configuration may have been altered.
EDESC
#
#
#
EVENT warmStart .1.3.6.1.6.3.1.1.5.2 "Status Events" Normal
FORMAT Device reinitialized (warmStart)
#EXEC qpage -f TRAP notifygroup1 "Device reinitialized (warmStart)"
SDESC
A warmStart trap signifies that the SNMPv2 entity, acting
in an agent role, is reinitializing itself such that its
configuration is unaltered.
EDESC
#
#
#
EVENT linkDown .1.3.6.1.6.3.1.1.5.3 "Status Events" Normal
FORMAT Link down on interface $1.  Admin state: $2.  Operational state: $3 
#EXEC qpage -f TRAP notifygroup1 "Link down on interface $1.  Admin state: $2.  Operational state: $3"
SDESC
A linkDown trap signifies that the SNMP entity, acting in
an agent role, has detected that the ifOperStatus object for
one of its communication links is about to enter the down
state from some other state (but not from the notPresent
state).  This other state is indicated by the included value
of ifOperStatus.
EDESC
#
#
#
EVENT linkUp .1.3.6.1.6.3.1.1.5.4 "Status Events" Normal
FORMAT Link up on interface $1.  Admin state: $2.  Operational state: $3
#EXEC qpage -f TRAP notifygroup1 "Link up on interface $1.  Admin state: $2.  Operational state: $3"
SDESC
A linkUp trap signifies that the SNMP entity, acting in an
agent role, has detected that the ifOperStatus object for
one of its communication links left the down state and
transitioned into some other state (but not into the
notPresent state).  This other state is indicated by the
included value of ifOperStatus.
EDESC
#
#
#
EVENT authenticationFailure .1.3.6.1.6.3.1.1.5.5 "Status Events" Normal
FORMAT SNMP athentication failure
#EXEC qpage -f TRAP notifygroup1 "SNMP authentication failure"
SDESC
An authenticationFailure trap signifies that the SNMPv2
entity, acting in an agent role, has received a protocol
message that is not properly authenticated.  While all
implementations of the SNMPv2 must be capable of generating
this trap, the snmpEnableAuthenTraps object indicates
whether this trap will be generated.
EDESC
#
#
#
#
MIB: LIEBERT-GP-AGENT-MIB (file:/usr/share/snmp/mibs/LIEBERT_GP_AGENT.MIB) converted on Tue Oct 17 11:27:45 2017 using snmpttconvertmib v1.4beta2
#
#
#
EVENT lgpAgentDeviceCommunicationLost .1.3.6.1.4.1.476.1.42.2.3.0.1 "Status Events" Normal
FORMAT The agent has lost communications with a managed device. $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
The agent has lost communications with a managed device.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentFirmwareUpdateSuccessful .1.3.6.1.4.1.476.1.42.2.3.0.5 "Status Events" Normal
FORMAT The firmware update to the agent card has completed successfully. $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
The firmware update to the agent card has completed successfully.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentFirmwareCorrupt .1.3.6.1.4.1.476.1.42.2.3.0.6 "Status Events" Normal
FORMAT The firmware update to the agent card has failed and the firmware is $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
The firmware update to the agent card has failed and the firmware is
now corrupt.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentHeartbeat .1.3.6.1.4.1.476.1.42.2.3.0.7 "Status Events" Critical
FORMAT The agent card is alive. $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
The agent card is alive.
Variables:
  1: sysUpTime
  2: lgpConditionsPresent
  3: lgpAgentConnectedDeviceCount
EDESC
#
#
#
EVENT lgpAgentDnsLookupFailure .1.3.6.1.4.1.476.1.42.2.3.0.8 "Status Events" Normal
FORMAT A Domain Name System (DNS) lookup of a network name failed to $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
A Domain Name System (DNS) lookup of a network name failed to
resolve.  This may result in one or more of the following:
1. failure to notify a target address of an important condition
2. failure allow access for monitoring purposes
This issue should be resolved as soon as possible with a
network or system administrator.
Variables:
  1: sysUpTime
  2: lgpNetworkName
EDESC
#
#
#
EVENT lgpAgentDeviceCommunicationLostLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.1 "Status Events" Normal
FORMAT The agent has lost communications with a managed device. $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
The agent has lost communications with a managed device.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentFirmwareUpdateSuccessfulLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.5 "Status Events" Normal
FORMAT The firmware update to the agent card has completed successfully. $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
The firmware update to the agent card has completed successfully.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentFirmwareCorruptLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.6 "Status Events" Normal
FORMAT The firmware update to the agent card has failed and the firmware is $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
The firmware update to the agent card has failed and the firmware is
now corrupt.
Variables:
  1: sysUpTime
EDESC
#
#
#
EVENT lgpAgentHeartbeatLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.7 "Status Events" Critical
FORMAT Well this is bullshit.
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC The agent card is alive.
EDESC
#
#
#
EVENT lgpAgentDnsLookupFailureLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.8 "Status Events" Normal
FORMAT A Domain Name System (DNS) lookup of a network name failed to $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
A Domain Name System (DNS) lookup of a network name failed to
resolve.  This may result in one or more of the following:
1. failure to notify a target address of an important condition
2. failure allow access for monitoring purposes
This issue should be resolved as soon as possible with a
network or system administrator.
Variables:
  1: sysUpTime
  2: lgpNetworkName
EDESC
#
#
#
#
MIB: LIEBERT-GP-SYSTEM-MIB (file:/usr/share/snmp/mibs/LIEBERT_GP_SYSTEM.MIB) converted on Tue Oct 17 18:23:51 2017 using snmpttconvertmib v1.4beta2
#
#
#
EVENT lgpSysNotification .1.3.6.1.4.1.476.1.42.3.7.8.1 "Status Events" Critical
FORMAT This notification is a generic notification intended for direct user $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
This notification is a generic notification intended for direct user
visibility.  The user event description identifies the system
condition that has occurred.  This text will be prefixed with either
'Active:', 'Cleared:', or 'Message:' depending on the state of the
event.  Note: That a prefix of 'Message:' identifies a stateless event
and as such there will be no corresponding 'Cleared:' trap sent.
Variables:
  1: sysUpTime
  2: lgpSysEventDescription
EDESC
#
#
#
EVENT lgpSysCritical .1.3.6.1.4.1.476.1.42.3.7.8.2 "Status Events" Critical
FORMAT The system has returned to a Critical operating state. This implies $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
The system has returned to a Critical operating state. This implies
prior to the generation of this event the system was operating in a
state where one or more alarm or warning conditions were present.
All of those alarms or conditions have now cleared.
NOTE: This notification may be generated after a short delay during a
cold boot of the system -- if no alarms or conditions are present in the
monitored device(s) at that time.
Variables:
  1: sysUpTime
  2: lgpAgentConnectedDeviceCount
EDESC
#
#
#
#
MIB: UPS-MIB (file:/usr/share/snmp/mibs/RFC1628_UPS_MIB.MIB) converted on Thu Oct 19 13:51:06 2017 using snmpttconvertmib v1.4beta2
#
#
#
EVENT upsTrapOnBattery .1.3.6.1.2.1.33.2.1 "Status Events" Critical
FORMAT The UPS is operating on battery power.  This trap is $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
The UPS is operating on battery power.  This trap is
persistent and is resent at one minute intervals until
the UPS either turns off or is no longer running on
battery.
Variables:
  1: upsEstimatedMinutesRemaining
  2: upsSecondsOnBattery
  3: upsConfigLowBattTime
EDESC
#
#
#
EVENT upsTrapTestCompleted .1.3.6.1.2.1.33.2.2 "Status Events" Normal
FORMAT This trap is sent upon completion of a UPS diagnostic $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
This trap is sent upon completion of a UPS diagnostic
test.
Variables:
  1: upsTestId
  2: upsTestSpinLock
  3: upsTestResultsSummary
  4: upsTestResultsDetail
  5: upsTestStartTime
  6: upsTestElapsedTime
EDESC
#
#
#
EVENT upsTrapAlarmEntryAdded .1.3.6.1.2.1.33.2.3 "Status Events" Normal
FORMAT This trap is sent each time an alarm is inserted into $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
This trap is sent each time an alarm is inserted into
to the alarm table.  It is sent on the insertion of
all alarms except for upsAlarmOnBattery and
upsAlarmTestInProgress.
Variables:
  1: upsAlarmId
  2: upsAlarmDescr
EDESC
#
#
#
EVENT upsTrapAlarmEntryRemoved .1.3.6.1.2.1.33.2.4 "Status Events" Normal
FORMAT This trap is sent each time an alarm is removed from $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
This trap is sent each time an alarm is removed from
the alarm table.  It is sent on the removal of all
alarms except for upsAlarmTestInProgress.
Variables:
  1: upsAlarmId
  2: upsAlarmDescr
EDESC
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Recieving SNMP Traps

Post by tgriep »

Change the lgpAgentHeartbeatLegacy section to the following

Code: Select all

EVENT lgpAgentHeartbeatLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.7 "Status Events" Normal
FORMAT The agent card is alive. $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "The agent card is alive. $*"
SDESC
The agent card is alive.
Variables:
  1: sysUpTime
  2: lgpConditionsPresent
  3: lgpAgentConnectedDeviceCount
EDESC
Save the file and restart the trap translator.

Code: Select all

service snmptt restart
Make sure the daemon restarted so you know that it reread the config files.

Generate a trap and see if it is received formatted correctly.
Also, in the XI GUI, go to the Admin > Unconfigures Objects menu and make sure there is not a new entry that needs to be configured.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ahoward12
Posts: 137
Joined: Thu Jan 05, 2017 10:24 am

Re: Recieving SNMP Traps

Post by ahoward12 »

All of that has been completed. Nothing has changed except for now I have the additional text "The agent card is alive" along with the rest.

I still get this in snmptt.log:

Code: Select all

Thu Nov  2 10:17:59 2017 .1.3.6.1.4.1.476.1.42.2.3.0.0.7 Critical "Status Events" 10.10.99.245 - The agent card is alive. 12:20:05:27.50 0 1
Thu Nov  2 10:17:59 2017 .1.3.6.1.4.1.476.1.42.2.3.0.0.7 Critical "Status Events" 10.10.99.245 - The agent card is alive. 12:20:05:27.50 0 1
Event Log now gets this:

Code: Select all

2017-11-02 10:26:01 SERVICE NOTIFICATION: ahadm;Core UPS Rack 3 .245;SNMP Traps;CRITICAL;xi_service_notification_handler;The agent card is alive. / sysUpTime (TICKS):12:20:13:26.55 lgpConditionsPresent (GAUGE):0 gpAgentConnectedDeviceCount (UNSIGNED32):1
I have tried many different things but I only seem to make it worse.

Any ideas on getting rid of everything after the "The agent card is alive"?

I got rid of the variables and made it this, hoping it would get rid of all of the extra. It still works but I have all the extra text still:

Code: Select all

EVENT lgpAgentHeartbeatLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.7 "Status Events" Critical
FORMAT The agent card is alive. $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "The agent card is alive."
SDESC
The agent card is alive.
EDESC
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Recieving SNMP Traps

Post by tgriep »

Take a look at this KB article and search for the section called "SNMPTT is using the script /usr/local/bin/snmptraphandling.py"
https://support.nagios.com/kb/article/n ... orial.html
That section describes what data gets sent to Nagios XI and displayed in the GUI.
Specifically, this section, is the data "The agent card is alive. $*" that is displayed.

The $* means it will expand all the variables (OBJECTS) that were sent with the trap (exactly the same as the FORMAT line)

So to change what is displayed, you would have to change the $* to something else.

Here is a list of what you can put in that section and the meaning.

Code: Select all

$A - Trap agent host name (see Note 1)
$aA - Trap agent IP address
$Be - securityEngineID (snmpEngineID) (see Note 7)
$Bu - securityName (snmpCommunitySecurityName) (see Note 7)
$BE - contextEngineID (snmpCommunityContextEngineID) (see Note 7)
$Bn - contextName (snmpCommunityContextName) (see Note 7)
$c - Category
$C - Trap community string
$D - Description text from SNMPTT.CONF or MIB file (see Note 6)
$E - Enterprise trap OID in symbolic format
$e  - Enterprise trap OID in number format
$Fa  - alarm (bell) (BEL)
$Ff  - form feed (FF)
$Fn  - newline (LF, NL)
$Fr  - return (CR)
$Ft  - tab (HT, TAB)
$Fz  - Translated FORMAT line (EXEC only)
$G  - Generic trap number (0 if enterprise trap)
$H  - Host name of the system running SNMPTT
$S  - Specific trap number (0 if generic trap)
$N  - Event name defined in .conf file of matched entry
$i  - Event OID defined in .conf file of matched entry (could be a wildcard OID)
$O - Trap OID in symbolic format (see Note 4)
$o - Trap OID in numerical format (see Note 4)
$R, $r  - Trap hostname (see Note 1)
$aR, $ar - IP address
$s  - Severity
$T  - Uptime:  Time since network entity was initialized
$X  - Time trap was spooled (daemon mode) or current time (standalone mode)
$x  - Date trap was spooled (daemon mode) or current date (standalone mode)
$# - Number of (how many) variable-bindings in the trap
$$  - Print a $
$@ - Number of seconds since the epoch of when the trap was spooled (daemon mode) or the current time (standalone mode)
$n  - Expand variable-binding n (1-n) (see Note 2,5)
$+n  - Expand variable-binding n (1-n) in the format of variable name:value (see Note 2,3,5)
$-n  - Expand variable-binding n (1-n) in the format of variable name (variable type):value (see Note 2,3,5)
$vn  - Expand variable name of the variable-binding n (1-n)(see Note 3)
$*  - Expand all variable-bindings (see Note 5)
$+*  - Expand all variable-bindings in the format of variable name:value (see Note 2,3,5)
$-*  - Expand all variable-bindings in the format of variable name (variable type):value (see Note 2,3,5)
That list came from this link
http://snmptt.sourceforge.net/docs/snmp ... ONF-FORMAT

To get the trap to look similar to the snmptt.log file, you would change the EXEC to

Code: Select all

EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "The agent card is alive. $1 $2 $3"
Be sure to check out our Knowledgebase for helpful articles and solutions!
ahoward12
Posts: 137
Joined: Thu Jan 05, 2017 10:24 am

Re: Recieving SNMP Traps

Post by ahoward12 »

Hey, I am all set. I am going to finish this off for anyone else being confused and I don't want all of your hard work to go to waste! I appreciate the help more than you know and I know it was painful for you :|

What I wanted to achieve was just getting an identical event to the log message in snmptt.log. I did eventually get there doing a log of reading mostly of what you have sent me. I read all of those prior however I missing a key detail:

The EXEC line is the command that will be executed.

SNMPTT is using the script /usr/local/bin/snmptraphandling.py which sends PASSIVE check results to the Nagios command pipe. It requires the following arguments:

<HOST> <SERVICE> <SEVERITY> <TIME> <PERFDATA> <DATA>
<HOST> = The host object in Nagios that this event is for
<SERVICE> = The service object in Nagios this event is for
<SEVERITY> = The state of the object, which can be INFORMATIONAL, NORMAL, SEVERE, MAJOR, CRITICAL, WARNING, MINOR (the script turns these into Nagios status codes 0/1/2/3)
<TIME> = The time which should be recored for the passive check
<PERFDATA> = Any performance data (can be left empty)
<DATA> = The useful status information

I misinterpreted "required" and "can be left empty." (both of these I bolded above). Just to reinstate these are values and place holders.

This MIB:

Code: Select all

EVENT lgpAgentHeartbeatLegacy .1.3.6.1.4.1.476.1.42.2.3.0.0.7 "Status Events" Critical
FORMAT The agent card is alive.
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "The agent card is alive."
Produced this event:

Code: Select all

SERVICE NOTIFICATION: ahadm;Core UPS Rack 3 .245;SNMP Traps;CRITICAL;xi_service_notification_handler;The agent card is alive. 13:1:52:14.43 0 1 / sysUpTime (TICKS):13:1:52:14.43 lgpConditionsPresent (GAUGE):0 lgpAgentConnectedDeviceCount (UNSIGNED32):1
That event is very lengthy I just wanted the "The agent card is alive". Nothing more. So I began playing with the variables as you suggested. However I wasn't trying to add or customize anything, only remove. So I began trial and error with the EXEC line but I fell short because anytime I removed any of the variables ("$r" "SNMP Traps" "$s" "$@" "$-*"), Nagios did not interpret it correctly and an event was never generated.

The solution is that these variables are also place holders, example below:
This works >

Code: Select all

EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "The agent card is alive."
This does not >

Code: Select all

EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "The agent card is alive."
< It is missing "$-*"
This DOES work and gives me the desired event >

Code: Select all

EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "" "The agent card is alive."
< You don't need <"$-*"> as a value, but you do need "" as a place holder to to complete the syntax.

The latter of those gives me this event:

Code: Select all

SERVICE NOTIFICATION: ahadm;Core UPS Rack 3 .245;SNMP Traps;CRITICAL;xi_service_notification_handler;The agent card is alive.
Hope this helps someone in the future.

tgriep thanks for your patience through all of that.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Recieving SNMP Traps

Post by tgriep »

Nice! Glad you have it formatted like you want.
I didn't know for sure that you did not want the sysUpTime, lgpConditionsPresent, and lgpAgentConnectedDeviceCount in the data so I added them to be safe.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked