LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-04-2011, 02:37 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
Stuck with Nagios


Hi all

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.
 
Old 04-04-2011, 03:17 AM   #2
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
Why can't use NRPE instead of this script??
 
Old 04-04-2011, 03:19 AM   #3
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

Original Poster
Blog Entries: 2

Rep: Reputation: 12
i'm sorry for the stupid question

but what does NRPE do and how do i use it?
 
Old 04-04-2011, 03:27 AM   #4
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
NRPE help you to execute nagios plugins on your remote server and pass the values to your Nagios manager..
http://exchange.nagios.org/directory...ecutor/details
 
Old 04-04-2011, 03:29 AM   #5
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

Original Poster
Blog Entries: 2

Rep: Reputation: 12
indeed, i've also found something that might be interesting (some kinda tutorial)

so for people who needs information about NRPE, check also this link

thanks for the advice
 
Old 04-04-2011, 03:30 AM   #6
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
Refer the following there are lot of agents
http://exchange.nagios.org/directory...itoring-Agents

Even you can use snmp as your agent to monitor your remote servers, network etc..
 
Old 04-04-2011, 03:35 AM   #7
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
NRPE, SNMP are more secure way to monitor your remote system than you use your own script...
 
Old 04-04-2011, 03:37 AM   #8
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

Original Poster
Blog Entries: 2

Rep: Reputation: 12
Quote:
Originally Posted by kirukan View Post
Refer the following there are lot of agents
http://exchange.nagios.org/directory...itoring-Agents

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 ^^
 
Old 04-04-2011, 04:10 AM   #9
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
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
 
Old 04-04-2011, 04:26 AM   #10
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

Original Poster
Blog Entries: 2

Rep: Reputation: 12
thx ^^ i'm trying to install NRPE and using NRPE as i speak
 
  


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
LXer: Nagios and Oreon (Nagios web front end) installation and Configuration LXer Syndicated Linux News 1 05-31-2016 07:26 AM
LXer: April Nagios Training Dates Include Advanced Nagios Class LXer Syndicated Linux News 0 03-18-2011 09:30 AM
Fail to install Nagios Pluggin nagios-plugins-1.4.15.tar.gz fred_xlf Linux - Software 1 11-27-2010 06:09 AM
cannot find Nagios web interface (Nagios 3.2.0) and O/S = Fedora 10 gutiojj Linux - Newbie 7 02-04-2010 08:55 AM
LXer: Nagios 2.5 and Oreon 1.3 (Nagios web front end) installation with screenshots LXer Syndicated Linux News 0 08-11-2006 05:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:15 PM.

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
Open Source Consulting | Domain Registration