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.
amitdaniel
Posts: 25 Joined: Mon Jul 01, 2013 9:17 am
Post
by amitdaniel » Mon Nov 11, 2013 4:00 am
Hey ,
i created a script that check if some process is running .
Code: Select all
#!/bin/bash
# Nagios return codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
while getopts H:u:p:L: OPT
do
case $OPT in
"H" ) FLAGH="TRUE" ; HOST="$OPTARG" ;;
"p" ) FLAGu="TRUE" ; PEM="$OPTARG" ;;
* ) echo "Usage: $CMDNAME [-H HOST] [-pem /pem/file/location.pem ]. Example: -H 10.0.3.101 -pem /root/x.pem" 1>&2
exit $STATE_UNKNOWN ;;
esac
done
# Commands
RESULT=`ssh -i $PEM $HOST 'ps -ef | grep logstash | grep -v grep | wc -l'`
case $RESULT in
[1-2]*)
echo "OK - $RESULT proc found ."
exit $STATE_OK
;;
[0]*)
echo "CRITICAL - $RESULT proc found ."
exit $STATE_CRITICAL
;;
*)
echo "UNKNOWN - $RESULT proc found ."
exit $STATE_UNKNOWN
;;
esac
When i ran this command on /usr/local/nagios/libexec
Code: Select all
./check_logstash.sh -H openx-dist1d -p /root/x.pem
the result is : " OK - 1 proc found . "
i created command like this :
Code: Select all
define command{
command_name check_logstash_virginia
command_line /usr/local/nagios/libexec/check_logstash.sh -H $HOSTADDRESS$ -p /root/x.pem
}
and on nagios UI i get this warning - Status Information: UNKNOWN - proc found .
Some can help me ?
Thanks !!!
Last edited by
abrist on Mon Nov 11, 2013 12:03 pm, edited 2 times in total.
Reason: Use code wraps when possible, thanks :)
abrist
Red Shirt
Posts: 8334 Joined: Thu Nov 15, 2012 1:20 pm
Post
by abrist » Mon Nov 11, 2013 12:05 pm
Can you try running the command as user nagios?
Code: Select all
su nagios
./check_logstash.sh -H openx-dist1d -p /root/x.pem
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the
Dark Side .
amitdaniel
Posts: 25 Joined: Mon Jul 01, 2013 9:17 am
Post
by amitdaniel » Mon Nov 11, 2013 12:16 pm
Hey
Thanks for your quick replay
when i tried to run the command with nagios user it's looks like the command ignore my pem file
./check_logstash.sh -H openx-dist1d -p /usr/local/nagios/x.pem
nagios@openx-dist1d's password:
But i don't have password.
what should i do ?
Thanks !!!!
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Mon Nov 11, 2013 12:36 pm
amitdaniel wrote:
./check_logstash.sh -H openx-dist1d -p /usr/local/nagios/x.pem
nagios@openx-dist1d's password:
What are the permissions on /usr/local/nagios/x.pem ?
and is /usr/local/nagios/x.pem the same as /root/x.pem that you said was working?
amitdaniel
Posts: 25 Joined: Mon Jul 01, 2013 9:17 am
Post
by amitdaniel » Mon Nov 11, 2013 12:40 pm
Hey
Thanks again for you very quick response.
Yes the x.pem is the same.
permission are :
-rw------- 1 nagios nagios 1679 Nov 11 17:12 /usr/local/nagios/x.pem
Thanks !
abrist
Red Shirt
Posts: 8334 Joined: Thu Nov 15, 2012 1:20 pm
Post
by abrist » Mon Nov 11, 2013 1:22 pm
Change the permissions to include the nagios group:
Code: Select all
chmod g+xr /usr/local/nagios/x.pem
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the
Dark Side .
amitdaniel
Posts: 25 Joined: Mon Jul 01, 2013 9:17 am
Post
by amitdaniel » Mon Nov 11, 2013 1:28 pm
Done but now i have other issue
-rw-r-x--- 1 nagios nagios 1679 Nov 11 17:12 /usr/local/nagios/x.pem
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0650 for '/usr/local/nagios/x.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /usr/local/nagios/x.pem
Thanks !
abrist
Red Shirt
Posts: 8334 Joined: Thu Nov 15, 2012 1:20 pm
Post
by abrist » Mon Nov 11, 2013 1:42 pm
Well, heck. Remove the permission:
Code: Select all
chmod g-xr /usr/local/nagios/x.pem
amitdaniel wrote: But i don't have password.
what should i do ?
Thanks !!!!
Are you sure your pem is not password protected?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the
Dark Side .
amitdaniel
Posts: 25 Joined: Mon Jul 01, 2013 9:17 am
Post
by amitdaniel » Mon Nov 11, 2013 2:34 pm
i succeed to run the command using
su nagios
if i ran the command like this
./check_logstash.sh -H root@openx-dist1d -p /usr/local/nagios/x.pem
amitdaniel
Posts: 25 Joined: Mon Jul 01, 2013 9:17 am
Post
by amitdaniel » Mon Nov 11, 2013 2:39 pm
but still i config the command :
define command{
command_name check_logstash_virginia
command_line /usr/local/nagios/libexec/check_logstash.sh -H $HOSTADDRESS$ -p /usr/local/nagios/x.pem
}
RETURN : UNKNOWN - proc found .