ActionsComponent

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
monitoreo1
Posts: 124
Joined: Wed Feb 18, 2015 10:41 am

ActionsComponent

Post by monitoreo1 »

Hi,
I have the following shell scrip
It runs fine on Linux console
But when run from a ActionsComponent :
/usr/local/nagios/libexec/script.sh %hostaddress% %hostname%

The desired result is not obtained

#!/bin/bash
#Parametros de entrada
HOSTADDRESS=$1
HOSTNAME=$2
USER=" "
PASS=" "

HOSTNAMEUP="$(echo $HOSTNAME | tr '[a-z]' '[A-Z]')"
SUFIJO="_SAZ_10.log"
RUTA=/logs/$DIR/producto/JBOSS/JBOSS62/SAZ/$HOSTNAMEUP$SUFIJO
scp -pr $USER@$HOSTADDRESS:$RUTA ./$HOSTNAMEUP$SUFIJO

cat $HOSTNAMEUP$SUFIJO

Nagios XI Version : 2014R2.6
x86_64
Red Hat Enterprise Linux Server release 7.0 (Maipo)
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: ActionsComponent

Post by abrist »

Does your hostname include spaces? If so, please wrap the variables in quotes:

Code: Select all

/usr/local/nagios/libexec/script.sh %hostaddress% "%hostname%"
Also, could you echo the incoming variables to a file to see if they are populated correctly?

Code: Select all

#!/bin/bash
#Parametros de entrada
HOSTADDRESS=$1
HOSTNAME="$2"
USER=" "
PASS=" "

echo "$HOSTNAME" > /tmp/actions_test.txt
echo "$HOSTADDRESS" >> /tmp/actions_test.txt

HOSTNAMEUP="$(echo "$HOSTNAME" | tr '[a-z]' '[A-Z]')"
SUFIJO="_SAZ_10.log"
RUTA=/logs/$DIR/producto/JBOSS/JBOSS62/SAZ/$HOSTNAMEUP$SUFIJO
scp -pr $USER@$HOSTADDRESS:$RUTA ./$HOSTNAMEUP$SUFIJO

cat $HOSTNAMEUP$SUFIJO
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
monitoreo1
Posts: 124
Joined: Wed Feb 18, 2015 10:41 am

Re: ActionsComponent

Post by monitoreo1 »

I already made the modification to ActionsComponent :
/usr/local/nagios/libexec/logsSAZ.sh %hostaddress% "%hostname%"

The result from nagios is

Running: /usr/local/nagios/libexec/logsSAZ.sh
150.250.146.101
"lvmclcasjbnp01"

But it does not copy the file

It runs fine on Linux console

[root@lvm libexec]# ./logsSAZ.sh $ipaddress lvmclcasjbnp01
lvmclcasjbnp01
$ipaddress
Get the copy : LVM_SAZ_10.log
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: ActionsComponent

Post by jdalrymple »

selinux *should* be disabled by the NagiosXI intall, but can you verify?

Does the user nagios have proper permissions to execute scp? Are the proper ssh bits in place for passwordless SSH authentication to the remote host?
monitoreo1
Posts: 124
Joined: Wed Feb 18, 2015 10:41 am

Re: ActionsComponent

Post by monitoreo1 »

Nagios It does not execute scp and ssh.
How could solve this detail.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: ActionsComponent

Post by ssax »

The problem is that scp requires you to accept the key fingerprint:

You can do that this way, from the XI box:

Code: Select all

su - nagios
ssh user@yourserver
Then accept the key, you would have to do this for all the machines you want to connect to though so the nagios user has those fingerprints cached.

You could also use this command, I wouldn't recommend it for security reasons but it is an option:

Code: Select all

scp -pr -oStrictHostKeyChecking=no $USER@$HOSTADDRESS:$RUTA ./$HOSTNAMEUP$SUFIJO
You could also follow this guide:
http://xmodulo.com/how-to-accept-ssh-ho ... linux.html
monitoreo1
Posts: 124
Joined: Wed Feb 18, 2015 10:41 am

Re: ActionsComponent

Post by monitoreo1 »

You can close the topic.
Thanks
Locked