forked from hummypkg/webif
new disk diagnostics. Progress on mobile
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1173 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
eb0adb8f29
commit
57b78c4c0d
@ -247,6 +247,12 @@ pre, .pre
|
||||
color: black;
|
||||
}
|
||||
|
||||
.redshade
|
||||
{
|
||||
background: #ff4000;
|
||||
color: white;
|
||||
}
|
||||
|
||||
img.progress
|
||||
{
|
||||
background: transparent url(/img/percentback.png) top left no-repeat;
|
||||
|
@ -46,6 +46,7 @@ puts {
|
||||
|
||||
<tr>
|
||||
<td colspan=2 align=center>
|
||||
<button id=diskdiag style="width: 48%">Hard Disc</button>
|
||||
<button id=channelinfo style="width: 48%">Channel Information</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
162
var/mongoose/html/diag/disk.jim
Executable file
162
var/mongoose/html/diag/disk.jim
Executable file
@ -0,0 +1,162 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require system.class
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts ""
|
||||
|
||||
header
|
||||
|
||||
set space [system diskspace]
|
||||
set device [string range [lindex $space 5] 0 end-1]
|
||||
|
||||
set smart Unknown
|
||||
set line ""
|
||||
# smartctl uses non-zero exit status to indicate health hence catch.
|
||||
catch { set line [exec /mod/bin/smartctl -H $device | sed -n 5p] } msg
|
||||
if {$msg ne "" && $line eq ""} { set line $msg }
|
||||
if {$line ne ""} {
|
||||
set smart [string range [lindex [split $line :] 1] 1 end]
|
||||
}
|
||||
|
||||
puts "
|
||||
<h3 class=va>
|
||||
<img class=va width=100 src=/img/disc.png>
|
||||
SMART data read from device $device
|
||||
</h3>
|
||||
<fieldset class=cleft>
|
||||
<legend>Disk Information</legend>
|
||||
<table>
|
||||
<tr><th class=key>SMART Status</th><td>$smart<td></tr>
|
||||
"
|
||||
foreach line [split [exec /mod/bin/smartctl -i $device] "\n"] {
|
||||
if {[string match "*Not in smartctl database*" $line]} continue
|
||||
if {[string match "*: *" $line]} {
|
||||
regsub -all -- {[[:space:]]+} $line " " line
|
||||
set fields [split $line ":"]
|
||||
puts "<tr><th class=key>[lindex $fields 0]</th>"
|
||||
puts "<td>[join [lrange $fields 1 end] :]</td></tr>"
|
||||
}
|
||||
}
|
||||
puts {
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class=cleft>
|
||||
<legend>Attributes</legend>
|
||||
<table class=borders cellpadding=3>
|
||||
<tr>
|
||||
<th class=odd>ID</th>
|
||||
<th class=odd>Name</th>
|
||||
<th class=odd>Flags</th>
|
||||
<th class=odd>Raw Value</th>
|
||||
<th class=odd>Value</th>
|
||||
<th class=odd>Worst</th>
|
||||
<th class=odd>Thresh</th>
|
||||
<th class=odd>Type</th>
|
||||
<th class=odd>Updated</th>
|
||||
<th class=odd>When Failed</th>
|
||||
</tr>
|
||||
}
|
||||
|
||||
#set flag_autokeep 0x20
|
||||
#set flag_count 0x10
|
||||
#set flag_rate 0x08
|
||||
#set flag_speed 0x04
|
||||
#set flag_online 0x02
|
||||
#set flag_prefailure 0x01
|
||||
|
||||
set flaglist [split "POSRCK" ""]
|
||||
set flagdescr [list \
|
||||
"P prefailure warning" \
|
||||
"O updated online" \
|
||||
"S speed/performance" \
|
||||
"R error rate" \
|
||||
"C event count" \
|
||||
"K auto-keep" \
|
||||
]
|
||||
|
||||
proc flags {val} {
|
||||
global flaglist flagdescr
|
||||
set f ""
|
||||
set fx ""
|
||||
loop i 0 [llength $flaglist] {
|
||||
if {[expr $val & (1 << $i)]} {
|
||||
append f [lindex $flaglist $i]
|
||||
append fx "[lindex $flagdescr $i]\n"
|
||||
} else {
|
||||
append f "-"
|
||||
}
|
||||
}
|
||||
return "<span title=\"$fx\">$f</span>"
|
||||
}
|
||||
|
||||
set i 0
|
||||
foreach line [split [exec /mod/bin/smartctl -A $device] "\n"] {
|
||||
regsub -all -- {[[:space:]]+} $line " " line
|
||||
regsub -all -- {^[[:space:]]+} $line "" line
|
||||
if {[incr i] < 8} continue
|
||||
lassign [split $line] \
|
||||
id name flags val worst thresh type updated when rval
|
||||
set class normal
|
||||
switch $id {
|
||||
5 { if {$rval > 0} { set class orangeshade } }
|
||||
197 { if {$rval > 0} { set class redshade } }
|
||||
198 { if {$rval > 0} { set class redshade } }
|
||||
}
|
||||
puts "<tr class=$class>"
|
||||
puts "
|
||||
<td>$id</td>
|
||||
<td>$name</td>
|
||||
<td>[flags $flags]</td>
|
||||
<td>$rval</td>
|
||||
<td>$val</td>
|
||||
<td>$worst</td>
|
||||
<td>$thresh</td>
|
||||
<td>$type</td>
|
||||
<td>$updated</td>
|
||||
<td>$when</td>
|
||||
</tr>"
|
||||
}
|
||||
|
||||
puts {
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class=cleft>
|
||||
<legend>Self-test logs</legend>
|
||||
<table class=borders cellpadding=3>
|
||||
<tr>
|
||||
<th class=odd>No.</th>
|
||||
<th class=odd>Description</th>
|
||||
<th class=odd>Status</th>
|
||||
<th class=odd>Remaining</th>
|
||||
<th class=odd>When</th>
|
||||
<th class=odd>First Error LBA</th>
|
||||
</tr>
|
||||
}
|
||||
|
||||
set i 0
|
||||
foreach line [split [exec /mod/bin/smartctl -l selftest $device] "\n"] {
|
||||
regsub -all -- {[[:space:]][[:space:]]+} $line "|" line
|
||||
if {[incr i] < 7} continue
|
||||
lassign [split $line "|"] id name status remaining when lba
|
||||
puts "<tr>
|
||||
<td>$id</td>
|
||||
<td>$name</td>
|
||||
<td>$status</th>
|
||||
<td>$remaining</th>
|
||||
<td>$when</th>
|
||||
<td>$lba</th>
|
||||
</tr>"
|
||||
}
|
||||
|
||||
puts {
|
||||
</table>
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
footer
|
||||
|
@ -49,6 +49,11 @@ $('#channelinfo').click(function(e) {
|
||||
window.location = '/cgi-bin/channel.jim';
|
||||
});
|
||||
|
||||
$('#diskdiag').click(function(e) {
|
||||
e.preventDefault();
|
||||
window.location = 'disk.jim';
|
||||
});
|
||||
|
||||
$('#dlna').click(function(e) {
|
||||
e.preventDefault();
|
||||
window.location = '/dlna/dlna.jim';
|
||||
|
BIN
var/mongoose/html/img/disc.png
Normal file
BIN
var/mongoose/html/img/disc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 109 KiB |
@ -30,7 +30,7 @@ foreach e $records {
|
||||
set nday [clock format $st -format "%F"]
|
||||
if {$day ne $nday} {
|
||||
set day $nday
|
||||
puts "<li data-role=list-divider>
|
||||
puts "<li class=stick data-role=list-divider>
|
||||
[clock format $st -format "%a %d %b %Y"]
|
||||
</li>"
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ proc tb {icon txt link {height 80} {width 0}} {
|
||||
if {[file exists "/mod/bin/ir"]} {
|
||||
tb "/img/remote.png" "Remote" "/plugin/ir/m/index.jim\" rel=\"external"
|
||||
}
|
||||
tb "/images/328_1_26_Menu_TV_Guide.png" "Now/Next" "nownext.jim"
|
||||
tb "/images/323_1_10_Menu_Video.png" "Browse" "#"
|
||||
tb "/images/321_1_00_Menu_CHList.png" "Schedule" "#"
|
||||
tb "/images/328_1_26_Menu_TV_Guide.png" "Now/Next" "nownext.jim"
|
||||
tb "/img/spanner.png" "Services" "#"
|
||||
tb "/img/packages.png" "Packages" "#"
|
||||
tb "/images/326_1_00_Menu_Settings.png" "Settings" \
|
||||
|
@ -34,10 +34,12 @@ puts {
|
||||
</head>
|
||||
}
|
||||
|
||||
set pageid [string range $env(SCRIPT_NAME) 3 end-4]
|
||||
|
||||
puts "
|
||||
<body>
|
||||
|
||||
<div data-role=page data-add-back-btn=true>
|
||||
<div data-role=page data-add-back-btn=true id=${pageid}page>
|
||||
|
||||
<div class=\"hidden status\"></div>
|
||||
|
||||
|
@ -5,3 +5,7 @@ $(document).bind('pageinit', function() {
|
||||
});
|
||||
});
|
||||
|
||||
//$(document).delegate('#channelpage', 'pageinit', function() {
|
||||
//console.log('pageinit for channelpage');
|
||||
//});
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
.va
|
||||
{
|
||||
vertical-align: middle;
|
||||
@ -25,3 +26,14 @@ div.status
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
li.stick
|
||||
{
|
||||
display: block;
|
||||
}
|
||||
|
||||
li.sticky
|
||||
{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
|
@ -92,10 +92,12 @@ proc {system diskspace} {} {
|
||||
set used 0
|
||||
set free 0
|
||||
set perc 0
|
||||
set dev 0
|
||||
foreach line [split [exec /mod/bin/busybox/df -h $part 2>>/dev/null] "\n\r"] {
|
||||
if {[string match "/*" $line]} {
|
||||
regsub -all -- {[[:space:]]+} $line " " line
|
||||
set fields [split $line]
|
||||
set dev [lindex $fields 0]
|
||||
set size [lindex $fields 1]
|
||||
set used [lindex $fields 2]
|
||||
set free [lindex $fields 3]
|
||||
@ -105,7 +107,7 @@ proc {system diskspace} {} {
|
||||
}
|
||||
}
|
||||
|
||||
return [list $size $used $perc $free $fperc]
|
||||
return [list $size $used $perc $free $fperc $dev]
|
||||
}
|
||||
|
||||
proc {system busy} {} {
|
||||
|
Loading…
Reference in New Issue
Block a user