proc action_info {chan path env} { global db global tivoswversion global version global nowshowingdir global channeltablestation global channeltablestation_alt global source_dir global selectiontypes global presentationbehtypes set date [expr [clock seconds]/86400] set time [expr [clock seconds]%86400] puts $chan [html_start "Info Page"] puts $chan [html_table_start "width=1%" "" "colspan=5"] set reccount 0 set seltypestr "Not Recording" ForeachMfsFile id name "tyDb" "/Recording/InProgress" "" { RetryTransaction { set inprog [db $db openid $id] set indexpath [dbobj $inprog get IndexPath] if {![string match "*LiveCache*" $indexpath]} { set showing [dbobj $inprog get Showing] set program [dbobj $showing get Program] set station [dbobj $showing get Station] set stationid [dbobj $station fsid] if { [catch {set data $channeltablestation($stationid)}] != 1 || [catch {set data $channeltablestation_alt($stationid)}] != 1 } { set channum [join [split [lindex $data 0] .] -] set callsign [lindex $data 2] incr reccount } else { set channum "" set callsign [dbobj $station get CallSign] } puts $chan [tr "" [th "colspan=5" "Currently Recording"]] puts $chan [tr "" [td "Channel:"][td "colspan=4" "$channum $callsign"]] 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]]]] if {$::version >= 3} { 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"]] } } } if { $reccount < $::num_tuners } { 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 stationid [dbobj $station fsid] if { [catch {set data $channeltablestation($stationid)}] != 1 || [catch {set data $channeltablestation_alt($stationid)}] != 1 } { set channum [join [split [lindex $data 0] .] -] set callsign [lindex $data 2] } else { set channum "" set callsign [dbobj $station get CallSign] } set datestr $date set schedlist [get_fsidbyprefix "/Schedule" "$stationid:$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" "$stationid:$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" "$stationid:$datestr:$stoptimestr:"] } } } else { #error "Invalid /Schedule format: [lindex $schedlist 1]" } } puts $chan [tr "" [th "colspan=5" "Currently on Live TV"]] if { $schedlist == "" } { #puts $chan [tr "" [td "colspan=5" "UNKNOWN"]] puts $chan [tr "" [td "Channel:"][td "colspan=4" "$channum $callsign"]] puts $chan [tr "" [td "Guide Data:"][td "colspan=4" "Unavailable"]] } 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" "$channum $callsign"]] 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]]]] } } if { ![info exists program] } { puts $chan [tr "" [td "colspan=5" "UNKNOWN"]] } } } } # 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}" puts $chan [tr "" [th "colspan=5" "TiVo Box Information"]] set cur_temp [exec cat /proc/therm] set cur_tempF [expr 1.8*[string trim $cur_temp 'C']+32]F set remoteaddress "" if {$::version >= 3} { RetryTransaction { set setup [db $db open /State/GeneralConfig] set remoteaddress [defaultval 0 [dbobj $setup get RemoteAddress]] } } else { RetryTransaction { set setup [db $db open /Setup] set remoteaddress [defaultval 0 [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]] set secs [clock seconds] set tzoffset [get_tzoffset $secs] set timestr [clock format [expr $secs + $tzoffset] -format "%I:%M%P, %e-%b-%y"] if { $::uktivo } { set tivotype "United Kingdom" } else { set tivotype "United States" } if { $::series1 } { set tivotype "$tivotype Series 1" } else { set tivotype "$tivotype Series 2" } if { $::dtivo } { set tivotype "$tivotype DirecTiVo" } else { set tivotype "$tivotype Stand-Alone" } if {[file exists /etc/oztivo_version] || [file exists /etc/oztivo-version]} { if {[file exists /etc/oztivo_version]} { set fd [open /etc/oztivo_version "r"] } else { set fd [open /etc/oztivo-version "r"] } gets $fd oztivo_version close $fd puts $chan [tr "" [td "Software System:"][td "colspan=4" "$tivoswversion  (OzTivo $oztivo_version)"]] } else { puts $chan [tr "" [td "Software System:"][td "colspan=4" "$tivoswversion"]] } puts $chan [tr "" [td "Service Number:"][td "colspan=4" "$::sn"]] puts $chan [tr "" [td "System Type:"][td "colspan=4" "$tivotype"]] puts $chan [tr "" [td "Tuner Count:"][td "colspan=4" "$::num_tuners"]] puts $chan [tr "" [td "Remote Address:"][td "colspan=4" "$remoteaddress"]] puts $chan [tr "" [td "TiVo Time:"][td "colspan=4" "$timestr"]] puts $chan [tr "" [td "Uptime:"][td "colspan=4" "$uptimestr"]] puts $chan [tr "" [td "Current Temperature:"][td "colspan=4" "$cur_temp / $cur_tempF"]] puts $chan [tr "" [th "colspan=5" "Network Information"]] puts $chan [tr "" [td "TiVo Address:"][td "colspan=4" "$::ip_address"]] puts $chan [tr "" [td "Remote Client Address:"][td "colspan=4" "$::REMOTE_ADDR"]] puts $chan [tr "" [td "HTTP Host Address:"][td "colspan=4" "$::HTTP_HOST"]] if {$::version >= 3} { set config "/State/PhoneConfig" set suffix "SecInDay" } else { set config "/Setup" set suffix "" } RetryTransaction { set pc [db $db open $config] set lastcallstatus [defaultval "Unknown" [dbobj $pc get LastCallStatus]] set lastcallattempt [defaultval 0 [dbobj $pc get LastCallAttempt$suffix]] set lastsuccesscall [defaultval 0 [dbobj $pc get LastSuccessCall$suffix]] set nextcallattempt [defaultval 0 [dbobj $pc get NextCallAttempt$suffix]] set day 0 catch {set day [dbobj $pc get LastCallAttemptDay]} if {$day > 0} { incr lastcallattempt [expr $day * 86400] set day [defaultval 0 [dbobj $pc get LastSuccessCallDay]] incr lastsuccesscall [expr $day * 86400] set day [defaultval 0 [dbobj $pc get NextCallAttemptDays]] incr nextcallattempt [expr $day * 86400] } } set lastcalltimestr [ftime $lastcallattempt "%I:%M%P, %e-%b-%y"] set lastcallsuccstr [ftime $lastsuccesscall "%I:%M%P, %e-%b-%y"] set nextcalltimestr [ftime $nextcallattempt "%I:%M%P, %e-%b-%y"] puts $chan [tr "" [th "colspan=5" "Phone Call Information"]] puts $chan [tr "" [td "Last Call"][td "colspan=4" "$lastcalltimestr"]] puts $chan [tr "" [td "Last Call Status"][td "colspan=4" "$lastcallstatus"]] if {$lastcalltimestr != $lastcallsuccstr} { puts $chan [tr "" [td "Last Success Call"][td "colspan=4" "$lastcallsuccstr"]] } puts $chan [tr "" [td "Next Call"][td "colspan=4" "$nextcalltimestr"]] if {[file exists $source_dir/.dist/version]} { set fd [open $source_dir/.dist/version "r"] gets $fd dist_version close $fd puts $chan [tr "" [th "colspan=5" "$TWP::NAME Distribution"]] if {$path == "/dist"} { puts $chan [tr "" [td "colspan=5" "
Version $dist_version
"]] puts $chan [tr "" [td "colspan=5" "
[exec $source_dir/check_dist.sh -simple]
"]] } else { puts $chan [tr "" [td "colspan=5" "
Version $dist_version
([html_link "/info/dist" "include output from distribution check"])"]] } unset fd dist_version } 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" "Memory Information"]] puts $chan [tr "" [td "colspan=5" "
Memory Statistics:\n[exec cat /proc/meminfo]
"]] puts $chan [tr "" [th "colspan=5" "File System/Disk Information"]] puts $chan [tr "" [td "colspan=5" "
[exec df -h -T]
"]] catch { exec smartctl -c /dev/hda } smartctla puts $chan [tr "" [td "colspan=5" "
[exec hdparm -acdgmC /dev/hda]\n\n$smartctla
"]] if {![catch { exec hdparm -acdgmC /dev/hdb } execout] } { catch { exec smartctl -c /dev/hdb } smartctlb puts $chan [tr "" [td "colspan=5" "
$execout\n\n$smartctlb
"]] } unset time set list [list] set rlist [list] store_space space time count list 103 0 0 store_space rspace rtime rcount rlist 103 0 0 if {$::version <= 3} { 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] if { $state != "" } { set recquality [dbobj $rec get RecordQuality] if {$state == 5} { set rectype 102 } else { if {$::version >= 3} { 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) && ($::version < 3 || $rectype != 8)} { store_space space time count list 103 $streamsize $recdur } } } ForeachMfsFileTrans fsid name type "/Recording/DiskUsed/11" "" 15 { set rec [db $db openid $fsid] scan $name "%d:%d" fsid streamsize set state "" catch { set state [dbobj $rec get State] } if { $state != "" } { set recquality [dbobj $rec get RecordQuality] if {$state == 5} { set rectype 102 } else { if {$::version >= 3} { 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 rspace rtime rcount rlist $rectype $streamsize $recdur if {($::dtivo || $::defrecquality == $recquality) && ($::version < 3 || $rectype != 8)} { store_space rspace rtime rcount rlist 103 $streamsize $recdur } } } } else { ForeachMfsFileTrans fsid name type "/DiskUsed" "" 15 { set rec [db $db openid $fsid] scan $name "%d:%d:%d:%d" spacetype junk streamsize fsid set state "" catch { set state [dbobj $rec get State] } if { $state != "" } { set recquality [dbobj $rec get RecordQuality] if {$state == 5} { set rectype 102 } else { if {$::version >= 3} { 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] if { $spacetype == 10 } { store_space space time count list $rectype $streamsize $recdur } else { store_space rspace rtime rcount rlist $rectype $streamsize $recdur } if {($::dtivo || $::defrecquality == $recquality) && ($::version < 3 || $rectype != 8)} { if { $spacetype == 10 } { store_space space time count list 103 $streamsize $recdur } else { store_space rspace rtime rcount rlist 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] # Attempt to find the partsize as people may have used # BufferHack to alter the default size if {[catch {set partsize [mfs size [lindex $parts 1]]}]} { if {$::dtivo} { set size [expr [llength $parts] * 256 * 1024] } else { set size [expr [llength $parts] * 204 * 1024] } } else { set size [expr [llength $parts] * $partsize * 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" "User Space"]] set list [lsort -integer $list] set rlist [lsort -integer $rlist] set tcount 0 set tspace 0 set ttime 0 set trcount 0 set trspace 0 set trtime 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) } } disp_spacerow $chan "Used User Space" $tcount [expr $tspace/1024] [timeconv $ttime] $::usersize puts $chan [tr "" [th "colspan=5" "Reserved Space"]] foreach type $rlist { if {$type <= 102} { disp_spacerow $chan [get_type $type] $rcount($type) [expr $rspace($type)/1024] [timeconv $rtime($type)] $::usersize incr trcount $rcount($type) incr trspace $rspace($type) incr trtime $rtime($type) } } disp_spacerow $chan "Used Reserved Space" $trcount [expr $trspace/1024] [timeconv $trtime] $::usersize set freespace [expr $::usersize - ($tspace+$trspace)/1024] set freestr "Total Free" if {!$::dtivo} { switch $::defrecquality { 0 {set quality "Basic"} 40 {set quality "Medium"} 75 {set quality "High"} default {set quality "Best"} } append freestr " - $quality" } set type 103 if { $count($type) == 1 && $rcount($type) == 1 } { set totaltime "-" set freetime "-" } else { set averagebitrate 0 catch {set averagebitrate [expr ($space($type)+$rspace($type))/(($time($type)+$rtime($type))*1.0)]} if {$averagebitrate > 0} { set totaltime [timeconv [expr round($::usersize*1024/$averagebitrate)]] set freetime [timeconv [expr round($freespace*1024/$averagebitrate)]] } else { set totaltime "-" set freetime "-" } } puts $chan [tr "" [th "colspan=5" "Space Summary"]] disp_spacerow $chan "Total Space" "-" $::usersize $totaltime $::usersize disp_spacerow $chan "Total Used" [expr $trcount+$tcount] [expr ($tspace+$trspace)/1024] [timeconv [expr $trtime+$ttime]] $::usersize disp_spacerow $chan $freestr "-" $freespace $freetime $::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] if {[lsearch $list $type] != -1} { puts $chan "** Deleted is a subset of Total Free
" } puts $chan [html_end] } proc get_totalsizes {} { global usersize set retval [catch {set getspace [exec "$::bin_dir/get_space"]} error] if {$retval != 1} { scan $getspace "%*d %*d %d %*d" totalmedia } else { error $error } set usersize [expr round($totalmedia/2/1024)] } 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] } set durationsecs 0 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 {$::version >= 3} { 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"