0

I'm in a unix environment where I'm using check_by_ssh to execute Nagios plug-ins. A few hosts have a different unix account to which Nagios needs to ssh into to run the plug-ins. I pass the account name with -l like this:

command_line    $USER1$/check_by_ssh -p 22 \
   -H $HOSTADDRESS$ -l <user> -i /home/nagios/.ssh/$HOSTNAME$ -C '<plug-in path>'

For the machines that have a different unix account is there a way to not have to double all the command definitions e.g. replacing -l nagios with -l user1 ?

I was hoping there was a way to pass the username in the host definition to say this set of hosts should login with user1 and this other set of hosts should use user2.

Any help is appreciated.

Thanks

1

1 Answer 1

1

Note: I haven't tested this code.

That said, I would probably define an alternate check in commands.cfg with something along the lines of:

# Check by SSH for hosts with different account

command_line    $USER1$/check_by_ssh_alt -p 22 \
   -H $HOSTADDRESS$ -l $ARG1$ -i /home/nagios/.ssh/$HOSTNAME$ -C '<plug-in path>'

And then invoke it with something like:

define service{
        use                     generic-service
        hostgroup_name          hostgroup_1
        service_description     Some Check by SSH
        contacts                hostgroup_1_admins
        notification_options    w,c,r
        notification_period     24x7
        notification_interval   0
        check_command           check_ssh_alt!user1
        }

Good luck!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .