2011-12-07 KIKUCHI Koichiro <koichiro@rworks.jp>

* pandora_agent_installer: Removed duplicated lines and spaces to
	  tabs.  Also removed lines that set group to wheel (gid of wheel is 0).
	* plugins/files_indir: Added support for FreeBSD.
	* plugins/pandora_update: Fixed $conf_path for FreeBSD and spaces
	  to tabs.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5237 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
koichirok 2011-12-07 10:07:43 +00:00
parent 916127733e
commit 8d487fd13e
4 changed files with 94 additions and 108 deletions

View File

@ -1,3 +1,11 @@
2011-12-07 KIKUCHI Koichiro <koichiro@rworks.jp>
* pandora_agent_installer: Removed duplicated lines and spaces to
tabs. Also removed lines that set group to wheel (gid of wheel is 0).
* plugins/files_indir: Added support for FreeBSD.
* plugins/pandora_update: Fixed $conf_path for FreeBSD and spaces
to tabs.
2011-11-15 Ramon Novoa <rnovoa@artica.es> 2011-11-15 Ramon Novoa <rnovoa@artica.es>
* pandora_agent: Re-wrote broker agent code (was not working properly). * pandora_agent: Re-wrote broker agent code (was not working properly).

View File

@ -171,7 +171,7 @@ install () {
echo "Detecting Unix distribution: $OS_NAME version $OS_VERSION" echo "Detecting Unix distribution: $OS_NAME version $OS_VERSION"
if [ -f $PANDORA_BASE$PANDORA_HOME ] && [ "$FORCE" = "0" ] if [ -f $PANDORA_BASE$PANDORA_HOME ] && [ "$FORCE" = "0" ]
then then
echo "Seems that default dir already exists. Please use --force to" echo "Seems that default dir already exists. Please use --force-install to"
echo "force installer to install on $PANDORA_BASE$PANDORA_HOME" echo "force installer to install on $PANDORA_BASE$PANDORA_HOME"
exit exit
else else
@ -180,7 +180,7 @@ install () {
if [ -f $PANDORA_BASE$PANDORA_BIN ] && [ "$FORCE" = "0" ] if [ -f $PANDORA_BASE$PANDORA_BIN ] && [ "$FORCE" = "0" ]
then then
echo "Seems that $PANDORA_BASE$PANDORA_BIN already exists. Please use --force to" echo "Seems that $PANDORA_BASE$PANDORA_BIN already exists. Please use --force-install to"
echo "force installer to reinstall overwriting it" echo "force installer to reinstall overwriting it"
echo " " echo " "
exit exit
@ -188,78 +188,78 @@ install () {
echo "Checking Pandora FMS Agent on $PANDORA_BASE$PANDORA_BIN...." echo "Checking Pandora FMS Agent on $PANDORA_BASE$PANDORA_BIN...."
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
AGENT_CFG=$OS_NAME/pandora_agent.conf
AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp
echo $PANDORA_BASE > PANDORA_BASE.temp echo $PANDORA_BASE > PANDORA_BASE.temp
sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2 sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2
PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2` PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2`
rm PANDORA_BASE.temp PANDORA_BASE.temp2 rm PANDORA_BASE.temp PANDORA_BASE.temp2
if [ "$OS_NAME" = "FreeBSD" ] if [ "$OS_NAME" = "FreeBSD" ]
then then
sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/local\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/local\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
mv $DAEMON_TEMP $DAEMON_SCRIPT mv $DAEMON_TEMP $DAEMON_SCRIPT
sed -e "s/^command\=[.]*/command\=$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/^command_args\=\"[.]*/command_args\=\"$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
sed -e 's/^required_files\=\"[.]*/required_files\=\"$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 else
sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
mv $DAEMON_TEMP $DAEMON_SCRIPT mv $DAEMON_TEMP $DAEMON_SCRIPT
sed -e "s/^PANDORA_PATH\=[.]*/PANDORA_PATH\=$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/^LOGFILE\=[.]*/LOGFILE\=$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 sed -e "s/^DAEMON\=[.]*/DAEMON\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
mv $DAEMON_TEMP $DAEMON_SCRIPT mv $DAEMON_TEMP $DAEMON_SCRIPT
sed -e "s/^PANDORA_USER\=.*/PANDORA_USER\=$PANDORA_USER/g" $DAEMON_SCRIPT > $DAEMON_TEMP sed -e "s/^PANDORA_USER\=.*/PANDORA_USER\=$PANDORA_USER/g" $DAEMON_SCRIPT > $DAEMON_TEMP
mv $DAEMON_TEMP $DAEMON_SCRIPT 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
echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME"
sed -e "s/^temporal [.]*/temporal $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP if [ ! -z "$PANDORA_BASE" ]
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 "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" ]
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
@ -296,14 +296,8 @@ install () {
chmod 755 $PANDORA_BASE$PANDORA_BIN chmod 755 $PANDORA_BASE$PANDORA_BIN
cp pandora_agent_exec $PANDORA_BASE$PANDORA_EXEC_BIN cp pandora_agent_exec $PANDORA_BASE$PANDORA_EXEC_BIN
chmod 755 $PANDORA_BASE$PANDORA_EXEC_BIN chmod 755 $PANDORA_BASE$PANDORA_EXEC_BIN
if [ "$OS_NAME" = "FreeBSD" ] chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_BIN
then chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_EXEC_BIN
chown $PANDORA_USER:wheel $PANDORA_BASE$PANDORA_BIN
chown $PANDORA_USER:wheel $PANDORA_BASE$PANDORA_EXEC_BIN
else
chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_BIN
chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_EXEC_BIN
fi
echo "Copying Pandora FMS Agent configuration file to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf..." echo "Copying Pandora FMS Agent configuration file to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf..."
if [ -f $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf ] if [ -f $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf ]
@ -325,23 +319,12 @@ install () {
echo "Copying tentacle server to $PANDORA_BASE$TENTACLE_SERVER" echo "Copying tentacle server to $PANDORA_BASE$TENTACLE_SERVER"
cp tentacle_server $PANDORA_BASE$TENTACLE_SERVER cp tentacle_server $PANDORA_BASE$TENTACLE_SERVER
chmod 755 $PANDORA_BASE$TENTACLE_SERVER chmod 755 $PANDORA_BASE$TENTACLE_SERVER
if [ "$OS_NAME" = "FreeBSD" ] chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE_SERVER
then
chown $PANDORA_USER:wheel $PANDORA_BASE$TENTACLE_SERVER
else
chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE_SERVER
fi
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
if [ "$OS_NAME" = "FreeBSD" ] chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE
then
chown $PANDORA_USER:wheel $PANDORA_BASE$TENTACLE
else
chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE
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
@ -353,17 +336,15 @@ install () {
chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME
chmod -R 700 $PANDORA_BASE$PANDORA_TEMP/data_out chmod -R 700 $PANDORA_BASE$PANDORA_TEMP/data_out
chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
chown $PANDORA_USER:0 $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: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
chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
fi 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 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
@ -432,12 +413,6 @@ install () {
chown root:wheel $PANDORA_STARTUP chown root:wheel $PANDORA_STARTUP
fi 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
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"

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# Syntax: # Syntax:
# #
@ -13,10 +13,14 @@ then
fi fi
DIRE=$1 DIRE=$1
DIRETMP=`echo $DIRE | md5sum | awk '{ print $1 }'` if [ `uname -s` = "FreeBSD" ];then
DIRETMP=`echo $DIRE | /sbin/md5`;
else
DIRETMP=`echo $DIRE | md5sum | awk '{ print $1 }'`
fi
DIRETMP=/tmp/$DIRETMP DIRETMP=/tmp/$DIRETMP
CURRENT=`ls -la ${DIRE} | wc -l` CURRENT=`ls -la ${DIRE} | wc -l | tr -d ' '`
if [ -e $DIRETMP ] if [ -e $DIRETMP ]
then then

View File

@ -88,7 +88,7 @@ sub get_agent_pid ($$) {
my $app_path = shift; my $app_path = shift;
$ENV{'COLUMNS'}=400; $ENV{'COLUMNS'}=400;
my $os_name=`uname -s`; my $os_name=`uname -s`;
my $pid = ""; my $pid = "";
my $cmd = ""; my $cmd = "";
@ -106,9 +106,9 @@ sub get_agent_pid ($$) {
if ( $zone =~ /global/) { if ( $zone =~ /global/) {
$cmd ="ps -f -z global | grep \"$truncated_daemon\" | grep -v grep | head -1 | awk '{ print \$2 }'"; $cmd ="ps -f -z global | grep \"$truncated_daemon\" | grep -v grep | head -1 | awk '{ print \$2 }'";
} else { } else {
$cmd ="ps -Af | grep \"$truncated_daemon\" | grep -v grep | head -1 | awk '{ print \$2 }'"; $cmd ="ps -Af | grep \"$truncated_daemon\" | grep -v grep | head -1 | awk '{ print \$2 }'";
} }
} else { } else {
$cmd ="ps -Af | grep \"$daemon $app_path\" | grep -v grep | head -1 | awk '{ print \$2 }'"; $cmd ="ps -Af | grep \"$daemon $app_path\" | grep -v grep | head -1 | awk '{ print \$2 }'";
} }
@ -145,18 +145,17 @@ if (defined($ARGV[1])) {
# Location of binaries # Location of binaries
# Unix # Unix
my $running_binary; my ($running_binary, $updated_binary, $conf_path);
my $updated_binary;
if ($^O eq 'freebsd') { if ($^O eq 'freebsd') {
$running_binary = $opt_dir."/usr/local/bin/pandora_agent"; $running_binary = $opt_dir."/usr/local/bin/pandora_agent";
$updated_binary = $opt_dir."/usr/local/etc/pandora/collections/$fc_path/pandora_agent"; $updated_binary = $opt_dir."/usr/local/etc/pandora/collections/$fc_path/pandora_agent";
$conf_path = $opt_dir."/usr/local/etc/pandora";
} else { } else {
$running_binary = $opt_dir."/usr/bin/pandora_agent"; $running_binary = $opt_dir."/usr/bin/pandora_agent";
$updated_binary = $opt_dir."/etc/pandora/collections/$fc_path/pandora_agent"; $updated_binary = $opt_dir."/etc/pandora/collections/$fc_path/pandora_agent";
$conf_path = $opt_dir."/etc/pandora";
} }
my $conf_path = $opt_dir."/etc/pandora";
# Windows # Windows
#my $running_binary = $base_path."/../PandoraAgent.exe"; #my $running_binary = $base_path."/../PandoraAgent.exe";
@ -169,11 +168,11 @@ my $conf_path = $opt_dir."/etc/pandora";
my $start_pandora; my $start_pandora;
my $stop_pandora; my $stop_pandora;
if ($^O eq 'freebsd') { if ($^O eq 'freebsd') {
$start_pandora = $opt_dir."/usr/local/etc/rc.d/pandora_agent start"; $start_pandora = $opt_dir."/usr/local/etc/rc.d/pandora_agent start";
$stop_pandora = $opt_dir."/usr/local/etc/rc.d/pandora_agent stop"; $stop_pandora = $opt_dir."/usr/local/etc/rc.d/pandora_agent stop";
} else { } else {
$start_pandora = $opt_dir."/etc/init.d/pandora_agent_daemon start"; $start_pandora = $opt_dir."/etc/init.d/pandora_agent_daemon start";
$stop_pandora = $opt_dir."/etc/init.d/pandora_agent_daemon stop"; $stop_pandora = $opt_dir."/etc/init.d/pandora_agent_daemon stop";
} }
# Windows stuff # Windows stuff