Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've got a major issue with Nagios. I'm a newb to Nagios, so I hope I can find here some people who are experienced with it!
I made some scripts that i need to run with Nagios (the scripts are shells).
So in my scripts I need to copy another script to my remote server, then i need to execute it and then the copied file needs to give back feedback so i can handle that information locally (it can sound crazy, but it doesn't matter what they do, i just need to get this work).
So, if i run it in Nagios (testing it) i get some feedback (like echoes) but in my other script i also use echoes but Nagios doesn't show it.
Oke, time for some code... This is the mainscript:
Code:
#!/bin/bash
PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
"
# Exit codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
# Initiliaze variables
EXITSTATUS=$STATE_UNKNOWN
echo testing
EXITSTATUS=$STATE_WARNING #default
while test -n "$1"; do
case "$1" in
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
--version)
print_revision $PROGNAME $VERSION
exit $STATE_OK
;;
-V)
print_revision $PROGNAME $VERSION
exit $STATE_OK
;;
--hostname)
host=$2
shift
;;
-H)
host=$2
shift
;;
-p)
path=$2
shift
;;
--path)
path=$2
shift
;;
*)
echo "Unknown argumen: $1"
print_usge
exit $STATE_UNKNOWN
;;
esac
shift
done
# Copying a file to the remote server
# Then executing the script I just copied
scp $path user@$host:/some/folder
ssh user@host 'echo hello'
VAR=$(ssh user@$host './scp_cd.sh')
echo $VAR
#ssh user@host 'rm -f /home/vusbe/scp_cd.sh'
if [ $VAR = 2 ]; then
EXITSTATUS=$STATE_CRITICAL
echo STATE_ERROR
elif [ $VAR = 1 ]; then
EXITSTATUS=$STATE_WARNING
echo STATE_WARNING
else
echo niks aan de hand
EXITSTATUS=$STATE_OK
fi
# End of script
echo script is ten einde
and this is the subscript:
Code:
#!/usr/bin/ksh
echo subscript
error=`ls /some/folder/ | grep error* | wc -w`
warning=`ls /some/folder/ | grep -ie *.tmp | wc -w`
if [ $error -gt 0 ]; then
i="0" # ERROR MESSAGE
else
i="0" # OK MESSAGE
fi
echo $i
this is what i use in Nagios
$USER1$/check_test.sh -H remote_server -p path_to_script_needed_to_copy
I have also did a SSH-KEYSWAP so i don't need to log me in everytime, and this works
can someone help me?
Last edited by brownie_cookie; 04-04-2011 at 02:55 AM.
Even you can use snmp as your agent to monitor your remote servers, network etc..
i don't need to monitor networks, CPU's or whatever, i only need to check/monitor some files and folders, so i don't think i need SNMP?
but thx for the tip, i'll sure have a look ^^
Yup, Both NRPE & SNMP will help you to check/monitor files/folders... your subscript(which is helping you to check/monitor files/folders) can integrate with SNMP & NRPE
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.