From 83368c071fdd0adcdfa446b8d95247f9f2c10d4e Mon Sep 17 00:00:00 2001 From: raulmateos Date: Mon, 15 Nov 2010 10:32:23 +0000 Subject: [PATCH] 2010-11-15 Raul Mateos * 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 --- pandora_agents/unix/ChangeLog | 5 + pandora_agents/unix/pandora_agent | 152 +++++++-------- pandora_agents/unix/pandora_agent.spec | 8 +- pandora_agents/unix/pandora_agent_daemon | 10 +- pandora_agents/unix/pandora_agent_installer | 198 ++++++++++---------- pandora_agents/unix/pandora_exec | 4 +- pandora_agents/unix/plugins/pandora_update | 74 ++++---- 7 files changed, 228 insertions(+), 223 deletions(-) diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index cec6f10bb9..53b58a62c3 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,8 @@ +2010-11-15 Raúl Mateos + + * pandora_agent*, pandora_exec, plugins/pandora_update: Small changes: + Year, version, spaces to tabs. + 2010-11-14 Sancho Lerena * plugins/pandora_update: Small tool (in perl), used also in windows diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 93d2e9926b..13f79a1db9 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -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 <&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 <&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 ('', )); - 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 .= " \n" . - " {'name'} . "]]>\n" . - " {'description'} . "]]>\n" . - " " . $module->{'type'} . "\n"; + $Xml .= " \n" . + " {'name'} . "]]>\n" . + " {'description'} . "]]>\n" . + " " . $module->{'type'} . "\n"; if ($module->{'interval'} > 1) { - $Xml .= " " . $module->{'interval'} . "\n"; + $Xml .= " " . $module->{'interval'} . "\n"; } # Data list if ($#data > 0) { - $Xml .= " \n"; + $Xml .= " \n"; foreach my $data_item (@data) { chomp ($data_item); - $Xml .= " \n"; + $Xml .= " \n"; } - $Xml .= " \n"; + $Xml .= " \n"; # Single data } else { chomp ($data[0]); - $Xml .= " \n"; + $Xml .= " \n"; } - $Xml .= " \n"; + $Xml .= " \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 = "\n" . - " # # 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 diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 101a120cfa..51a278b899 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -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 diff --git a/pandora_agents/unix/pandora_exec b/pandora_agents/unix/pandora_exec index 6cd4d48d01..6e84791640 100755 --- a/pandora_agents/unix/pandora_exec +++ b/pandora_agents/unix/pandora_exec @@ -8,8 +8,8 @@ # # Usage: pandora_exec ########################################################################## -# 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 diff --git a/pandora_agents/unix/plugins/pandora_update b/pandora_agents/unix/plugins/pandora_update index 8471758638..c259b10af2 100755 --- a/pandora_agents/unix/plugins/pandora_update +++ b/pandora_agents/unix/plugins/pandora_update @@ -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 = ; - close FILE1; - my $hash1 = md5($data1); + open FILE1, $file1; + binmode FILE1; + my $data1 = ; + close FILE1; + my $hash1 = md5($data1); - open FILE2, $file2; - binmode FILE2; - my $data2 = ; - close FILE2; - my $hash2 = md5($data2); + open FILE2, $file2; + binmode FILE2; + my $data2 = ; + 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;