LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 04-01-2011, 05:20 AM   #1
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
[NAGIOS] problems with mainscript and subscript


Hi all

I've made a mainscript and a subscript that must be implemented in NAGIOS.
What do those scripts do, well:
situation:
the mainscript makes connection to a remote server, then it copies another script (=subscript) to it and executes it, then the result of that subscript is redirected to a variable on the local server where the mainscript can do something with it (e.g. if the variable contains a 1 -> OK, 2 -> WARNING, ...)

code:
Code:
mainscript
# Initiliaze variables
EXITSTATUS=$STATE_OK

# Copying a file to the remote server
# Then executing the script I just copied
scp /folder/scriptname user@host:/home/vusbe
VAR=$(ssh user@host './scp_cd.sh')
echo $VAR

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 finished
subscript:
Code:
#!/usr/bin/ksh
echo subscript

error=`ls /some/folder/ | grep error* | wc -w`

if [ $error -gt 0 ]; then
	i="2" # ERROR MESSAGE
else
	i="0" # OK MESSAGE
fi

echo $i
the result (NAGIOS):
Code:
niks aan de hand
script is finished
but it should give me the STATE_ERROR !!
so, can anyone say what i'm doing wrong (i'm not experienced with NAGIOS, i'm a first-timer to this )
is it also possible to copy another script in a NAGIOS plugin?

I know it's a lot of information/code and it can be a little tricky to answer, but i hope you guys are up for the challenge

Thx

Last edited by brownie_cookie; 04-01-2011 at 05:22 AM.
 
Old 04-01-2011, 07:43 AM   #2
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
can anyone explain this ?
Code:
use vars qw($host $opt_V $opt_h $opt_v $verbose $PROGNAME $pattern $opt_p $mmin $opt_m $opt_w $opt_e $opt_c $opt_t $opt_H $status $state $msg $msg_q $MAILQ $SHELL $device $used $avail $percent $fs $blocks $CMD $RMTOS);

$pattern = $opt_p;
$mmin = $opt_m;

if ( $RMTOS eq "Linux" ) {
	$CMD = "/usr/local/bin/find " . $pattern . " -type f -mmin " . $mmin . " 2>/dev/null| /usr/bin/wc -l";
}
i've found this in a nagios plugin, but i don't know why it's for...
it's written in PERL and i don't know anything about perl
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Subscript operator for a list class vbx_wx Programming 1 06-27-2010 09:26 AM
Trouble overloading subscript operator [] m_lp_ql_m Programming 6 04-27-2007 12:34 AM
problems with Nagios on check_overcr fcastells Linux - Software 0 10-26-2005 09:43 AM
Problems with nagios config ignus Linux - Software 4 07-26-2005 09:17 AM
Nagios and NagMIN problems pnh73 Linux - Software 7 11-20-2004 05:28 AM


All times are GMT -5. The time now is 02:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration