# TiVoWeb's get_space.c



## andyjenkins (Jul 29, 2001)

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?


----------



## Spire (Jun 6, 2001)

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.


----------



## andyjenkins (Jul 29, 2001)

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) ?


----------



## Spire (Jun 6, 2001)

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.


----------



## andyjenkins (Jul 29, 2001)

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.


----------



## Spire (Jun 6, 2001)

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.


----------



## tefster (Mar 15, 2004)

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.


----------



## andyjenkins (Jul 29, 2001)

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)


----------



## andyjenkins (Jul 29, 2001)

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?


----------



## 10203 (Nov 11, 2001)

Works fine for me  Do you run lots of, ahem, other utilities on your TiVo?


----------



## andyjenkins (Jul 29, 2001)

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 ?


----------



## 10203 (Nov 11, 2001)

andyjenkins said:


> Ah, the man himself


Hello!



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


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.


----------



## andyjenkins (Jul 29, 2001)

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)


----------



## 10203 (Nov 11, 2001)

andyjenkins said:


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


Yes  

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


----------



## andyjenkins (Jul 29, 2001)

Marvelous 

Do me a favour? Make sure you publicise it eh?


----------



## andyjenkins (Jul 29, 2001)

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.


----------



## 10203 (Nov 11, 2001)

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 ).

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?


----------



## andyjenkins (Jul 29, 2001)

LJ said:


> Funny you should bump this now


Great ! 


> Having said that the disk calculation code hasn't changed.


Ah bum 


> 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?


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?


----------



## NCG_Mike (Dec 13, 2003)

LJ said:


> ... incorporting Ekuns suggestions (daily call detection that works on v3+ TiVos and single/dual tuner support for % recording time).


I'm sorry... am I missing something given you're in Wessex?


----------



## Quinten (Jun 4, 2002)

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.


----------



## ekuns (Oct 10, 2005)

LJ, any update?  If it's documentation that's the delay, I'll help you write some.


----------



## mikerr (Jun 2, 2005)

To solve your stuttering problem you could look at setpri, and this thread:
http://www.tivocommunity.com/tivo-vb/showthread.php?t=332017

heh, just noticed the time gap of the posts on this thread


----------

