tazpanel annotate hardware.cgi @ rev 419

Bunch of changes. Development in progress, please note it have few known bugs.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Mar 24 03:39:08 2015 +0200 (2015-03-24)
parents 33fd4be42594
children d6586247420a
rev   line source
pankso@46 1 #!/bin/sh
pankso@46 2 #
pankso@46 3 # Hardware part of TazPanel - Devices, drivers, printing
pankso@46 4 #
al@419 5 # Copyright (C) 2011-2015 SliTaz GNU/Linux - BSD License
pankso@46 6 #
pankso@46 7
pankso@46 8 # Common functions from libtazpanel
pankso@46 9 . lib/libtazpanel
pankso@46 10 get_config
pascal@81 11 header
pankso@46 12
al@292 13 TITLE=$(gettext 'TazPanel - Hardware')
pankso@46 14
paul@385 15 # Call an optional module
pascal@373 16 lib()
pascal@373 17 {
pascal@373 18 module=lib/$1
pascal@373 19 shift
pascal@373 20 [ -s $module ] && . $module "$@"
pascal@373 21 }
pascal@373 22
al@419 23
al@363 24 lsusb_table()
al@363 25 {
al@419 26 cat <<EOT
al@419 27 <table class="wide zebra">
al@363 28 <thead><tr><td>Bus</td><td>Device</td><td>ID</td><td>Name</td></thead>
al@363 29 <tbody>
al@363 30 EOT
al@363 31 lsusb | sed 's|^Bus \([0-9]*\)|<tr><td>\1</td>|;
al@363 32 s|</td> Device \([0-9]*\):|</td><td>\1</td>|;
al@363 33 s|</td> ID \([^:]*:[^ ]*\)|</td><td><a href="?lsusb=\1">\1</a></td>|;
al@363 34 s| |<td>|2;
al@363 35 s|.*$|\0</td></tr>|'
al@363 36 echo "</tbody></table>"
al@363 37 }
al@363 38
al@419 39
al@363 40 lspci_table()
al@363 41 {
al@419 42 cat <<EOT
al@419 43 <table class="wide zebra">
al@363 44 <thead><tr><td>Slot</td><td>Device</td><td>Name</td></thead>
al@363 45 <tbody>
al@363 46 EOT
al@363 47 lspci | sed 's| |</td><td>|;
al@363 48 s|: |</td><td>|;
al@363 49 s|^\([^<]*\)|<a href="?lspci=\1">\1</a>|;
al@363 50 s|^.*$|<tr><td>\0</td></tr>|'
al@363 51 echo "</tbody></table>"
al@363 52 }
al@363 53
pankso@46 54 #
pankso@46 55 # Commands
pankso@46 56 #
pankso@46 57
pascal@81 58 case " $(GET) " in
pascal@81 59 *\ print\ *)
al@303 60 xhtml_header
al@419 61 echo "<h2>TODO</h2>"
al@419 62 ;;
al@419 63
al@419 64
psychomaniak@407 65 *\ tazx\ *)
psychomaniak@407 66 xhtml_header
al@419 67 cat <<EOT
psychomaniak@407 68 <pre>$(tazx auto)</pre>
psychomaniak@407 69 EOT
psychomaniak@407 70 ;;
al@419 71
al@419 72
pankso@242 73 *\ detect\ *)
pankso@242 74 # Front end for Tazhw
pankso@242 75 # TODO: Add button to detect webcam, etc. Like in tazhw box.
pankso@242 76 xhtml_header
al@419 77 cat <<EOT
al@419 78 <h2>$(gettext 'Detect hardware')</h2>
al@419 79 <p>$(gettext 'Detect PCI and USB hardware')</p>
al@303 80
al@419 81 <section>
al@419 82 <div>
al@419 83 <pre>$(tazhw detect-pci | sed 's|^>|\&gt;|g')</pre>
al@419 84 <pre>$(tazhw detect-usb | sed 's|^>|\&gt;|g')</pre>
al@419 85 </div>
al@419 86 </section>
pankso@242 87 EOT
al@303 88 ;;
al@419 89
al@419 90
pascal@81 91 *\ modules\ *|*\ modinfo\ *)
pankso@46 92 xhtml_header
al@419 93 cat <<EOT
al@419 94 <h2>$(gettext 'Kernel modules')</h2>
al@419 95
al@419 96 <form id="actions">
al@419 97 <input type="hidden" name="modules"/>
al@419 98 $(gettext 'Manage, search or get information about the Linux kernel modules')
al@419 99
al@419 100 <input type="search" name="search" class="float-right" placeholder="$(gettext 'Modules search')" results="5" autosave="modsearch" autocomplete="on"/>
al@419 101 </form>
pankso@46 102 EOT
pankso@66 103 # Request may be modinfo output that we want in the page itself
al@303 104 get_modinfo="$(GET modinfo)"
al@303 105 if [ -n "$get_modinfo" ]; then
al@419 106 cat <<EOT
al@419 107 <section>
al@419 108 <header>$(eval_gettext 'Detailed information for module: $get_modinfo')</header>
al@303 109
al@303 110 EOT
al@419 111 modinfo $get_modinfo | awk 'BEGIN{print "<table class=\"wide zebra\">"}
al@419 112 {
al@419 113 printf("<tr><td><b>%s</b></td>", $1)
al@419 114 $1=""; printf("<td>%s</td></tr>", $0)
al@419 115 }
al@419 116 END{print "</table></section>"}'
pascal@81 117 fi
al@419 118
pascal@81 119 if [ -n "$(GET modprobe)" ]; then
al@303 120 echo "<pre>$(modprobe -v $(GET modprobe))</pre>"
pascal@81 121 fi
pascal@81 122 if [ -n "$(GET rmmod)" ]; then
pascal@81 123 echo "Removing"
pascal@81 124 rmmod -w $(GET rmmod)
pascal@81 125 fi
al@303 126 get_search="$(GET search)"
al@303 127 if [ -n "$get_search" ]; then
al@303 128 eval_gettext 'Matching result(s) for: $get_search'
pascal@81 129 echo '<pre>'
pascal@81 130 modprobe -l | grep "$(GET search)" | while read line
pascal@81 131 do
pascal@81 132 name=$(basename $line)
pascal@81 133 mod=${name%.ko.gz}
al@406 134 echo "$(gettext 'Module:') <a href='?modinfo=$mod'>$mod</a>"
pascal@81 135 done
pascal@81 136 echo '</pre>'
pascal@81 137 fi
al@419 138 cat <<EOT
al@419 139 <section>
al@419 140 <table class="zebra borders hborders">
al@419 141 <thead>
al@419 142 <tr>
al@419 143 <td>$(gettext 'Module')</td>
al@419 144 <td>$(gettext 'Description')</td>
al@419 145 <td>$(gettext 'Size')</td>
al@419 146 <td>$(gettext 'Used')</td>
al@419 147 <td>$(gettext 'by')</td>
al@419 148 </tr>
al@419 149 <thead>
al@419 150 <tbody>
pankso@46 151 EOT
pankso@46 152 # Get the list of modules and link to modinfo
al@419 153 lsmod | tail -n+2 | awk '{
al@419 154 gsub(",", " ", $4);
al@419 155 printf("<tr><td><a href=\"?modinfo=%s\">%s</a></td><td>", $1, $1);
al@419 156 system("modinfo -d " $1);
al@419 157 printf("</td><td>%s</td><td>%s</td><td>%s</td></tr>", $2, $3, $4);
al@419 158 }'
al@419 159 cat <<EOT
al@419 160 </thead>
al@419 161 </table>
al@419 162 </section>
pankso@46 163 EOT
al@419 164 ;;
al@419 165
al@419 166
al@363 167 *\ lsusb\ *)
al@363 168 xhtml_header
al@363 169 vidpid="$(GET lsusb)"
al@419 170 cat <<EOT
al@419 171 <h2>$(eval_gettext 'Information for USB Device $vidpid')</h2>
al@419 172
al@419 173 <p>$(gettext 'Detailed information about specified device.')</p>
al@419 174
al@419 175 <section>$(lsusb_table)</section>
al@419 176
al@419 177 <section>
al@419 178 <div>
al@419 179 <pre style="white-space: pre-wrap">$(lsusb -vd $vidpid | syntax_highlighter lsusb)</pre>
al@419 180 </div>
al@419 181 </section>
al@363 182 EOT
al@363 183 ;;
al@419 184
al@419 185
al@363 186 *\ lspci\ *)
al@363 187 xhtml_header
al@363 188 slot="$(GET lspci)"
al@419 189 cat <<EOT
al@419 190 <h2>$(eval_gettext 'Information for PCI Device $slot')</h2>
al@419 191
al@419 192 <p>$(gettext 'Detailed information about specified device.')</p>
al@419 193
al@419 194 <section>$(lspci_table)</section>
al@419 195
al@419 196 <section>
al@419 197 <div>
al@419 198 <pre style="white-space: pre-wrap">$(lspci -vs $slot | syntax_highlighter lspci)</pre>
al@419 199 </div>
al@419 200 </section>
al@363 201 EOT
al@363 202 ;;
al@419 203
al@419 204
pankso@66 205 *)
pascal@217 206 [ -n "$(GET brightness)" ] &&
pascal@262 207 echo -n $(GET brightness) > /sys/devices/virtual/backlight/$(GET dev)/brightness
al@292 208
pankso@66 209 #
pankso@66 210 # Default to summary with mounted filesystem, loaded modules
pankso@66 211 #
pankso@66 212 xhtml_header
al@419 213 cat <<EOT
al@419 214 <h2>$(gettext 'Drivers &amp; Devices')</h2>
al@419 215 <p>$(gettext 'Manage your computer hardware')</p>
al@419 216
al@419 217 <form><!--
al@419 218 --><button name="modules" data-icon="modules">$(gettext 'Kernel modules')</button><!--
al@419 219 --><button name="detect" data-icon="detect" >$(gettext 'Detect PCI/USB')</button><!--
al@419 220 --><button name="tazx" data-icon="tazx" >$(gettext 'Auto-install Xorg video driver')</button>
al@419 221 </form>
pascal@219 222
pascal@217 223 EOT
al@419 224
al@419 225
al@419 226 # Battery state
al@419 227 if [ -n "$(ls /proc/acpi/battery/*/info 2>/dev/null)" ]; then
al@419 228 cat <<EOT
al@419 229 <section>
al@419 230 <header>$(gettext 'Battery')</header>
al@419 231 <div>
al@419 232 <table class="wide">
al@419 233 EOT
pascal@219 234 for dev in /proc/acpi/battery/*; do
pascal@219 235 grep ^present $dev/info | grep -q yes || continue
al@419 236 design=$(sed '/design capacity:/!d; s/[^0-9]*\([0-9]*\).*/\1/' < $dev/info)
al@419 237 remain=$(sed '/remaining capacity/!d; s/[^0-9]*\([0-9]*\).*/\1/' < $dev/state)
al@419 238 rate=$(sed '/present rate/!d; s/[^0-9]*\([0-9]*\).*/\1/' < $dev/state)
al@419 239 full=$(sed '/last full capacity/!d; s/[^0-9]*\([0-9]*\).*/\1/' < $dev/info)
al@303 240 warning=$(sed '/design capacity warning/!d;s/[^0-9]*\([0-9]*\).*/\1/' < $dev/info)
al@419 241 low=$(sed '/design capacity low/!d; s/[^0-9]*\([0-9]*\).*/\1/' < $dev/info)
al@419 242 state=$(sed '/charging state/!d; s/\([^:]*:[ ]\+\)\([a-z]\+\)/\2/' < $dev/state)
al@303 243
al@303 244 rempct=$(( $remain * 100 / $full ))
al@419 245 cat <<EOT
al@419 246 <tr>
al@419 247 <td><span data-icon="battery">$(gettext 'Battery')</span>
al@419 248 $(grep "^battery type" $dev/info | sed 's/.*: *//')
al@419 249 $(grep "^design capacity:" $dev/info | sed 's/.*: *//') </td>
al@419 250 <td>$(gettext 'health') $(( (100*$full)/$design))%</td>
al@419 251 <td class="meter"><meter min="0" max="$full" value="$remain" low="$low"
al@419 252 high="$warning" optimum="$full"></meter>
al@419 253 <span>
pascal@219 254 EOT
al@303 255 case "$state" in
al@303 256 "discharging")
al@303 257 remtime=$(( $remain * 60 / $rate ))
al@303 258 remtimef=$(printf "%d:%02d" $(($remtime/60)) $(($remtime%60)))
al@303 259 eval_gettext 'Discharging $rempct% - $remtimef' ;;
al@303 260 "charging")
al@303 261 remtime=$(( ($full - $remain) * 60 / $rate ))
al@303 262 remtimef=$(printf "%d:%02d" $(($remtime/60)) $(($remtime%60)))
al@303 263 eval_gettext 'Charging $rempct% - $remtimef' ;;
al@303 264 "charged")
al@303 265 gettext 'Charged 100%' ;;
al@303 266 esac
al@419 267 cat <<EOT
al@419 268
al@419 269 </span>
al@419 270 </td>
al@419 271 </tr>
al@419 272 EOT
pascal@219 273 done
al@419 274 cat <<EOT
al@419 275 </table>
al@419 276 </div>
al@419 277 </section>
al@419 278 EOT
pascal@219 279 fi
al@303 280
al@419 281
al@419 282 # Thermal sensors
al@419 283 if [ -n "$(ls /sys/devices/virtual/thermal/*/temp 2>/dev/null)" ]; then
al@419 284 echo "<p><span data-icon=\"temperature\">$(gettext 'Temperature:')</span>"
pascal@262 285 for temp in /sys/devices/virtual/thermal/*/temp; do
al@419 286 awk '{ print $1/1000 "℃" }' < $temp
pascal@219 287 done
al@303 288 echo '</p>'
pascal@219 289 fi
al@303 290
al@419 291
al@419 292 # Brightness
al@419 293 if [ -n "$(ls /sys/devices/virtual/backlight/*/brightness 2>/dev/null)" ]; then
al@419 294 echo '<form>'
al@419 295 for dev in /sys/devices/virtual/backlight/*/brightness; do
pascal@262 296 name=$(echo $dev | sed 's|.*/backlight/\([^/]*\).*|\1|')
pascal@217 297 cat <<EOT
al@419 298 <input type="hidden" name="dev" value="$name"/>
al@419 299 <span data-icon="brightness">$(gettext 'Brightness')</span> \
pascal@263 300 $(sed 's/.*\.//;s/_*$//' < /sys/devices/virtual/backlight/$name/device/path):
al@419 301 <select name="brightness" onchange="submit();">
pascal@217 302 EOT
pascal@262 303 max=$(cat /sys/devices/virtual/backlight/$name/max_brightness)
pascal@262 304 for i in $(seq 0 $max); do
pascal@262 305 echo -n "<option value=\"$i\""
pascal@262 306 [ $i -eq $(cat /sys/devices/virtual/backlight/$name/actual_brightness) ] &&
pascal@262 307 echo -n " selected=\"selected\""
pascal@262 308 echo "> $(( (($i + 1) * 100) / ($max + 1) ))% </option>"
pascal@262 309 done
al@419 310 echo '</select>'
pascal@217 311 done
al@419 312 echo '</form>'
pascal@217 313 fi
pankso@152 314
al@363 315
al@419 316 cat <<EOT
al@419 317 <section>
al@419 318 <form action="#mount" class="wide">
al@419 319 <header id="disk">$(gettext 'Filesystem usage statistics')</header>
al@419 320 <div>
al@419 321 <pre>$(fdisk -l | fgrep Disk)</pre>
al@419 322 </div>
pankso@66 323 EOT
al@303 324
al@303 325
pankso@153 326 #
pascal@376 327 # Loop device management actions
pascal@376 328 #
pascal@376 329 device=$(GET loopdev)
pascal@376 330 lib crypto $device
pascal@376 331 case "$device" in
pascal@376 332 /dev/loop*)
pascal@376 333 set -- $(losetup | grep ^$device:)
pascal@376 334 [ -n "$3" ] && losetup -d $device
pascal@376 335 ro=""
pascal@376 336 [ -n "$(GET readonly)" ] && ro="-r"
pascal@376 337 file="$(GET backingfile)"
pascal@376 338 [ -n "$file" ] && losetup -o $(GET offset) $ro $device $file
pascal@376 339 esac
al@419 340
al@419 341
pascal@376 342 #
al@303 343 # Disk stats and management (mount, umount, check)
pankso@153 344 #
pascal@344 345 device=$(GET device)
pascal@373 346 lib crypto $device
pascal@344 347 case "$device" in
pascal@344 348 *[\;\`\&\|\$]*) ;;
pascal@344 349 mount\ *)
pascal@375 350 ro=""
pascal@375 351 [ -n "$(GET readonly)" ] && ro="-r"
pascal@389 352 mntdir="$(GET mountpoint)"
pascal@389 353 [ -d "$mntdir" ] || mkdir -p "$mntdir"
pascal@389 354 $device $ro "$mntdir";;
pascal@344 355 umount\ *|swapon\ *|swapoff\ *)
pascal@344 356 $device ;;
pascal@344 357 esac
al@419 358 cat <<EOT
al@419 359 <table id="mount" class="zebra wide center">
al@303 360 EOT
pankso@153 361 df_thead
al@303 362 echo '<tbody>'
al@419 363 for fs in $(blkid | sort | sed 's/:.*//')
pankso@153 364 do
pascal@373 365 set -- $(df -h | grep "^$fs ")
pascal@343 366 size=$2
pascal@343 367 used=$3
pascal@343 368 av=$4
pascal@375 369 grep "^$fs " /proc/mounts | grep -q "[, ]ro[, ]" &&
pascal@375 370 av="<del>$av</del>"
pascal@343 371 pct=$5
pascal@343 372 mp=$6
al@419 373
al@419 374 # action
pascal@344 375 action="mount"
pascal@344 376 [ -n "$mp" ] && action="umount"
pascal@344 377 type=$(blkid $fs | sed '/TYPE=/!d;s/.*TYPE="\([^"]*\).*/\1/')
pascal@344 378 [ "$type" == "swap" ] && action="swapon"
pascal@344 379 if grep -q "^$fs " /proc/swaps; then
pascal@344 380 action="swapoff"
pascal@344 381 set -- $(grep "^$fs " /proc/swaps)
pascal@364 382 size=$(blk2h $(($3*2)))
pascal@364 383 used=$(blk2h $(($4*2)))
pascal@364 384 av=$(blk2h $((2*($3-$4))))
pascal@344 385 pct=$(((100*$4)/$3))%
pascal@344 386 mp=swap
pascal@344 387 fi
al@419 388
al@419 389 # size
pascal@364 390 [ -z "$size" ] &&
pascal@364 391 size="$(blk2h $(cat /sys/block/${fs#/dev/}/size /sys/block/*/${fs#/dev/}/size))"
al@419 392
al@419 393 # image
al@419 394 disktype="hdd"
al@419 395 case "$(cat /sys/block/${fs#/dev/}/removable 2>/dev/null ||
al@419 396 cat /sys/block/${fs:5:3}/removable 2>/dev/null)" in
al@419 397 1) disktype="removable" ;;
pascal@373 398 esac
al@419 399 case "$(cat /sys/block/${fs#/dev/}/ro 2>/dev/null ||
al@419 400 cat /sys/block/${fs:5:3}/ro 2>/dev/null)" in
al@419 401 1) disktype="cd" ;;
pascal@373 402 esac
al@419 403
al@419 404 cat <<EOT
al@419 405 <tr>
al@419 406 <td><input type="radio" name="device" value="$action $fs" id="${fs#/dev/}"/><!--
al@419 407 --><label for="${fs#/dev/}" data-icon="$disktype">&thinsp;${fs#/dev/}</label></td>
al@419 408 <td>$(blkid $fs | sed '/LABEL=/!d;s/.*LABEL="\([^"]*\).*/\1/')</td>
al@419 409 <td>$type</td>
al@419 410 <td>$size</td>
al@419 411 <td>$av</td>
pascal@343 412 EOT
pascal@343 413 if [ -n "$pct" ]; then
al@419 414 cat <<EOT
al@419 415 <td class="meter"><meter min="0" max="100" value="${pct%%%}" low="70"
al@419 416 high="90" optimum="10"></meter>
al@419 417 <span>$used - $pct</span>
al@419 418 </td>
pascal@343 419 EOT
pascal@343 420 else
al@419 421 cat <<EOT
al@419 422 <td> </td>
pascal@343 423 EOT
pascal@343 424 fi
al@419 425 cat <<EOT
al@419 426 <td>$mp</td>
al@419 427 <td>$(blkid $fs | sed '/UUID=/!d;s/.*UUID="\([^"]*\).*/\1/')</td>
al@419 428 </tr>
pankso@153 429 EOT
pankso@153 430 done
al@419 431 cat <<EOT
al@419 432 </tbody>
al@419 433 </table>
al@419 434 $(lib crypto input)
al@363 435
al@419 436 <footer>
al@419 437 <button type="submit">mount / umount</button> -
al@419 438 $(gettext 'new mount point:') <input type="text" name="mountpoint" value="/media/usbdisk"/> -
al@419 439 <input type="checkbox" name="readonly" id="ro"><label for="ro">&thinsp;$(gettext 'read-only')</label>
al@419 440 </footer>
al@419 441 </form>
al@419 442 </section>
al@363 443 EOT
al@363 444
al@419 445
al@419 446 #
al@419 447 # /etc/fstab
al@419 448 #
al@419 449 cat <<EOT
al@419 450 <section>
al@419 451 <header>$(gettext 'Filesystems table')</header>
al@419 452 <table class="wide zebra center">
al@419 453 <thead>
al@419 454 <tr>
al@419 455 <td>$(gettext 'Disk')</td>
al@419 456 <td>$(gettext 'Mount point')</td>
al@419 457 <td>$(gettext 'Type')</td>
al@419 458 <td>$(gettext 'Options')</td>
al@419 459 <td>$(gettext 'Freq')</td>
al@419 460 <td>$(gettext 'Pass')</td>
al@419 461 </tr>
al@419 462 </thead>
al@419 463 <tbody>
al@419 464 EOT
al@419 465
al@419 466 grep -v '^#' /etc/fstab | awk '{
al@419 467 print "<tr><td>" $1 "</td><td>" $2 "</td><td>" $3 "</td><td>" $4
al@419 468 print "</td><td>" $5 "</td><td>" $6 "</td></tr>"
al@419 469 }
al@363 470 END{print "</tbody></table>"}'
al@363 471
al@419 472 cat <<EOT
al@419 473 <footer>
al@419 474 <form action="index.cgi">
al@419 475 <input type="hidden" name="file" value="/etc/fstab"/>
al@419 476 <button name="action" value="edit" data-icon="edit">$(gettext 'Edit')</button>
al@419 477 </form>
al@419 478 </footer>
al@419 479 </section>
al@419 480 EOT
al@363 481
al@363 482
al@419 483 #
al@419 484 # Loop device management GUI
al@419 485 #
al@419 486 cat <<EOT
al@419 487 <section>
al@419 488 <header>$(gettext 'Loop devices')</header>
al@419 489
al@419 490 <form action="#loop" class="wide">
al@419 491 <table id="loop" class="wide zebra">
al@419 492 <thead>
al@419 493 <tr>
al@419 494 <td>$(gettext 'Device')</td>
al@419 495 <td>$(gettext 'Backing file')</td>
al@419 496 <td>$(gettext 'Access')</td>
al@419 497 <td>$(gettext 'Offset')</td>
al@419 498 </tr>
al@419 499 </thead>
al@419 500 <tbody>
pascal@373 501 EOT
al@419 502 for devloop in $(ls /dev/loop[0-9]*); do
al@419 503 loop="${devloop#/dev/}"
al@419 504 case "$(cat /sys/block/$loop/ro 2>/dev/null)" in
al@419 505 0) ro="$(gettext "read/write")" ;;
al@419 506 1) ro="$(gettext "read only")" ;;
pascal@373 507 *) ro="" ;;
pascal@373 508 esac
al@419 509 set -- $(losetup | grep ^$devloop:) ${ro// /&nbsp;}
al@419 510 cat <<EOT
al@419 511 <tr><td><input type="radio" name="loopdev" value="$devloop" id="$loop"/><!--
al@419 512 --><label for="$loop" data-icon="loopback">$loop</label></td>
al@419 513 <td>$3</td><td align="center">$4</td><td align="right">$2</td>
al@419 514 </tr>
pascal@373 515 EOT
pascal@373 516 done
al@419 517 cat <<EOT
al@419 518 </tbody>
al@419 519 </table>
al@419 520
pascal@373 521 $(lib crypto input)
al@419 522
al@419 523 <footer>
al@419 524 <button type="submit" data-icon="ok">$(gettext 'Setup')</button> -
al@419 525 $(gettext 'new backing file:') <input type="text" name="backingfile"/> -
al@419 526 $(gettext 'offset in bytes:') <input type="text" name="offset" value="0" size="8"/> -
al@419 527 <input type="checkbox" name="readonly" id="ro"/><label for="ro">$(gettext 'read only')</label>
al@419 528 </footer>
al@419 529 </form>
al@419 530 </section>
pascal@373 531 EOT
pascal@373 532
al@419 533
al@419 534 #
al@419 535 # System memory
al@419 536 #
al@419 537 mem_total=$(free -m | awk '$1 ~ "M" {print $2}')
al@419 538 mem_used=$((100 * $(free -m | awk '$1 ~ "+" {print $3}') / mem_total))
al@419 539 mem_buff=$((100 * $(free -m | awk '$1 ~ "M" {print $6}') / mem_total))
al@419 540 mem_free=$((100 - mem_used - mem_buff))
al@419 541
al@419 542 cat <<EOT
al@419 543 <section>
al@419 544 <header>$(gettext 'System memory')</header>
al@419 545
al@419 546 <div class="sysmem"><!--
al@419 547 --><span class="sysmem_used" style="width: ${mem_used}%" title="$(gettext 'Used')" ><span>${mem_used}%</span></span><!--
al@419 548 EOT
al@419 549 [ $mem_buff != 0 ] && cat <<EOT
al@419 550 --><span class="sysmem_buff" style="width: ${mem_buff}%" title="$(gettext 'Buffers')"><span>${mem_buff}%</span></span><!--
al@419 551 EOT
al@419 552 cat <<EOT
al@419 553 --><span class="sysmem_free" style="width: ${mem_free}%" title="$(gettext 'Free')" ><span>${mem_free}%</span></span><!--
al@419 554 --></div>
al@419 555
al@419 556 <table class="wide zebra center">
al@419 557 <thead>
al@419 558 <tr>
al@419 559 <td>&nbsp;</td>
al@419 560 <td>total</td>
al@419 561 <td>used</td>
al@419 562 <td>free</td>
al@419 563 <td>shared</td>
al@419 564 <td>buffers</td>
al@419 565 </tr>
al@419 566 </thead>
al@419 567 <tbody>
al@303 568 EOT
al@303 569
al@419 570 free -m | awk '
al@419 571 $1 ~ "M" {print "<tr><td>"$1"</td><td>"$2"</td><td>"$3"</td><td>"$4"</td><td>"$5"</td><td>"$6"</td></tr>"}
al@419 572 $1 ~ "+" {print "<tr><td>"$1 $2"</td><td></td><td>"$3"</td><td>"$4"</td><td></td><td></td></tr>"}
al@419 573 $1 ~ "S" {print "<tr><td>"$1"</td><td>"$2"</td><td>"$3"</td><td>"$4"</td><td></td><td></td></tr>"}'
al@303 574
al@419 575 cat <<EOT
al@419 576 </tbody>
al@419 577 </table>
al@419 578 </section>
al@419 579 EOT
al@303 580
al@419 581
al@419 582 #
al@419 583 # lspci and lsusb summary tables
al@419 584 #
al@419 585 cat <<EOT
al@419 586 <section>
al@419 587 <header>lspci</header>
al@419 588 $(lspci_table)
al@419 589 </section>
al@419 590
al@419 591
al@419 592 <section>
al@419 593 <header>lsusb</header>
al@419 594 $(lsusb_table)
al@419 595 </section>
al@303 596 EOT
al@419 597 ;;
pankso@46 598 esac
pankso@46 599
pankso@46 600 xhtml_footer
pankso@46 601 exit 0