LINUX.ORG.RU
решено ФорумAdmin

Nagios + smstools не отправляет смс

 , , ,


1

1

Добрый день. Прошу помощи, если кратко, то Nagios+smstools не отправляют смс, просто smstools шлет без проблем.

Имеется Debian6 x64, Nagios 3.2.1, Smstools, модем на базе Siemens MC75.

Нагиос настроен на отправку почтовых оповещений через exim4. Ставлю SMStools, копирую скрипт из шаблона в /ust/local/bin/, даю права на запуск.

Пробую

/usr/local/bin/sendsms +7920xxxxxxx "this is test..."

Смс приходит.

Определяю команды

define command{
        command_name    host-notify-by-sms
        command_line    /usr/local/bin/sendsms $CONTACTADDRESS1$ "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"
        }

define command{
        command_name    service-notify-by-sms
        command_line    /usr/local/bin/sendsms $CONTACTADDRESS1$ "** $NOTIFICATIONTYPE$ : $SERVICEDESC$ for Host:$HOSTNAME$ State: $SERVICESTATE$ ($SERVICEOUTPUT$) **"
        }

Определяю контакт

define contact{
        contact_name                    erm-megafon
        alias                           megafon-notify
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   service-notify-by-sms
        host_notification_commands      host-notify-by-sms
        address1                        +7920XXXXXXX
        }

Ставлю в nagios.cfg debug_level=32

Рестартую Nagios и smstools

Кладу на другом сервере веб-сервер.

nagios.log

[1372773636] SERVICE ALERT: TFTP;HTTP;CRITICAL;SOFT;1;Connection refused
[1372773696] SERVICE ALERT: TFTP;HTTP;CRITICAL;SOFT;2;Connection refused
[1372773756] SERVICE ALERT: TFTP;HTTP;CRITICAL;SOFT;3;Connection refused
[1372773816] SERVICE ALERT: TFTP;HTTP;CRITICAL;HARD;4;Connection refused
[1372773816] SERVICE NOTIFICATION: erm-mail;TFTP;HTTP;CRITICAL;notify-service-by-email;Connection refused
[1372773826] SERVICE NOTIFICATION: erm-megafon;TFTP;HTTP;CRITICAL;service-notify-by-sms;Connection refused

Почта пришла, смс нет.

Смотрим nagios.debug

[1372773816.025082] [032.0] [pid=5742] ** Service Notification Attempt ** Host: 'TFTP', Service: 'HTTP', Type: 0, Options: 0, Current State: 2, Last Notification: Thu Jan  1 03:00:00 1970
[1372773816.025147] [032.0] [pid=5742] Notification viability test passed.
[1372773816.025156] [032.1] [pid=5742] Current notification number: 1 (incremented)
[1372773816.025165] [032.2] [pid=5742] Creating list of contacts to be notified.
[1372773816.025173] [032.1] [pid=5742] Service notification will NOT be escalated.
[1372773816.025180] [032.1] [pid=5742] Adding normal contacts for service to notification list.
[1372773816.025185] [032.2] [pid=5742] Adding members of contact group 'admins' for service to notification list.
[1372773816.025191] [032.2] [pid=5742] Adding contact 'erm-megafon' to notification list.
[1372773816.025196] [032.2] [pid=5742] Adding contact 'erm-mail' to notification list.
[1372773816.025211] [032.2] [pid=5742] ** Attempting to notifying contact 'erm-mail'...
[1372773816.025219] [032.2] [pid=5742] ** Checking service notification viability for contact 'erm-mail'...
[1372773816.025240] [032.2] [pid=5742] ** Service notification viability for contact 'erm-mail' PASSED.
[1372773816.025247] [032.2] [pid=5742] ** Notifying contact 'erm-mail'
[1372773816.025259] [032.2] [pid=5742] Raw notification command: /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTAT$
[1372773816.025300] [032.2] [pid=5742] Processed notification command: /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: HTTP\nHost: Config Backup Server\nAddress: 192.168.100.91\nState: CRITICAL\n\nDate$
[1372773826.370226] [032.2] [pid=5742] ** Attempting to notifying contact 'erm-megafon'...
[1372773826.370249] [032.2] [pid=5742] ** Checking service notification viability for contact 'erm-megafon'...
[1372773826.370287] [032.2] [pid=5742] ** Service notification viability for contact 'erm-megafon' PASSED.
[1372773826.370295] [032.2] [pid=5742] ** Notifying contact 'erm-megafon'
>>>>>[1372773826.370309] [032.2] [pid=5742] Raw notification command: /usr/local/bin/sendsms $CONTACTADDRESS1$ "** $NOTIFICATIONTYPE$ : $SERVICEDESC$ for Host:$HOSTNAME$ State: $SERVICESTATE$ ($SERVICEOUTPUT$) **"
>>>>>[1372773826.370342] [032.2] [pid=5742] Processed notification command: /usr/local/bin/sendsms +7920XXXXXXX "** PROBLEM : HTTP for Host:TFTP State: CRITICAL (Connection refused) **"
[1372773826.394869] [032.2] [pid=5742] Calculating next valid notification time...
[1372773826.394887] [032.2] [pid=5742] Default interval: 0.000000
[1372773826.394901] [032.2] [pid=5742] Interval used for calculating next valid notification time: 0.000000
[1372773826.394929] [032.0] [pid=5742] 2 contacts were notified.  Next possible notification time: Tue Jul  2 18:03:36 2013
>>>>>[1372773826.394939] [032.0] [pid=5742] 2 contacts were notified.

Смотрим sms.log

2013-07-02 18:19:51,5, GSM1: Waiting for messages to send...

Куда копать не знаю... При отправке СМС руками, скрипт создает соответствующий файлик в папке .../outgoing/. Когда скрипт запускает Nagios, файлика не создается.



Последнее исправление: Ivy (всего исправлений: 1)

Когда скрипт запускает Nagios, файлика не создается.

Права проверь. Руками из под рута небось запускаешь, а нагиос из под юзера nagios. Очевидно же.

anonymous
()
Ответ на: комментарий от anonymous

Спасибо за наводку. Прописал в скрипте

chmod 777 $TMPFILE 

И все заработало.

Ivy
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.