Teplota: 6.4 °C
Tlak: 1007.52 hPa
Vlhkost: 80.0 %
Vítr: JJZ , 0 m/s
Takze jsem vcera v hospode neco placnul a jestli si vzpominam, tak to byla ta uprava logovani ve s, to by melo vypadat zhruba takhle:
[code:1]root@cronos:/# cat /usr/local/info/addrstat
IP=$1
NAME=$2
LOGFILE=/etc/rc.d/wifisetup/woo
STATDIR=/free/wusers/kucik/datadir/netstat/
ping -c4 $IP |grep "time="
#####
if test "$?" = "1"
then
if ! grep "DEAD" $STATDIR$NAME
then
date >> $LOGFILE
echo "$NAME Unreachable" >> $LOGFILE
echo "DEAD" > $STATDIR$NAME
echo "$NAME" >> $STATDIR$NAME
date >> $STATDIR$NAME
fi
else
#####
if grep "DEAD" $STATDIR$NAME
then
date >> $LOGFILE
echo "$NAME Reachable" >> $LOGFILE
fi
echo "ALIVE" > $STATDIR$NAME
echo "$NAME" >> $STATDIR$NAME
date >> $STATDIR$NAME
fi[/code:1]
a pak to sledovani useru:
[code:1]root@cronos:/# cat /usr/local/info/usrstat
#!/bin/sh
logfile="/free/wusers/kucik/datadir/usrstat/users.log"
newlogfile="/free/wusers/kucik/datadir/usrstat/users.log.new"
wordcnt=`wc -l /etc/dhcpd.conf`
wordcnt=`echo \ \ $wordcnt | tr -s ' ' | cut -d\ -f2`
begin=`cat /etc/dhcpd.conf | grep -n '#group' | cut -d: -f1`
cat /etc/dhcpd.conf | tail -n $(( $wordcnt - $begin )) > /tmp/actdhcp
cat /tmp/actdhcp | grep -v '#' | grep 'host' | tr -s ' ' | cut -d\ -f3 > /tmp/actdhcp-host
cat /tmp/actdhcp | grep -v '#' | grep 'address' | tr ' ' ' ' | tr -s ' ' | cut -d\ -f3 | tr -d ';' > /tmp/actdhcp-adr
rm /tmp/actdhcp
wordcnt=`wc -l /tmp/actdhcp-host`
wordcnt=`echo \ \ $wordcnt | tr -s ' ' | cut -d\ -f2`
echo users: > $newlogfile
for line in `seq $wordcnt`
do
ip=`head -n $line /tmp/actdhcp-adr | tail -n 1`
host=`head -n $line /tmp/actdhcp-host | tail -n 1`
ping -c4 $ip |grep "time="
if test "$?" = "1"
then
if ! grep "$host;DEAD" $logfile
then
echo "$ip;$host;DEAD;`date`" >> $newlogfile
else
cat $logfile | grep "$host;DEAD;" >> $newlogfile
fi
else
echo "$ip;$host;ALIVE;`date`" >> $newlogfile
fi
done
mv $newlogfile $logfile
rm /tmp/actdhcp-host
rm /tmp/actdhcp-adr
[/code:1]
Protoze jsem linej tam ty usery psat, tak si je to taha z dhcpd.conf
a nejak takhle k tomu vypada ten php ksichtik
[code:1]
<?php
$basedir=getenv("DOCUMENT_ROOT");
$line=file($basedir."datadir/usrstat/users.log");
for($i=1;$i\n";
else
print "\n";
print $parm[$i][0];
print "\n".$parm[$i][1];
print "\n";
print $parm[$i][2];
print "\n\n";
}
?>
[/code:1]
Tady to sviti. Dal jsem tomu refresh 20 minut. [url]http://cronos/usrstat.php[/url]
Edit: Jo este takovy maly howto.
U prvniho scriptu je zmena oproti puvodnimu akorat v tom, co je uzavreny do tech #####.
U druhyho si upravte podle svyho promeny logfile a newlogfile.
A ten php script se da vrazit asi do cehokoliv.