2010-11-15 Raul Mateos <raulofpandora@gmail.com>
* pandora_agent*, pandora_exec, plugins/pandora_update: Small changes: Year, version, spaces to tabs. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3584 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
730f0d6a30
commit
83368c071f
|
@ -1,3 +1,8 @@
|
|||
2010-11-15 Raúl Mateos <raulofpandora@gmail.com>
|
||||
|
||||
* pandora_agent*, pandora_exec, plugins/pandora_update: Small changes:
|
||||
Year, version, spaces to tabs.
|
||||
|
||||
2010-11-14 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* plugins/pandora_update: Small tool (in perl), used also in windows
|
||||
|
|
|
@ -48,7 +48,7 @@ eval {
|
|||
require threads;
|
||||
require threads::shared;
|
||||
require Thread::Semaphore;
|
||||
require IO::Socket;
|
||||
require IO::Socket;
|
||||
};
|
||||
if (!$@) {
|
||||
threads::shared::share (\$Xml);
|
||||
|
@ -61,7 +61,7 @@ use constant AGENT_BUILD => '101103';
|
|||
|
||||
# Commands to retrieve total memory information in kB
|
||||
use constant TOTALMEMORY_CMDS => {
|
||||
linux => 'cat /proc/meminfo | grep MemTotal: | awk \'{ print $2 }\'',
|
||||
linux => 'cat /proc/meminfo | grep MemTotal: | awk \'{ print $2 }\'',
|
||||
solaris => 'MEM=`prtconf | grep Memory | awk \'{print $3}\'` bash -c \'echo $(( 1024 * $MEM ))\'',
|
||||
hpux => 'swapinfo -t | grep memory | awk \'{print $2}\'',
|
||||
freebsd => 'sysctl hw.physmem | awk \'{print $2 / 1024}\''
|
||||
|
@ -69,7 +69,7 @@ use constant TOTALMEMORY_CMDS => {
|
|||
|
||||
# Commands to retrieve free memory information in kB
|
||||
use constant FREEMEMORY_CMDS => {
|
||||
linux => 'cat /proc/meminfo | grep MemFree: | awk \'{ print $2 }\'',
|
||||
linux => 'cat /proc/meminfo | grep MemFree: | awk \'{ print $2 }\'',
|
||||
solaris => 'vmstat 1 2 | tail -1 | awk \'{ print $5 }\'',
|
||||
hpux => 'swapinfo -t | grep memory | awk \'{print $4}\'',
|
||||
freebsd => 'vmstat -H 1 2 | tail -1 | awk \'{ print $5 }\''
|
||||
|
@ -150,9 +150,9 @@ my %Conf = (
|
|||
'timezone_offset' => 0,
|
||||
'pandora_exec' => 'pandora_exec',
|
||||
'agent_threads' => 1,
|
||||
'udp_server_port' => 41122,
|
||||
'udp_server_auth_address' => '0.0.0.0',
|
||||
'udp_server' => 0
|
||||
'udp_server_port' => 41122,
|
||||
'udp_server_auth_address' => '0.0.0.0',
|
||||
'udp_server' => 0
|
||||
);
|
||||
|
||||
# Modules
|
||||
|
@ -464,19 +464,19 @@ sub send_file {
|
|||
} elsif ($Conf{'transfer_mode'} eq 'ssh') {
|
||||
$output = `scp -P $Conf{'server_port'} $file pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >$DevNull`;
|
||||
} elsif ($Conf{'transfer_mode'} eq 'ftp') {
|
||||
my $base = basename ($file);
|
||||
my $dir = dirname ($file);
|
||||
my $base = basename ($file);
|
||||
my $dir = dirname ($file);
|
||||
|
||||
$output = `ftp -n $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1
|
||||
quote USER pandora
|
||||
quote PASS $Conf{'server_pwd'}
|
||||
lcd "$dir"
|
||||
cd "$Conf{'server_path'}"
|
||||
put "$base"
|
||||
quit
|
||||
FEOF1`
|
||||
quote USER pandora
|
||||
quote PASS $Conf{'server_pwd'}
|
||||
lcd "$dir"
|
||||
cd "$Conf{'server_path'}"
|
||||
put "$base"
|
||||
quit
|
||||
FEOF1`
|
||||
} elsif ($Conf{'transfer_mode'} eq 'local') {
|
||||
$output = `cp $file $Conf{'server_path'}/ 2>&1 >$DevNull`;
|
||||
$output = `cp $file $Conf{'server_path'}/ 2>&1 >$DevNull`;
|
||||
}
|
||||
|
||||
# Get the errorlevel
|
||||
|
@ -521,17 +521,17 @@ sub recv_file ($) {
|
|||
} elsif ($Conf{'transfer_mode'} eq 'ssh') {
|
||||
$output = `scp -P $Conf{'server_port'} pandora@"$Conf{'server_ip'}:$Conf{'server_path'}/$file" $Conf{'temporal'} 2>&1 >$DevNull`;
|
||||
} elsif ($Conf{'transfer_mode'} eq 'ftp') {
|
||||
my $base = basename ($file);
|
||||
my $dir = dirname ($file);
|
||||
my $base = basename ($file);
|
||||
my $dir = dirname ($file);
|
||||
|
||||
$output = `ftp -n $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1
|
||||
quote USER pandora
|
||||
quote PASS $Conf{'server_pwd'}
|
||||
lcd "$Conf{'temporal'}"
|
||||
cd "$Conf{'server_path'}"
|
||||
get "$file"
|
||||
quit
|
||||
FEOF1`
|
||||
quote USER pandora
|
||||
quote PASS $Conf{'server_pwd'}
|
||||
lcd "$Conf{'temporal'}"
|
||||
cd "$Conf{'server_path'}"
|
||||
get "$file"
|
||||
quit
|
||||
FEOF1`
|
||||
} elsif ($Conf{'transfer_mode'} eq 'local') {
|
||||
$output = `cp $Conf{'server_path'}/$file $Conf{'temporal'} 2>&1 >$DevNull`;
|
||||
}
|
||||
|
@ -554,11 +554,11 @@ sub check_remote_config () {
|
|||
|
||||
# Calculate the configuration file MD5 digest
|
||||
open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!.");
|
||||
binmode(CONF_FILE);
|
||||
binmode(CONF_FILE);
|
||||
my $conf_md5 = md5 (join ('', <CONF_FILE>));
|
||||
close (CONF_FILE);
|
||||
|
||||
# Get the remote MD5 file
|
||||
close (CONF_FILE);
|
||||
|
||||
# Get the remote MD5 file
|
||||
if (recv_file ($RemoteMD5File) != 0) {
|
||||
open (MD5_FILE, "> $Conf{'temporal'}/$RemoteMD5File") || error ("Could not open file '$ConfDir/$RemoteMD5File' for writing: $!.");
|
||||
print MD5_FILE $conf_md5;
|
||||
|
@ -1201,29 +1201,29 @@ sub write_module_xml ($@) {
|
|||
# Critical section
|
||||
$Sem->down () if (defined ($Sem));
|
||||
|
||||
$Xml .= " <module>\n" .
|
||||
" <name><![CDATA[" . $module->{'name'} . "]]></name>\n" .
|
||||
" <description><![CDATA[" . $module->{'description'} . "]]></description>\n" .
|
||||
" <type>" . $module->{'type'} . "</type>\n";
|
||||
$Xml .= " <module>\n" .
|
||||
" <name><![CDATA[" . $module->{'name'} . "]]></name>\n" .
|
||||
" <description><![CDATA[" . $module->{'description'} . "]]></description>\n" .
|
||||
" <type>" . $module->{'type'} . "</type>\n";
|
||||
|
||||
if ($module->{'interval'} > 1) {
|
||||
$Xml .= " <module_interval>" . $module->{'interval'} . "</module_interval>\n";
|
||||
$Xml .= " <module_interval>" . $module->{'interval'} . "</module_interval>\n";
|
||||
}
|
||||
|
||||
# Data list
|
||||
if ($#data > 0) {
|
||||
$Xml .= " <datalist>\n";
|
||||
$Xml .= " <datalist>\n";
|
||||
foreach my $data_item (@data) {
|
||||
chomp ($data_item);
|
||||
$Xml .= " <data><value><![CDATA[$data_item]]></value></data>\n";
|
||||
$Xml .= " <data><value><![CDATA[$data_item]]></value></data>\n";
|
||||
}
|
||||
$Xml .= " </datalist>\n";
|
||||
$Xml .= " </datalist>\n";
|
||||
# Single data
|
||||
} else {
|
||||
chomp ($data[0]);
|
||||
$Xml .= " <data><![CDATA[$data[0]]]></data>\n";
|
||||
$Xml .= " <data><![CDATA[$data[0]]]></data>\n";
|
||||
}
|
||||
$Xml .= " </module>\n";
|
||||
$Xml .= " </module>\n";
|
||||
|
||||
$Sem->up () if (defined ($Sem));
|
||||
}
|
||||
|
@ -1232,7 +1232,7 @@ sub write_module_xml ($@) {
|
|||
# Receive a UDP server signal to restart agent
|
||||
################################################################################
|
||||
sub udp_server_signal () {
|
||||
log_message ('udp server', 'Received signal to restart the agent.');
|
||||
log_message ('udp server', 'Received signal to restart the agent.');
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
@ -1240,29 +1240,29 @@ sub udp_server_signal () {
|
|||
################################################################################
|
||||
sub udp_server ($$) {
|
||||
|
||||
my $udp_port = shift;
|
||||
my $udp_auth_address = shift;
|
||||
my $parent_pid = getppid();
|
||||
my $udp_port = shift;
|
||||
my $udp_auth_address = shift;
|
||||
my $parent_pid = getppid();
|
||||
|
||||
my($sock, $oldmsg, $newmsg, $hisaddr, $hishost, $MAXLEN);
|
||||
$MAXLEN = 1024;
|
||||
my($sock, $oldmsg, $newmsg, $hisaddr, $hishost, $MAXLEN);
|
||||
$MAXLEN = 1024;
|
||||
|
||||
log_message ('udp server', 'Starting UDP server listening on '.$udp_auth_address.":".$udp_port);
|
||||
$sock = IO::Socket::INET->new(LocalPort => $udp_port, Proto => 'udp') or die "socket: $@";
|
||||
log_message ('udp server', 'Starting UDP server listening on '.$udp_auth_address.":".$udp_port);
|
||||
$sock = IO::Socket::INET->new(LocalPort => $udp_port, Proto => 'udp') or die "socket: $@";
|
||||
|
||||
while ($sock->recv($newmsg, $MAXLEN)) {
|
||||
my($port, $ipaddr) = sockaddr_in($sock->peername);
|
||||
$hishost = gethostbyaddr($ipaddr, AF_INET);
|
||||
while ($sock->recv($newmsg, $MAXLEN)) {
|
||||
my($port, $ipaddr) = sockaddr_in($sock->peername);
|
||||
$hishost = gethostbyaddr($ipaddr, AF_INET);
|
||||
|
||||
log_message ('udp server', 'Received signal from '.$hishost);
|
||||
log_message ('udp server', 'Received signal from '.$hishost);
|
||||
|
||||
if (($udp_auth_address eq "0.0.0.0") || ($hishost eq $udp_auth_address)){
|
||||
if ($newmsg =~ /REFRESH AGENT/){
|
||||
# Send signal to restart agent
|
||||
kill 'SIGINT' , $parent_pid;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (($udp_auth_address eq "0.0.0.0") || ($hishost eq $udp_auth_address)){
|
||||
if ($newmsg =~ /REFRESH AGENT/){
|
||||
# Send signal to restart agent
|
||||
kill 'SIGINT' , $parent_pid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
@ -1324,22 +1324,22 @@ $ENV{'PATH'} .= ":$ConfDir/plugins";
|
|||
|
||||
# Start UDP server if configured
|
||||
if ($Conf{'udp_server'} == 1){
|
||||
my $pid = fork();
|
||||
my $pid = fork();
|
||||
|
||||
if ($pid == 0){
|
||||
udp_server ($Conf{'udp_server_port'}, $Conf{'udp_server_auth_address'});
|
||||
exit;
|
||||
}
|
||||
if ($pid == 0){
|
||||
udp_server ($Conf{'udp_server_port'}, $Conf{'udp_server_auth_address'});
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Loop
|
||||
while (1) {
|
||||
|
||||
# Ignore signals from UDP server while processing execution
|
||||
if ($Conf{'udp_server'} == 1){
|
||||
$SIG{'INT'} = 'DEFAULT';
|
||||
}
|
||||
# Ignore signals from UDP server while processing execution
|
||||
if ($Conf{'udp_server'} == 1){
|
||||
$SIG{'INT'} = 'DEFAULT';
|
||||
}
|
||||
|
||||
# Check for a new configuration
|
||||
check_remote_config () unless ($Conf{'debug'} eq '1');
|
||||
|
@ -1348,16 +1348,16 @@ while (1) {
|
|||
check_collections () unless ($Conf{'debug'} eq '1');
|
||||
|
||||
$Xml = "<?xml version='1.0' encoding='" . $Conf{'encoding'} . "'?>\n" .
|
||||
"<agent_data description='" . $Conf{'description'} ."' group='" . $Conf{'group'} .
|
||||
"' os_name='$OS' os_version='$OS_VERSION' interval='" . $Conf{'interval'} .
|
||||
"' version='" . AGENT_VERSION . '(Build ' . AGENT_BUILD . ')' . ($Conf{'autotime'} eq '1' ? '' : "' timestamp='" . strftime ('%Y/%m/%d %H:%M:%S', localtime ())) .
|
||||
"' agent_name='" . $Conf{'agent_name'} . "' timezone_offset='". $Conf{'timezone_offset'};
|
||||
"<agent_data description='" . $Conf{'description'} ."' group='" . $Conf{'group'} .
|
||||
"' os_name='$OS' os_version='$OS_VERSION' interval='" . $Conf{'interval'} .
|
||||
"' version='" . AGENT_VERSION . '(Build ' . AGENT_BUILD . ')' . ($Conf{'autotime'} eq '1' ? '' : "' timestamp='" . strftime ('%Y/%m/%d %H:%M:%S', localtime ())) .
|
||||
"' agent_name='" . $Conf{'agent_name'} . "' timezone_offset='". $Conf{'timezone_offset'};
|
||||
|
||||
if (defined ($Conf{'parent_agent_name'})) {
|
||||
$Xml .= "' parent_agent_name='" .$Conf{'parent_agent_name'};
|
||||
}
|
||||
if (defined ($Conf{'longitude'}) && defined ($Conf{'latitude'})) {
|
||||
$Xml .= "' longitude='" .$Conf{'longitude'} . "' latitude='" .$Conf{'latitude'};
|
||||
$Xml .= "' longitude='" .$Conf{'longitude'} . "' latitude='" .$Conf{'latitude'};
|
||||
if (defined ($Conf{'altitude'})) {
|
||||
$Xml .= "' altitude='" .$Conf{'altitude'};
|
||||
}
|
||||
|
@ -1431,10 +1431,10 @@ while (1) {
|
|||
# Cron mode
|
||||
last if ($Conf{'cron_mode'} == 1);
|
||||
|
||||
# Enable signal capture to break the Sleep interval on UDP signal
|
||||
if ($Conf{'udp_server'} == 1){
|
||||
$SIG{'INT'} = \&udp_server_signal;
|
||||
}
|
||||
# Enable signal capture to break the Sleep interval on UDP signal
|
||||
if ($Conf{'udp_server'} == 1){
|
||||
$SIG{'INT'} = \&udp_server_signal;
|
||||
}
|
||||
|
||||
# Go to sleep
|
||||
#
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 3.2dev
|
||||
%define version 3.2
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
Version: %{version}
|
||||
|
@ -58,7 +58,7 @@ fi
|
|||
cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUILD_ROOT/usr/share/pandora_agent/pandora_agent.conf.rpmnew
|
||||
|
||||
if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then
|
||||
rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec
|
||||
rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec
|
||||
fi
|
||||
|
||||
%clean
|
||||
|
@ -75,7 +75,7 @@ if [ ! -d /etc/pandora ] ; then
|
|||
fi
|
||||
|
||||
if [ ! -f /usr/share/pandora_agent/pandora_agent.conf ] ; then
|
||||
cp /usr/share/pandora_agent/pandora_agent.conf.rpmnew /usr/share/pandora_agent/pandora_agent.conf
|
||||
cp /usr/share/pandora_agent/pandora_agent.conf.rpmnew /usr/share/pandora_agent/pandora_agent.conf
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/pandora/pandora_agent.conf ] ; then
|
||||
|
@ -99,7 +99,7 @@ chkconfig pandora_agent_daemon on
|
|||
|
||||
# Upgrading
|
||||
if [ "$1" = "1" ]; then
|
||||
exit 0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
chkconfig --del pandora_agent_daemon
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# (c) 2008-2010 Sancho Lerena <slerena@gmail.com>
|
||||
#
|
||||
# Please see http://www.pandorafms.org
|
||||
# v3.1 Build 100515
|
||||
# v3.2 Build 101115
|
||||
# This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
|||
# Provides: pandora_agent
|
||||
# Required-Start: $network
|
||||
# Required-Stop: $network
|
||||
# Default-Start: 2 3 5
|
||||
# Default-Start: 2 3 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Startup script daemon for Pandora FMS agent
|
||||
# Description: Startup script daemon for Pandora FMS agent (linux)
|
||||
|
@ -93,7 +93,7 @@ case "$1" in
|
|||
exit 1
|
||||
else
|
||||
echo "Stopping Pandora Agent."
|
||||
kill -9 $PANDORA_PID > /dev/null 2>&1
|
||||
kill -9 $PANDORA_PID > /dev/null 2>&1
|
||||
fi
|
||||
;;
|
||||
|
||||
|
@ -115,7 +115,7 @@ case "$1" in
|
|||
;;
|
||||
|
||||
*)
|
||||
echo "Uso: /etc/init.d/pandora_agent_daemon {start|stop|restart|status}"
|
||||
exit 1
|
||||
echo "Usage: /etc/init.d/pandora_agent_daemon {start|stop|restart|status}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION=3.1
|
||||
PI_BUILD=100515
|
||||
PI_VERSION=3.2
|
||||
PI_BUILD=101115
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
@ -81,15 +81,15 @@ help () {
|
|||
|
||||
uninstall () {
|
||||
OS_NAME=`uname -s`
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
then
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
then
|
||||
PANDORA_HOME=/usr/local/share/pandora_agent
|
||||
PANDORA_BIN=/usr/local/bin/pandora_agent
|
||||
PANDORA_EXEC_BIN=/usr/local/bin/pandora_exec
|
||||
PANDORA_CFG=/usr/local/etc/pandora
|
||||
TENTACLE=/usr/local/bin/tentacle_client
|
||||
PANDORA_MAN=/usr/local/man
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Removing Pandora FMS Agent..."
|
||||
rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null
|
||||
|
@ -125,10 +125,10 @@ uninstall () {
|
|||
rm -Rf $PANDORA_BASE/$PANDORA_CFG 2> /dev/null
|
||||
fi
|
||||
|
||||
if [ ! -z "$PANDORA_BASE" ]
|
||||
then
|
||||
echo "Please delete manually $PANDORA_BASE for complete uninstall"
|
||||
fi
|
||||
if [ ! -z "$PANDORA_BASE" ]
|
||||
then
|
||||
echo "Please delete manually $PANDORA_BASE for complete uninstall"
|
||||
fi
|
||||
|
||||
echo " "
|
||||
echo "Done"
|
||||
|
@ -170,19 +170,19 @@ install () {
|
|||
echo "Checking Pandora FMS Agent on $PANDORA_BASE$PANDORA_BIN...."
|
||||
fi
|
||||
|
||||
echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME"
|
||||
if [ ! -z "$PANDORA_BASE" ]
|
||||
then
|
||||
mkdir -p $PANDORA_BASE 2> /dev/null
|
||||
mkdir -p $PANDORA_BASE/var/log 2> /dev/null
|
||||
mkdir -p $PANDORA_BASE/$PANDORA_MAN/man1 2> /dev/null
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME"
|
||||
if [ ! -z "$PANDORA_BASE" ]
|
||||
then
|
||||
mkdir -p $PANDORA_BASE/usr/local/bin 2> /dev/null
|
||||
else
|
||||
mkdir -p $PANDORA_BASE/usr/bin 2> /dev/null
|
||||
mkdir -p $PANDORA_BASE 2> /dev/null
|
||||
mkdir -p $PANDORA_BASE/var/log 2> /dev/null
|
||||
mkdir -p $PANDORA_BASE/$PANDORA_MAN/man1 2> /dev/null
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
then
|
||||
mkdir -p $PANDORA_BASE/usr/local/bin 2> /dev/null
|
||||
else
|
||||
mkdir -p $PANDORA_BASE/usr/bin 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p $PANDORA_BASE$PANDORA_HOME 2> /dev/null
|
||||
|
||||
|
@ -238,22 +238,22 @@ install () {
|
|||
echo "Copying Pandora FMS Agent plugins to $PANDORA_BASE$PANDORA_HOME/plugins..."
|
||||
cp -r plugins $PANDORA_BASE$PANDORA_HOME
|
||||
chmod -R 700 $PANDORA_BASE$PANDORA_HOME/plugins
|
||||
ln -s $PANDORA_BASE$PANDORA_HOME/plugins $PANDORA_BASE$PANDORA_CFG
|
||||
ln -s $PANDORA_BASE$PANDORA_HOME/plugins $PANDORA_BASE$PANDORA_CFG
|
||||
|
||||
echo "Copying Pandora FMS Agent collections to $PANDORA_BASE$PANDORA_HOME/collections..."
|
||||
cp -r collections $PANDORA_BASE$PANDORA_HOME
|
||||
chmod -R 700 $PANDORA_BASE$PANDORA_HOME/collections
|
||||
ln -s $PANDORA_BASE$PANDORA_HOME/collections $PANDORA_BASE$PANDORA_CFG
|
||||
ln -s $PANDORA_BASE$PANDORA_HOME/collections $PANDORA_BASE$PANDORA_CFG
|
||||
|
||||
echo "Copying tentacle client to $PANDORA_BASE$TENTACLE"
|
||||
cp tentacle_client $PANDORA_BASE$TENTACLE
|
||||
chmod 755 $PANDORA_BASE$TENTACLE
|
||||
|
||||
echo "Installing the Pandora Agent and Tentacle Client manuals"
|
||||
cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
|
||||
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz
|
||||
cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
|
||||
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz
|
||||
cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
|
||||
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz
|
||||
cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
|
||||
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz
|
||||
|
||||
echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
|
||||
chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME
|
||||
|
@ -261,72 +261,72 @@ install () {
|
|||
chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
then
|
||||
chown $PANDORA_USER:wheel $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
|
||||
chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP
|
||||
chmod -R 770 $PANDORA_BASE$PANDORA_TEMP
|
||||
chmod 775 $PANDORA_BASE$PANDORA_TEMP
|
||||
chown $PANDORA_USER:wheel $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
|
||||
chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP
|
||||
chmod -R 770 $PANDORA_BASE$PANDORA_TEMP
|
||||
chmod 775 $PANDORA_BASE$PANDORA_TEMP
|
||||
else
|
||||
chown root:root $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
|
||||
chown root:root $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
|
||||
fi
|
||||
|
||||
# Alter dynamically the daemon launcher and setup the new path
|
||||
# if PANDORA_BASE is customized.
|
||||
# Alter dynamically the daemon launcher and setup the new path
|
||||
# if PANDORA_BASE is customized.
|
||||
|
||||
if [ ! -z "$PANDORA_BASE" ]
|
||||
then
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
if [ ! -z "$PANDORA_BASE" ]
|
||||
then
|
||||
DAEMON_SCRIPT=FreeBSD/pandora_agent
|
||||
DAEMON_TEMP=pandora_agent_daemon_temp
|
||||
else
|
||||
DAEMON_SCRIPT=pandora_agent_daemon
|
||||
DAEMON_TEMP=pandora_agent_daemon_temp
|
||||
fi
|
||||
|
||||
AGENT_CFG=$OS_NAME/pandora_agent.conf
|
||||
AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
then
|
||||
DAEMON_SCRIPT=FreeBSD/pandora_agent
|
||||
DAEMON_TEMP=pandora_agent_daemon_temp
|
||||
else
|
||||
DAEMON_SCRIPT=pandora_agent_daemon
|
||||
DAEMON_TEMP=pandora_agent_daemon_temp
|
||||
fi
|
||||
|
||||
echo $PANDORA_BASE > PANDORA_BASE.temp
|
||||
sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2
|
||||
AGENT_CFG=$OS_NAME/pandora_agent.conf
|
||||
AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp
|
||||
|
||||
PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2`
|
||||
rm PANDORA_BASE.temp PANDORA_BASE.temp2
|
||||
echo $PANDORA_BASE > PANDORA_BASE.temp
|
||||
sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2
|
||||
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
then
|
||||
sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/local\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2`
|
||||
rm PANDORA_BASE.temp PANDORA_BASE.temp2
|
||||
|
||||
sed -e "s/^command\=[.]*/command\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
then
|
||||
sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/local\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
|
||||
sed -e 's/^command_args\=\"[.]*/command_args\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
sed -e "s/^command\=[.]*/command\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
|
||||
sed -e 's/^required_files\=\"[.]*/required_files\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
else
|
||||
sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
sed -e 's/^command_args\=\"[.]*/command_args\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
|
||||
sed -e "s/^PANDORA_PATH\=[.]*/PANDORA_PATH\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
sed -e 's/^required_files\=\"[.]*/required_files\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
else
|
||||
sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
|
||||
sed -e "s/^LOGFILE\=[.]*/LOGFILE\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
sed -e "s/^PANDORA_PATH\=[.]*/PANDORA_PATH\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
|
||||
sed -e "s/^DAEMON\=[.]*/DAEMON\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
sed -e "s/^LOGFILE\=[.]*/LOGFILE\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
|
||||
sed -e "s/^DAEMON\=[.]*/DAEMON\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
|
||||
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
||||
fi
|
||||
|
||||
sed -e "s/^temporal [.]*/temporal $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP
|
||||
mv $AGENT_CFG_TEMP $AGENT_CFG
|
||||
|
||||
sed -e "s/^logfile [.]*/logfile $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP
|
||||
mv $AGENT_CFG_TEMP $AGENT_CFG
|
||||
fi
|
||||
|
||||
sed -e "s/^temporal [.]*/temporal $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP
|
||||
mv $AGENT_CFG_TEMP $AGENT_CFG
|
||||
|
||||
sed -e "s/^logfile [.]*/logfile $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP
|
||||
mv $AGENT_CFG_TEMP $AGENT_CFG
|
||||
fi
|
||||
|
||||
echo "Copying default agent configuration to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf"
|
||||
echo "Copying default agent configuration to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf"
|
||||
|
||||
cp $OS_NAME/pandora_agent.conf $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
|
||||
chmod 600 $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
|
||||
|
@ -350,7 +350,7 @@ install () {
|
|||
|
||||
if [ $OS_NAME = "HP-UX" ]
|
||||
then
|
||||
PANDORA_STARTUP=/sbin/init.d/pandora_agent_daemon
|
||||
PANDORA_STARTUP=/sbin/init.d/pandora_agent_daemon
|
||||
cp pandora_agent_daemon $PANDORA_STARTUP
|
||||
ln -s /sbin/init.d/pandora_agent_daemon /sbin/rc3.d/S90pandora_agent_daemon 2> /dev/null
|
||||
ln -s /sbin/init.d/pandora_agent_daemon /sbin/rc2.d/S90pandora_agent_daemon 2> /dev/null
|
||||
|
@ -359,7 +359,7 @@ install () {
|
|||
|
||||
if [ $OS_NAME = "SunOS" ]
|
||||
then
|
||||
PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
|
||||
PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
|
||||
cp pandora_agent_daemon $PANDORA_STARTUP
|
||||
ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent_daemon 2> /dev/null
|
||||
echo "Pandora FMS agent has been included in /etc/rc2.d/S90pandora_agent_daemon"
|
||||
|
@ -367,7 +367,7 @@ install () {
|
|||
|
||||
if [ $OS_NAME = "Linux" ]
|
||||
then
|
||||
PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
|
||||
PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
|
||||
cp pandora_agent_daemon $PANDORA_STARTUP
|
||||
if [ -d /etc/rc.d/ ]
|
||||
then
|
||||
|
@ -388,17 +388,17 @@ install () {
|
|||
fi
|
||||
|
||||
echo "Installing the Pandora Agent and Tentacle Client manuals"
|
||||
cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
|
||||
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz
|
||||
cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
|
||||
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz
|
||||
cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
|
||||
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz
|
||||
cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
|
||||
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz
|
||||
|
||||
echo "Done."
|
||||
echo " "
|
||||
echo "You have your startup script ready at $PANDORA_STARTUP"
|
||||
echo " "
|
||||
echo "Tentacle is the default transfer mode since 2.0 version."
|
||||
echo " "
|
||||
echo " "
|
||||
echo "If you want to use SSH, firstly you need to copy your public SSH keys "
|
||||
echo " ($HOME/.ssh/id_dsa) under /home/pandora/.ssh/authorized_keys "
|
||||
echo "on your Pandora FMS Server host"
|
||||
|
@ -407,10 +407,10 @@ install () {
|
|||
echo " "
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
then
|
||||
echo "Define 'pandora_agent_enable=\"YES\"' in /etc/rc.conf to enable the daemon."
|
||||
echo "Define 'pandora_agent_enable=\"YES\"' in /etc/rc.conf to enable the daemon."
|
||||
else
|
||||
echo "Check your startup configuration to be sure Pandora FMS Agent is ready "
|
||||
echo "to start automatically when system restarts":
|
||||
echo "Check your startup configuration to be sure Pandora FMS Agent is ready "
|
||||
echo "to start automatically when system restarts":
|
||||
fi
|
||||
|
||||
}
|
||||
|
@ -433,23 +433,23 @@ echo " "
|
|||
case "$MODE" in
|
||||
|
||||
'--force-install')
|
||||
FORCE=1
|
||||
install
|
||||
exit
|
||||
;;
|
||||
FORCE=1
|
||||
install
|
||||
exit
|
||||
;;
|
||||
|
||||
'--install')
|
||||
install
|
||||
exit
|
||||
;;
|
||||
install
|
||||
exit
|
||||
;;
|
||||
|
||||
'--uninstall')
|
||||
uninstall
|
||||
exit
|
||||
;;
|
||||
uninstall
|
||||
exit
|
||||
;;
|
||||
|
||||
*)
|
||||
help
|
||||
;;
|
||||
help
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#
|
||||
# Usage: pandora_exec <timeout in seconds> <command>
|
||||
##########################################################################
|
||||
# Copyright (c) 2008 Ramon Novoa, rnovoa@gmail.com
|
||||
# (c) 2008 Artica Soluciones Tecnologicas S.L
|
||||
# Copyright (c) 2008-2010 Ramon Novoa, rnovoa@gmail.com
|
||||
# (c) 2008-2010 Artica Soluciones Tecnologicas S.L
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -37,46 +37,46 @@ use Digest::MD5 qw(md5);
|
|||
# This small function return the current base path (where this tool is stored)
|
||||
|
||||
sub return_basepath () {
|
||||
return $FindBin::Bin;
|
||||
return $FindBin::Bin;
|
||||
}
|
||||
|
||||
# Function to compare two binary files. Return 0 if different 1 if equal, 2 error
|
||||
|
||||
sub compare_twofiles ($$) {
|
||||
|
||||
my $file1 = $_[0];
|
||||
my $file2 = $_[1];
|
||||
my $file1 = $_[0];
|
||||
my $file2 = $_[1];
|
||||
|
||||
my $size1 = -s $file1;
|
||||
my $size2 = -s $file2;
|
||||
my $size1 = -s $file1;
|
||||
my $size2 = -s $file2;
|
||||
|
||||
# Size matters;
|
||||
# Size matters;
|
||||
|
||||
if ((!defined($size1)) || (!defined($size2))){
|
||||
return 2;
|
||||
}
|
||||
if ((!defined($size1)) || (!defined($size2))){
|
||||
return 2;
|
||||
}
|
||||
|
||||
if ($size1 != $size2){
|
||||
return 0;
|
||||
}
|
||||
if ($size1 != $size2){
|
||||
return 0;
|
||||
}
|
||||
|
||||
open FILE1, $file1;
|
||||
binmode FILE1;
|
||||
my $data1 = <FILE1>;
|
||||
close FILE1;
|
||||
my $hash1 = md5($data1);
|
||||
open FILE1, $file1;
|
||||
binmode FILE1;
|
||||
my $data1 = <FILE1>;
|
||||
close FILE1;
|
||||
my $hash1 = md5($data1);
|
||||
|
||||
open FILE2, $file2;
|
||||
binmode FILE2;
|
||||
my $data2 = <FILE2>;
|
||||
close FILE2;
|
||||
my $hash2 = md5($data2);
|
||||
open FILE2, $file2;
|
||||
binmode FILE2;
|
||||
my $data2 = <FILE2>;
|
||||
close FILE2;
|
||||
my $hash2 = md5($data2);
|
||||
|
||||
if ($hash1 eq $hash2){
|
||||
return 1;
|
||||
}
|
||||
if ($hash1 eq $hash2){
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
@ -132,21 +132,21 @@ my $local_log = "/tmp/pandora_update.log";
|
|||
# [SETUP END]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if (compare_twofiles ($running_binary, $updated_binary) == 0 ){
|
||||
# Do the update
|
||||
# Do the update
|
||||
|
||||
# Create the temp file to "acknoledge" a update has been succeed
|
||||
open (FILE3,">$local_log");
|
||||
close (FILE3);
|
||||
# Create the temp file to "acknoledge" a update has been succeed
|
||||
open (FILE3,">$local_log");
|
||||
close (FILE3);
|
||||
|
||||
my $output = `$stop_pandora`;
|
||||
copy($updated_binary, $running_binary) or die "Problems updating binary from $updated_binary";
|
||||
$output = `$start_pandora`;
|
||||
my $output = `$stop_pandora`;
|
||||
copy($updated_binary, $running_binary) or die "Problems updating binary from $updated_binary";
|
||||
$output = `$start_pandora`;
|
||||
|
||||
} else {
|
||||
if (-e $local_log){
|
||||
print "Updated binary from $updated_binary\n";
|
||||
unlink $local_log;
|
||||
}
|
||||
if (-e $local_log){
|
||||
print "Updated binary from $updated_binary\n";
|
||||
unlink $local_log;
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
|
|
Loading…
Reference in New Issue