Page 1 of 2
sms alerts for vmware monitoring
Posted: Fri Mar 06, 2015 3:56 pm
by venkitesh
Hi Team,
i am using the below mentioned command for sms alerts if a host is down and it works fine.
ssh
[email protected] '/usr/bin/smssend +91-xxxxxxxxxx " Infra says: $HOSTNAME$ is $HOSTSTATE$ Info is: $HOSTOUTPUT$ $LONGDATETIME$"'
i am using the box293_check_vmware.zip plugin with VMA for monitroring vmware infrastructure.
i have added a vcenter server and monitoring the datastores of the hosts under that.
i have set a threshold of warning free space 10GB and critical 5GB.
so i need an sms alert once it goes to critical.
so kindly help me in putting a command like i am using for host down mentioned above.
This is the vmware_datastore_usage command in nagios xi
$USER1$/check_by_ssh -E 1 -t 90 -l vi-admin -H $ARG1$ -C "~/box293_check_vmware.pl --timeout 90 --server $ARG2$ --check Datastore_Usage --name \"$ARG3$\" --reporting_si \"$ARG4$\" \"$ARG5$\" \"$ARG6$\" \"$ARG7$\" \"$ARG8$\""
Re: sms alerts for vmware monitoring
Posted: Fri Mar 06, 2015 8:22 pm
by Box293
Great to see you using box293_check_vmware
It should be along the same lines but with service macros:
Code: Select all
ssh [email protected] '/usr/bin/smssend +91-xxxxxxxxxx " Infra says: $HOSTNAME$ with service $SERVICEDESC$ is $SERVICESTATE$ with the outptut: $SERVICEOUTPUT$"'
Here is a list of Nagios Macros:
http://nagios.sourceforge.net/docs/3_0/macrolist.html
Re: sms alerts for vmware monitoring
Posted: Sun Mar 08, 2015 7:45 am
by venkitesh
hi box_293,
thanks for your reply.
could you please tell me the exact macros which i need to put in the below lines for sending alerts for a datastore which goes critical as per the threshold as i find it a bit difficult to find out from the list.
Re: sms alerts for vmware monitoring
Posted: Sun Mar 08, 2015 6:59 pm
by Box293
Here's an example command:
Code: Select all
./box293_check_vmware.pl --server vcenter.box293.local --check Datastore_Usage --host esxi001.box293.local --name VOL_02_03 --critical datastore_free:2700
Here's the output:
Code: Select all
CRITICAL: Datastore 'VOL_02_03' {Free Space: 2,582.6 GB (CRITICAL <= 2,700)} {Used Space: 211.4 GB} {Capacity: 2,794 GB}|'Free Space'=2582.6GB;;2700 'Used Space'=211.4GB 'Capacity'=2794GB [Datastore_Usage]
Anything to the LEFT of the pipe | symbol is $SERVICEOUTPUT$
Code: Select all
CRITICAL: Datastore 'VOL_02_03' {Free Space: 2,582.6 GB (CRITICAL <= 2,700)} {Used Space: 211.4 GB} {Capacity: 2,794 GB}
Anything to the RIGHT of the pipe | symbol is $SERVICEPERFDATA$
Code: Select all
'Free Space'=2582.6GB;;2700 'Used Space'=211.4GB 'Capacity'=2794GB [Datastore_Usage]
The perfdata string follows a format that can include the critical threshold value (2700 in this case). Refer to this documentation about how performance data is formatted:
https://nagios-plugins.org/doc/guidelines.html#AEN200
venkitesh wrote:could you please tell me the exact macros which i need to put in the below lines for sending alerts for a datastore which goes critical as per the threshold as i find it a bit difficult to find out from the list.
There are no macros for the actual warning or critical thresholds. Nagios does not deal with that information, it simply executes a plugin with a bunch of arguments and receives back a result with an exit code.
Re: sms alerts for vmware monitoring
Posted: Mon Mar 09, 2015 12:17 am
by venkitesh
hi box293,
Thanks for your reply.
so what you mean to say is we cant send an sms alert if a datastore is in critical threshold.
Re: sms alerts for vmware monitoring
Posted: Mon Mar 09, 2015 1:11 am
by Box293
I think there is some confusion here. There is nothing special about the box293_check_vmware plugin and alerts being sent from nagios based on check results received from it. Yes you can send alerts when it reaches crtitical threshold.
The example command I gave you shows the --critical argument you could use for datastore_free.
Have you consulted the manual?
I'm not exactly sure if you have a problem with the plugin or if you don't know how to configure SMS in Nagios XI.
Bascially any service can send notifications via Email, SMS, or any other required means. This is built into Nagios XI.
Have you tried sending a notification test for the service?
Nagios XI
Search for the service
Click the service
Click the Advanced tab
Click the Send custom notification link
Follow the steps
You should receive the sms.
If you did not receive the SMS, is the contact assigned to the service under Core Configuration Manager?
How did you create the contact?
How have you configured Nagios XI to send SMS messages? Under Admin > System Config > Manage Mobile Carriers?
Have you configured the user account to allow SMS's to be sent to it? This is done by:
Login to Nagios XI as the user who you want the SMS to go to
Click the users name in the top right corner
Under Notification preferences
Are Enable notifications checked?
Are the relevant SMS options checked?
Under Notification Methods
Are Mobile Phone Text Messages enabled?
Have you populated the phone number?
Re: sms alerts for vmware monitoring
Posted: Mon Mar 09, 2015 4:14 am
by venkitesh
hi box293,
Sorry for the confusion.
lets make it simple.
i am able to send an sms alert from nagios xi when the a particular datastore has gone critical.
As i already told you, i am using the below mentioned command for sending sms when a datastore has gone critical which works fine.
ssh
[email protected] '/usr/bin/smssend +91-xxxxxxxxxx " INFRA Says: Datastore $HOSTNAME$ is: $HOSTOUTPUT$ MORE THAN 90% $LONGDATETIME$"'
the only challenge i am facing in the above command is datastore name is not fetching. i tried with a couple of macros, but its not happening.
Thanks
Re: sms alerts for vmware monitoring
Posted: Mon Mar 09, 2015 3:47 pm
by lmiltchev
Let's clarify - you have the following check set up on your Nagios XI server:
Code: Select all
$USER1$/check_by_ssh -E 1 -t 90 -l vi-admin -H $ARG1$ -C "~/box293_check_vmware.pl --timeout 90 --server $ARG2$ --check Datastore_Usage --name \"$ARG3$\" --reporting_si \"$ARG4$\" \"$ARG5$\" \"$ARG6$\" \"$ARG7$\" \"$ARG8$\""
Why don't you send SMS alets via the "default" XI notifications methods?
Username->Notification Methods->Mobile Text
In the following command:
Code: Select all
ssh [email protected] '/usr/bin/smssend +91-xxxxxxxxxx " INFRA Says: Datastore $HOSTNAME$ is: $HOSTOUTPUT$ MORE THAN 90% $LONGDATETIME$"'
what is the 1.1.1.1 IP? Is this the XI server's IP? Can you elaborate on this command?
Re: sms alerts for vmware monitoring
Posted: Mon Mar 09, 2015 5:01 pm
by Box293
venkitesh wrote:As i already told you, i am using the below mentioned command for sending sms when a datastore has gone critical which works fine.
ssh
[email protected] '/usr/bin/smssend +91-xxxxxxxxxx " INFRA Says: Datastore $HOSTNAME$ is: $HOSTOUTPUT$ MORE THAN 90% $LONGDATETIME$"'
Just to go back to basics.
The VMware checks should be defined as a service.
Your commands are using HOST macros, there is no reference to the service macros that contain the service check output.
Which takes me back to my original reply:
Code: Select all
ssh [email protected] '/usr/bin/smssend +91-xxxxxxxxxx " Infra says: $HOSTNAME$ with service $SERVICEDESC$ is $SERVICESTATE$ with the outptut: $SERVICEOUTPUT$"'
venkitesh wrote:ssh
[email protected] '/usr/bin/smssend +91-xxxxxxxxxx " INFRA Says: Datastore $HOSTNAME$ is: $HOSTOUTPUT$ MORE THAN 90% $LONGDATETIME$"'
the only challenge i am facing in the above command is datastore name is not fetching. i tried with a couple of macros, but its not happening.
I don't know where you thing the "datastore name should be fetched from". Please paste the Nagios Service definition so we can see it:
Core Configuration Manager
Find the service
Click the Disk Icon
Paste the service definition here in a code block
ALSO, one other thing to keep in mind, SMS messages are historically restricted to 160 characters.
Re: sms alerts for vmware monitoring
Posted: Tue Mar 10, 2015 1:44 am
by venkitesh
hi lmiltchev
we have a linux based sms gateway(say 1.1.1.1) which we have integrated with nagios for sms alerting.
This is the vmware_datastore_usage command in nagios xi
$USER1$/check_by_ssh -E 1 -t 90 -l vi-admin -H $ARG1$ -C "~/box293_check_vmware.pl --timeout 90 --server $ARG2$ --check Datastore_Usage --name \"$ARG3$\" --reporting_si \"$ARG4$\" \"$ARG5$\" \"$ARG6$\" \"$ARG7$\" \"$ARG8$\""
command i used to send sms is
ssh
[email protected] '/usr/bin/smssend +91-xxxxxxxxxx " INFRA Says: Datastore $HOSTNAME$ is: $HOSTOUTPUT$ MORE THAN 90% $LONGDATETIME$"'
Output of this command will send an sms to the concerned number given in the above script that Some datastore has gone critical.
Say i have added one vcenter called testvc
under that i have added 2 datastores called testdatastore,testdatastore1
if any of this datastores has gone critical i will use the above sms script that Datastore testdatastore is critical more than 90%
the only issue we face is in the above sms script is datastore name(testdatastore) is not coming. only if we know which datastore has gone critical, then only we can take action right.
so just my request is what is the macro i have to use in the above script to get the datastores name.
Hope i mentioned my requirement exactly.