Для отправки SMS уведомлений через GSM-модем мастер-модуля Vutlan из Nagios можно воспользоваться следующими скриптами:
СМС для версий до To send SMS notifications via GSM-modem is the Vutlan master units in Nagios, you can use the following scripts:
SMS for v. 2.3.3 и нижеand lower
СМС для версий от SMS for v. 2.4.0 и вышеand higher
Code Block | ||||
---|---|---|---|---|
| ||||
#!/bin/bash # Скрипт отправки SMS для версии 2.4.x системы SkyControl usage() { cat << EOF usage: $0 options OPTIONS: -?,-h Show this message -H Hostname or IP address -u User name -p Password -P Phone for sending -m Message for sending EOF } HOSTIP= USERNAME= PASSWORD= TOPHONE= MESSAGE='Test' while getopts “hH:u:p:P:m:” OPTION do case $OPTION in h) usage exit 1 ;; H) HOSTIP=$OPTARG ;; u) USERNAME=$OPTARG ;; p) PASSWORD=$OPTARG ;; P) TOPHONE=$OPTARG ;; m) MESSAGE=$OPTARG ;; ?) usage exit ;; esac done if [[ -z $HOSTIP ]] || [[ -z $USERNAME ]] || [[ -z $PASSWORD ]] || [[ -z $TOPHONE ]] || [[ -z $MESSAGE ]] then usage exit 1 fi # 1) хешhash пароля HASH=`echo -n ${PASSWORD} | openssl dgst -sha1 | awk '{print $NF}'` # 2) авторизацияautorisation RESPONSE=`curl -s -d "querytype=auth&name=${USERNAME}&h=${HASH}" "${HOSTIP}/engine.htm"` # 3) ключsession сессииkey KEY=`echo -n ${RESPONSE} | awk -F"\"" '{print $4}'` # 4) отправитьsend SMS curl -d "querytype=send_sms_message&k=${KEY}" --data-urlencode "to_phone=${TOPHONE}" --data-urlencode "message=${MESSAGE}" ${HOSTIP}/engine.htm > /dev/null 2>&1 |
Пример оправки SMS через скриптSend SMS through a script example:
Code Block | ||||
---|---|---|---|---|
| ||||
./sendsms_skycontrol -H 192.168.0.193 -p secret -P +777 -m 'This is a text' |
где where 192.168.0.193 - адрес мастер-модуля с установленным address of the master unit with GSM-модемомmodem;
secret - пароль пользователя для мастер-модуля с установленным GSM-модемомuser password for the master unit with GSM-modem;
+777 - номер телефона для отправки сообщенияphone number to send a message;
'This is a text' - текст пересылаемого сообщения;Для того, чтобы привязать текущий скрипт к Nagios, необходимо создать команды отправки уведомлений в файле конфигурации Nagiosforwarded message text;
In order to bind the current script to Nagios, you must create a notification command in the Nagios configuration file:
Code Block | ||||
---|---|---|---|---|
| ||||
define command{ command_name notify-service-by-sms command_line $USER1$/sendsms_skycontrol -H 192.168.1.190 -p guest -P $CONTACTPAGER$ -m "Nagios – $NOTIFICATIONTYPE$ : $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" } define command{ command_name notify-host-by-sms command_line $USER1$/sendsms_skycontrol -H 192.168.1.190 -p guest -P $CONTACTPAGER$ -m "Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$" } |
Также необходимо создать, либо отредактировать контакт NagiosYou must also create or edit a Nagios contact:
Code Block | ||||
---|---|---|---|---|
| ||||
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 service_notification_options w,u,c,r host_notification_options d,u,r service_notification_commands notify-service-by-email,notify-service-by-sms host_notification_commands notify-host-by-email,notify-host-by-sms email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** pager +329999999999 ; <<***** CHANGE THIS TO YOUR PHONE NUMBER ****** } |
Пример доставленных уведомленийDelivered notifications example:
Code Block | ||||
---|---|---|---|---|
| ||||
Nagios – PROBLEM : Local EMS/Vutlan Element Service is WARNING |
...