Problem running ssh script in nagios
Charlie R
charlie.reddington at gmail.com
Tue Nov 9 23:33:22 CET 2010
Please disregard, turned out I needed to add a full path to my ssh
config file :/
Charlie
On Nov 9, 2010, at 4:07 PM, Charlie R wrote:
> Hi List,
>
> Before we start, check_ssh and check_by_ssh is not a workable
> solution for me. I have a special setup in place that needs to run
> checks over native ssh since I have a bunch of ssh config options
> per host and need to use a proxy from where my nagios server is. So
> far what I have found doesn't let me use my ssh config file. My goal
> is to use ssh to check for host uptime since that's available on
> every host.
>
> I wrote a script that is very very basic. It's job is to ssh to a
> host to determine if it's up or down. Here's the meat and potatoes
> of that.
>
> --- checkhost.sh ---
> #!/bin/bash
>
> # Purpose: Replacement host alive check for nagios
> # on hosts that cannot be directly pinged
>
> # Usage function
> usage()
> {
> cat << EOF
>
> usage: checkhost.sh -H <host>
>
> OPTIONS:
> -h Show this message
> -H SSH host address
> EOF
> }
>
> # Variables
> SSHPath='/usr/bin/ssh'
>
> # Options menu
> while getopts "hH:" OPTION
> do
> case $OPTION in
> h)
> usage
> exit 1
> ;;
> H)
> SSHHost=$OPTARG
> ;;
> ?)
> usage
> exit 1
> ;;
> esac
> done
>
> # Make sure the required stuff is here
> if [[ -z $SSHHost ]]
> then
> usage
> exit 1
> fi
>
> # Connect function
> SSHConnect()
> {
> $SSHPath -q $SSHHost exit
> if [[ "$?" -eq 0 ]]
> then
> echo "Host is reachable"
> exit 0
> else
> echo "Unable to reach host"
> exit 2
> fi
> }
> SSHConnect
> --- end script ---
>
> When I run this script on my bash shell, it works perfect. When I
> run this as a host check in nagios, it fails with (Return code of
> 255 is out of bounds).
>
> I've checked to make sure it's not getting prompted to accept the
> local host key.
> I've checked nagios.debug to make sure the command is parsing
> correctly
> I've checked ssh key permissions
> I've changed my ssh code around to return something no matter what
> and it works.
>
> At this point, I'd like to blame ssh but I'm not 100% sure on that.
>
> Is there any caveats to run SSH on the native system with ssh keys
> and a more than customized ssh config file? Maybe I'm missing a ssh
> option? I've tried with and with out -T and -t. I've specifcally
> specified my config file along with my ssh keys.
>
> Thanks,
>
> Charlie
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list