Welcome to Pandora FMS Community!

Find answers, ask questions, and connect with our community around the world.

Welcome to Pandora FMS Community Forums Community support the changes/tweaks Imade to Pandora_server 1.2

  • the changes/tweaks Imade to Pandora_server 1.2

    Posted by daggett on December 6, 2006 at 19:01

    I just wanted to put here all the changes I made to pandora FMS 1.2 to make them available to all to use/see/criticise/modify…

    bin/pandora_server.pl :
    use threads; (deprecated)
    use threads::shared; (deprecated)
    replaced by
    use forks;
    use forks::shared;

    pandora_server :
    [code:1]#!/bin/sh
    # Pandora Data Server startup script
    # Sancho Lerena,
    # Linux Version (generic)
    # v1.2 (Ene/2006)

    # Configurable path and filenames
    PANDORA_HOME=”/opt/pandora/pandora_server”
    PANDORA_SERVER_PID=”$PANDORA_HOME/var/pandora_server.pid”

    # Main script

    if [ ! -f $PANDORA_HOME/bin/pandora_server.pl ]
    then
    echo “Pandora Data Server not found, please check setup and read manual”
    exit
    fi

    case “$1″ in
    start)
    OLD_PATH=”`pwd`”
    if [ -f $PANDORA_SERVER_PID ]
    then
    echo “Pandora Data Server is currently running on this machine. Aborting now…”
    exit
    fi
    # we check if we have instances of the server already running
    NUMPID=`ps aux | grep ‘pandora_server.pl’ | grep -v grep | wc -l`
    if [ $NUMPID -gt 0 ]
    then
    echo Warning! It seems that there are some instances of pandora server already running
    echo Starting anyway… but you may have some problems.
    fi
    # we change to the pandora server bin directory
    cd $PANDORA_HOME/bin
    ./pandora_server.pl $PANDORA_HOME -D
    # the server may take some time to start, so we need to pause before collecting PIDs
    sleep 2
    # collecting first line (first PID with head -1) then the second (tail -1). It doesn’t matter if MYPID==MYPID2
    MYPID=`ps aux | grep ‘pandora_server.pl’ | grep -v grep | tail -2 | head -1 | awk ‘{print $2}’`
    MYPID2=`ps aux | grep ‘pandora_server.pl’ | grep -v grep | tail -1 | awk ‘{print $2}’`
    if [ ! -z “$MYPID” ]
    then
    # there is at least one PID, so server is running, so put PID in the .pid file and create this file
    echo $MYPID > $PANDORA_SERVER_PID
    echo $MYPID2 >> $PANDORA_SERVER_PID
    echo “Pandora Data Server is now running with PID $MYPID and $MYPID2”
    else
    # no PID collected, the server is not running
    echo “Cannot start Pandora Data Server. Aborted”
    fi
    cd “$OLD_PATH”
    ;;
    stop)
    if [ -f $PANDORA_SERVER_PID ]
    then
    echo “Stopping Pandora Data Server”
    # fetching PID from the .pid file it doesn’t matter if PID_1==PID_2
    PID_1=`cat $PANDORA_SERVER_PID | head -1`
    PID_2=`cat $PANDORA_SERVER_PID | tail -1`
    # we check if PID_1 and PID_2 are still existing, if yes then we kill them
    PIDS=`ps -F -p $PID_1 $PID_2 | grep -v grep | grep ‘pandora_server.pl’| awk ‘{print $2}’`
    if [ ! -z “$PIDS” ]
    then
    kill $PIDS 2> /dev/null > /dev/null
    fi
    echo “Stopping PID: ” $PIDS
    # we check if our PIDs were killed or not, we grep pandora_server. because of zombies loosing their “pl”
    PIDS=`ps -F -p $PID_1 $PID_2 | grep -v grep | grep ‘pandora_server.’| awk ‘{print $2}’`
    if [ ! -z “$PIDS”]
    then
    echo “Following PID didn’t stop, sending signal 9 to ” $PIDS
    kill -9 $PIDS 2> /dev/null > /dev/null
    fi
    rm -f $PANDORA_SERVER_PID
    echo Server Stopped
    else
    echo “Pandora Data Server is not running, cannot stop it.”
    fi
    ;;
    force-reload|restart)
    $0 stop
    $0 start
    ;;
    *)
    echo “Usage: pandora_network {start|stop|restart}”
    exit 1
    esac

    daggett replied 18 years, 2 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.