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:
raulmateos 2010-11-15 10:32:23 +00:00
parent d0f9ef293c
commit c59bba0018
7 changed files with 228 additions and 223 deletions

View File

@ -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> 2010-11-14 Sancho Lerena <slerena@artica.es>
* plugins/pandora_update: Small tool (in perl), used also in windows * plugins/pandora_update: Small tool (in perl), used also in windows

View File

@ -48,7 +48,7 @@ eval {
require threads; require threads;
require threads::shared; require threads::shared;
require Thread::Semaphore; require Thread::Semaphore;
require IO::Socket; require IO::Socket;
}; };
if (!$@) { if (!$@) {
threads::shared::share (\$Xml); threads::shared::share (\$Xml);
@ -61,7 +61,7 @@ use constant AGENT_BUILD => '101103';
# Commands to retrieve total memory information in kB # Commands to retrieve total memory information in kB
use constant TOTALMEMORY_CMDS => { 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 ))\'', solaris => 'MEM=`prtconf | grep Memory | awk \'{print $3}\'` bash -c \'echo $(( 1024 * $MEM ))\'',
hpux => 'swapinfo -t | grep memory | awk \'{print $2}\'', hpux => 'swapinfo -t | grep memory | awk \'{print $2}\'',
freebsd => 'sysctl hw.physmem | awk \'{print $2 / 1024}\'' freebsd => 'sysctl hw.physmem | awk \'{print $2 / 1024}\''
@ -69,7 +69,7 @@ use constant TOTALMEMORY_CMDS => {
# Commands to retrieve free memory information in kB # Commands to retrieve free memory information in kB
use constant FREEMEMORY_CMDS => { 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 }\'', solaris => 'vmstat 1 2 | tail -1 | awk \'{ print $5 }\'',
hpux => 'swapinfo -t | grep memory | awk \'{print $4}\'', hpux => 'swapinfo -t | grep memory | awk \'{print $4}\'',
freebsd => 'vmstat -H 1 2 | tail -1 | awk \'{ print $5 }\'' freebsd => 'vmstat -H 1 2 | tail -1 | awk \'{ print $5 }\''
@ -150,9 +150,9 @@ my %Conf = (
'timezone_offset' => 0, 'timezone_offset' => 0,
'pandora_exec' => 'pandora_exec', 'pandora_exec' => 'pandora_exec',
'agent_threads' => 1, 'agent_threads' => 1,
'udp_server_port' => 41122, 'udp_server_port' => 41122,
'udp_server_auth_address' => '0.0.0.0', 'udp_server_auth_address' => '0.0.0.0',
'udp_server' => 0 'udp_server' => 0
); );
# Modules # Modules
@ -464,19 +464,19 @@ sub send_file {
} elsif ($Conf{'transfer_mode'} eq 'ssh') { } elsif ($Conf{'transfer_mode'} eq 'ssh') {
$output = `scp -P $Conf{'server_port'} $file pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >$DevNull`; $output = `scp -P $Conf{'server_port'} $file pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >$DevNull`;
} elsif ($Conf{'transfer_mode'} eq 'ftp') { } elsif ($Conf{'transfer_mode'} eq 'ftp') {
my $base = basename ($file); my $base = basename ($file);
my $dir = dirname ($file); my $dir = dirname ($file);
$output = `ftp -n $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1 $output = `ftp -n $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1
quote USER pandora quote USER pandora
quote PASS $Conf{'server_pwd'} quote PASS $Conf{'server_pwd'}
lcd "$dir" lcd "$dir"
cd "$Conf{'server_path'}" cd "$Conf{'server_path'}"
put "$base" put "$base"
quit quit
FEOF1` FEOF1`
} elsif ($Conf{'transfer_mode'} eq 'local') { } 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 # Get the errorlevel
@ -521,17 +521,17 @@ sub recv_file ($) {
} elsif ($Conf{'transfer_mode'} eq 'ssh') { } 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`; $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') { } elsif ($Conf{'transfer_mode'} eq 'ftp') {
my $base = basename ($file); my $base = basename ($file);
my $dir = dirname ($file); my $dir = dirname ($file);
$output = `ftp -n $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1 $output = `ftp -n $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1
quote USER pandora quote USER pandora
quote PASS $Conf{'server_pwd'} quote PASS $Conf{'server_pwd'}
lcd "$Conf{'temporal'}" lcd "$Conf{'temporal'}"
cd "$Conf{'server_path'}" cd "$Conf{'server_path'}"
get "$file" get "$file"
quit quit
FEOF1` FEOF1`
} elsif ($Conf{'transfer_mode'} eq 'local') { } elsif ($Conf{'transfer_mode'} eq 'local') {
$output = `cp $Conf{'server_path'}/$file $Conf{'temporal'} 2>&1 >$DevNull`; $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 # Calculate the configuration file MD5 digest
open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!."); 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>)); my $conf_md5 = md5 (join ('', <CONF_FILE>));
close (CONF_FILE); close (CONF_FILE);
# Get the remote MD5 file # Get the remote MD5 file
if (recv_file ($RemoteMD5File) != 0) { if (recv_file ($RemoteMD5File) != 0) {
open (MD5_FILE, "> $Conf{'temporal'}/$RemoteMD5File") || error ("Could not open file '$ConfDir/$RemoteMD5File' for writing: $!."); open (MD5_FILE, "> $Conf{'temporal'}/$RemoteMD5File") || error ("Could not open file '$ConfDir/$RemoteMD5File' for writing: $!.");
print MD5_FILE $conf_md5; print MD5_FILE $conf_md5;
@ -1201,29 +1201,29 @@ sub write_module_xml ($@) {
# Critical section # Critical section
$Sem->down () if (defined ($Sem)); $Sem->down () if (defined ($Sem));
$Xml .= " <module>\n" . $Xml .= " <module>\n" .
" <name><![CDATA[" . $module->{'name'} . "]]></name>\n" . " <name><![CDATA[" . $module->{'name'} . "]]></name>\n" .
" <description><![CDATA[" . $module->{'description'} . "]]></description>\n" . " <description><![CDATA[" . $module->{'description'} . "]]></description>\n" .
" <type>" . $module->{'type'} . "</type>\n"; " <type>" . $module->{'type'} . "</type>\n";
if ($module->{'interval'} > 1) { if ($module->{'interval'} > 1) {
$Xml .= " <module_interval>" . $module->{'interval'} . "</module_interval>\n"; $Xml .= " <module_interval>" . $module->{'interval'} . "</module_interval>\n";
} }
# Data list # Data list
if ($#data > 0) { if ($#data > 0) {
$Xml .= " <datalist>\n"; $Xml .= " <datalist>\n";
foreach my $data_item (@data) { foreach my $data_item (@data) {
chomp ($data_item); 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 # Single data
} else { } else {
chomp ($data[0]); 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)); $Sem->up () if (defined ($Sem));
} }
@ -1232,7 +1232,7 @@ sub write_module_xml ($@) {
# Receive a UDP server signal to restart agent # Receive a UDP server signal to restart agent
################################################################################ ################################################################################
sub udp_server_signal () { 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 ($$) { sub udp_server ($$) {
my $udp_port = shift; my $udp_port = shift;
my $udp_auth_address = shift; my $udp_auth_address = shift;
my $parent_pid = getppid(); my $parent_pid = getppid();
my($sock, $oldmsg, $newmsg, $hisaddr, $hishost, $MAXLEN); my($sock, $oldmsg, $newmsg, $hisaddr, $hishost, $MAXLEN);
$MAXLEN = 1024; $MAXLEN = 1024;
log_message ('udp server', 'Starting UDP server listening on '.$udp_auth_address.":".$udp_port); 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: $@"; $sock = IO::Socket::INET->new(LocalPort => $udp_port, Proto => 'udp') or die "socket: $@";
while ($sock->recv($newmsg, $MAXLEN)) { while ($sock->recv($newmsg, $MAXLEN)) {
my($port, $ipaddr) = sockaddr_in($sock->peername); my($port, $ipaddr) = sockaddr_in($sock->peername);
$hishost = gethostbyaddr($ipaddr, AF_INET); $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 (($udp_auth_address eq "0.0.0.0") || ($hishost eq $udp_auth_address)){
if ($newmsg =~ /REFRESH AGENT/){ if ($newmsg =~ /REFRESH AGENT/){
# Send signal to restart agent # Send signal to restart agent
kill 'SIGINT' , $parent_pid; kill 'SIGINT' , $parent_pid;
} }
} }
} }
} }
################################################################################ ################################################################################
@ -1324,22 +1324,22 @@ $ENV{'PATH'} .= ":$ConfDir/plugins";
# Start UDP server if configured # Start UDP server if configured
if ($Conf{'udp_server'} == 1){ if ($Conf{'udp_server'} == 1){
my $pid = fork(); my $pid = fork();
if ($pid == 0){ if ($pid == 0){
udp_server ($Conf{'udp_server_port'}, $Conf{'udp_server_auth_address'}); udp_server ($Conf{'udp_server_port'}, $Conf{'udp_server_auth_address'});
exit; exit;
} }
} }
# Loop # Loop
while (1) { while (1) {
# Ignore signals from UDP server while processing execution # Ignore signals from UDP server while processing execution
if ($Conf{'udp_server'} == 1){ if ($Conf{'udp_server'} == 1){
$SIG{'INT'} = 'DEFAULT'; $SIG{'INT'} = 'DEFAULT';
} }
# Check for a new configuration # Check for a new configuration
check_remote_config () unless ($Conf{'debug'} eq '1'); check_remote_config () unless ($Conf{'debug'} eq '1');
@ -1348,16 +1348,16 @@ while (1) {
check_collections () unless ($Conf{'debug'} eq '1'); check_collections () unless ($Conf{'debug'} eq '1');
$Xml = "<?xml version='1.0' encoding='" . $Conf{'encoding'} . "'?>\n" . $Xml = "<?xml version='1.0' encoding='" . $Conf{'encoding'} . "'?>\n" .
"<agent_data description='" . $Conf{'description'} ."' group='" . $Conf{'group'} . "<agent_data description='" . $Conf{'description'} ."' group='" . $Conf{'group'} .
"' os_name='$OS' os_version='$OS_VERSION' interval='" . $Conf{'interval'} . "' 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 ())) . "' 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_name='" . $Conf{'agent_name'} . "' timezone_offset='". $Conf{'timezone_offset'};
if (defined ($Conf{'parent_agent_name'})) { if (defined ($Conf{'parent_agent_name'})) {
$Xml .= "' parent_agent_name='" .$Conf{'parent_agent_name'}; $Xml .= "' parent_agent_name='" .$Conf{'parent_agent_name'};
} }
if (defined ($Conf{'longitude'}) && defined ($Conf{'latitude'})) { 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'})) { if (defined ($Conf{'altitude'})) {
$Xml .= "' altitude='" .$Conf{'altitude'}; $Xml .= "' altitude='" .$Conf{'altitude'};
} }
@ -1431,10 +1431,10 @@ while (1) {
# Cron mode # Cron mode
last if ($Conf{'cron_mode'} == 1); last if ($Conf{'cron_mode'} == 1);
# Enable signal capture to break the Sleep interval on UDP signal # Enable signal capture to break the Sleep interval on UDP signal
if ($Conf{'udp_server'} == 1){ if ($Conf{'udp_server'} == 1){
$SIG{'INT'} = \&udp_server_signal; $SIG{'INT'} = \&udp_server_signal;
} }
# Go to sleep # Go to sleep
# #

View File

@ -2,7 +2,7 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 3.2dev %define version 3.2
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}
Version: %{version} 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 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 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 fi
%clean %clean
@ -75,7 +75,7 @@ if [ ! -d /etc/pandora ] ; then
fi fi
if [ ! -f /usr/share/pandora_agent/pandora_agent.conf ] ; then 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 fi
if [ ! -f /etc/pandora/pandora_agent.conf ] ; then if [ ! -f /etc/pandora/pandora_agent.conf ] ; then
@ -99,7 +99,7 @@ chkconfig pandora_agent_daemon on
# Upgrading # Upgrading
if [ "$1" = "1" ]; then if [ "$1" = "1" ]; then
exit 0 exit 0
fi fi
chkconfig --del pandora_agent_daemon chkconfig --del pandora_agent_daemon

View File

@ -6,7 +6,7 @@
# (c) 2008-2010 Sancho Lerena <slerena@gmail.com> # (c) 2008-2010 Sancho Lerena <slerena@gmail.com>
# #
# Please see http://www.pandorafms.org # Please see http://www.pandorafms.org
# v3.1 Build 100515 # v3.2 Build 101115
# This code is licensed under GPL 2.0 license. # This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
@ -14,7 +14,7 @@
# Provides: pandora_agent # Provides: pandora_agent
# Required-Start: $network # Required-Start: $network
# Required-Stop: $network # Required-Stop: $network
# Default-Start: 2 3 5 # Default-Start: 2 3 5
# Default-Stop: 0 1 6 # Default-Stop: 0 1 6
# Short-Description: Startup script daemon for Pandora FMS agent # Short-Description: Startup script daemon for Pandora FMS agent
# Description: Startup script daemon for Pandora FMS agent (linux) # Description: Startup script daemon for Pandora FMS agent (linux)
@ -93,7 +93,7 @@ case "$1" in
exit 1 exit 1
else else
echo "Stopping Pandora Agent." echo "Stopping Pandora Agent."
kill -9 $PANDORA_PID > /dev/null 2>&1 kill -9 $PANDORA_PID > /dev/null 2>&1
fi fi
;; ;;
@ -115,7 +115,7 @@ case "$1" in
;; ;;
*) *)
echo "Uso: /etc/init.d/pandora_agent_daemon {start|stop|restart|status}" echo "Usage: /etc/init.d/pandora_agent_daemon {start|stop|restart|status}"
exit 1 exit 1
esac esac

View File

@ -9,8 +9,8 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION=3.1 PI_VERSION=3.2
PI_BUILD=100515 PI_BUILD=101115
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0
@ -81,15 +81,15 @@ help () {
uninstall () { uninstall () {
OS_NAME=`uname -s` OS_NAME=`uname -s`
if [ "$OS_NAME" = "FreeBSD" ] if [ "$OS_NAME" = "FreeBSD" ]
then then
PANDORA_HOME=/usr/local/share/pandora_agent PANDORA_HOME=/usr/local/share/pandora_agent
PANDORA_BIN=/usr/local/bin/pandora_agent PANDORA_BIN=/usr/local/bin/pandora_agent
PANDORA_EXEC_BIN=/usr/local/bin/pandora_exec PANDORA_EXEC_BIN=/usr/local/bin/pandora_exec
PANDORA_CFG=/usr/local/etc/pandora PANDORA_CFG=/usr/local/etc/pandora
TENTACLE=/usr/local/bin/tentacle_client TENTACLE=/usr/local/bin/tentacle_client
PANDORA_MAN=/usr/local/man PANDORA_MAN=/usr/local/man
fi fi
echo "Removing Pandora FMS Agent..." echo "Removing Pandora FMS Agent..."
rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null
@ -125,10 +125,10 @@ uninstall () {
rm -Rf $PANDORA_BASE/$PANDORA_CFG 2> /dev/null rm -Rf $PANDORA_BASE/$PANDORA_CFG 2> /dev/null
fi fi
if [ ! -z "$PANDORA_BASE" ] if [ ! -z "$PANDORA_BASE" ]
then then
echo "Please delete manually $PANDORA_BASE for complete uninstall" echo "Please delete manually $PANDORA_BASE for complete uninstall"
fi fi
echo " " echo " "
echo "Done" echo "Done"
@ -170,19 +170,19 @@ install () {
echo "Checking Pandora FMS Agent on $PANDORA_BASE$PANDORA_BIN...." echo "Checking Pandora FMS Agent on $PANDORA_BASE$PANDORA_BIN...."
fi fi
echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME" echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME"
if [ ! -z "$PANDORA_BASE" ] 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" ]
then then
mkdir -p $PANDORA_BASE/usr/local/bin 2> /dev/null mkdir -p $PANDORA_BASE 2> /dev/null
else mkdir -p $PANDORA_BASE/var/log 2> /dev/null
mkdir -p $PANDORA_BASE/usr/bin 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
fi
mkdir -p $PANDORA_BASE$PANDORA_HOME 2> /dev/null 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..." echo "Copying Pandora FMS Agent plugins to $PANDORA_BASE$PANDORA_HOME/plugins..."
cp -r plugins $PANDORA_BASE$PANDORA_HOME cp -r plugins $PANDORA_BASE$PANDORA_HOME
chmod -R 700 $PANDORA_BASE$PANDORA_HOME/plugins 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..." echo "Copying Pandora FMS Agent collections to $PANDORA_BASE$PANDORA_HOME/collections..."
cp -r collections $PANDORA_BASE$PANDORA_HOME cp -r collections $PANDORA_BASE$PANDORA_HOME
chmod -R 700 $PANDORA_BASE$PANDORA_HOME/collections 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" echo "Copying tentacle client to $PANDORA_BASE$TENTACLE"
cp tentacle_client $PANDORA_BASE$TENTACLE cp tentacle_client $PANDORA_BASE$TENTACLE
chmod 755 $PANDORA_BASE$TENTACLE chmod 755 $PANDORA_BASE$TENTACLE
echo "Installing the Pandora Agent and Tentacle Client manuals" echo "Installing the Pandora Agent and Tentacle Client manuals"
cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1 cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz
cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1 cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz
echo "Setting secure permissions and ownership for all Pandora FMS Agent files..." echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME
@ -261,72 +261,72 @@ install () {
chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
if [ "$OS_NAME" = "FreeBSD" ] if [ "$OS_NAME" = "FreeBSD" ]
then then
chown $PANDORA_USER:wheel $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG chown $PANDORA_USER:wheel $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP
chmod -R 770 $PANDORA_BASE$PANDORA_TEMP chmod -R 770 $PANDORA_BASE$PANDORA_TEMP
chmod 775 $PANDORA_BASE$PANDORA_TEMP chmod 775 $PANDORA_BASE$PANDORA_TEMP
else else
chown root:root $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG chown root:root $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
fi fi
# Alter dynamically the daemon launcher and setup the new path # Alter dynamically the daemon launcher and setup the new path
# if PANDORA_BASE is customized. # if PANDORA_BASE is customized.
if [ ! -z "$PANDORA_BASE" ] if [ ! -z "$PANDORA_BASE" ]
then
if [ "$OS_NAME" = "FreeBSD" ]
then then
DAEMON_SCRIPT=FreeBSD/pandora_agent if [ "$OS_NAME" = "FreeBSD" ]
DAEMON_TEMP=pandora_agent_daemon_temp then
else DAEMON_SCRIPT=FreeBSD/pandora_agent
DAEMON_SCRIPT=pandora_agent_daemon DAEMON_TEMP=pandora_agent_daemon_temp
DAEMON_TEMP=pandora_agent_daemon_temp else
fi DAEMON_SCRIPT=pandora_agent_daemon
DAEMON_TEMP=pandora_agent_daemon_temp
AGENT_CFG=$OS_NAME/pandora_agent.conf fi
AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp
echo $PANDORA_BASE > PANDORA_BASE.temp AGENT_CFG=$OS_NAME/pandora_agent.conf
sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2 AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp
PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2` echo $PANDORA_BASE > PANDORA_BASE.temp
rm PANDORA_BASE.temp PANDORA_BASE.temp2 sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2
if [ "$OS_NAME" = "FreeBSD" ] PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2`
then rm PANDORA_BASE.temp PANDORA_BASE.temp2
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\=[.]*/command\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP if [ "$OS_NAME" = "FreeBSD" ]
mv $DAEMON_TEMP $DAEMON_SCRIPT 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 sed -e "s/^command\=[.]*/command\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
mv $DAEMON_TEMP $DAEMON_SCRIPT mv $DAEMON_TEMP $DAEMON_SCRIPT
sed -e 's/^required_files\=\"[.]*/required_files\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP sed -e 's/^command_args\=\"[.]*/command_args\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP
mv $DAEMON_TEMP $DAEMON_SCRIPT 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/^PANDORA_PATH\=[.]*/PANDORA_PATH\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP sed -e 's/^required_files\=\"[.]*/required_files\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP
mv $DAEMON_TEMP $DAEMON_SCRIPT 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 sed -e "s/^PANDORA_PATH\=[.]*/PANDORA_PATH\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
mv $DAEMON_TEMP $DAEMON_SCRIPT mv $DAEMON_TEMP $DAEMON_SCRIPT
sed -e "s/^DAEMON\=[.]*/DAEMON\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP sed -e "s/^LOGFILE\=[.]*/LOGFILE\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
mv $DAEMON_TEMP $DAEMON_SCRIPT 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 fi
sed -e "s/^temporal [.]*/temporal $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP echo "Copying default agent configuration to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf"
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"
cp $OS_NAME/pandora_agent.conf $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 chmod 600 $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
@ -350,7 +350,7 @@ install () {
if [ $OS_NAME = "HP-UX" ] if [ $OS_NAME = "HP-UX" ]
then then
PANDORA_STARTUP=/sbin/init.d/pandora_agent_daemon PANDORA_STARTUP=/sbin/init.d/pandora_agent_daemon
cp pandora_agent_daemon $PANDORA_STARTUP 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/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 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" ] if [ $OS_NAME = "SunOS" ]
then then
PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
cp pandora_agent_daemon $PANDORA_STARTUP cp pandora_agent_daemon $PANDORA_STARTUP
ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent_daemon 2> /dev/null 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" echo "Pandora FMS agent has been included in /etc/rc2.d/S90pandora_agent_daemon"
@ -367,7 +367,7 @@ install () {
if [ $OS_NAME = "Linux" ] if [ $OS_NAME = "Linux" ]
then then
PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
cp pandora_agent_daemon $PANDORA_STARTUP cp pandora_agent_daemon $PANDORA_STARTUP
if [ -d /etc/rc.d/ ] if [ -d /etc/rc.d/ ]
then then
@ -388,17 +388,17 @@ install () {
fi fi
echo "Installing the Pandora Agent and Tentacle Client manuals" echo "Installing the Pandora Agent and Tentacle Client manuals"
cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1 cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz
cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1 cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz
echo "Done." echo "Done."
echo " " echo " "
echo "You have your startup script ready at $PANDORA_STARTUP" echo "You have your startup script ready at $PANDORA_STARTUP"
echo " " echo " "
echo "Tentacle is the default transfer mode since 2.0 version." 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 "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 " ($HOME/.ssh/id_dsa) under /home/pandora/.ssh/authorized_keys "
echo "on your Pandora FMS Server host" echo "on your Pandora FMS Server host"
@ -407,10 +407,10 @@ install () {
echo " " echo " "
if [ "$OS_NAME" = "FreeBSD" ] if [ "$OS_NAME" = "FreeBSD" ]
then 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 else
echo "Check your startup configuration to be sure Pandora FMS Agent is ready " echo "Check your startup configuration to be sure Pandora FMS Agent is ready "
echo "to start automatically when system restarts": echo "to start automatically when system restarts":
fi fi
} }
@ -433,23 +433,23 @@ echo " "
case "$MODE" in case "$MODE" in
'--force-install') '--force-install')
FORCE=1 FORCE=1
install install
exit exit
;; ;;
'--install') '--install')
install install
exit exit
;; ;;
'--uninstall') '--uninstall')
uninstall uninstall
exit exit
;; ;;
*) *)
help help
;; ;;
esac esac

View File

@ -8,8 +8,8 @@
# #
# Usage: pandora_exec <timeout in seconds> <command> # Usage: pandora_exec <timeout in seconds> <command>
########################################################################## ##########################################################################
# Copyright (c) 2008 Ramon Novoa, rnovoa@gmail.com # Copyright (c) 2008-2010 Ramon Novoa, rnovoa@gmail.com
# (c) 2008 Artica Soluciones Tecnologicas S.L # (c) 2008-2010 Artica Soluciones Tecnologicas S.L
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License

View File

@ -37,46 +37,46 @@ use Digest::MD5 qw(md5);
# This small function return the current base path (where this tool is stored) # This small function return the current base path (where this tool is stored)
sub return_basepath () { sub return_basepath () {
return $FindBin::Bin; return $FindBin::Bin;
} }
# Function to compare two binary files. Return 0 if different 1 if equal, 2 error # Function to compare two binary files. Return 0 if different 1 if equal, 2 error
sub compare_twofiles ($$) { sub compare_twofiles ($$) {
my $file1 = $_[0]; my $file1 = $_[0];
my $file2 = $_[1]; my $file2 = $_[1];
my $size1 = -s $file1; my $size1 = -s $file1;
my $size2 = -s $file2; my $size2 = -s $file2;
# Size matters; # Size matters;
if ((!defined($size1)) || (!defined($size2))){ if ((!defined($size1)) || (!defined($size2))){
return 2; return 2;
} }
if ($size1 != $size2){ if ($size1 != $size2){
return 0; return 0;
} }
open FILE1, $file1; open FILE1, $file1;
binmode FILE1; binmode FILE1;
my $data1 = <FILE1>; my $data1 = <FILE1>;
close FILE1; close FILE1;
my $hash1 = md5($data1); my $hash1 = md5($data1);
open FILE2, $file2; open FILE2, $file2;
binmode FILE2; binmode FILE2;
my $data2 = <FILE2>; my $data2 = <FILE2>;
close FILE2; close FILE2;
my $hash2 = md5($data2); my $hash2 = md5($data2);
if ($hash1 eq $hash2){ if ($hash1 eq $hash2){
return 1; return 1;
} }
return 0; return 0;
} }
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@ -132,21 +132,21 @@ my $local_log = "/tmp/pandora_update.log";
# [SETUP END]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # [SETUP END]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (compare_twofiles ($running_binary, $updated_binary) == 0 ){ 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 # Create the temp file to "acknoledge" a update has been succeed
open (FILE3,">$local_log"); open (FILE3,">$local_log");
close (FILE3); close (FILE3);
my $output = `$stop_pandora`; my $output = `$stop_pandora`;
copy($updated_binary, $running_binary) or die "Problems updating binary from $updated_binary"; copy($updated_binary, $running_binary) or die "Problems updating binary from $updated_binary";
$output = `$start_pandora`; $output = `$start_pandora`;
} else { } else {
if (-e $local_log){ if (-e $local_log){
print "Updated binary from $updated_binary\n"; print "Updated binary from $updated_binary\n";
unlink $local_log; unlink $local_log;
} }
} }
exit; exit;