Clickatell API’sini kullanarak nagios ile sms uyarısı gönderme

Bunun için öncelikle Clickatel firmasından gerekli üyeliği almalısınız.

Size verilen kullanıcı ve api bilgilerini aşağıdaki gibi /etc/nagios3/commands.cfg dosyasına yazın.

define command{
command_name host-notify-by-sms
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$ \nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | wget "http:/
/api.clickatell.com/http/sendmsg?user=USERNAME&password=PASSWORD&&api_id=API_ID&to=$CONTACTEMAIL$&text='** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ @ $LONGDATETIME$ **'"
}

define command{
command_name service-notify-by-sms
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$ \nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | wget "http:/
/api.clickatell.com/http/sendmsg?user=USERNAME&password=PASSWORD&&api_id=API_ID&to=$CONTACTEMAIL$&text='** $NOTIFICATIONTYPE$ Service Alert: $SERVICEDESC$ on $HOSTNAME$ State: $SERVICESTATE$ @ $LONGDATETIME$ **'"
}

Daha sonra /etc/nagios3/conf.d/contacts_nagios2.cfg dosyası içine aşağıdaki gibi notification komutlarını girin. ( Kırmızı renkteki satırlar )

# Kursad DARA
####################

define contact{
contact_name                    swn_kursadd_sms
alias                           Kursad DARA
service_notification_period     nonworkhours
host_notification_period        nonworkhours
service_notification_options    w,c,r
host_notification_options       d,u,r
service_notification_commands   service-notify-by-sms
host_notification_commands      host-notify-by-sms
pager                           532xxxxxxx
}

Sonrasında

/usr/sbin/nagios3 -v /etc/nagios3/nagios.cfg

komutu ile nagios konfigürasyonunuzu kontrol edip hata yapmadığınızdan emin olun. Hata varsa düzeltmeniz gerekecek.

Hata yok ise

service nagios3 restart

ile nagios servisini tekrar başlatın.

Artık herhangi bir uyarı durumunda nagios size sms ile bilgi verecektir.

Posted in Linux, Nagios on September 16th, 2011 by Kürşad DARA | | 0 Comments