proc action_info {chan path env} { global db global tivoswversion global version3 global nowshowingdir global selectiontypes global presentationbehtypes set date [expr [clock seconds]/86400] set time [expr [clock seconds]%86400] puts $chan [html_start "Info Page"] RetryTransaction { set state [db $db open "/State/MyWorld"] set channel [dbobj $state get LastChannel] set chnum [dbobj $channel get Number] set station [dbobj $channel get Station] set stationfsid [dbobj $station fsid] set chname [strim [dbobj $station get Name]] set datestr $date set schedlist [get_fsidbyprefix "/Schedule" "$stationfsid:$datestr:"] if { [scan [lindex $schedlist 1] "%d:%d:%d:%d:" dummy dummy2 starttimesched duration] == 4 } { regsub {^0+([1-9])} $starttimesched {\1} starttimesched regsub {^0+([1-9])} $duration {\1} duration if {$starttimesched > $time} { set datestr [expr $date - 1] set schedlist [get_fsidbyprefix "/Schedule" "$stationfsid:$datestr:"] if { [scan [lindex $schedlist 1] "%d:%d:%d:%d:" dummy dummy2 starttimesched duration] != 4 } { error "Invalid /Schedule format: '[lindex $schedlist 1]'" } regsub {^0+([1-9])} $starttimesched {\1} starttimesched regsub {^0+([1-9])} $duration {\1} duration } if { $::dtivo } { if {$starttimesched + $duration <= $time} { set stoptimestr [format "%05d" [expr $starttimesched + $duration]] set schedlist [get_fsidbyprefix "/Schedule" "$stationfsid:$datestr:$stoptimestr:"] } } } else { error "Invalid /Schedule format: '[lindex $schedlist 1]'" } } puts $chan [html_table_start "width=1%" "Current Channel" "colspan=5"] if { $schedlist == "" } { puts $chan [tr "" [td "UNKNOWN"]] } else { RetryTransaction { set stationday [db $db openid [lindex $schedlist 0]] set showings [dbobj $stationday get Showing] foreach showing $showings { set duration [dbobj $showing get Duration] set starttime [dbobj $showing get Time] if { $starttime <= $time && ($starttime + $duration) > $time } { set program [dbobj $showing get Program] puts $chan [tr "" [td "Channel:"][td "colspan=4" "$chnum $chname"]] puts $chan [tr "" [td "Program:"] [td "colspan=4" [strim [dbobj $program get Title]]]] puts $chan [tr "" [td "Episode:"][td "colspan=4" [strim [dbobj $program get EpisodeTitle]]]] puts $chan [tr "" [td "Description:"][td "colspan=4" [strim [dbobj $program get Description]]]] } } } # set selectiontypes "{Show Recommendation} {Package Recommendation} {By Name} {By Channel} Manual {Suggestion} {Fuzzy Package} Bookmark {Season Pass} {Manual Season Pass} Guide IPreview WishListPass Extended ManualExtended CaptureRequest" # set presentationbehtypes "Single {Season Pass} Wishlist {Watch Only} {Tivo Clips} Suggestion {Tivo Clips Suggestion} Invisible {Manual Season Pass} Manual {Cache History}" set seltypestr "Not Recording" ForeachMfsFile id name "tyDb" "/Recording/InProgress" "" { RetryTransaction { set inprog [db $db openid $id] if {$::version3} { set recbeh [dbobj $inprog get RecordingBehavior] set diskbeh [dbobj $recbeh get DiskBehavior] if {$diskbeh != 12} { set presbeh [dbobj $recbeh get PresentationBehavior] set seltypestr [lindex $presentationbehtypes [expr $presbeh - 1]] } } else { set contenttype [dbobj $inprog get ContentType] if {$contenttype != 3} { set seltype [dbobj $inprog get SelectionType] set seltypestr [lindex $selectiontypes [expr $seltype - 1]] } } } } puts $chan [tr "" [td "Recording Status:"][td "colspan=4" "$seltypestr"]] } puts $chan [tr "" [th "colspan=5" "TiVo Box Information"]] set cur_temp [exec cat /proc/therm] set remoteaddress "" if {$version3} { RetryTransaction { set setup [db $db open /State/GeneralConfig] set remoteaddress [dbobj $setup get RemoteAddress] } } else { RetryTransaction { set setup [db $db open /Setup] set remoteaddress [dbobj $setup get RemoteAddress] } } set uptime [lindex [exec cat /proc/uptime] 0] set uptime [expr int($uptime)] set uptimestr [format "%dd %dh %02dm %02ds" [expr $uptime / 86400] [expr ($uptime % 86400) / 3600] [expr ($uptime % 3600) / 60] [expr $uptime % 60]] puts $chan [tr "" [td "Current Temperature:"][td "colspan=4" "$cur_temp"]] puts $chan [tr "" [td "Software System:"][td "colspan=4" "$tivoswversion"]] puts $chan [tr "" [td "Remote Address"][td "colspan=4" "$remoteaddress"]] puts $chan [tr "" [td "Uptime"][td "colspan=4" "$uptimestr"]] puts $chan [tr "" [th "colspan=5" "Kernel Information"]] puts $chan [tr "" [td "colspan=5" "
Version [exec uname -r]\nCompile [exec uname -v]
"]] # puts $chan [tr "" [th "colspan=5" "File System/Disk Information"]] # puts $chan [tr "" [td "colspan=5" "
Mounted File Systems:\n[exec mount]
"]] # puts $chan [tr "" [td "colspan=5" "
Disk Full:\n[exec df -h]
"]] # puts $chan [tr "" [td "colspan=5" "
[exec hdparm -i /dev/hda][exec hdparm /dev/hda]
"]] # if {![catch { exec hdparm -i /dev/hdb } execout] } { # puts $chan [tr "" [td "colspan=5" "
$execout[exec hdparm /dev/hdb]
"]] # } puts $chan [tr "" [th "colspan=5" "Memory Information"]] puts $chan [tr "" [td "colspan=5" "
Memory Statistics:\n[exec cat /proc/meminfo]
"]] unset time ForeachMfsFileTrans fsid name type "/Recording/DiskUsed/10" "" 15 { set rec [db $db openid $fsid] scan $name "%d:%d" fsid streamsize set state [dbobj $rec get State] set recquality [dbobj $rec get RecordQuality] if {$state == 5} { set rectype 102 } else { if {$::version3} { set recbeh [dbobj $rec get RecordingBehavior] set rectype [dbobj $recbeh get PresentationBehavior] } else { set rectype [dbobj $rec get SelectionType] } set expsecs [timedateconv $rec Expiration] if {$expsecs < [clock seconds]} { set rectype -$rectype } } set recdur [rec_get_dur $rec] store_space space time count list $rectype $streamsize $recdur if {($::dtivo || $::defrecquality == $recquality) && (!$::version3 || $rectype != 8)} { store_space space time count list 103 $streamsize $recdur } } ForeachMfsFileTrans fsid name type "/Recording/InProgress" "" 15 { set rec [db $db openid $fsid] set indexpath [dbobj $rec get IndexPath] if {[string match "*LiveCache*" $indexpath]} { set parts [dbobj $rec gettarget Part] if {$::dtivo} { set size [expr [llength $parts] * 256 * 1024] } else { set size [expr [llength $parts] * 204 * 1024] } set secs [expr round($size / (5960000.0/8/1024))] store_space space time count list 100 $size $secs } else { set parts [dbobj $rec get Part] set size [expr [llength $parts] * 512 * 1024] set secs 0 foreach part $parts { set begin [dbobj $part get Begin] set end [dbobj $part get End] if {$end != "" && $begin != ""} { set diff [expr ($end - $begin)/1000] incr secs $diff } } store_space space time count list 101 $size $secs } } if {[info exists space]} { puts $chan [tr "" [th "colspan=5" "Space Used - $::usersize MB"]] set list [lsort -integer $list] set tcount 0 set tspace 0 set ttime 0 foreach type $list { if {$type < 102} { disp_spacerow $chan [get_type $type] $count($type) [expr $space($type)/1024] [timeconv $time($type)] $::usersize incr tcount $count($type) incr tspace $space($type) incr ttime $time($type) } } puts $chan "" disp_spacerow $chan "Total" $tcount [expr $tspace/1024] [timeconv $ttime] $::usersize set type 103 if {[lsearch $list $type] != -1} { set freestr "Free Space" if {!$::dtivo} { switch $::defrecquality { 0 {set quality "Basic"} 40 {set quality "Medium"} 75 {set quality "High"} default {set quality "Best"} } append freestr " - $quality" } set averagebitrate [expr $space($type)/($time($type)*1.0)] set freespace [expr $::usersize - $tspace/1024] disp_spacerow $chan $freestr "-" $freespace [timeconv [expr round($freespace*1024/$averagebitrate)]] $::usersize } set type 102 if {[lsearch $list $type] != -1} { disp_spacerow $chan [get_type $type] $count($type) [expr $space($type)/1024] [timeconv $time($type)] $::usersize } } puts $chan [html_table_end] set retval [catch {set hserverspace [exec "grep" "MFS_TOT" "/tmp/HServer.send"]} error] if {$retval != 1} { set hservertotmedia 0 set hservertotclips 0 set hserverspacelist [split $hserverspace "\n\r"] if {[llength $hserverspacelist] > 1} { foreach line $hserverspacelist { set hlist [split $line " "] if {[lindex $hlist 0] == "IDB_MFS_TOTMEDIA:"} { set hservertotmedia [lindex $hlist 1] } elseif {[lindex $hlist 0] == "IDB_MFS_TOTCLIPS:"} { set hservertotclips [lindex $hlist 1] } } } if {$hservertotmedia != 0} { set mismatch 0 if {$::version3} { if {[expr round($hservertotclips/1024)] != $::reservedsize} { set mismatch 1 } elseif {[expr round($hservertotmedia/2/1024) - round($hservertotclips/1024)] != $::usersize} { set mismatch 1 } } else { if {[expr round($hservertotclips/2/1024)] != $::reservedsize} { set mismatch 1 } elseif {[expr round($hservertotmedia/2/1024) - round($hservertotclips/2/1024)] != $::usersize} { set mismatch 1 } } if {$mismatch} { puts $chan "

The reserved space was calculated incorrectly, if you want it to be correct, send the following information to the tivoweb authors:
" puts $chan "$::tivoswversion
" puts $chan "$hservertotmedia $hservertotclips
" puts $chan "$::usersize $::reservedsize
" } } } puts $chan [html_end] } proc get_totalsizes {} { global source_dir global usersize reservedsize set retval [catch {set getspace [exec "$source_dir/get_space"]} error] if {$retval != 1} { scan $getspace "%*d %*d %d %*d" totalmedia } else { error $error } set suffix [string range $::tivoswversion [expr [string length $::tivoswversion] - 3] end] if {$::uktivo} { if {$totalmedia > 130000000} { set reservedsize [expr round(20000000/2/1024)] } elseif {$totalmedia > 100000000} { set reservedsize [expr round(($totalmedia - 96403456)/2/1024)] } else { set reservedsize [expr round(($totalmedia - 65314816)/2/1024)] } } elseif {$::dtivo} { if {$totalmedia > 232000000} { set reservedsize [expr round(20000000/2/1024)] } elseif {$totalmedia > 120000000} { if {$suffix == "011"} { set reservedsize [expr round(22217032/2/1024)] } else { set reservedsize [expr round(20000000/2/1024)] } } elseif {$totalmedia > 100000000} { set reservedsize [expr round(($totalmedia - 96403456)/2/1024)] } else { set reservedsize [expr round(($totalmedia - 70586800)/2/1024)] } } elseif {[PrefixMatches "3.2" $::tivoswversion]} { if {$totalmedia > 130000000} { set reservedsize [expr round(11158400/1024)] } else { set reservedsize [expr round(9421824/1024)] } } else { if {$totalmedia > 340000000} { set reservedsize [expr round(10000000/1024)] } elseif {$totalmedia > 280000000} { if {$suffix == "010"} { set reservedsize [expr round(($totalmedia/2 - 132907754)/1024)] } else { set reservedsize [expr round(10000000/1024)] } } elseif {$totalmedia > 120000000} { set reservedsize [expr round(10000000/1024)] } elseif {$totalmedia > 105000000} { set reservedsize [expr round(($totalmedia/2 - 48201728)/1024)] } elseif {$totalmedia > 90000000} { set reservedsize [expr round(4194304/1024)] } elseif {$totalmedia > 60000000} { set reservedsize [expr round(7127848/1024)] } elseif {$totalmedia > 45000000} { set reservedsize [expr round(2933760/1024)] } elseif {$totalmedia > 35000000} { set reservedsize [expr round(3889152/1024)] } else { set reservedsize [expr round(423936/1024)] } } set usersize [expr round($totalmedia/2/1024) - $reservedsize] } proc disp_spacerow {chan type count size time totalsize} { puts $chan "" puts $chan "$type" puts $chan "$count" puts $chan "$size MB" puts $chan "[expr round(($size + 0.0)/$totalsize * 1000)/10.0]%" puts $chan "$time" puts $chan "" } proc store_space {spacevar timevar countvar listvar rectype streamsize rectime} { upvar $spacevar space upvar $timevar time upvar $countvar count upvar $listvar list if {[info exists space($rectype)]} { incr space($rectype) $streamsize incr time($rectype) $rectime incr count($rectype) } else { lappend list $rectype set space($rectype) $streamsize set time($rectype) $rectime set count($rectype) 1 } } proc rec_get_dur {rec} { set objtype [dbobj $rec type] if {$objtype == "VideoClip"} { return 0 } set showing [dbobj $rec get Showing] set stopdate [dbobj $rec get StopDate] set stoptime [dbobj $rec get StopTime] if { $stoptime == "" } { set stoptime [expr ([dbobj $showing get Time] + [dbobj $showing get Duration]) % 86400] } set startdate [dbobj $rec get StartDate] set starttime [dbobj $rec get StartTime] if { $starttime == "" } { set starttime [dbobj $showing get Time] } if { $stopdate != "" } { set durationsecs [expr ($stopdate * 86400 + $stoptime) - ($startdate * 86400 + $starttime)] } set showingdurationsecs [dbobj $showing get Duration] if { $durationsecs == 0 } { set durationsecs $showingdurationsecs } return $durationsecs } proc timedateconv {obj what} { return [expr [dbobj $obj get ${what}Date]*86400+[dbobj $obj get ${what}Time]] } proc timeconv {time} { return [format "%d:%02d:%02d" [expr ($time/(60*60))] [expr ($time/60)%60] [expr $time%60]] } proc get_type {type} { global selectiontypes global presentationbehtypes if {$type == 100} { set name "Live Cache" } elseif {$type == 101} { set name "In Progress" } elseif {$type == 102} { set name "Deleted" } else { if {$type < 0} { set name "Expired " set type [expr abs($type)] } else { set name "" } if {$::version3} { set name "$name[strim [lindex $presentationbehtypes [expr $type - 1]]]" } else { set name "$name[strim [lindex $selectiontypes [expr $type - 1]]]" } } return $name } if {$reload == 0} { get_totalsizes } register_module "info" "Info" "Various Info about your Tivo"