Új hozzászólás Aktív témák

  • Addel

    senior tag

    válasz tpeter #3856 üzenetére

    #!/bin/sh
    TMP=`wl isup | grep -c "1"`
    TMP2=`date | awk '{print substr($0,5,15)}'`
    if [ "$TMP" = "1" ]
    then
    TMP=`wl assoclist | grep -c "assoclist"`
    if [ "$TMP" = "0" ]
    then
    # echo "$TMP2 wlancheck: restart WLAN - no clients in WLAN" >>/tmp/syslog.log
    # echo "$TMP2 wlancheck: restart WLAN - no clients in WLAN" >>/opt/var/wlan.log
    # wl radio off
    # sleep 5s
    # wl radio on
    echo "$TMP2 wlancheck: no clients is WLAN" >>/opt/var/wlan.log
    # echo "$TMP2 wlancheck: no clients is WLAN" >>/tmp/syslog.log
    else
    echo "$TMP2 wlancheck: have $TMP client(s) in WLAN" >>/opt/var/wlan.log
    # echo "$TMP2 wlancheck: have $TMP client(s) in WLAN" >>/tmp/syslog.log

    TMP=`wl assoclist | sed -e 's/assoclist/ /g'`
    for MACI in $TMP ; do
    GEP=`grep -i $MACI /opt/wlanmac.conf | awk '{print $2}'`
    WIP=`grep -i $MACI /proc/net/arp | awk '{print $1}'`
    if [ "$WIP" == "" ]
    then
    WIP=`grep -i $MACI /etc/ethers | awk '{print $2}'`
    fi
    if [ "$WIP" == "" ]
    then
    WIP="<unknown ip>"
    fi
    echo -e ${MACI}'\t'${WIP}'\t'${GEP} >>/opt/var/wlan.log ;
    done
    fi
    else
    # echo "$TMP2 wlancheck: wlan radio disabled or wlan down" >>/tmp/syslog.log
    echo "$TMP2 wlancheck: wlan radio disabled or wlan down" >>/opt/var/wlan.log
    fi

    Ez a /opt/var/wlan.log fileba irogatja a wlanon csatlakozott gépek ipcímét és macadresszét(ha talál hozzá gépnevet, akkor azt is).
    Én Cron-nal futtatom 5 percenként.
    igy néz ki a log:

    Jul 26 16:25:01 wlancheck: no clients is WLAN
    Jul 26 16:30:01 wlancheck: no clients is WLAN
    Jul 26 16:35:02 wlancheck: have 1 client(s) in WLAN
    00:1C:D6:34:62:29 192.168.1.65
    Jul 26 16:40:02 wlancheck: no clients is WLAN
    Jul 26 16:45:01 wlancheck: no clients is WLAN
    Jul 26 16:50:01 wlancheck: no clients is WLAN

    [ Szerkesztve ]

Új hozzászólás Aktív témák