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)
ActionsComponent
Re: ActionsComponent
Does your hostname include spaces? If so, please wrap the variables in quotes:
Also, could you echo the incoming variables to a file to see if they are populated correctly?
Code: Select all
/usr/local/nagios/libexec/script.sh %hostaddress% "%hostname%"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$SUFIJOFormer 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.
"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
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
/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
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?
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
Nagios It does not execute scp and ssh.
How could solve this detail.
How could solve this detail.
Re: ActionsComponent
The problem is that scp requires you to accept the key fingerprint:
You can do that this way, from the XI box:
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:
You could also follow this guide:
http://xmodulo.com/how-to-accept-ssh-ho ... linux.html
You can do that this way, from the XI box:
Code: Select all
su - nagios
ssh user@yourserver
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$SUFIJOhttp://xmodulo.com/how-to-accept-ssh-ho ... linux.html
-
monitoreo1
- Posts: 124
- Joined: Wed Feb 18, 2015 10:41 am
Re: ActionsComponent
You can close the topic.
Thanks
Thanks