Link to home
Create AccountLog in
Avatar of Fulgent

asked on

Nagios SMS Alerts through gnokii - or lack of....

Hi all,

Ubuntu Desktop 11.04 32 bit
Gnokki 0.6.30
Nokia 6301 mobile phone hooked up via USB with a working Sim card.

Im at my wits end.
Spent 2 days now trying to get Nagios to SMS me through gnokii but a lunar eclipse is a more frequent event!

I have email alerts working from Ubuntu through my Excange Server and have no problem with this.

Now i also want a text message as a failover incase my Exchange server/internet line goes down.

I have installed and configured gnokii to what i think is at a functioning level.

I can send a text message out through the phone via CLI using
gnokii --sendsms [mobilenumber]
no issue at all with both my admin user logged in and also when i log in as the nagios user so i know i have the correct permissions on the ttyACM0 port that is assigned to the 6301.

Will Nagios send an SMS alert - will it f*£$!!

Here is my command.cfg relevant part
# 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line /usr/bin/printf "%.120s" "***** Nagios ***** $NOTIFICATIONTYPE$: Host $HOSTALIAS$ is $HOSTSTATE$ | /usr/bin/gnokii --sendsms $CONTACTPAGER$

# 'notify-service-by-sms' command definition
define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%.120" "***** Nagios ***** $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ | /usr/bin/gnokii --sendsms $CONTACTPAGER$

Open in new window

Here is my contact.cfg

define contact{
contact_name MYNAME
use generic-contact
alias MYNAME
host_notification_options d,u,r,f
service_notification_options w,u,c,r,f
pager +44XXXXXXXXX
host_notification_period 24x7
service_notification_period 24x7
host_notification_commands notify-host-by-email,notify-host-by-sms
service_notification_commands notify-service-by-email,notify-service-by-sms

Open in new window

Here is my templates.cfg

define contact{
name generic-contact
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-email, notify-service-by-sms
host_notification_commands notify-host-by-email, notify-host-by-sms
register 0

Open in new window

i wont include my gnokiirc file as im sure thats fine as i can send through gnokii fine via CLI

Anybody any idea why nagios wont send out a text?

If you need any commands running please ask and i will post back the outputs.

Thanks in advance
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Fulgent



Thankyou - i was indeed missing a "
Days pulling my hair out and it turned out to be a "

Anyhow this line now works

command_line /usr/bin/printf "%b" "***** Nagios ***** $NOTIFICATIONTYPE$: Host $HOSTALIAS$ is $HOSTSTATE$" | /usr/bin/gnokii --sendsms $CONTACTPAGER$

Open in new window

For reference - the $CONTACTPAGER$ variable basically calls on the contact.cfg file and executes the pager entry (mobile number)

Thank for your help