nagios и уведомления на email (не отправляет)
Модераторы: SLEDopit, Модераторы разделов
-
PolecatZZZ
- Сообщения: 258
- ОС: Debian 6
nagios и уведомления на email
Посмотрел в сети - очень частая проблема, но решение найти не могу. Может здесь кто-нибудь поможет. Установил nagios и sendmail. Сделал ссылку ln -s /usr/bin/mail /bin/mail. Из командной строки сообщения на ящик уходят, а вот сам нагиос почему-то не оправляет оповещения... 
У вас нет необходимых прав для просмотра вложений в этом сообщении.
OpenSUSE >>> Debian
-
arkhnchul
- Сообщения: 2284
- Статус: Толчковый инженер
- ОС: Debian, Fedora
Re: nagios и уведомления на email
оповещения настраивать еще надо, кроме замены адреса. И, сколь помню, включить в вебморде...
Losing is fun!
-
PolecatZZZ
- Сообщения: 258
- ОС: Debian 6
Re: nagios и уведомления на email
Если можно, наведите на путь. Делал всё по мануалу. Вроде бы ничего не пропустил, там про настройку оповещений ничего не было. К слову сказать, в руководствах этого пункта нет - типа всё само заработает. В веб-морде посмотрел - на самом деле пишет в секции Notifications раздела Reports у меня "No notifications have been recorded in the current log file". Поэтому такой вопрос - как включить оповещения?
OpenSUSE >>> Debian
-
arkhnchul
- Сообщения: 2284
- Статус: Толчковый инженер
- ОС: Debian, Fedora
Re: nagios и уведомления на email
ну, у меня, например...
contacts.cfg:commands.cfg:
jabber.sh - наколеночный скрипт.
общий смысл - для контакта должны быть прописаны команды уведомления, также настроенные как команды нагиоса и нормально работающие сами по себе.
contacts.cfg:
Код: Выделить всё
...
define contact{
contact_name arkhnchul
use generic-contact
alias Arkhnchul
address1 arkhnchul@jabber.ru
service_notification_commands notify-service-by-jabber
host_notification_commands notify-host-by-jabber
host_notification_period 24x7
host_notification_options d,u,r
service_notification_period workhours
}
...Код: Выделить всё
define command{
command_name notify-service-by-jabber
command_line /usr/lib/nagios/plugins/jabber.sh "$NOTIFICATIONTYPE$" "$SERVICEDESC$" "$HOSTALIAS$" "$HOSTADDRESS$" "$SERVICESTATE$" "$LONGDATETIME$" "$SERVICEOUTPUT$" "$CONTACTADDRESS1$" &>> /tmp/notify
}
define command{
command_name notify-host-by-jabber
command_line /usr/lib/nagios/plugins/jabber.sh "WARN" "$HOSTNAME$" "$HOSTSTATE$" "$HOSTADDRESS$" "12345" "$LONGDATETIME$" "$HOSTOUTPUT$" "$CONTACTADDRESS1$" &>> /tmp/notify
}
...jabber.sh - наколеночный скрипт.
общий смысл - для контакта должны быть прописаны команды уведомления, также настроенные как команды нагиоса и нормально работающие сами по себе.
Losing is fun!
-
arkhnchul
- Сообщения: 2284
- Статус: Толчковый инженер
- ОС: Debian, Fedora
Re: nagios и уведомления на email
да, и в templates для хостов и сервисов тоже надо указать интервалы и типы уведомлений, если этого еще нет.
Losing is fun!
-
PolecatZZZ
- Сообщения: 258
- ОС: Debian 6
Re: nagios и уведомления на email
commands.cfg
Код: Выделить всё
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}конфиг моего хоста testhost.cfg
Код: Выделить всё
define host{
use windows-server
host_name testhost
address 192.168.100.100
}
define service{
use local-service
host_name testhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define hostgroup{
hostgroup_name windows-servers
alias Windows Servers
}В тэмплэйте local-service присутствует:
Код: Выделить всё
define host{
name windows-server ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, Windows servers are monitored round the clock
check_interval 5 ; Actively check the server every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each server 10 times (max)
check_command check-host-alive ; Default command to check if servers are "alive"
notification_period 24x7 ; Send notification out at any time - day or night
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
hostgroups windows-servers ; Host groups that Windows servers should be a member of
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}
define service{
name generic-service ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
normal_check_interval 10 ; Check the service every 10 minutes under normal conditions
retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determined
contact_groups admins ; Notifications get sent out to everyone in the 'admins' group
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
# Local service definition template - This is NOT a real service, just a template!
define service{
name local-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until a hard state can be determined
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
# SNMP Trap service
define service{
name snmptrap-service
use generic-service
service_description TRAP
is_volatile 1
flap_detection_enabled 0
check_command check-host-alive
max_check_attempts 1
normal_check_interval 1
retry_check_interval 1
passive_checks_enabled 1
notification_options w,u,c
register 0
}Где затык? Что я мог упустить в конфиге?
OpenSUSE >>> Debian
-
arkhnchul
- Сообщения: 2284
- Статус: Толчковый инженер
- ОС: Debian, Fedora
Re: nagios и уведомления на email
contacts.cfg покажите. Ну или где там у вас контакты описаны.
Losing is fun!
-
PolecatZZZ
- Сообщения: 258
- ОС: Debian 6
Re: nagios и уведомления на email
Целиком файл прикреплял в первом посте.
Код: Выделить всё
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email nagios@gov.kzn.ru ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}OpenSUSE >>> Debian
-
arkhnchul
- Сообщения: 2284
- Статус: Толчковый инженер
- ОС: Debian, Fedora
Re: nagios и уведомления на email
так. Ну тогда, перенаправьте вывод отправки письма в файл, и посмотрите, будет там что-нибудь или нет.
Losing is fun!
-
PolecatZZZ
- Сообщения: 258
- ОС: Debian 6
-
arkhnchul
- Сообщения: 2284
- Статус: Толчковый инженер
- ОС: Debian, Fedora
Re: nagios и уведомления на email
define command{
command_name notify-host-by-jabber
command_line /usr/lib/nagios/plugins/jabber.sh foobar &>> /tmp/notify
}
Losing is fun!