All pastes #372615 Raw Edit

Untitled

public text v1 · immutable
#372615 ·published 2007-02-26 05:26 UTC
rendered paste body
#!/bin/sh
#
# Attempts to order the server status page my cpu load 

if test -z "$1"
then
        echo "Usage: ./status.sh <server name>"
        exit
fi

echo
echo "PID CPU DOMAIN ACTION REQUEST"
echo "-----------------------------"
lynx -source $1/Status |
        perl -ne '
                if(/^<tr><td><b>.*<\/b><td>(\d+|-)<td>\d+\/\d+\/\d+<td>/){
                        $pid = $1;
                        print "$pid ";  
                }
                if(/^<td>(\d+\.\d+)<td>\d+<td>\d+<td>\d+\.\d+<td>\d+\.\d+<td>\d+\.\d+$/){
                        $cpu = $1;
                        print "$cpu ";
}
                if(/^<td>\d+\.\d+\.\d+\.\d+<td nowrap>(.*)<td nowrap>(GET|POST|HEAD) <A .*>(.*)<\/A>.*<\/tr>$/){
                        $domain = $1;
                        $get_post = $2;
                        $request = $3;
                        print "$domain $get_post $request\n";
                }'|
                sort -rn -k 2|
                head -5
echo