From ea57a76272648e70c5784af87d84861822f41b5f Mon Sep 17 00:00:00 2001 From: slerena Date: Tue, 11 Nov 2008 12:32:58 +0000 Subject: [PATCH] 2008-11-11 Sancho Lerena * conf/pandora_server.conf: Added mta_user parameter who defines mail address used for alerts. * pandora_ctl: General control script to start/stop Pandora FMS daemons. * util/SLES10/*: Alternative start/stop daemons for SUSE and other systems that don't work fine with standard scripts. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1239 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 11 ++ pandora_server/conf/pandora_server.conf | 2 + pandora_server/pandora_ctl | 44 +++++ pandora_server/util/SLES10/pandora_network | 60 +++++++ pandora_server/util/SLES10/pandora_plugin | 60 +++++++ pandora_server/util/SLES10/pandora_prediction | 61 +++++++ pandora_server/util/SLES10/pandora_recon | 60 +++++++ pandora_server/util/SLES10/pandora_server | 59 +++++++ .../util/SLES10/pandora_snmpconsole | 151 ++++++++++++++++++ pandora_server/util/SLES10/pandora_wmi | 60 +++++++ 10 files changed, 568 insertions(+) create mode 100755 pandora_server/pandora_ctl create mode 100644 pandora_server/util/SLES10/pandora_network create mode 100644 pandora_server/util/SLES10/pandora_plugin create mode 100644 pandora_server/util/SLES10/pandora_prediction create mode 100644 pandora_server/util/SLES10/pandora_recon create mode 100644 pandora_server/util/SLES10/pandora_server create mode 100644 pandora_server/util/SLES10/pandora_snmpconsole create mode 100644 pandora_server/util/SLES10/pandora_wmi diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 3b065e164a..1950e96e15 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,14 @@ +2008-11-11 Sancho Lerena + + * conf/pandora_server.conf: Added mta_user parameter who defines + mail address used for alerts. + + * pandora_ctl: General control script to start/stop Pandora FMS + daemons. + + * util/SLES10/*: Alternative start/stop daemons for SUSE and + other systems that don't work fine with standard scripts. + 2008-11-08 Sancho Lerena * Config.pm: Fixed bug parsing config options with more diff --git a/pandora_server/conf/pandora_server.conf b/pandora_server/conf/pandora_server.conf index 9d94efcffb..789a2cbb44 100755 --- a/pandora_server/conf/pandora_server.conf +++ b/pandora_server/conf/pandora_server.conf @@ -173,6 +173,8 @@ mta_address localhost # mta_user: MTA User (if needed for auth) # mta_pass: MTA Pass (if needed for auth) # mta_auth: MTA Auth system (if needed, support: LOGIN PLAIN CRAM-MD5 DIGEST-MD) +# mta_from: Email address that sends the mail, by default is pandora@localhost +# probably you need to change it to avoid problems with your antispam # xprobe: If provided, is used to detect with recon server, OS fingerprint # of detected hosts. Xprobe2 is a GNU tool to detect OS types. diff --git a/pandora_server/pandora_ctl b/pandora_server/pandora_ctl new file mode 100755 index 0000000000..100b5ce770 --- /dev/null +++ b/pandora_server/pandora_ctl @@ -0,0 +1,44 @@ +#!/bin/bash + +# Global Startup / Control script for Pandora FMS +# Written by A. Delgado, contributed to Pandora FMS project +# (c) A.Delgado 2008 + +if [ $# -eq 0 ] +then + +echo -e "\nPandora FMS 2.0 Control script - http://pandorafms.org +Usage: pandora start/stop [server] [server] ... + +Servers : pandora_server pandora_network pandora_recon pandora_snmpconsole \n pandora_prediction pandora_plugin pandora_wmi \n" +exit 0 +fi + + +ACCION=$1 +SERVIDOR2=$2 +SERVIDOR3=$3 +SERVIDOR4=$4 +SERVIDOR5=$5 +SERVIDOR6=$6 +SERVIDOR7=$7 +SERVIDOR8=$8 + +if [ $# -eq 1 ] +then + /etc/init.d/pandora_server $ACCION + /etc/init.d/pandora_network $ACCION + /etc/init.d/pandora_recon $ACCION + /etc/init.d/pandora_snmpconsole $ACCION + /etc/init.d/pandora_prediction $ACCION + /etc/init.d/pandora_plugin $ACCION + /etc/init.d/pandora_wmi $ACCION +else + [ ! -z $SERVIDOR2 ] && /etc/init.d/$SERVIDOR2 $ACCION && echo -e "\n$ACCION server $SERVIDOR2\n" + [ ! -z $SERVIDOR3 ] && /etc/init.d/$SERVIDOR3 $ACCION && echo -e "\n$ACCION server $SERVIDOR3\n" + [ ! -z $SERVIDOR4 ] && /etc/init.d/$SERVIDOR4 $ACCION && echo -e "\n$ACCION server $SERVIDOR4\n" + [ ! -z $SERVIDOR5 ] && /etc/init.d/$SERVIDOR5 $ACCION && echo -e "\n$ACCION server $SERVIDOR5\n" + [ ! -z $SERVIDOR6 ] && /etc/init.d/$SERVIDOR6 $ACCION && echo -e "\n$ACCION server $SERVIDOR6\n" + [ ! -z $SERVIDOR7 ] && /etc/init.d/$SERVIDOR7 $ACCION && echo -e "\n$ACCION server $SERVIDOR7\n" + [ ! -z $SERVIDOR8 ] && /etc/init.d/$SERVIDOR8 $ACCION && echo -e "\n$ACCION server $SERVIDOR8\n" +fi diff --git a/pandora_server/util/SLES10/pandora_network b/pandora_server/util/SLES10/pandora_network new file mode 100644 index 0000000000..63ba00622d --- /dev/null +++ b/pandora_server/util/SLES10/pandora_network @@ -0,0 +1,60 @@ +#!/bin/bash + +# Pandora FMS Network Server, startup script +# Sancho Lerena, +# SLES 10 Version +# v2.0 Build 081111 + +# Configurable path and filenames +PANDORA_HOME="/etc/pandora/pandora_server.conf" +PANDORA_DAEMON=/usr/local/bin/pandora_network + +# Main script + +if [ ! -f $PANDORA_DAEMON ] +then + echo "Pandora FMS Network Server not found, please check setup and read manual" + exit +fi + +case "$1" in + start) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z $PANDORA_PID ] + then + echo "Pandora FMS Network Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..." + exit 1 + fi + + $PANDORA_DAEMON $PANDORA_HOME -D + sleep 1 + + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z "$PANDORA_PID" ] + then + echo "Pandora Network Server is now running with PID $PANDORA_PID" + else + echo "Cannot start Pandora FMS Network Server. Aborted." + fi + ;; + stop) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ -z "$PANDORA_PID" ] + then + echo "Pandora FMS Network Server is not running, cannot stop it." + exit 1 + else + echo "Stopping Pandora FMS Network Server" + kill $PANDORA_PID + fi + ;; + force-reload|restart) + $0 stop + sleep 10 + $0 start + ;; + *) + echo "Usage: pandora_network {start|stop|restart}" + exit 1 +esac + diff --git a/pandora_server/util/SLES10/pandora_plugin b/pandora_server/util/SLES10/pandora_plugin new file mode 100644 index 0000000000..0b94ff8289 --- /dev/null +++ b/pandora_server/util/SLES10/pandora_plugin @@ -0,0 +1,60 @@ +#!/bin/bash + +# Pandora FMS Plugin Server, startup script +# Sancho Lerena, +# SLES 10 +# v2.0 Build 081111 + +# Configurable path and filenames +PANDORA_HOME="/etc/pandora/pandora_server.conf" +PANDORA_DAEMON=/usr/bin/pandora_plugin + +# Main script + +if [ ! -f $PANDORA_DAEMON ] +then + echo "Pandora FMS Plugin Server not found, please check setup and read manual" + exit +fi + +case "$1" in + start) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z $PANDORA_PID ] + then + echo "Pandora FMS Plugin Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..." + exit 1 + fi + + $PANDORA_DAEMON $PANDORA_HOME -D + sleep 1 + + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z "$PANDORA_PID" ] + then + echo "Pandora FMS Plugin Server is now running with PID $PANDORA_PID" + else + echo "Cannot start Pandora FMS Plugin Server. Aborted." + fi + ;; + stop) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ -z "$PANDORA_PID" ] + then + echo "Pandora FMS Plugin Server is not running, cannot stop it." + exit 1 + else + echo "Stopping Pandora FMS Plugin Server" + kill $PANDORA_PID + fi + ;; + force-reload|restart) + $0 stop + sleep 10 + $0 start + ;; + *) + echo "Usage: pandora_network {start|stop|restart}" + exit 1 +esac + diff --git a/pandora_server/util/SLES10/pandora_prediction b/pandora_server/util/SLES10/pandora_prediction new file mode 100644 index 0000000000..f208000eab --- /dev/null +++ b/pandora_server/util/SLES10/pandora_prediction @@ -0,0 +1,61 @@ +#!/bin/bash + +# Pandora FMS Prediction Server, startup script +# Sancho Lerena, +# SLES 10 +# v2.0 build 081111 + +# Configurable path and filenames +PANDORA_HOME="/etc/pandora/pandora_server.conf" +PANDORA_DAEMON=/usr/bin/pandora_prediction + +# Main script + + +if [ ! -f $PANDORA_DAEMON ] +then + echo "Pandora FMS Prediction Server not found, please check setup and read manual" + exit +fi + +case "$1" in + start) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z $PANDORA_PID ] + then + echo "Pandora FMS Prediction Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..." + exit 1 + fi + + $PANDORA_DAEMON $PANDORA_HOME -D + sleep 1 + + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z "$PANDORA_PID" ] + then + echo "Pandora FMS Prediction Server is now running with PID $PANDORA_PID" + else + echo "Cannot start Pandora FMS Prediction Server. Aborted." + fi + ;; + stop) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ -z "$PANDORA_PID" ] + then + echo "Pandora FMS Prediction Server is not running, cannot stop it." + exit 1 + else + echo "Stopping Pandora FMS Prediction Server" + kill $PANDORA_PID + fi + ;; + force-reload|restart) + $0 stop + sleep 10 + $0 start + ;; + *) + echo "Usage: pandora_prediction {start|stop|restart}" + exit 1 +esac + diff --git a/pandora_server/util/SLES10/pandora_recon b/pandora_server/util/SLES10/pandora_recon new file mode 100644 index 0000000000..5e1b9b210d --- /dev/null +++ b/pandora_server/util/SLES10/pandora_recon @@ -0,0 +1,60 @@ +#!/bin/bash + +# Pandora FMS Recon Server, startup script +# Sancho Lerena, +# SLES Version +# v2.0 build 081111 + +# Configurable path and filenames +PANDORA_HOME="/etc/pandora/pandora_server.conf" +PANDORA_DAEMON=/usr/local/bin/pandora_recon + +# Main script + +if [ ! -f $PANDORA_DAEMON ] +then + echo "Pandora FMS Recon Server not found, please check setup and read manual" + exit +fi + +case "$1" in + start) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z $PANDORA_PID ] + then + echo "Pandora FMS Recon Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..." + exit 1 + fi + + $PANDORA_DAEMON $PANDORA_HOME -D + sleep 1 + + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z "$PANDORA_PID" ] + then + echo "Pandora Recon Server is now running with PID $PANDORA_PID" + else + echo "Cannot start Pandora FMS Recon Server. Aborted." + fi + ;; + stop) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ -z $PANDORA_PID ] + then + echo "Pandora FMS Recon Server is not running, cannot stop it." + exit 1 + else + echo "Stopping Pandora FMS Recon Server" + kill $PANDORA_PID > /dev/null 2>&1 + fi + ;; + force-reload|restart) + $0 stop + sleep 10 + $0 start + ;; + *) + echo "Usage: pandora_recon {start|stop|restart}" + exit 1 +esac + diff --git a/pandora_server/util/SLES10/pandora_server b/pandora_server/util/SLES10/pandora_server new file mode 100644 index 0000000000..ebc4b14e4d --- /dev/null +++ b/pandora_server/util/SLES10/pandora_server @@ -0,0 +1,59 @@ +#!/bin/bash + +# Pandora FMS Data Server, startup script +# Sancho Lerena, +# SLES 10 version +# v2.0 build 081111 + +# Configurable path and filenames +PANDORA_HOME="/etc/pandora/pandora_server.conf" +PANDORA_DAEMON=/usr/bin/pandora_server +# Main script + +if [ ! -f $PANDORA_DAEMON ] +then + echo "Pandora FMS Data Server not found, please check setup and read manual" + exit +fi + +case "$1" in + start) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z $PANDORA_PID ] + then + echo "Pandora FMS Data Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..." + exit 1 + fi + + $PANDORA_DAEMON $PANDORA_HOME -D + sleep 1 + + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z "$PANDORA_PID" ] + then + echo "Pandora FMS Data Server is now running with PID $PANDORA_PID" + else + echo "Cannot start Pandora FMS Data Server. Aborted." + fi + ;; + stop) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ -z "$PANDORA_PID" ] + then + echo "Pandora FMS Data Server is not running, cannot stop it." + exit 1 + else + echo "Stopping Pandora FMS Data Server" + kill $PANDORA_PID > /dev/null 2>&1 + fi + ;; + force-reload|restart) + $0 stop + sleep 10 + $0 start + ;; + *) + echo "Usage: pandora_server {start|stop|restart}" + exit 1 +esac + diff --git a/pandora_server/util/SLES10/pandora_snmpconsole b/pandora_server/util/SLES10/pandora_snmpconsole new file mode 100644 index 0000000000..fac95e6e05 --- /dev/null +++ b/pandora_server/util/SLES10/pandora_snmpconsole @@ -0,0 +1,151 @@ +#!/bin/bash + +# Startup script for Pandora SNMP Console +# Sancho Lerena, +# SLES 10 Version +# v2.0 build 081111 + +# Compatible with NetSNMP 5.1 or higher + +# Configurable path and filenames +PANDORA_HOME="/etc/pandora/pandora_server.conf" +PANDORA_PID_PATH="/var/run" +PANDORA_PID=$PANDORA_PID_PATH/pandora_snmp.pid +PANDORA_DAEMON=/usr/local/bin/pandora_snmpconsole + +DAEMON_LOG="/var/log/pandora/pandora_snmptrap.log" +DAEMON_PID="$PANDORA_PID_PATH/pandora_snmptrapd.pid" +DAEMON_PATH=/usr/sbin/snmptrapd + +# Dont touch this call unless you know are doing. For different versions of NetSNMP Trap daemon, it's possible you need to change some options +# Please refer NetSNMP documentation in that case. +DAEMON_OPTIONS="-t -On -n -a -Lf $DAEMON_LOG -p $DAEMON_PID -F %4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]%a[**]%N[**]%w[**]%W[**]%q[**]%v\n" +DAEMON="$DAEMON_PATH $DAEMON_OPTIONS" + +if [ ! -d "$PANDORA_PID_PATH" ] +then + echo "Pandora FMS cannot write it's PID file in $PANDORA_PID_PATH. Please create that directory" + exit +fi + +if [ ! -f "$DAEMON_PATH" ] +then + echo "NetSNMP snmptrapd not found at $DAEMON_PATH, please check setup and read manual" + exit +fi + +case "$1" in + start) + if [ -f $DAEMON_PID ] + then + CHECK_PID=`cat $DAEMON_PID` + CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "snmp" | wc -l` + if [ $CHECK_PID_RESULT == 1 ] + then + echo "NetSNMP Trap daemon is currently running on this machine with PID ($CHECK_PID). Aborting now..." + exit + fi + fi + + SNMP_WARNING=`ps aux | grep "$DAEMON_PATH" | grep -v grep | wc -l` + if [ $SNMP_WARNING == 1 ] + then + echo "WARNING: Seems to be already running a SNMP trap daemon on this system not associated with Pandora FMS" + echo "Check manually if their output logfile is been used for Pandora FMS and it's format is correct" + fi + + # Launch SNMP TRAP Daemon + $DAEMON + + sleep 1 + if [ ! -f $DAEMON_LOG ] + then + echo "Problem with NetSNMP Trap daemon (Logfile $DAEMON_LOG not found!). Aborting" + exit + fi + + if [ -f $DAEMON_PID ] + then + CHECK_PID=`cat $DAEMON_PID` + CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "snmp" | wc -l` + if [ $CHECK_PID_RESULT != 1 ] + then + echo "Problem starting NetSNMP Trap daemon on this machine (PID File not correct). Aborting now..." + exit + fi + else + echo "Problem starting NetSNMP Trap daemon on this machine (Cannot get PID File). Aborting now..." + exit + fi + + RESULT="`cat $DAEMON_LOG | grep 'errno 13' 2> /dev/null`" + if [ -z "$RESULT" ] + then + echo "NetSNMP Trap daemon is now running with PID `cat $DAEMON_PID 2> /dev/null`" + else + echo "NetSNMP cannot open port (udp/162). Please execute as root user" + rm -f $DAEMON_PID 2> /dev/null + fi + + if [ -f $PANDORA_PID ] + then + CHECK_PID=`cat $PANDORA_PID` + CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "pandora_snmpconsole" | wc -l` + if [ $CHECK_PID_RESULT == 1 ] + then + echo "Pandora FMS SNMP Server is currently running on this machine with PID ($CHECK_PID). Aborting now..." + exit + fi + fi + + $PANDORA_DAEMON $PANDORA_HOME -D + sleep 1 + + MYPID=`ps aux | grep "$PANDORA_DAEMON" | grep -v grep | tail -1 | awk '{print $2}'` + if [ ! -z "$MYPID" ] + then + echo $MYPID > $PANDORA_PID + echo "Pandora FMS SNMP Server is now running with PID $MYPID" + else + echo "Cannot start Pandora FMS SNMP Server. Aborted" + fi + cd "$OLD_PATH" + ;; + stop) + if [ -f $DAEMON_PID ] + then + echo "Stopping NetSNMP Trap daemon" + PID_1=`cat $DAEMON_PID` + if [ ! -z "`ps -F -p $PID_1 | grep -v grep | grep 'snmptrapd'`" ] + then + kill -9 `cat $DAEMON_PID 2> /dev/null` + fi + rm -f $DAEMON_PID 2> /dev/null > /dev/null + rm -f $DAEMON_LOG 2> /dev/null > /dev/null + else + echo "NetSNMP Trap daemon is not running, cannot stop it." + fi + + if [ -f $PANDORA_PID ] + then + echo "Stopping Pandora SNMP Console" + PID_2=`cat $PANDORA_PID` + if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'pandora_snmpconsole'`" ] + then + kill `cat $PANDORA_PID` 2> /dev/null > /dev/null + fi + rm -f $PANDORA_PID + else + echo "Pandora FMS SNMP Console is not running, cannot stop it." + fi + ;; + force-reload|restart) + $0 stop + sleep 5 + $0 start + ;; + *) + echo "Usage: pandora_snmpconsole {start|stop|restart}" + exit 1 +esac + diff --git a/pandora_server/util/SLES10/pandora_wmi b/pandora_server/util/SLES10/pandora_wmi new file mode 100644 index 0000000000..5e3572816a --- /dev/null +++ b/pandora_server/util/SLES10/pandora_wmi @@ -0,0 +1,60 @@ +#!/bin/bash + +# Pandora FMS WMI Server, startup script +# Sancho Lerena, +# SLES 10 Version +# v2.0 Build 081111 + +# Configurable path and filenames +PANDORA_HOME="/etc/pandora/pandora_server.conf" +PANDORA_DAEMON=/usr/bin/pandora_wmi + +# Main script + +if [ ! -f $PANDORA_DAEMON ] +then + echo "Pandora FMS WMI Server not found, please check setup and read manual" + exit +fi + +case "$1" in + start) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z $PANDORA_PID ] + then + echo "Pandora FMS WMI Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..." + exit 1 + fi + + $PANDORA_DAEMON $PANDORA_HOME -D + sleep 1 + + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ ! -z "$PANDORA_PID" ] + then + echo "Pandora FMS WMI Server is now running with PID $PANDORA_PID" + else + echo "Cannot start Pandora FMS WMI Server. Aborted." + fi + ;; + stop) + PANDORA_PID=$(pidof -x $PANDORA_DAEMON) + if [ -z "$PANDORA_PID" ] + then + echo "Pandora FMS WMI Server is not running, cannot stop it." + exit 1 + else + echo "Stopping Pandora FMS WMI Server" + kill $PANDORA_PID + fi + ;; + force-reload|restart) + $0 stop + sleep 10 + $0 start + ;; + *) + echo "Usage: pandora_network {start|stop|restart}" + exit 1 +esac +