#!/bin/sh # (c)2003 by Jan Krupa (krupaj@mobilnews.cz) # http://www.mobilnews.cz/honza/ # Changes by Jirka Klir (Unreal][) for Mapstats v3.0 AJAX. http://www.jklir.net # -- Configuration --------------------------------------------------- # Mapstats directory STATS_PATH=/var/www/www.kobylisy.czf/mapstats # Program paths PING_PATH=ping NMAP_PATH=nmap FPING_PATH=fping # STATS_TYPE - ping, fping or nmap STATS_TYPE=ping # -------------------------------------------------------------------- # Don't change anything bellow this line if you are not sure what # you are doing ;) # -------------------------------------------------------------------- cd $STATS_PATH for LINE in `ls -1 $STATS_PATH | grep .nodes`; do a_file=`echo $LINE | awk -F. '{ printf "%s", $1 }'` file_comp=$STATS_PATH/$a_file.nodes file_state=$STATS_PATH/$a_file.state printf "" > $file_state # Get computer states if [ $STATS_TYPE = "fping" ]; then ping_host_all="" for LINE in `cat $file_comp`; do ping_host=`echo -n $LINE | awk -F\; '{ printf "%s", $5 }'` ping_host_all="${ping_host_all} ${ping_host}" done $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 fi if [ $STATS_TYPE = "ping" ]; then for LINE in `cat $file_comp`; do ping_host=`echo -n $LINE | awk -F\; '{ printf "%s", $5 }'`; ping_lat=\;`$PING_PATH -c 1 -w 2 $ping_host | grep rtt | awk -F\ '{ printf "%s", $4 }' | awk -F\/ ' { printf "%s", $2 }'`; if [ "$ping_lat" = ";" ]; then ping_lat=\;`$PING_PATH -c 1 -w 2 $ping_host | grep rtt | awk -F\ '{ printf "%s", $4 }' | awk -F\/ ' { printf "%s", $2 }'`; fi if [ "$ping_lat" = ";" ]; then echo "$ping_host;0;0" >> $file_state else echo "$ping_host;1$ping_lat" >> $file_state fi done fi if [ $STATS_TYPE = "nmap" ]; then ping_host_all="" for LINE in `cat $file_comp`; do ping_host=`echo -n $LINE | awk -F\; '{ printf "%s", $5 }'` ping_host_all="${ping_host_all} ${ping_host}" done $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 fi done #!/bin/sh # (c)2003 by Jan Krupa (krupaj@mobilnews.cz) # http://www.mobilnews.cz/honza/ # Changes by Jirka Klir (Unreal][) for Mapstats v3.0 AJAX. http://www.jklir.net # -- Configuration --------------------------------------------------- # Mapstats directory STATS_PATH=/var/www/www.kobylisy.czf/mapstats cd $STATS_PATH # Program paths PING_PATH=ping NMAP_PATH=nmap FPING_PATH=fping # STATS_TYPE - ping, fping or nmap STATS_TYPE=ping # Don't change anything bellow this line if you are not sure what # you are doing ;) # -------------------------------------------------------------------- for LINE in `ls -1 $STATS_PATH_DATA | grep .nodes`; do a_file=`echo $LINE | awk -F. '{ printf "%s", $1 }'` file_comp=$STATS_PATH/$a_file.nodes file_state=$STATS_PATH/$a_file.state printf "" > $file_state # Get computer states if [ $STATS_TYPE = "fping" ]; then ping_host_all="" for LINE in `cat $file_comp`; do ping_host=`echo -n $LINE | awk -F\; '{ printf "%s", $5 }'` ping_host_all="${ping_host_all} ${ping_host}" done $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 fi if [ $STATS_TYPE = "ping" ]; then for LINE in `cat $file_comp`; do ping_host=`echo -n $LINE | awk -F\; '{ printf "%s", $5 }'`; ping_lat=\;`$PING_PATH -c 1 -w 2 $ping_host | grep rtt | awk -F\ '{ printf "%s", $4 }' | awk -F\/ ' { printf "%s", $2 }'`; if [ "$ping_lat" = ";" ]; then ping_lat=\;`$PING_PATH -c 1 -w 2 $ping_host | grep rtt | awk -F\ '{ printf "%s", $4 }' | awk -F\/ ' { printf "%s", $2 }'`; fi if [ "$ping_lat" = ";" ]; then echo "$ping_host;0;0" >> $file_state else echo "$ping_host;1$ping_lat" >> $file_state fi done fi if [ $STATS_TYPE = "nmap" ]; then ping_host_all="" for LINE in `cat $file_comp`; do ping_host=`echo -n $LINE | awk -F\; '{ printf "%s", $5 }'` ping_host_all="${ping_host_all} ${ping_host}" done $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 fi done WebSVN - mapstats - Diff - Rev 9 and 1 - /gen_mapstats
  jablonka.czprosek.czf

mapstats

Subversion Repositories:
[/] [gen_mapstats] - Diff between revs 1 and 9

Show entire file Ignore whitespace

Rev 1 Rev 9

Powered by WebSVN 2.2.1