Hi Stevie, thank you for answering!
Sure, so I read that there should be something extra, that handles the snmptraps, but I don’t know how to do it and what to use, because for me it looked like the old Icinga1 Instance had it working without all of this, but I might be wrong, I don’t have the correct information about that and don’t know what to look for, so I can’t compare it to the new Instance.
I installed some rpm packages that had to do with net-snmp (like utils etc.), but that’s about it.
There is something that I forgot to mention before: I send snmptrap heartbeats to the same destination hosts and those work perfectly, but those aren’t handled as notifications but rather as cronjobs.
Now to the important stuff, here are the requested informations and some more. The IPs, descriptions etc. are all dummies (security reasons) so if you see only a single letter or number don’t panic, I just wrote something else in the place of what is there:
notifications.conf
object NotificationCommand "a-snmptrap-host-notification-command" {
command = [ PluginDir + "snmp.sh", "$host.vars.i_infos.p$", "$host.last_state_change$", "$host.name$", "$host.vars.i_infos.id$", "$host.vars.i_infos.moc$", "$host.i_infos.moi$", "$host.state$", "$host.i_infos.pcc$", "$host.output$" ]
}
object NotificationCommand "a-snmptrap-service-notification-command" {
command = [ PluginDir + "snmp.sh", "$host.vars.i_infos.p$", "$service.last_state_change$" ,"$host.name$", "$service.i_infos.id$", "$service.vars.i_infos.moc$", "$service.vars.i_infos.moi$", "$service.state$", "$service.vars.i_infos.pcc$", "$service.output$" ]
}
apply Notification "a-snmptrap-host-notification" to Host {
if (len(host.vars.notification.snmptrap.users) == 0 && len(host.vars.notification.snmptrap.user_groups) == 0) {
log(LogWarning, "config", "Host '" + host.name + "' does not specify required user/user_groups configuration attributes for notification '" + name + "'.")
}
//vars.notification_logtosyslog = true
import "generic-host-notification-template"
command = "a-snmptrap-host-notification-command"
users = host.vars.notification.snmptrap.users
user_groups = host.vars.notification.snmptrap.groups
assign where host.vars.notification.snmptrap && typeof(host.vars.notification.snmptrap) == Dictionary
}
apply Notification "a-snmptrap-service-notification" to Service {
if (len(service.vars.notification.snmptrap.users) == 0 && len(service.vars.notification.snmptrap.user_groups) == 0) {
log(LogWarning, "config", "Service '" + service.name + "' does not specify required user/user_groups configuration attributes for notification '" + name + "'.")
}
//vars.notification_logtosyslog = true
//log(LogWarning, "config", "users: '" + service.vars.notification.snmptrap.users + "' groups: '" + service.vars.notification.snmptrap.groups + "' assign: '" + service.vars.notification.snmptrap)
import "generic-service-notification-template"
command = "a-snmptrap-service-notification-command"
users = service.vars.notification.snmptrap.users
user_groups = service.vars.notification.snmptrap.groups
assign where service.vars.notification.snmptrap && typeof(service.vars.notification.snmptrap) == Dictionary
}
templates.conf
template Notification "generic-host-notification-template" {
interval = 24h
period = "7x24"
types = [ Problem, Recovery ] // DowntimeStart, DowntimeEnd, DowntimeRemoved, Custom, Acknowledgement, Problem, Recovery, FlappingStart, FlappingEnd
states = [ Up, Down ]
}
template Notification "generic-service-notification-template" {
interval = 24h
period = "7x24"
types = [ Problem, Recovery ] // DowntimeStart, DowntimeEnd, DowntimeRemoved, Custom, Acknowledgement, Problem, Recovery, FlappingStart, FlappingEnd
states = [ OK, Warning, Critical, Unknown ]
}
template Host "linux-host-template" {
import "generic-host-template"
vars.os_type = "Linux"
}
template Host "generic-host-template" {
check_command = "hostalive"
max_check_attempts = 4
check_period = "7x24"
check_timeout = 20s
check_interval = 5m
retry_interval = 1m
enable_notifications = true
enable_active_checks = true
enable_passive_checks = false
enable_event_handler = false
enable_flapping = false
enable_perfdata = true
vars.os_type = "Unknown"
vars.location = "Unknown"
vars.project = "G"
vars.i_infos = { p = "G", id = "G1", moc = "Node", moi = "Node", pcc = "123456" }
vars.notification["mail"] = { users = [ "a" ]}
vars.notification["snmptrap"] = { users = [ "i" ]}
}
template User "generic-user-template" {
enable_notifications = true
period = "7x24"
types = [ Problem, Recovery ]
states = [ OK, Warning, Critical, Unknown ]
}
hosts.conf
#That's what a Host would look like in this conf
object Host "test-host-01" {
import "linux-host-template"
address = "15.15.15.15"
notes = "sampletext"
vars.i_infos = { p = "G", id = "G1", address = "15.15.15.15" }
}
hosts File linux
10.10.10.10 1.TEST.SERVER.HOST
20.20.20.20 2.TEST.SERVER.HOST
/usr/lib64/nagios/plugins service being used snmp.sh
#!/bin/bash
echo "Running $0 ($#)..."
#
# initialize varibles from arguments
#
S_P_CODE=${1}
I_ALARM_RAISED_TIME=${2}
S_NODE=${3}
S_E_ID=${4}
S_M_O_C=${5}
S_M_O_I=${6}
S_STATUS=${7}
I_P_C_C=${8}
S_ADDITIONAL_TEXT=${9}
# test 10.10.10.10 20.20.20.20
#send snmp trap
/usr/bin/snmptrap -v 2c -c public 1.TEST.SERVER.HOST "" MIB::gEventNotification sPCode s "$S_P_CODE" iAlarmRaisedTime i $I_ALARM_RAISED_TIME sNode s "$S_NODE" sEId s "$S_E_ID" sMOC s "$S_M_O_C" sMOI s "$S_M_O_I" sNagiosState s "$S_STATUS" iPCC i $I_P_C_C sAdditionalText s "$S_ADDITIONAL_TEXT"
users.conf
object User "a" {
import "generic-user-template"
email = "testmail@test.com"
}
#The user in question not getting the traps Notification
object User "i" {
import "generic-user-template"
}
RPM Packages installed with snmp
perl-Net-SNMP-6.0.1-7.el7.noarch.rpm
net-snmp-5.7.2-49.el7.x86_64.rpm
net-snmp-agent-libs-5.7.2-49.el7.x86_64.rpm
net-snmp-utils-5.7.2-49.el7.x86_64.rpm
Used Icingaweb2 Modules
Only Monitoring is enabled
Also, is there a way to know, how I can check which program or service is used on the old instance for sendning snmptraps/mails notification? That would actually help a lot too.
Thanks in Advance.
Cheers,
Andy