TiVoWeb's get_space.c

Discussion in 'TiVo Series 1 - UK' started by andyjenkins, Nov 27, 2005.

  1. andyjenkins

    andyjenkins New Member

    258
    0
    Jul 29, 2001
    England, UK
    Probably absolutely no need, but after some good success with RRD and my router, I'm now trying to get RRD working with TiVo. One of the first things I need is to obviously get some metrics.

    Looking at TiVoWeb's 'Info' page - that seems to have all the info I could need (uptime, diskspace usage etc etc), but I'm struggling how to get the values extracted. I'm going to have to perl script the getting routine on my WebServer - so the format they come out of Tivo is of little concern to me.

    I found 'get_space.c' but this returns some values, which I'm struggling to associate with any amount of capacity on my disks in TiVo.

    Eg, an execution of get_space returns "785104 588968 310677504 21608448". According to info.itcl, there's some math done (/2/1024), but this is 162919 and means nothing to me .. is that total diskspace? If so - thats difference to what TiVoWeb's info panel is showing (which is 151698).

    Any ideas?
     
  2. Spire

    Spire Fallen

    5,031
    6
    Jun 6, 2001
    Everywhere...
    The call to get_totalsizes executes the get_space binary appropriate to your platform, which in turn returns four values in a single string.

    The first, second, and fourth value returned by get_space are discarded. The third value is assigned to the variable totalmedia.

    A second variable, usersize is calculated by taking totalmedia, dividing it by 2 and then by 1024, and then rounding down the result.

    In your example, the third value returned by get_space is 310677504, which gets assigned to totalmedia. Dividing that by 2 and then 1024 and rounding that down, you get 151,698, which is assigned to usersize. This the same value that is displayed as Total Space in the Space Summary section on the Info page.
     
  3. andyjenkins

    andyjenkins New Member

    258
    0
    Jul 29, 2001
    England, UK
    Thanks Spire, so is TotalSpace really equivical to the total amount of recording space on the disk (not free, just total - ie taking into account used and free) ?
     
  4. Spire

    Spire Fallen

    5,031
    6
    Jun 6, 2001
    Everywhere...
    It appears to be the total space available for all recordings, including the hidden reserved space used for recording promotional content.

    I can't vouch for the accuracy of this value; after all, it's returned by a closed-source binary, and space calculation on the TiVo platform is something of a black art to begin with. However, on my various TiVo units, it does seem to be at least in the right ballpark.
     
  5. andyjenkins

    andyjenkins New Member

    258
    0
    Jul 29, 2001
    England, UK
    Again, thanks Spire. I should've looked further into this before posting as to getting total space though - as trying to split the further metrics out looks long winded.

    Unless I simply do a http get through a perl script and parse the HTML output - but thats ugly.

    Maybe I'll have a think on how (if!) to proceed.

    Thanks again though - appriciate it.
     
  6. Spire

    Spire Fallen

    5,031
    6
    Jun 6, 2001
    Everywhere...
    As you've seen, info.itcl does a lot of complicated stuff behind the scenes to arrive at the information that it displays. Much of what it does is buried layers deep, scattered about, and going back as far as the initialization of TiVoWeb[Plus] itself. Reimplementing all of this logic in your own script might be more trouble than it's worth.

    Practically speaking, I think your idea to simply parse the output of the Info page is a step in the right direction. I'd go further and look into creating a customized version of info.itcl that dumps only the information you need -- formatted the way you want it, and without all of that messy HTML markup. That would make it much easier for your Perl script to parse, and faster to boot.
     
  7. tefster

    tefster New Member

    300
    0
    Mar 15, 2004
    London (NE), UK
    LJ has some Tivo/TivoWeb scripts pre-done which turn most of the salient data points into MRTG-ready data blocks, converting those to use with RRD should be simple.

    Your best bet would be as mentioned above to just customise the info scripts to dump out the raw data, or if you write a standalone cron'd script to dump them to a text file then I have a TivoWeb module available that serves arbitrary text files back to browsers.

    Failing that I do have a tool on my unix boxes I wrote which screen-scrapes HTML screens and produces RRD-ready output, which I use for pulling stats from systems which only provide statistics via HTTP-interfaces. I've been meaning for ages to tidy that up and produce scrape-maps for TivoWeb screens, I'll try and get around to that.
     
  8. andyjenkins

    andyjenkins New Member

    258
    0
    Jul 29, 2001
    England, UK
    Yes, I found LJ's scripts do pretty much what I'm after. Its not as flexible or complete as I'd like, but its a start at least ;o)
     
  9. andyjenkins

    andyjenkins New Member

    258
    0
    Jul 29, 2001
    England, UK
    Anyone else using LJ's 'mrtgdata' ?

    I find it's unusable - every call makes TiVo stutter in its playback - making use of the a script calling the html impossible in reality.

    Anyone using the script without such an impact? Maybe some config I need on TiVo?
     
  10. LJ

    LJ New Member

    786
    0
    Nov 11, 2001
    West...
    Works fine for me ;) Do you run lots of, ahem, other utilities on your TiVo?
     
  11. andyjenkins

    andyjenkins New Member

    258
    0
    Jul 29, 2001
    England, UK
    Ah, the man himself :)

    Not really .. there's TiVoWeb (obviously) and thats about it thats running at the moment I think. MSFTP etc is disabled.

    What I have noticed is that half of the stats appear straight away with no stutter - its one of the stats thats causing the pause .. not sure which one though .. yet :).

    edit : Its the 'DiskUsed' stat ... any ideas why ?
     
  12. LJ

    LJ New Member

    786
    0
    Nov 11, 2001
    West...
    Hello!

    It has to trawl through all the recordings to decide what space is in use / deleted / available etc, which takes quite a few disk accesses.

    I will *eventually* (Hi Ekuns, Milhouse,...! ;)) get around to posting the latest scripts which tidy unnecessary code in lj_mrtg and make it faster.
     
  13. andyjenkins

    andyjenkins New Member

    258
    0
    Jul 29, 2001
    England, UK
    Hi LJ .. sorry for the delay in getting back.

    Any timeframe on when this is likely to happen? This year? Next?

    Not that I'm pushy or anything ;o)
     
  14. LJ

    LJ New Member

    786
    0
    Nov 11, 2001
    West...
    Yes :p :D

    ...bit busy at the moment - over the Christmas - New Year break looks like a possibility...
     
  15. andyjenkins

    andyjenkins New Member

    258
    0
    Jul 29, 2001
    England, UK
    Marvelous :)

    Do me a favour? Make sure you publicise it eh?
     
  16. andyjenkins

    andyjenkins New Member

    258
    0
    Jul 29, 2001
    England, UK
    Sorry to bump and old thread, but I have today revisited my project to get all my devices monitored. TiVo is by far the most "critical" device to be monitored of course so has the highest need to get this project working.

    I'm using LJ's MRTG scripts has the base for yanking out metrics from TiVo - problem is, as above, the disk calculation is causing TiVo to pause whenever I get the metrics from the TiVo - hence its not really usable (for me) in this state. I know LJ said he was going to implement some others new ideas (maybe this would be the answer to my problem) but so far, there's been no update on this.

    So, has anyone got any ideas how to remove the disk calculations from lj_mrtg.itcl ? (attached).

    For anyone else contemplating what the graphs look like, attached is also a screenshot from todays activity.
     

    Attached Files:

  17. LJ

    LJ New Member

    786
    0
    Nov 11, 2001
    West...
    Funny you should bump this now... yesterday I got around to tidying up lj_mrtg.itcl and incorporting Ekuns suggestions (daily call detection that works on v3+ TiVos and single/dual tuner support for % recording time). All I need now is to make a generic version of the Perl script that feeds MRTG and then write some new documentation (bleh, documentation :p).

    Having said that the disk calculation code hasn't changed. Are you running, ahem, other things that use a lot of CPU? No one else has reported pauses when the stats are generated. Are all your hacks backgrounded? How many hacks are running?
     
  18. andyjenkins

    andyjenkins New Member

    258
    0
    Jul 29, 2001
    England, UK
    Great !
    Ah bum :(
    I rebooted TiVo last night and when she restarted (no hacks auto start as far as I'm aware) the only thing I started was TiVoWeb - thats it.

    Not sure if its worthy of mention, but I have replaced the disks mind - now have the original 40GB and a new 120GB in there (160GB total). Maybe the size is just a tad too large for realistic calculations?
     
  19. NCG_Mike

    NCG_Mike New Member

    39
    0
    Dec 13, 2003
    Bristol, UK
    I'm sorry... am I missing something given you're in Wessex?
     
  20. Quinten

    Quinten dutch tivo bloke

    49
    0
    Jun 4, 2002
    Bucks
    I've done a similar thing for monitoring HDD temperature and uptime. Except that I was having problems using a TCL page for retrieving the details, so I wrote (well, took YAC and slimmed it right down) a small C program which runs on the TiVo to which you can telnet and it reports the data back and then closes the connection. This combined with a small perl script on my RRD/cacti server gives me the data nicely, and it doesn't rely on TivoWeb at all.

    Have a look at my graphs. If anyone is interested in the source or binary, I can attach it here.
     

Share This Page