Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
t3dus
Posts: 161 Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:
Post
by t3dus » Tue Apr 09, 2019 7:08 pm
How do I make nagios send me brief and informative alerts via sms? The current long winded ones get broken up into multiple messages which is super annoying because I get multiple messages regarding a single outage.
I want something like the folks talked about
here
What I don't understand is if I was to add this code to commands.cfg how I get certain notifications to use that vs the long winded alert.
Code: Select all
define command{
command_name notify-host-by-sms
command_line /usr/bin/printf "%.120s" "$HOSTALIAS$ is $HOSTSTATE$" |/usr/local/bin/gnokii --sendsms $CONTACTPAGER$ -r
}
define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%.120s" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" | /usr/local/bin/gnokii --sendsms $CONTACTPAGER$ -r
}
t3dus
Posts: 161 Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:
Post
by t3dus » Thu Apr 11, 2019 12:50 pm
I did that in the contacts.cfg file but it isn't sending anything to my phone via text.
Code: Select all
define contact{
contact_name mattphone
alias Matt
service_notification_commands notify-service-by-sms
host_notification_commands notify-host-by-sms
email REMOVED NUMBER FOR PRIVACY@email.uscc.net
pager REMOVED NUMBER FOR PRIVACY@email.uscc.net
}
and added "mattphone" to the contact groups.
Code: Select all
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members sysadmins,gldgmail,gidalerts,bp,mattphone
}
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Thu Apr 11, 2019 12:53 pm
Have you tried testing these from the command line to see if the command works?
Code: Select all
/usr/bin/printf "%.120s" "host_alias is CRITICAL" |/usr/local/bin/gnokii --sendsms 'REMOVED NUMBER FOR PRIVACY@email.uscc.net' -r
t3dus
Posts: 161 Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:
Post
by t3dus » Thu Apr 11, 2019 1:00 pm
Oh I see the issue. it comes back with the error
Code: Select all
-bash: /usr/local/bin/gnokii: No such file or directory
Do I have to use gnokii or what do you suggest I use?
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Thu Apr 11, 2019 1:15 pm
t3dus wrote: Oh I see the issue. it comes back with the error
Code: Select all
-bash: /usr/local/bin/gnokii: No such file or directory
Do I have to use gnokii or what do you suggest I use?
I don't even know what gnokii is....
If this is a email to text notification, I would suggest setting them up like your email commands
t3dus
Posts: 161 Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:
Post
by t3dus » Thu Apr 11, 2019 1:16 pm
Ok I got it working. This is what I did..
I change the command to the following
Code: Select all
define command{
command_name notify-host-by-sms
command_line /usr/bin/printf "%b" "$HOSTALIAS$ is $HOSTSTATE$" |/usr/bin/mail -s --sendsms $CONTACTPAGER$
}
define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%b" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" |/usr/bin/mail -s --sendsms $CONTACTPAGER$
}
My next question is how can I get it so it doesn't text me "S:--sendsms"
Attachments
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Thu Apr 11, 2019 1:24 pm
change it to this
Code: Select all
define command{
command_name notify-host-by-sms
command_line /usr/bin/printf "%b" "$HOSTALIAS$ is $HOSTSTATE$" |/usr/bin/mail $CONTACTPAGER$
}
define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%b" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" |/usr/bin/mail $CONTACTPAGER$
}
the -s flag is defining the subject
t3dus
Posts: 161 Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:
Post
by t3dus » Thu Apr 11, 2019 1:41 pm
So I narrowed it down with your commands to where it says
but is there a way to ditch the "S:" and "M:"
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Thu Apr 11, 2019 1:49 pm
t3dus wrote: but is there a way to ditch the "S:" and "M:"
My guess is your mail to sms provider is adding them to the message, where: