Untìl URU Server Basic process info on a webpage

The following is a small php script which goofy posted on the D'ni guilds site with the aim of it showing the server status on a web page:

<?php chdir('/usr/local/games/plServers/rc.d/');system("sh plasma-servers.sh status")?>

The escape sequences generated by the plasma-servers.sh don't make for nice viewing on a web page. But an edited plasma-servers.sh script, can do this and also include some HTML formatting to make this a bit neater. This script I called info.sh

# description: info on plasma processes
# Thanks to Striker for writing the plasma-servers.sh script which this is based on. Hope you don't mind! -gav

### EDIT THIS
# Full Path to Plasma Root:
PLASMA_ROOT=/usr/local/games/plServers

### EDIT THE REST AT YOUR OWN RISK!
PATH=${PLASMA_ROOT}/bin:/sbin:/bin:/usr/bin:/usr/sbin
BASE_DIR=${PLASMA_ROOT}/var
SERVER_LIST=${PLASMA_ROOT}/etc/servers.list
RETVAL=0
    # crazy voodoo magic!
    for prog in `cat ${SERVER_LIST}`; do
        echo -n "$prog: "
        if [[ -a ${BASE_DIR}/$prog.pid  ]]; then
            PID=`cat  ${BASE_DIR}/$prog.pid`
            if [[ -z `ps -cp $PID | grep plNet` ]]; then
                echo -e "Stale PID file! [FAILED] <br>"
                RETVAL=1
            else
                echo -e "Running, PID: $PID [OK] <br>"
            fi
        else
            echo -en "PID file missing"
            PID=`pidof $prog | awk '{ print $NF }'`
            if [ -n "$PID" ]; then
                echo -en "; PID Found: $PID [WARNING]<br>"
            else
                echo -en "; Not running.[FAILED] <br>"
            fi
            RETVAL=1
            echo
        fi
    done
exit $RETVAL

So, if you now use the following:

<?php chdir('/usr/local/games/plServers/rc.d/');system("sh info.sh")?>

You get an output something like this:

plNetAuthServer: Running, PID: 2228 [OK] 
plNetLookupServer: Running, PID: 2237 [OK] 
plNetVaultServer: Running, PID: 2250 [OK] 
plNetServerAgent: Running, PID: 2268 [OK]

Urkle, perhaps this all could be moved to a "PHP utilities" section? I'm going to jazz this up a bit and am working on some more similar things too.

ServerStatusOnline (last edited 2008-12-27 16:35:31 by localhost)