2008-01-08 Sancho Lerena <slerena@gmail.com>
* mac_osx/*: Added code for Mac OsX Agent contributed by Evi Vanoost. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@689 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
6586e86d59
commit
b16edfa6b9
|
@ -1,3 +1,7 @@
|
|||
2008-01-08 Sancho Lerena <slerena@gmail.com>
|
||||
|
||||
* mac_osx/*: Added code for Mac OsX Agent contributed by Evi Vanoost.
|
||||
|
||||
2008-01-02 Sancho lerena <slerena@gmail.com>
|
||||
|
||||
* openWRT/*: Added code for new ASYNC agent for OpenWRT/Arduino
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Description</key>
|
||||
<string>Pandora FMS Agent 1.3 (Mac)</string>
|
||||
<key>OrderPreference</key>
|
||||
<string>None</string>
|
||||
<key>Provides</key>
|
||||
<array>
|
||||
<string>PandoraFMS</string>
|
||||
</array>
|
||||
<key>Uses</key>
|
||||
<array>
|
||||
<string>Network</string>
|
||||
<string>Resolver</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,347 @@
|
|||
#!/bin/bash
|
||||
# **********************************************************************
|
||||
# Pandora FMS Generic Host Agent
|
||||
# GNU/Linux version 1.3
|
||||
# (c) 2003-2007 Sancho Lerena <slerena@gmail.com>
|
||||
# with the help of many people. Please see http://pandora.sourceforge.net
|
||||
# This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
AGENT_VERSION=1.3
|
||||
AGENT_BUILD=070725
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo " "
|
||||
echo "Fatal error: I need an argument to Pandora FMS Agent config directory"
|
||||
echo " "
|
||||
echo " example: pandora_agent /etc/pandora "
|
||||
echo " "
|
||||
exit -1
|
||||
else
|
||||
PANDORA_HOME=$1
|
||||
fi
|
||||
|
||||
if [ ! -f $PANDORA_HOME/pandora_agent.conf ]
|
||||
then
|
||||
echo " "
|
||||
echo "FATAL ERROR: Cannot load $PANDORA_HOME/pandora_agent.conf"
|
||||
echo " "
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# Init internal variables
|
||||
CONTADOR=0
|
||||
EXECUTE=1
|
||||
MODULE_END=0
|
||||
TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
|
||||
IFS=$'\n'
|
||||
|
||||
# Default values
|
||||
CHECKSUM_MODE=1
|
||||
DEBUG_MODE=0
|
||||
DELAYED_STARTUP=0
|
||||
SERVER_PORT=22
|
||||
PANDORA_NICE=0
|
||||
INTERVAL=300
|
||||
TRANSFER_MODE=ssh
|
||||
if [ -z "`echo $LANG | grep '\.'`" ]
|
||||
then
|
||||
ENCODING="iso-8859-1"
|
||||
else
|
||||
ENCODING=`echo $LANG | cut -f 2 -d "."`
|
||||
fi
|
||||
|
||||
NOMBRE_HOST=`/bin/hostname`
|
||||
OS_NAME=`uname -s`
|
||||
PANDORA_LOGFILE=/var/log/pandora/pandora_agent.log
|
||||
TEMP=/tmp
|
||||
|
||||
# Read config file
|
||||
for a in `cat $PANDORA_HOME/pandora_agent.conf | grep -v -e "^#" | grep -v -e "^module" `
|
||||
do
|
||||
a=`echo $a | tr -s " " " "`
|
||||
# Get general configuration parameters from config file
|
||||
if [ ! -z "`echo $a | grep -e '^logfile'`" ]
|
||||
then
|
||||
PANDORA_LOGFILE=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Pandora Logfile is $PANDORA_LOGFILE" >> $PANDORA_LOGFILE
|
||||
fi
|
||||
if [ ! -z "`echo $a | grep -e '^server_ip'`" ]
|
||||
then
|
||||
SERVER_IP=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Server IP Address is $SERVER_IP" >> $PANDORA_LOGFILE
|
||||
fi
|
||||
if [ ! -z "`echo $a | grep -e '^server_path'`" ]
|
||||
then
|
||||
SERVER_PATH=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Server Path is $SERVER_PATH" >> $PANDORA_LOGFILE
|
||||
fi
|
||||
if [ ! -z "`echo $a | grep -e '^temporal'`" ]
|
||||
then
|
||||
TEMP=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Temporal Path is $TEMP" >> $PANDORA_LOGFILE
|
||||
fi
|
||||
if [ ! -z "`echo $a | grep -e '^interval'`" ]
|
||||
then
|
||||
INTERVAL=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Interval is $INTERVAL seconds" >> $PANDORA_LOGFILE
|
||||
fi
|
||||
if [ ! -z "`echo $a | grep -e '^agent_name'`" ]
|
||||
then
|
||||
NOMBRE_HOST=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Agent name is $NOMBRE_HOST " >> $PANDORA_LOGFILE
|
||||
fi
|
||||
if [ ! -z "`echo $a | grep -e '^debug'`" ]
|
||||
then
|
||||
DEBUG_MODE=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Debug mode is $DEBUG_MODE " >> $PANDORA_LOGFILE
|
||||
fi
|
||||
if [ ! -z "`echo $a | grep -e '^checksum'`" ]
|
||||
then
|
||||
CHECKSUM_MODE=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Checksum is $CHECKSUM_MODE " >> $PANDORA_LOGFILE
|
||||
fi
|
||||
# Contribution of daggett
|
||||
if [ ! -z "`echo $a | grep -e '^server_port'`" ]
|
||||
then
|
||||
SERVER_PORT=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Server Port is $SERVER_PORT" >> $PANDORA_LOGFILE
|
||||
fi
|
||||
# Contribution of daggett
|
||||
if [ ! -z "`echo $a | grep -e '^encoding'`" ]
|
||||
then
|
||||
ENCODING=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Encoding is $ENCODING" >> $PANDORA_LOGFILE
|
||||
fi
|
||||
if [ ! -z "`echo $a | grep -e '^transfer_mode'`" ]
|
||||
then
|
||||
TRANSFER_MODE=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - Transfer Mode is $TRANSFER_MODE" >> $PANDORA_LOGFILE
|
||||
fi
|
||||
if [ ! -z "`echo $a | grep -e '^delayed_startup'`" ]
|
||||
then
|
||||
DELAYED_STARTUP=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - DELAYED_STARTUP is $DELAYED_STARTUP" >> $PANDORA_LOGFILE
|
||||
fi
|
||||
# CPU protection
|
||||
if [ ! -z "`echo $a | grep -e '^pandora_nice'`" ]
|
||||
then
|
||||
PANDORA_NICE=`echo $a | awk '{ print $2 }' `
|
||||
echo "$TIMESTAMP - [SETUP] - PandoraFMS Nice is $PANDORA_NICE" >> $PANDORA_LOGFILE
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Get kernel name (Darwin) and version (9.0.0) = Leopard
|
||||
OS_VERSION=`uname -r`
|
||||
LINUX_DISTRO=`uname -s`
|
||||
|
||||
# Script banner at start
|
||||
echo "Pandora FMS Agent $AGENT_VERSION (c) Sancho Lerena 2007"
|
||||
echo "This program is licensed under GPL2 Terms. http://pandora.sf.net"
|
||||
echo "Running in $NOMBRE_HOST at $TIMESTAMP"
|
||||
echo " "
|
||||
|
||||
|
||||
# Make some checks
|
||||
if [ "$TRANSFER_MODE" == "ftp" ]
|
||||
then
|
||||
if [ ! -f $HOME/.netrc ]
|
||||
then
|
||||
echo "(EE) Transfer mode is FTP but there is no usable .netrc file. Aborting."
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$DEBUG_MODE" == "1" ]
|
||||
then
|
||||
echo "(**) Warning: Running in DEBUG mode"
|
||||
fi
|
||||
|
||||
if [ $DELAYED_STARTUP != 0 ]
|
||||
then
|
||||
echo "Delayed startup in $DELAYED_STARTUP minutes "
|
||||
echo "Delayed startup in $DELAYED_STARTUP minutes" >> $PANDORA_LOGFILE.err
|
||||
echo " "
|
||||
sleep $(($DELAYED_STARTUP*60))
|
||||
fi
|
||||
|
||||
# Renice me
|
||||
renice $PANDORA_NICE $$
|
||||
|
||||
# MAIN Program loop begin
|
||||
|
||||
while [ "1" == "1" ]
|
||||
do
|
||||
# Deleted debug / error info on each run to avoid giant logs
|
||||
rm -Rf $PANDORA_LOGFILE.err 2> /dev/null
|
||||
|
||||
# Date and time, SERIAL is number of seconds since 1/1/1970, for every packet.
|
||||
TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
|
||||
SERIAL=`date +"%s"`
|
||||
|
||||
# File names
|
||||
DATA=$TEMP/$NOMBRE_HOST.$SERIAL.data
|
||||
DATA2=$TEMP/$NOMBRE_HOST.$SERIAL.data_temp
|
||||
CHECKSUM=$TEMP/$NOMBRE_HOST.$SERIAL.checksum
|
||||
PANDORA_FILES="$TEMP/$NOMBRE_HOST.$SERIAL.*"
|
||||
|
||||
# Makes data packet
|
||||
echo "<?xml version=\"1.0\" encoding=\"$ENCODING\"?> " > $DATA
|
||||
echo "<agent_data os_name='$OS_NAME' os_version='$OS_VERSION' interval='$INTERVAL' version='$AGENT_VERSION' timestamp='$TIMESTAMP' agent_name='$NOMBRE_HOST'>" >> $DATA
|
||||
|
||||
for a in `cat $PANDORA_HOME/pandora_agent.conf | grep -v -e "^#" | grep -e "^module" `
|
||||
do
|
||||
a=`echo $a | tr -s " " " "`
|
||||
|
||||
if [ ! -z "`echo $a | grep -e '^module_exec'`" ]
|
||||
then
|
||||
if [ $EXECUTE -eq 0 ]
|
||||
then
|
||||
execution=`echo $a | cut -c 13- `
|
||||
res=`eval $execution`
|
||||
if [ -z "$flux_string" ]
|
||||
then
|
||||
res=`eval expr $res 2> $PANDORA_LOGFILE.err`
|
||||
fi
|
||||
echo "<data><![CDATA[$res]]></data>" >> $DATA2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "`echo $a | grep -e '^module_name'`" ]
|
||||
then
|
||||
name=`echo $a | cut -c 13- `
|
||||
echo "<name><![CDATA[$name]]></name>" >> $DATA2
|
||||
fi
|
||||
|
||||
if [ ! -z "`echo $a | grep -e '^module_begin'`" ]
|
||||
then
|
||||
echo "<module>" >> $DATA2
|
||||
EXECUTE=0
|
||||
fi
|
||||
|
||||
if [ ! -z "`echo $a | grep -e '^module_max' `" ]
|
||||
then
|
||||
max=`echo $a | awk '{ print $2 }' `
|
||||
echo "<max><![CDATA[$max]]></max>" >> $DATA2
|
||||
fi
|
||||
|
||||
if [ ! -z "`echo $a | grep -e '^module_min'`" ]
|
||||
then
|
||||
min=`echo $a | awk '{ print $2 }' `
|
||||
echo "<min><![CDATA[$min]]></min>" >> $DATA2
|
||||
fi
|
||||
|
||||
if [ ! -z "`echo $a | grep -e '^module_description'`" ]
|
||||
then
|
||||
desc=`echo $a | cut -c 20- `
|
||||
echo "<description><![CDATA[$desc]]></description>" >> $DATA2
|
||||
fi
|
||||
|
||||
if [ ! -z "`echo $a | grep -e '^module_end'`" ]
|
||||
then
|
||||
echo "</module>" >> $DATA2
|
||||
MODULE_END=1
|
||||
else
|
||||
MODULE_END=0
|
||||
fi
|
||||
|
||||
if [ ! -z "`echo $a | grep -e '^module_type'`" ]
|
||||
then
|
||||
mtype=`echo $a | awk '{ print $2 }' `
|
||||
if [ ! -z "`echo $mtype | grep 'generic_data_string'`" ]
|
||||
then
|
||||
flux_string=1
|
||||
else
|
||||
flux_string=0
|
||||
unset flux_string
|
||||
fi
|
||||
echo "<type><![CDATA[$mtype]]></type>" >> $DATA2
|
||||
fi
|
||||
|
||||
if [ ! -z "`echo $a | grep '^module_interval'`" ]
|
||||
then
|
||||
# Determine if execution is to be done
|
||||
MODULEINTERVAL=`echo $a | awk '{ print $2 }'`
|
||||
EXECUTE=`expr \( $CONTADOR + 1 \) % $MODULEINTERVAL`
|
||||
fi
|
||||
|
||||
# If module ends, and execute for this module is enabled
|
||||
# then write
|
||||
|
||||
if [ $MODULE_END -eq 1 ]
|
||||
then
|
||||
if [ $EXECUTE -eq 0 ]
|
||||
then
|
||||
cat $DATA2 >> $DATA
|
||||
fi
|
||||
rm -Rf $DATA2 > /dev/null 2> /dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
# Count number of agent runs
|
||||
CONTADOR=`expr $CONTADOR + 1`
|
||||
# Keep a limit of 100 for overflow reasons
|
||||
if [ $CONTADOR -eq 100 ]
|
||||
then
|
||||
CONTADOR=0
|
||||
fi
|
||||
|
||||
# Call for user-defined script for data adquisition
|
||||
if [ -f "$PANDORA_HOME/pandora_user.conf" ]
|
||||
then
|
||||
/bin/bash $PANDORA_HOME/pandora_user.conf >> $DATA
|
||||
fi
|
||||
|
||||
# Checking MD5
|
||||
if [ "$CHECKSUM_MODE" == "1" ]
|
||||
then
|
||||
# Calculate Checksum and prepare MD5 file
|
||||
CHECKSUM_DATA=`md5sum $DATA`
|
||||
echo $CHECKSUM_DATA > $CHECKSUM
|
||||
else
|
||||
CHECKSUM_DATA="No valid checksum"
|
||||
echo $CHECKSUM_DATA > $CHECKSUM
|
||||
fi
|
||||
|
||||
# Finish data packet
|
||||
echo "</agent_data>" >> $DATA
|
||||
echo "" >> $DATA
|
||||
|
||||
# Replace & chars in XML (should not to be any) to avoid syntax problems
|
||||
sed "s/&/&/g" $DATA > $TEMP/finalxml.tmp
|
||||
rm -f $DATA
|
||||
mv $TEMP/finalxml.tmp $DATA
|
||||
|
||||
if [ "$DEBUG_MODE" == "1" ]
|
||||
then
|
||||
echo "$TIMESTAMP - Finish writing XML $DATA" >> $PANDORA_LOGFILE
|
||||
echo "(**) Data file is at $DATA - Exiting now"
|
||||
echo " "
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Send packets to server and delete it
|
||||
if [ "$TRANSFER_MODE" == "ssh" ]
|
||||
then
|
||||
scp -P $SERVER_PORT $PANDORA_FILES pandora@$SERVER_IP:$SERVER_PATH > /dev/null 2> $PANDORA_LOGFILE.err
|
||||
fi
|
||||
|
||||
if [ "$TRANSFER_MODE" == "ftp" ]
|
||||
then
|
||||
ftp $SERVER_IP > /dev/null 2> $PANDORA_LOGFILE.err
|
||||
fi
|
||||
|
||||
if [ "$TRANSFER_MODE" == "local" ]
|
||||
then
|
||||
cp $PANDORA_FILES $SERVER_PATH > /dev/null 2> $PANDORA_LOGFILE.err
|
||||
fi
|
||||
|
||||
# Delete data
|
||||
rm -f $PANDORA_FILES> /dev/null 2> $PANDORA_LOGFILE.err
|
||||
|
||||
# Go to bed :-)
|
||||
sleep $INTERVAL
|
||||
done
|
||||
# This runs forever!
|
|
@ -0,0 +1,155 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 1.2
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2007 Sancho Lerena and others.
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
||||
server_ip skull
|
||||
server_path /var/spool/pandora/data_in
|
||||
temporal /var/spool/pandora/data_out
|
||||
logfile /var/log/pandora/pandora_agent.log
|
||||
|
||||
# Interval in seconds, 300 by default
|
||||
interval 300
|
||||
|
||||
# Debug mode only generate XML, and stop after first execution,
|
||||
# and does not copy XML to server.
|
||||
debug 0
|
||||
|
||||
# By default is activated
|
||||
checksum 0
|
||||
|
||||
# By default, agent takes machine name
|
||||
#agent_name adama
|
||||
|
||||
# By default agent try to take default encoding defined in host.
|
||||
# encoding iso-8859-15
|
||||
|
||||
# By default is 22 (for ssh)
|
||||
#server_port 22
|
||||
|
||||
# ftp, ssh or local
|
||||
transfer_mode ssh
|
||||
|
||||
# delayed_startup defines number of MINUTES before start execution
|
||||
# for first time when startup Pandora Agent
|
||||
|
||||
#delayed_startup 90
|
||||
|
||||
#Pandora nice defines priority of execution. Less priority means more intensive execution
|
||||
#A recommended value is 10. 0 priority means no Pandora CPU protection enabled
|
||||
#pandora_nice 0
|
||||
|
||||
|
||||
# Module Definition
|
||||
# =================
|
||||
|
||||
# System information
|
||||
|
||||
module_begin
|
||||
module_name cpu_user
|
||||
module_type generic_data
|
||||
module_interval 1
|
||||
module_exec iostat -C | tail -1 | awk '{ print $10 }'
|
||||
module_max 100
|
||||
module_min 0
|
||||
module_descripcion User CPU Usage (%)
|
||||
module_end
|
||||
|
||||
module_begin
|
||||
module_name cpu_sys
|
||||
module_type generic_data
|
||||
module_exec iostat -C | tail -1 | awk '{ print $11 }'
|
||||
module_max 100
|
||||
module_min 0
|
||||
module_description System CPU Usage (%)
|
||||
module_end
|
||||
|
||||
module_begin
|
||||
module_name disk_root_free
|
||||
module_type generic_data
|
||||
module_exec df -kh / | tail -1 | awk '{ print 100-$5 }'
|
||||
module_max 100
|
||||
module_min 0
|
||||
module_description Free disk Percentage of root partition
|
||||
module_end
|
||||
|
||||
module_begin
|
||||
module_name memused
|
||||
module_type generic_data
|
||||
module_exec sysctl -n hw.physmem
|
||||
module_end
|
||||
|
||||
module_begin
|
||||
module_name memfree
|
||||
module_type generic_data
|
||||
module_exec echo `sysctl -n hw.memsize` - `sysctl -n hw.physmem` | bc
|
||||
module_end
|
||||
|
||||
module_begin
|
||||
module_name proctotal
|
||||
module_type generic_data
|
||||
module_exec ps -A | wc -l
|
||||
module_description Total Processes
|
||||
module_end
|
||||
|
||||
# Hardware information
|
||||
|
||||
module_begin
|
||||
module_name numprocs
|
||||
module_type generic_data
|
||||
module_exec system_profiler -detailLevel mini | grep -i "Number of CPUs:" | awk '{ print $4}'
|
||||
module_max 8
|
||||
module_min 0
|
||||
module_description Number of Processors
|
||||
module_end
|
||||
|
||||
module_begin
|
||||
module_name arch
|
||||
module_type generic_data_string
|
||||
module_exec arch
|
||||
module_description Architecture
|
||||
module_end
|
||||
|
||||
# Informational stuff
|
||||
|
||||
module_begin
|
||||
module_name last_syslog
|
||||
module_type generic_data_string
|
||||
module_exec tail -1 /var/log/system.log
|
||||
module_description Last line of syslog
|
||||
module_end
|
||||
|
||||
module_begin
|
||||
module_name last_login
|
||||
module_type generic_data_string
|
||||
module_exec last | head -1
|
||||
module_description Last connected to system
|
||||
module_end
|
||||
|
||||
|
||||
# Networking
|
||||
|
||||
module_begin
|
||||
module_name incoming_pkt
|
||||
module_type generic_data_inc
|
||||
module_exec netstat -as | grep "total packets received" | awk '{ print $1 }' | head -1
|
||||
module_description Incoming packets arriving to system
|
||||
module_end
|
||||
|
||||
module_begin
|
||||
module_name outbound_pkt
|
||||
module_type generic_data_inc
|
||||
module_exec netstat -as | grep "packets sent from this host" | awk '{ print $1 }' | head -1
|
||||
module_description Outbound Packets sent by system
|
||||
module_end
|
||||
|
||||
module_begin
|
||||
module_name conn_resets
|
||||
module_type generic_data_inc
|
||||
module_exec netstat -as | grep "bad reset" | awk '{ print $1 }'
|
||||
module_description Bad Resets
|
||||
module_end
|
|
@ -0,0 +1,70 @@
|
|||
#!/bin/bash
|
||||
# Init script for Pandora FMS agent
|
||||
# Generic GNU/Linux version
|
||||
# (c) Sancho Lerena, <slerena@gmail.com>
|
||||
# (c) Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||
# v1.3
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: pandora_agent
|
||||
# Required-Start: $network
|
||||
# Required-Stop: $network
|
||||
# Default-Start: S 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: start/stop pandora-agent daemon
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
|
||||
PANDORA_PATH=/etc/pandora
|
||||
DAEMON=/usr/bin/pandora_agent
|
||||
PIDFILE=/var/run/pandora_agent.pid
|
||||
LOGFILE=/var/log/pandora_agent.log
|
||||
|
||||
if [ ! -f $DAEMON ]
|
||||
then
|
||||
echo "Pandora FMS Agent not found at $DAEMON, please check setup"
|
||||
exit
|
||||
fi
|
||||
|
||||
. /etc/rc.common
|
||||
|
||||
StartService()
|
||||
{
|
||||
if [ -f $PIDFILE ]
|
||||
then
|
||||
PID_BA=`cat $PIDFILE`
|
||||
if [ ! -z "`ps -Af | awk '{ print $2 }' | grep $PID_BA`" ]
|
||||
then
|
||||
echo "Pandora FMS Agent is currently running on this machine with PID $PID_BA"
|
||||
echo "Cannot launch again. Aborting."
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
nohup $DAEMON $PANDORA_PATH 2> $LOGFILE & MYPID=$!
|
||||
echo $MYPID > $PIDFILE
|
||||
echo "Pandora FMS Agent is now running with PID $MYPID"
|
||||
}
|
||||
|
||||
StopService()
|
||||
{
|
||||
if [ -f $PIDFILE ]
|
||||
then
|
||||
echo "Stopping Pandora Agent."
|
||||
PID_2=`cat $PIDFILE`
|
||||
if [ ! -z "`ps -f -p $PID_2 | grep -v grep | grep 'pandora_agent'`" ]
|
||||
then
|
||||
kill -9 $PID_2
|
||||
fi
|
||||
rm -f $PIDFILE
|
||||
else
|
||||
echo "Pandora FMS Agent is not running, cannot stop it. Aborting now..."
|
||||
fi
|
||||
}
|
||||
|
||||
RestartService()
|
||||
{
|
||||
$0 stop
|
||||
$0 start
|
||||
}
|
||||
|
||||
RunService "$1"
|
|
@ -0,0 +1,159 @@
|
|||
#!/bin/bash
|
||||
# **********************************************************************
|
||||
# Pandora FMS Agent - Generic Host Agent Installer
|
||||
# Mac OS X version
|
||||
# (c) 2007 Sancho Lerena <slerena@gmail.com>
|
||||
# (c) 2007 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||
# Please see http://pandora.sourceforge.net
|
||||
# This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION=1.0
|
||||
PANDORA_BIN=/usr/bin/pandora_agent
|
||||
PANDORA_HOME=/usr/share/pandora_agent
|
||||
PANDORA_TEMP=/var/spool/pandora
|
||||
PANDORA_CFG=/etc/pandora
|
||||
PANDORA_LOG=/var/log/pandora/pandora_agent.log
|
||||
PANDORA_STARTUP_FOLDER=/Library/StartupItems/pandora_fms
|
||||
PANDORA_STARTUP=/Library/StartupItems/pandora_fms/pandora_fms
|
||||
PANDORA_HOME_DIR=/rcbiUsers/pandora
|
||||
PANDORA_SERVER=skull
|
||||
FORCE=0
|
||||
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
|
||||
|
||||
MODE=$1
|
||||
|
||||
if [ ! -f "pandora_agent" ]
|
||||
then
|
||||
echo " "
|
||||
echo "You need to place pandora_agent file on main distribution directory before install"
|
||||
echo " "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
uninstall () {
|
||||
echo "Removing Pandora FMS Agent..."
|
||||
rm -f $PANDORA_BIN
|
||||
rm -Rf $PANDORA_TEMP
|
||||
rm -Rf $PANDORA_CFG
|
||||
rm -Rf $PANDORA_HOME
|
||||
rm -Rf $PANDORA_LOG
|
||||
rm -Rf $PANDORA_STARTUP_FOLDER
|
||||
echo "Done"
|
||||
}
|
||||
|
||||
install () {
|
||||
if [ -f $PANDORA_HOME ] && [ "$FORCE" = "0" ]
|
||||
then
|
||||
echo "Seems that default dir already exists. Please use --force to"
|
||||
echo "force installer to install on $PANDORA_HOME"
|
||||
exit
|
||||
else
|
||||
echo "Checking default dir $PANDORA_HOME..."
|
||||
fi
|
||||
|
||||
if [ -f $PANDORA_BIN ] && [ "$FORCE" = "0" ]
|
||||
then
|
||||
echo "Seems that $PANDORA_BIN already exists. Please use --force to"
|
||||
echo "force installer to reinstall overwriting it"
|
||||
exit
|
||||
else
|
||||
echo "Checking Pandora FMS Agent on $PANDORA_BIN...."
|
||||
fi
|
||||
|
||||
# Create directories
|
||||
echo "Creating Pandora FMS Agent home directory at $PANDORA_HOME ..."
|
||||
|
||||
mkdir $PANDORA_STARTUP_FOLDER
|
||||
mkdir $PANDORA_HOME
|
||||
mkdir $PANDORA_TEMP
|
||||
mkdir $PANDORA_TEMP/data_out
|
||||
mkdir $PANDORA_CFG
|
||||
mkdir /var/log/pandora
|
||||
|
||||
# Create logfile
|
||||
if [ ! -z "`touch $PANDORA_LOG`" ]
|
||||
then
|
||||
echo "Seems to be a problem generating logfile ($PANDORA_LOG) please check it";
|
||||
else
|
||||
echo "Creating logfile at $PANDORA_LOG..."
|
||||
fi
|
||||
|
||||
echo "$LOG_TIMESTAMP Pandora FMS installer has created this file at startup" > $PANDORA_LOG
|
||||
|
||||
# Copying agent and securing it
|
||||
echo "Copying Pandora FMS Agent to $PANDORA_BIN..."
|
||||
cp pandora_agent $PANDORA_BIN
|
||||
chmod 700 $PANDORA_BIN
|
||||
|
||||
echo "Copying Pandora FMS Agent contrib dir to $PANDORA_HOME/..."
|
||||
cp pandora_agent_daemon $PANDORA_HOME
|
||||
|
||||
echo "Copying Pandora FMS Agent configuration file to $PANDORA_HOME/pandora_agent.conf..."
|
||||
cp pandora_agent.conf $PANDORA_HOME
|
||||
chmod 600 $PANDORA_HOME/pandora_agent.conf
|
||||
|
||||
echo "Copying Pandora FMS Agent user configuration file to $PANDORA_HOME/pandora_user.conf..."
|
||||
cp pandora_user.conf $PANDORA_HOME
|
||||
chmod 700 $PANDORA_HOME/pandora_user.conf
|
||||
|
||||
echo "Linking Pandora FMS Agent configuration to $PANDORA_CFG/pandora_agent.conf..."
|
||||
ln -s $PANDORA_HOME/pandora_agent.conf $PANDORA_CFG
|
||||
|
||||
echo "Linking Pandora FMS Agent user configuration to $PANDORA_CFG/pandora_user.conf..."
|
||||
ln -s $PANDORA_HOME/pandora_user.conf $PANDORA_CFG
|
||||
|
||||
echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
|
||||
chown -R root $PANDORA_HOME
|
||||
chmod -R 600 $PANDORA_TEMP/data_out
|
||||
chmod 640 $PANDORA_LOG
|
||||
chgrp 3 $PANDORA_LOG
|
||||
echo "Copying start-up daemon script at $PANDORA_STARTUP";
|
||||
cp pandora_agent_daemon $PANDORA_STARTUP
|
||||
cp StartupParameters.plist $PANDORA_STARTUP
|
||||
chown -R root $PANDORA_BIN
|
||||
echo "Done."
|
||||
echo " "
|
||||
echo "You have your startup script ready at $PANDORA_STARTUP"
|
||||
echo "First you need to copy your public SSH keys ($HOME/.ssh/id_dsa)"
|
||||
echo "under /home/pandora/.ssh/authorized_keys on your Pandora FMS Server host"
|
||||
echo "You also need to setup your $PANDORA_CFG/pandora_agent.conf config file"
|
||||
echo " "
|
||||
|
||||
}
|
||||
|
||||
help () {
|
||||
echo " --force-install To force installation if already installed on system "
|
||||
echo " --install To install Pandora FMS Agent on this system"
|
||||
echo " --uninstall To uninstall and remove Pandora FMS Agent on this System"
|
||||
echo " "
|
||||
}
|
||||
|
||||
# Script banner at start
|
||||
echo " "
|
||||
echo "Pandora FMS Agent Installer $PI_VERSION (c) 2007 Sancho Lerena"
|
||||
echo "This program is licensed under GPL2 Terms. http://pandora.sourceforge.net"
|
||||
echo " "
|
||||
|
||||
case "$MODE" in
|
||||
|
||||
'--force-install')
|
||||
FORCE=1
|
||||
install
|
||||
exit
|
||||
;;
|
||||
|
||||
'--install')
|
||||
install
|
||||
exit
|
||||
;;
|
||||
|
||||
'--uninstall')
|
||||
uninstall
|
||||
exit
|
||||
;;
|
||||
|
||||
*)
|
||||
help
|
||||
esac
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
# Pandora User-Defined adquisition script
|
||||
# This code is under GPL licence
|
||||
# This is the default user script file
|
||||
# If you're using this is because default config doest fit all your needs
|
||||
# You can use the following variables
|
||||
#
|
||||
# All STDOUT output will be written in final XML file sent to Pandora Server.
|
||||
#
|
||||
# Please refer documentatation for more example and a more depth usage instructions
|
||||
#
|
||||
|
||||
# ================================
|
||||
# Temperature monitoring Mac OS X
|
||||
# ===============================
|
||||
|
||||
echo `ioreg -n IOHWSensor | awk '/location/ || /current-value/ || /"type"/' | sed -e 's/\n//' -e 's/[^"]*"//' -e 's/" =//' -e 's/"//g' | awk '{ d=($2/65536); if ($1=="current-value") print "<module><data>" substr(d,1,7) "</data>"; if ($1=="location") print "<name>" $2 " " $3 " " $4 " " $5 "</name><type>generic_data</type></module>";}'`
|
||||
|
||||
# ================================
|
||||
# Check for WEBPage content change
|
||||
# ================================
|
||||
|
||||
#MYMD5=`echo -e "GET / HTTP/1.0\n\n\n" | nc -w 30 www.artica.es 80 | grep -v "Date:" | md5sum | awk '{ print $1 }'`
|
||||
#VALIDMD5=e85c0b9018a22c1086c8e0179cd224b1
|
||||
#if [ "$MYMD5" != "$VALIDMD5" ]
|
||||
#then
|
||||
# MD5SUM=0
|
||||
#else
|
||||
# MD5SUM=1
|
||||
#fi
|
||||
#echo "<module>"
|
||||
#echo "<name>www.artica.es_WEBContenct</name>"
|
||||
#echo "<type>generic_proc</type>"
|
||||
#echo "<data>$MD5SUM</data>"
|
||||
#echo "</module>"
|
||||
|
||||
# MODULE END ========================
|
||||
|
||||
# ================================
|
||||
# Check for DNS Entry change
|
||||
# ================================
|
||||
|
||||
#HOSTNAME=arcadia.genterara.com
|
||||
#MAXHOPS=1
|
||||
#MAXHOPS2=`expr $MAXHOPS + 1`
|
||||
#SALIDA=`traceroute -n $HOSTNAME -w 5 -m $MAXHOPS2 2> /dev/null | awk '{ print $1 }' | tail -1`
|
||||
# if SALIDA != MAXHOPS, error (more than MAXHOPS hop, if this is our local IP, no more than MAXHOPS hop its needed
|
||||
#if [ "$SALIDA" == "$MAXHOPS" ]
|
||||
#then
|
||||
# DNS_STATUS=1
|
||||
#else
|
||||
# DNS_STATUS=0
|
||||
#fi
|
||||
#echo "<module>"
|
||||
#echo "<name>DNS_CHECK</name>"
|
||||
#echo "<type>generic_proc</type>"
|
||||
#echo "<data>$DNS_STATUS</data>"
|
||||
#echo "</module>"
|
||||
|
||||
# MODULE END ========================
|
||||
|
||||
|
||||
# ================================
|
||||
# Check for DNS Entry change
|
||||
# on local interface ppp0
|
||||
# ================================
|
||||
|
||||
# PLC_DNS=`dig @194.179.1.101 plc.genterara.com A +short | tail -1 `
|
||||
# PLC_LOCAL=`ifconfig ppp0 | head -2 | tail -1 | tr -s ":" " " | awk ' { print $3 } '`
|
||||
# if [ "$PLC_DNS" == "$PLC_LOCAL" ]
|
||||
# then
|
||||
# PLC_STATUS=1
|
||||
# else
|
||||
# PLC_STATUS=0
|
||||
# fi
|
||||
#
|
||||
# echo "<module>"
|
||||
# echo "<name>PLC_DNS_CHECK</name>"
|
||||
# echo "<type>generic_proc</type>"
|
||||
# echo "<data>$PLC_STATUS</data>"
|
||||
# echo "</module>"
|
||||
# MODULE END ========================
|
Loading…
Reference in New Issue