jablonka.czprosek.czf

mapstats

Subversion Repositories:
[/] [gen_mapstats] - Blame information for rev 10

 

Line No. Rev Author Line
11unreal#!/bin/sh
2 
3# (c)2003 by Jan Krupa (krupaj@mobilnews.cz)
4# http://www.mobilnews.cz/honza/
5# Changes by Jirka Klir (Unreal][) for Mapstats v3.0 AJAX. http://www.jklir.net
6 
7# -- Configuration ---------------------------------------------------
8# Mapstats directory
9STATS_PATH=/var/www/www.kobylisy.czf/mapstats
10 
11# Program paths
12PING_PATH=ping
13NMAP_PATH=nmap
14FPING_PATH=fping
15 
16# STATS_TYPE - ping, fping or nmap
17STATS_TYPE=ping
18 
199unreal# --------------------------------------------------------------------
201unreal# Don't change anything bellow this line if you are not sure what
21# you are doing ;)
22# --------------------------------------------------------------------
23 
249unrealcd $STATS_PATH
25 
26for LINE in `ls -1 $STATS_PATH | grep .nodes`; do
271unreal a_file=`echo $LINE | awk -F. '{ printf "%s", $1 }'`
28 
29 file_comp=$STATS_PATH/$a_file.nodes
30 file_state=$STATS_PATH/$a_file.state
31 
32 printf "" > $file_state
33 # Get computer states
34 if [ $STATS_TYPE = "fping" ]; then
35 ping_host_all=""
36 
37 for LINE in `cat $file_comp`; do
38 ping_host=`echo -n $LINE | awk -F\; '{ printf "%s", $5 }'`
39 ping_host_all="${ping_host_all} ${ping_host}"
40 done
41 $FPING_PATH -e $ping_host_all | awk -F\ '{ printf "%s;", $1; if ($3=="alive") printf "1;%s\n", substr($4, 2, (length($4)-1)); else printf "0;0\n"; }' > $file_state
42 fi
43 
44 if [ $STATS_TYPE = "ping" ]; then
45 for LINE in `cat $file_comp`; do
46 ping_host=`echo -n $LINE | awk -F\; '{ printf "%s", $5 }'`;
47 
48 ping_lat=\;`$PING_PATH -c 1 -w 2 $ping_host | grep rtt | awk -F\ '{ printf "%s", $4 }' | awk -F\/ ' { printf "%s", $2 }'`;
49 if [ "$ping_lat" = ";" ]; then
50 ping_lat=\;`$PING_PATH -c 1 -w 2 $ping_host | grep rtt | awk -F\ '{ printf "%s", $4 }' | awk -F\/ ' { printf "%s", $2 }'`;
51 fi
52 
53 if [ "$ping_lat" = ";" ]; then
54 echo "$ping_host;0;0" >> $file_state
55 else
56 echo "$ping_host;1$ping_lat" >> $file_state
57 fi
58 done
59 
60 fi
61 
62 if [ $STATS_TYPE = "nmap" ]; then
63 ping_host_all=""
64 
65 for LINE in `cat $file_comp`; do
66 ping_host=`echo -n $LINE | awk -F\; '{ printf "%s", $5 }'`
67 ping_host_all="${ping_host_all} ${ping_host}"
68 done
69 
70 $NMAP_PATH -vnsP $ping_host_all | awk -F\ '{ if ($1=="Host") { if (match($2, /\(/) == 0) { printf "%s", $2; } else { printf "%s", substr($2, 2, (length($2)-2)); } if ($6=="up.") printf ";1;-\n"; else printf ";0;-\n"; } }' > $file_state
71 fi
72 
73done

Powered by WebSVN 2.2.1