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

Logfile to jffs2

Discussion in 'Tomato Firmware' started by willi007, Oct 10, 2007.

  1. willi007

    willi007 LI Guru Member

    Hi,
    my WRT54GL now uses the tomato 1.09 - GREAT !
    I need a script to write the logfile (from status-menu) to the jffs2. Can someone please help me and has such a script?
    Thanks!
    Willi
     
  2. mstombs

    mstombs Network Guru Member

    How about this single command which copies the current message log to a date and time stamped archive on jffs?

    Code:
    cp /var/log/messages.* /jffs/log$(date '+%Y%m%d%H%M%S')
     
  3. mraneri

    mraneri LI Guru Member

    Careful with frequent writes to JFFS...

    Flash DOES wear out.. (May be 100k cycles or more... Depends on the technology.)

    I've actually been looking to e-mail the logs on a routine basis (whenever they get rotated), but there's not built-in tools to e-mail.
     
  4. mstombs

    mstombs Network Guru Member

    Absolutely agree, I hope jffs format properly cycles round to even wear but 100k seconds = 27 hours so continuous logging to flash could wear it out in days! I assumed the OP just wanted to do it every few days or before upgrade/reboot?
     
  5. danix71

    danix71 LI Guru Member

    But normally, where the logs go ? I mean, where is it ?
     
  6. mstombs

    mstombs Network Guru Member

    /var/log/messages.*

    which is a ram disk, would have to look in the source for the exact algorithm but "messages" holds the recent messages and "messages.0" older ones. I guess when "messages" reach a certain size it is copied over .0 and started afresh - not having a maximum size would lead to the classic system crash "Error - can't write to system log" (repeat until reboot!)
     
  7. danix71

    danix71 LI Guru Member

    So, if are in RAM, a reboot from time to time is necessary for not crashing the router, right ?
     
  8. mstombs

    mstombs Network Guru Member

    Wrong - the maximum size of logfile is defined, and old messages are overwritten - see the config of the logger function in the firmware, implemented by busysbox syslogd.c for example - Hyperwrt Thibor15c (viewable from google.com/codesearch) seems to default to 200k files.

    You can also log directly to a network machine.
     
  9. danix71

    danix71 LI Guru Member

    Oke thanks ! :thumbup:
     
  10. willi007

    willi007 LI Guru Member

    Thanks a lot!
    ok, jffs is not optimal, but logging to a network would be interest. But which network or server can do this for free? Do you know an adress?
     
  11. mstombs

    mstombs Network Guru Member

    With emphasis on 'free' Linksys used to give out a logViewer app - there is still a couple on their ftp site (/pub/utility, /pub/befsr41), not sure whether they still work with windows or Tomato, but remote logging is not a new function!

    Edit: Yes the wap54g one still works!
     
  12. mraneri

    mraneri LI Guru Member

    In the Stock Tomato configuration, Logs are rotated as previously stated. Log size in Tomato defaults at 50k, with one rotated log history.

    So, at most, there is 100k memory used up for log files on the RAM disk. (by default, of course)

    The router won't crash... If you want, you could probably come up with a script to run on a cron every 30 minutes that looks for the presence of a messages.0 file (means a 50k log rotated out) and MOVE it to JFFS (renaming it, so you don't overwrite an old log). So within 30 minutes of a log being rotated out, it's moved.

    This is almost exactly what I want to do, but instead of copying to JFFS and deleting, I want to e-mail it to myself, and delete it. (I don't run JFFS at all.)
     
  13. mstombs

    mstombs Network Guru Member

    I have just tested copying a mailer binary from my adsl modem to my router, they are similar Linux 2.4 mipsle versions

    Code:
    # ls -laF msmtp
    -rwxr-xr-x    1 root     root        96836 May 16 22:14 msmtp*
    
    #/jffs/msmtp --version
    msmtp version 1.4.7
    ...and it works, they can both now send me emails when they boot!

    I have the source distributed by Routertech.org originally from http://msmtp.sourceforge.net/ and see if I can compile it myself sometime...
     

Share This Page