1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DHCP daemon crashed, how come?

Discussion in 'Tomato Firmware' started by Rally, Dec 12, 2009.

  1. Rally

    Rally Addicted to LI Member

    My router's DHCP daemon crashed, for the first time ever. Clients stopped getting DHCP leases, but I was able to fix it by restarting just the DHCPD and not the whole router. What could have caused that? Running tomato 1.27. Traffic shaping and bandwidth monitoring is switched on.


    Name tomato
    Model Linksys WRT54G/GS/GL (it's a GL)

    Time Sat, 12 Dec 2009 11:29:15 +0100
    Uptime 9 days, 13:36:42
    CPU Load (1 / 5 / 15 mins) 0.21 / 0.06 / 0.02
    Total / Free Memory 14.19 MB / 6,364.00 KB (43.81%) (cache is reported as free)

    Code:
    ec 11 02:00:01 unknown syslog.info root: -- MARK --
    Dec 11 03:00:02 unknown syslog.info root: -- MARK --
    Dec 11 04:00:01 unknown syslog.info root: -- MARK --
    Dec 11 05:00:01 unknown syslog.info root: -- MARK --
    Dec 11 06:00:01 unknown syslog.info root: -- MARK --
    Dec 11 07:00:01 unknown syslog.info root: -- MARK --
    Dec 11 08:00:02 unknown syslog.info root: -- MARK --
    Dec 11 09:00:01 unknown syslog.info root: -- MARK --
    Dec 11 10:00:01 unknown syslog.info root: -- MARK --
    Dec 11 11:00:01 unknown syslog.info root: -- MARK --
    Dec 11 12:00:01 unknown syslog.info root: -- MARK --
    Dec 11 13:00:02 unknown syslog.info root: -- MARK --
    Dec 11 14:00:01 unknown syslog.info root: -- MARK --
    Dec 11 15:00:01 unknown syslog.info root: -- MARK --
    Dec 11 15:19:34 unknown daemon.info dnsmasq-dhcp[90]: DHCPREQUEST(br0) 10.10.10.7 00:26:54:10:1d:cf 
    Dec 11 15:19:34 unknown daemon.info dnsmasq-dhcp[90]: DHCPACK(br0) 10.10.10.7 00:26:54:10:1d:cf cobra
    Dec 11 15:57:14 unknown daemon.info dnsmasq-dhcp[90]: DHCPREQUEST(br0) 10.10.10.7 00:26:54:10:1d:cf 
    Dec 11 15:57:14 unknown daemon.info dnsmasq-dhcp[90]: DHCPACK(br0) 10.10.10.7 00:26:54:10:1d:cf cobra
    Dec 11 16:00:01 unknown syslog.info root: -- MARK --
    Dec 11 16:06:05 unknown daemon.info dnsmasq-dhcp[90]: DHCPREQUEST(br0) 10.10.10.7 00:26:54:10:1d:cf 
    Dec 11 16:06:05 unknown daemon.info dnsmasq-dhcp[90]: DHCPACK(br0) 10.10.10.7 00:26:54:10:1d:cf cobra
    Dec 11 16:10:34 unknown daemon.info dnsmasq-dhcp[90]: DHCPREQUEST(br0) 10.10.10.7 00:26:54:10:1d:cf 
    Dec 11 16:10:34 unknown daemon.info dnsmasq-dhcp[90]: DHCPACK(br0) 10.10.10.7 00:26:54:10:1d:cf cobra
    Dec 11 16:23:00 unknown daemon.info dnsmasq-dhcp[90]: DHCPREQUEST(br0) 10.10.10.7 00:26:54:10:1d:cf 
    Dec 11 16:23:00 unknown daemon.info dnsmasq-dhcp[90]: DHCPACK(br0) 10.10.10.7 00:26:54:10:1d:cf cobra
    Dec 11 16:57:23 unknown daemon.info dnsmasq-dhcp[90]: DHCPREQUEST(br0) 10.10.10.2 00:50:8d:68:05:66 
    Dec 11 16:57:23 unknown daemon.info dnsmasq-dhcp[90]: DHCPACK(br0) 10.10.10.2 00:50:8d:68:05:66 raider
    Dec 11 16:57:48 unknown daemon.info dnsmasq-dhcp[90]: DHCPINFORM(br0) 10.10.10.2 00:50:8d:68:05:66 
    Dec 11 16:57:48 unknown daemon.info dnsmasq-dhcp[90]: DHCPACK(br0) 10.10.10.2 00:50:8d:68:05:66 raider
    Dec 11 16:57:51 unknown daemon.info dnsmasq-dhcp[90]: DHCPINFORM(br0) 10.10.10.2 00:50:8d:68:05:66 
    Dec 11 16:57:51 unknown daemon.info dnsmasq-dhcp[90]: DHCPACK(br0) 10.10.10.2 00:50:8d:68:05:66 raider
    Dec 11 17:00:01 unknown syslog.info root: -- MARK --
    Dec 11 17:20:02 unknown user.err kernel: Out of Memory: Killed process 90 (dnsmasq).
    Dec 11 17:20:07 unknown user.err kernel: Out of Memory: Killed process 2209 (dnsmasq).
    Dec 11 18:00:02 unknown syslog.info root: -- MARK --
    Dec 11 19:00:01 unknown syslog.info root: -- MARK --
    Dec 11 20:00:01 unknown syslog.info root: -- MARK --
    Dec 11 21:00:01 unknown syslog.info root: -- MARK --
    Dec 11 22:00:01 unknown syslog.info root: -- MARK --
    Dec 11 23:00:02 unknown syslog.info root: -- MARK --
    Dec 12 00:00:01 unknown syslog.info root: -- MARK --
    Dec 12 01:00:01 unknown syslog.info root: -- MARK --
    Dec 12 02:00:01 unknown syslog.info root: -- MARK --
    Dec 12 03:00:01 unknown syslog.info root: -- MARK --
    Dec 12 04:00:02 unknown syslog.info root: -- MARK --
    Dec 12 05:00:01 unknown syslog.info root: -- MARK --
    Dec 12 06:00:01 unknown syslog.info root: -- MARK --
    Dec 12 07:00:01 unknown syslog.info root: -- MARK --
    Dec 12 08:00:01 unknown syslog.info root: -- MARK --
    Dec 12 09:00:01 unknown syslog.info root: -- MARK --
    Dec 12 10:00:01 unknown syslog.info root: -- MARK --
    EDIT: Accidentally posted too early, but it's good now.
     
  2. Planiwa

    Planiwa LI Guru Member

    Your system ran out of memory.
    It then started killing processes, trying to free up memory.

    Dnsmasq is usually the first to go, but it should simply restart a new one, assuming that there is enough memory, of course.

    It is interesting that we see:

    Code:
    Dec 11 17:00:01 unknown syslog.info root: -- MARK --
    Dec 11 17:20:02 unknown user.err kernel: Out of Memory: Killed process 90 (dnsmasq).
    Dec 11 17:20:07 unknown user.err kernel: Out of Memory: Killed process 2209 (dnsmasq).
    Dec 11 18:00:02 unknown syslog.info root: -- MARK --
    
    The qestion is: what used up all the memory?

    Keep in mind that running out of memory may mean that there is no space to log messages, including the messages that say that there was no space to log messages.

    There could be runaway processes, undead processes, or Connection storms.

    . . .

    What is the connection limit?
    Were there P2P applications at the time?
     
  3. Rally

    Rally Addicted to LI Member

    Thanks for your help!

    I figured that it might be a memory problem. I can't really check how much memory was used at the time of the crash, but there seems to be a lot free now. Whatever was taking up all that memory is gone now.

    Connection limit: 4096 It's the default, is that too high?
    P2P: yes, uTorrent, just like right now. Tomato says it's tracking about 190 connections and there is still 6,288.00 KB is free.

    I still have bandwidth usage data from the time when it occurred, it might help:
    [​IMG]
     
  4. Planiwa

    Planiwa LI Guru Member

    You could try reducing max connections to 3072, and reducing timeouts, especially Time_Wait and UDP down to 10s.

    If you reduce your ConnTrack table size, then you will get "CT table full" messages, rather than "out of memory" catastrophes.
     
  5. Rally

    Rally Addicted to LI Member

    Ok, I'll keep that in mind.

    And now I'm off to torrent something really big to see if I can reproduce the issue.
     
  6. Rally

    Rally Addicted to LI Member

    Maybe I'm just wasting your time because I haven't been able to reproduce the crash event. Maybe it will never happen again.

    Anyway, I've found this on the log from earlier:

    Dec 12 11:06:10 unknown user.warn kernel: nvram_commit(): init
    Dec 12 11:06:10 unknown user.warn kernel: nvram_commit: out of memory

    Is it related? Is it dangerous?
     
  7. Planiwa

    Planiwa LI Guru Member

    Did you make configuration changes at that time? Were they completed?

    What I would do is to monitor both the connections and the memory closely.
    But this requires a minimal adeptness with the command line interface.

    I have various commands to do such monitoring ... if there's interest, I'll post the latest version of Vit, which displays vital statistics of the system, including connections and memory.

    Looks like this:

    Code:
    # vit -M
    LANClients Connections Free,Cached,Buffered,Active,Inactive(KiBi) Load Processes FWUptime WANUptime SysUptime Interface<Dn>Up ...
    VIT: br0:2   3 F:628 C:4504 B:1024 A:4388 I:3028 .0 1/25 12d 12d 16d ppp0<878>4005 eth1<36>726
    # 
    
    Or, if run from Scheduler with output to syslog:

    Code:
    Dec 12 16:15:02 ROUTER user.info VIT: br0:2  22 F:912 C:4464 B:1024 A:4328 I:2880 .0 1/24 11d 11d 16d ppp0<697>3997 eth1<4148>717
    Dec 12 16:30:03 ROUTER user.info VIT: br0:2 270 F:904 C:4472 B:1024 A:4336 I:2880 .0 1/24 11d 11d 16d ppp0<753>3998 eth1<4205>719
    Dec 12 16:45:02 ROUTER user.info VIT: br0:2 283 F:896 C:4476 B:1024 A:4336 I:2884 .1 1/24 11d 11d 16d ppp0<771>4000 eth1<4223>720
    Dec 12 17:00:03 ROUTER user.info VIT: br0:2 295 F:864 C:4504 B:1024 A:4388 I:2864 .0 2/24 11d 11d 16d ppp0<782>4001 eth1<4233>721
    Dec 12 17:15:03 ROUTER user.info VIT: br0:2 291 F:864 C:4504 B:1024 A:4388 I:2864 .0 1/24 11d 11d 16d ppp0<818>4002 eth1<4270>723
    Dec 12 17:30:02 ROUTER user.info VIT: br0:2 377 F:864 C:4504 B:1024 A:4388 I:2864 .0 2/24 12d 12d 16d ppp0<830>4003 eth1<4282>724
    Dec 12 17:45:02 ROUTER user.info VIT: br0:2 227 F:552 C:4504 B:1024 A:4388 I:3120 .0 1/26 12d 12d 16d ppp0<877>4005 eth1<35>726
    
    Note the 32-bit rollover (2^32=4295M)
     
  8. Rally

    Rally Addicted to LI Member

    Didn't make the changes, I wanted to bring about the crash again.

    In the end, it didn't crash and one think surprised me. Memory usage barely moved during the whole time, plenty was free at all times. Is that normal? Anyway, I don't think torrents caused the crash. Test graph here:
    [​IMG]

    I am still interested in this vit tool. It might help me look deeper into the issue, show me. I already know how to use the command line.
     
  9. Slimey

    Slimey Network Guru Member

  10. Rally

    Rally Addicted to LI Member

    I think everything is going to be ok now.

    And I'm not too hot for flashing another new firmware on my thing. It's risky you know.
     
  11. Toastman

    Toastman Super Moderator Staff Member Member

    Why do you say it is risky?
     
  12. TVTV

    TVTV LI Guru Member

    The power might cut out, the OS may crash, IE or FF may crash etc. :p
     
  13. Planiwa

    Planiwa LI Guru Member

    Good attitude. :)

    Unless you watched the memory and the connections at sub-minute intervals, how can you be sure that memory and connections did not fluctuate wildly for a few seconds?

    Might want to run cflp (checking every 15s) for a while to monitor connection surges and memory changes.

    Vit gives more detail, but I wouldn't run it more ofen than once a minute.

    Code:
    # cflp -- minimalist Vital Stats # Planiwa 2009-12-13 [ May not work before V1.25 ]
    # 1. Enable JFFS and format it. (Administration > JFFS2)
    # 2. To keep the logs in JFFS (not recommended except for accute trouble-shooting):
    #    Place the "JFFS" line last, where it says so below ...
    # 3. Copy this to /jffs/cflp, make it executable with chmod +x /jffs/cflp
    # 4. After post-crash reboot, examine the recent entries in /jffs/CFLP
    # To start, run this from the command line: nohup sh /jffs/cflp &
    #    Or place /jffs/cflp into your Init Script
    
    FSDIR=/cifs1; DIR=CFLP; SUF=".txt" # put this line last, to use CIFS
    FSDIR=/jffs;  DIR=CFLP; SUF=""     # put this line last, to use JFFS (short-time only!)
    FSDIR=/tmp                         # put this line last, to use volatile RAM
    
    SLEEPSECDEFAULT=15
    CONRISE=100
    CONMIN=1000
    
    logger -p info -t $DIR "Starting ... $$"
    
    cd $FSDIR; if [ $? -ne 0 ];then logger -p error -t $DIR "Cannot cd to $FSDIR $$";exit;fi
    mkdir -p $DIR 
    
    cd $DIR; if [ $? -ne 0 ];then logger -p error -t $DIR "Cannot cd to $FSDIR/$DIR $$";exit;fi
    while :;do
    
      if [ -r /tmp/${DIR}SLEEPSEC ];then SLEEPSEC=$(cat /tmp/${DIR}SLEEPSEC)
      else SLEEPSEC=$SLEEPSECDEFAULT
      fi
    
      set -- $(cat /proc/meminfo); set -- $((${10}+${13})) ${10}
      CF=${1%???}; FR=${2%???}; FRE=$CF-$FR
    
      set -- $(cat /proc/loadavg)
      LOADL=${1%.*}; LOADL=${LOADL#0}; LOADR=${1#*.}; LOADR=${LOADR#0};
      LOADR=$(((LOADR+5)/10)); case $LOADR in 10)LOADR=9;;esac; LOA=$LOADL.$LOADR
      LD=$LOADL$LOADR
      PRO=${4#*/}
    
      USE=$(arp | wc -l) # set -- $(wl assoclist); USE=$(($#/2))
    
      if [ -r /proc/sys/net/ipv4/ip_conntrack_count ]
      then CON=$(cat /proc/sys/net/ipv4/ip_conntrack_count) ### Thanks, Teddy Bear!
      else CON=$(cat /proc/net/ip_conntrack | wc -l)        ### This is very costly
      fi
    
      MMSS=$(date +%M%S)
      HH=$(date +%H)
    
      if [ "$HH" != "$LASTHH" ];then
        TIMESTAMP="$(date '+%Y-%m-%d %H:%M:%S')"
        set -- $TIMESTAMP; YMD=$1; HMS=$2
        if [ "$LASTHH" == "" ];then ### First Time Ever
          case $TIMESTAMP in 19*) sleep $SLEEPSEC; continue;; esac # wait for NTP
          sleep 3;  if [ -r /tmp/${DIR}$$ ];then ID=$(cat /tmp/${DIR}$$);else ID=$$;fi
    
          # if another process is running, kill it
          if [ -r $HH$SUF ];then
            FILESEC=$(date -r $HH$SUF '+%s'); NOWSEC=$(date '+%s'); FILESECS=$((NOWSEC-FILESEC))
            if [ $FILESECS -lt 4000 ];then
              set -- $(grep $YMD $HH$SUF|tail -1)
              logger -p error -t $DIR "Duplicate Process ($3) Terminated by $ID"
              kill $3 || logger -p error -t $DIR "Failed to kill $3 [$*] by $ID"
            fi
          fi
    
          echo "$TIMESTAMP $ID RESTART" >> $HH$SUF
        else # Not first time
          echo "$TIMESTAMP $ID" > $HH$SUF ## erase 24h old hourlog
        fi
        echo "MMSS PR U LA FTOT-FMEM CON" >> $HH$SUF
        logger -p info -t $DIR "$PRO $USE $LOA $FRE $CON (${SLEEPSEC}s) $FSDIR/$DIR $ID"
      fi
    
    # Significance Thresholds: CON>>$CONRISE CON>$CONMIN CF<<400 FR<400 CF<2000 LD>.3 PRO>30
    
      # TT, etc is debug
      TT=0; TP=0; TL=0; TFD=0; TFT=0; TFM=0; TCR=0; TC=0 
      if [ "$HH" != "$LASTHH" ];then TT=1;fi
      if [ $PRO -ge 30 ];then TP=1;fi
      if [ $LD -ge 5 ];then TL=1;fi
      if [ $((${LASTFRE%-*}-CF)) -ge 400 ];then TFD=1;fi
      if [ $CF -lt 2000 ];then TFT=1;fi
      if [ $FR -lt 400 ];then TFM=1;fi
      if [ $((CON-LASTCON)) -ge $CONRISE ];then TCR=1;fi
      if [ $CON -ge $CONMIN ];then TC=1;fi
    
      if [ $CON -ge $CONMIN ]||[ $CF -lt 2000 ]||[ $FR -lt 400 ]||[ $LD -ge 5 ]||[ $PRO -ge 30 ]||[ $((CON-LASTCON)) -ge $CONRISE ]||[ $((${LASTFRE%-*}-CF)) -ge 400 ]||[ "$HH" != "$LASTHH" ];then
        # TT, etc is debug
        echo "$MMSS $PRO $USE $LOA $FRE $CON  $TT$TP$TL $TFD$TFT$TFM $TCR$TC" >> $HH$SUF
      fi
      LASTCON=$CON; LASTFRE=$FRE # LAST means "last interval", not "last output"
    
      LASTHH=$HH
      sleep $SLEEPSEC
    
    done &
    logger -p info -t $DIR "$$ ==> $! [Can change Interval in /tmp/${DIR}SLEEPSEC]"
    echo "$!" >/tmp/$DIR$$
    ### end CFLP
    
    
    Code:
    # vit: Vital Stats # Planiwa 2009-12-12
    
    INTERFACES="ppp0 eth1"; HALF=500; DIVI=1000; CONDIV=1; COUNTWHAT="bytes" # Defaults
    while [ $# -gt 0 ]
    do
    	case "$1" in
    	-*elp|-\?|-h) echo "Syntax		vit [-h] [-H] [-k] [-p] [-t] [-dir] [-I] [Interface ...]
            Could put this in /jffs/vit and run it from Scheduler, eg: /jffs/vit -l -H -M
    -h		This help
    -H		Don't show title headers
    -k		Show kiloBytes instead of MegaBytes, or kiloPackets instead of Packets
    -c		Show connections/100 instead of connections
    -p		Packets instead of Bytes
    -d		Prepend Datestamp
    -s SLEEPSEC	Repeat every SLEEPSEC seconds, until interrupted
    -l              Send output to syslog
    -dir DIR	Write output to file HHMM in directory DIR.
    		NB: Use CRU in INIT script to control exact Minute!  (Scheduler is unpredictable.)
    		eg: cru a Vit '01,16,31,46 * * * * /jffs/vit -d -p -dir /jffs/vitlog'
    -M		Show all Memory measures: Free Cached Buffered Active Inactive (in KiBi)
    -I		Show all Interfaces
    Interface ...	one or more interfaces.  Default: $INTERFACES
    " ;exit;;
        -H) NOHEADERS="Y";;
        -c) CONDIV=100;;
        -k) HALF=0; DIVI=1; KILO="kilo";; ### meaning of kilo is reversed for packets and bytes
        -p) COUNTWHAT="packets";;
        -M) ALLMEM="Y";;
        -I) INTERFACES="$(ifconfig|awk '/Link/{print$1}')";;
        -dir) DIR=$2; mkdir -p $DIR; HHMM=$(date '+%H%M'); shift;; ### write to file HHMM in $DIR
        -d) DATESTAMP=Y;;
        -l) LOGGER=Y;;
        -s) SLEEPSEC=$2;shift;;
        -s*) SLEEPSEC=${1#-s};;
    	-*) echo "vit: unrecognized paramter: $1"; set -- SHIFT -h;;
        *)  INTERFACES="$*"; break ;;
        esac
        shift
    done
    if [ "$NOHEADERS" == "" ];then
    case $ALLMEM in
    Y) echo "LANClients Connections Free,Cached,Buffered,Active,Inactive(KiBi) Load Processes FWUptime WANUptime SysUptime Interface<Dn>Up ...";;
    *) echo "LANClients Connections Free+Cached,Free(KiBi) Load Processes FWUptime WANUptime SysUptime Interface<Dn>Up ...";;
    esac; fi
    case $KILO$COUNTWHAT in
    kilopackets) HALF=500; DIVI=1000;;
    packets) HALF=0; DIVI=1;;
    esac
    
    while :;do
    if [ "$DATESTAMP" != "" ];then DATESTAMP="$(date '+%y%m%d_%H:%M:%S') "; fi
    
    set -- $(cat /proc/meminfo)
    case $ALLMEM in
    Y) MEM="F:${22} C:${31} B:${28} A:${37} I:${40}" ;;
    *) MEM="FC:$((${22}+${31})) F:${22}" ;;
    esac
    
    if [ -r /proc/sys/net/ipv4/ip_conntrack_count ]
    then CON=$(cat /proc/sys/net/ipv4/ip_conntrack_count) ### Thanks, Teddy Bear!
    else CON=$(cat /proc/net/ip_conntrack | wc -l)        ### This is very costly
    fi
    CON=$((CON/CONDIV))
    
    USE=$(arp|awk '/vlan1/{next};{N[$NF]++};END{for (i in N) print i ":" N[i]}')
    
    
    set -- $(cat /proc/loadavg)
    P=$4
    LOADL=${1%.*}; LOADL=${LOADL#0}; LOADR=${1#*.}; LOADR=${LOADR#0};
    LOADR=$(((LOADR+5)/10)); case $LOADR in 10)LOADR=9;;esac; LOAD=$LOADL.$LOADR
    
    X="";Y="";Z=""; for IF in $INTERFACES;do
      set -- $(ifconfig $IF |grep "$COUNTWHAT:")
      ### Beware: counters are reset at 4.3 GB (mod 2^32) ###
      case $# in
      0) Z="$Z $IF:Down";;
      *) case $COUNTWHAT in
         bytes)   RX=$2; TX=$6;;
         packets) RX=$2; TX=$8;;
         esac
         case $IF in ## these need some work, especially with unusual hardware or setups such as MLPPP
         ppp0|eth0|vlan1) X="$X $IF ${RX#*:} ${TX#*:}";; ## Up from router
         eth1|br0|*)      X="$X $IF ${TX#*:} ${RX#*:}";; ## Down from router
         esac;;
      esac
    done
    set -- $X; for X in $*;do
      case $X in
      [0-9]*) case $KILO$COUNTWHAT in
              *bytes)      if [ ${#X} -le 3 ];then X=0;else X=${X%???};fi; Y="$Y $(((X+$HALF)/$DIVI))";;
              *packets) Y="$Y $(((X+$HALF)/$DIVI))";;
              esac;;
      *)      Y="$Y $X";;
      esac
    done
    set -- $Y
    while [ $# -ge 3 ];do
      Z="$Z $1<$2>$3"
      shift 3
    done
    
    NOWSEC=$(date '+%s')
    
    BOOSEC=$(cat /proc/stat|grep btime); BOOSEC=${BOOSEC#* }
    BOOSECS=$((NOWSEC-BOOSEC))
    D=$((BOOSECS/86400));if [ $D -ge 2 ];then BOOTIME=${D}d;else
    H=$((BOOSECS/3600));if [ $H -ge 2 ];then BOOTIME=${H}h;else
    M=$((BOOSECS/60));if [ $M -ge 2 ];then BOOTIME=${M}m;else
    BOOTIME=${BOOSECS}s;fi;fi;fi
    #BOODATE=$(cat /proc/stat|grep btime|awk '{print strftime("%m%d.%H:%M",$2)}')
    
    WANSEC=$(date -r /var/lib/misc/wantime '+%s')
    if [ $WANSEC -lt 999999 ];then WANSECS=$WANSEC;WANPRE='+';else WANSECS=$((NOWSEC-WANSEC));WANPRE="";fi
    D=$((WANSECS/86400));if [ $D -ge 2 ];then WANTIME=${D}d;else
    H=$((WANSECS/3600));if [ $H -ge 2 ];then WANTIME=${H}h;else
    M=$((WANSECS/60));if [ $M -ge 2 ];then WANTIME=${M}m;else
    WANTIME=${WANSECS}s;fi;fi;fi
    #WANDATE=$(date -r /var/lib/misc/wantime '+%y%m%d.%H:%M')
    
    if [ -r /tmp/script_fire.sh ];then # recommend having a FW Script, even if only ":"
    FIRSEC=$(date -r /tmp/script_fire.sh '+%s')
    if [ $FIRSEC -lt 999999 ];then FIRSECS=$FIRSEC;FIRPRE='+';else FIRSECS=$((NOWSEC-FIRSEC));FIRPRE="";fi
    D=$((FIRSECS/86400));if [ $D -ge 2 ];then FIRTIME=${D}d;else
    H=$((FIRSECS/3600));if [ $H -ge 2 ];then FIRTIME=${H}h;else
    M=$((FIRSECS/60));if [ $M -ge 2 ];then FIRTIME=${M}m;else
    FIRTIME=${FIRSECS}s;fi;fi;fi
    else FIRTIME="?"
    fi
    
    while [ ${#CON} -lt 3 ];do CON=" $CON"; done
    OUTLINE="$DATESTAMP$USE $CON $MEM $LOAD $P $FIRPRE$FIRTIME $WANPRE$WANTIME $BOOTIME ${Z# }"
    if [ "$DIR" != "" ];then echo "VIT: $OUTLINE" > $DIR/$HHMM; exit; fi
    if [ "$LOGGER" != "" ];then logger -p info -t VIT "$OUTLINE"; exit; fi
    case "$(cat /proc/$PPID/cmdline)" in
    */tmp/sc[hr]*.sh) logger -p info -t VIT "$OUTLINE" ;; # Scheduler / Adm Script
    *)                echo             "VIT: $OUTLINE" ;; # Interactive Shell
    esac
    if [ "$SLEEPSEC" == "" ];then exit; else sleep $SLEEPSEC; fi
    done
    
     
  14. Rally

    Rally Addicted to LI Member

    Ok, thanks Plainwa. I'll get right on it after I recover, I'm sick right now.
     

Share This Page