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

"Definitive" guide to istatd installation on base Tomato (work in progress!)

Discussion in 'Tomato Firmware' started by rhester72, Apr 28, 2010.

  1. rhester72

    rhester72 Network Guru Member

    Read the *ENTIRE GUIDE* _before_ proceeding!

    This guide assumes you want external/WAN access to istatd, exclude the appropriate instructions if you do not.

    - scp istatd (http://multics.dynalias.com/tomato/PRECOMPILED/istatd) to a permanent mount (/jffs, /cifs1, etc.)
    - Execute "chmod u+x /<mountpoint>/istatd"
    - scp istatd.conf (attached as istat_conf.zip, unzip prior to scp) to a permanent mount (/jffs, /cifs1, etc.)

    STOP! Examine and edit istatd.conf if necessary - the defaults should work "out of the box" but you will almost certainly want to tune the disk parameters at minimum (if not the network and path parameters).

    Administration/Scripts/WAN Up (can be placed at beginning or end, will wait up to 15 seconds by default for mountpoint to appear before bailing out to give external mounts time on first boot):

    NOTE: Replace <mountpoint> with a valid directory containing istatd (e.g. /jffs) prior to pasting/saving!


    Code:
    PID=/var/run/istatd.pid
    MP=<mountpoint> # Change this to the appropriate location, e.g. /jffs
    if [ -f $PID ];then
     kill `cat $PID`
     rm $PID
     RE=re
    else
     RE=
    fi
    t=0
    mt=15
    while [[ ! -f $MP/istatd && $t -lt $mt ]];do
     t=$(( $t+1 ))
     sleep 1
    done
    if [ $t -eq $mt ];then
     logger -t istatd -p err NOT started, mountpoint $MP unavailable after $mt seconds
    else
     $MP/istatd -d -c $MP/istat.conf
     sleep 1
     logger -t istatd -p info ${RE}started, listening on `netstat -l|grep tcp|grep 5109|awk '{print $4}'`
    fi
    
    Reboot, and istatd should be running with your desired configuration. If you encounter problems, verify that a) any changes that you made to istat.conf are valid and b) that you set the MP variable in the WAN Up script to the correct path (without a trailing slash!).

    If you want to also be able to get to istatd from your WAN/Internet, do the following:

    Administration/Scripts/Firewall:

    Code:
    iptables -I INPUT 1 -p tcp --dport 5109 -j ACCEPT
    
    Port Forwarding/Basic:

    Code:
    On  Proto  Src Address  Ext Ports  Int Port  Int Address  Description
    
    On  TCP    <blank>      5109       <blank>   192.168.1.1  iStat
    
    Change the value for "Int Address" to the correct interface IP for your local LAN (the default is given, you should care about this only if you have changed the LAN IP for your router or set the network_addr value in istat.conf). Reboot and test.

    Good luck! I do not actually have the iPhone application that depends on this, so please let me know if you have problems and I'll do what I can to help. It at least gives answers when I 'fake' an iPhone client via telnet, so I have reason to believe it might actually work. ;)

    Rodney
     

    Attached Files:

  2. occamsrazor

    occamsrazor Network Guru Member

    This looks like a much better method than what was in the other thread (not that I understand any of the above!)

    I don't have time right now to try this out, but I did manage (clumsily) to get istatd running in the end using the info from your later posts in the other thread. Suggest new users start with the above method, and to tempt those who are wondering what this is about... see the screenshot attached!!

    The conf file still needs some tweaking (e.g. choosing which disk space to monitor, setting network interface to monitor, etc), but this is going to be really nice indeed...
     

    Attached Files:

  3. sydlexia

    sydlexia Addicted to LI Member

    Hi, I've been trying to get istatd running to no avail. I've read through both this guide and the posts from the previous thread several times. The problem I am having is that when I attempt to invoke istatd from a start-up script or from the shell it exits immediately with "User defined signal 1", nothing in the log file, and no istatd running in the proc table.

    I have tried both the precompiled dynamic and static binaries with the identical result. Im thinking there must be something missing from my environment, hopefully someone can point me in the right direction.

    I'm running Tomato 1.27 on a WRT54GL
    Code:
    # nvram find version
    Intel_firmware_version=v1.41.8
    bcm4712_firmware_version=v1.50.0
    ezc_version=2
    firmware_version=v4.30.11
    os_version=1.27.1798
    
    The relevant portion of my Wan-up script:
    Code:
    logger -t istatd -p info Attempting to start istatd server
    PID=/var/run/istatd.pid
    MP=/jffs
    if [ -f $PID ];then
        kill `cat $PID`
        rm $PID
        RE=re
    else
        RE=
    fi
    t=0
    mt=15
    while [[ ! -f $MP/istatd && $t -lt $mt ]];do
        t=$(( $t+1 ))
        sleep 1
    done
    if [ $t -eq $mt ];then
        logger -t istatd -p err NOT started, mountpoint $MP unavailable after $mt seconds
    else
        $MP/istatd -d -c $MP/istat.conf
        sleep 1
        logger -t istatd -p info ${RE}started, listening on `netstat -l|grep tcp|grep 5109|awk '{print $4}'`
    fi
    
    istat.conf:
    Code:
    network_addr    192.168.1.1
    server_code    12345
    server_user    nobody
    server_group    nobody
    server_pid    /var/run/istatd.pid
    cache_dir    /tmp
    monitor_net    ( br0 )
    monitor_disk    ( /jffs )
    disk_mount_path_label    1
    disk_filesystem_label    1
    
    I should note that I tried running istatd both as user nobody and as root by commenting the server_user and server_group variables within istat.conf
    Both with the same result.

    Let me know if there is any additional information I should be providing to help sort this out.

    TIA for any help.

    ~scott
     
  4. rhester72

    rhester72 Network Guru Member

    Do you have enough free RAM? Anything of interest in dmesg or /var/log/messages? Does /jffs exist/is mounted? If you try to launch directly from CLI what do you see?

    Rodney
     
  5. sydlexia

    sydlexia Addicted to LI Member

    Thanks for your quick reply.

    Good question regarding free memory. Not sure how much is required, but this is what I'm working with.. (not much)

    Code:
    # free
                  total         used         free       shared      buffers
      Mem:        14528        13060         1468            0         1272
     Swap:            0            0            0
    Total:        14528        13060         1468
    
    /jffs is mounted:

    Code:
    # df -k /jffs
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/mtdblock/3           1024       852       172  83% /jffs
    
    both binary and config file reside in /jffs

    Code:
    # ls -l /jffs/istat*
    -rw-r--r--    1 root     root         1827 May 10 02:55 /jffs/istat.conf
    -rwxr-xr-x    1 root     root       319488 May 10 02:47 /jffs/istatd
    
    when run from the shell it exits with what is shown below. Nothing in the logs and nothing out of the ordinary in dmesg.

    Code:
    # ./istatd -c /jffs/istat.conf
    User defined signal 1
    #
    
     
  6. rhester72

    rhester72 Network Guru Member

    That definitely is coming from the kernel and not istatd itself, I just checked the source.

    A little Google-fu suggests you're overflowing the stack. Please check the following:

    - Make sure that "Administration/Debugging/Count cache memory and buffers as free memory" _is_ checked
    - Once that's done, go to Status/Free Memory and see if it lines up with what you're seeing in "free" (since you appear to be running 1.27 stock, it probably won't - the Status page number is the more accurate one)
    - From the shell, execute "ulimit -a" and paste the results here

    Rodney
     
  7. sydlexia

    sydlexia Addicted to LI Member

    Ok, I made sure "Count cache memory and buffers as free memory" is checked, and Status | Overview | System | Total / Free Memory reports: 14.19 MB / 6,652.00 KB (45.79%)

    ulimit returns the following
    Code:
     # ulimit -a
    time(seconds)        unlimited
    file(blocks)         unlimited
    data(kb)             unlimited
    stack(kb)            8192
    coredump(blocks)     0
    memory(kb)           unlimited
    locked memory(kb)    unlimited
    process              128
    nofiles              1024
    vmemory(kb)          unlimited
    locks                unlimited
    
     
  8. rhester72

    rhester72 Network Guru Member

    Hrm. I don't immediately see any problems here - best guesses at this point is that either istatd requires more RAM than you have (possible, but unlikely) or that it (as compiled) is dependent on some K26-specific kernel service.

    I'll poke around a bit more.

    Rodney
     
  9. occamsrazor

    occamsrazor Network Guru Member

    Hi Rodney,

    Sorry for not being able to try this sooner... I had it working the "old" way but now have it working this way - very nice. It took me a while because I'd forgotten I'd changed the listening port in my iphone istat app, and forgot to add it back in in the istat.conf file.

    If anyone else wants to change the listening port, just add this line to the conf file:

    Code:
    network_port             5109
    
    ...and change the default 5109 to the port you want.

    One question, in the "old" way, I had these lines in my init script:

    Code:
    ## Create iStat directories
    mkdir -p /var/run/istat
    mkdir -p /var/cache/istat
    
    ## Set permissions of istatd
    chmod u+x /jffs/istatd
    
    ## Softlink istat.conf file to /etc
    ln -fs /jffs/istat.conf /etc
    
    I've kept them in but are they still necessary with your script above? I'm thinking it's worth keeping in the chmod one in case I update the istatd file in future and forget to chmod it, but what about the other two?

    Also, in your script I see this line:

    Code:
     logger -t istatd -p info ${RE}started, listening on `netstat -l|grep tcp|grep 5109|awk '{print $4}'`
    
    What does the grep 5109 do? and does it need to be changed to the listening port if I've changed that?

    Here's a new screenshot, this time showing the disk usage for jffs & cifs1 working....
     

    Attached Files:

  10. rhester72

    rhester72 Network Guru Member

    My solution puts the PID file in /var/run (not /var/run/istat), so you don't need that, and the path to /var/cache/istat is changed in istat.conf, the second mkdir won't be needed either. You can of course put them wherever you like, they just have to exist. (I believe I put the cache in /tmp since it's just a single file that doesn't need to persist across reboots.)

    The chmod can't hurt.

    The softlink isn't needed either since I'm declaring the path to istat.conf as part of the istatd command line.

    It just grabs the IP address that istatd bound to. If you keep the logging as-is (merely a metter of convenience/handy debugging), you should change the port to match istat.conf, yes.

    Rodney
     
  11. occamsrazor

    occamsrazor Network Guru Member

  12. occamsrazor

    occamsrazor Network Guru Member

    Three year necro-resurrection :)

    Anyone still using this and have it running? Mine stopped working ages ago and was trying to get it going again today. I'm using the script in the first post. I don't see istatd in the active process list so it doesn't seem to be loading. Back then I was running K24 and now K26, not sure if that could be an issue.
     

Share This Page