tazpanel view index.cgi @ rev 43

hardeare: display kernel module and link to modinfo
author Christophe Lincoln <pankso@slitaz.org>
date Thu Apr 07 03:12:38 2011 +0200 (2011-04-07)
parents a7b1d69663c3
children 56d55a9dcc9c
line source
1 #!/bin/sh
2 #
3 # Main CGI interface for TazPanel. In on word: KISS. Use the main cas form
4 # command so we are faster and dont load unneeded function. If nececarry
5 # you can use the lib/ dir to handle external resources.
6 #
7 # Copyright (C) 2011 SliTaz GNU/Linux - GNU gpl v3
8 #
9 echo "Content-Type: text/html"
10 echo ""
12 # Common functions from libtazpanel
13 . lib/libtazpanel
14 get_config
16 # Include gettext helper script.
17 . /usr/bin/gettext.sh
19 # Export package name for gettext.
20 TEXTDOMAIN='tazpanel'
21 export TEXTDOMAIN
23 #
24 # Commands
25 #
27 case "$QUERY_STRING" in
28 boot)
29 #
30 # Everything until user login
31 #
32 . /etc/rcS.conf
33 TITLE="- Boot"
34 xhtml_header
35 cat << EOT
36 <div id="wrapper">
37 <h2>`gettext "Boot &amp; startup"`</h2>
38 <p>
39 `gettext "Everything that appends before user login."`
40 </p>
41 </div>
43 <h3>`gettext "Kernel cmdline"`</h3>
44 <pre>
45 `cat /proc/cmdline`
46 </pre>
48 <h3>`gettext "Local startup commands"`</h3>
49 <pre>
50 `cat /etc/init.d/local.sh`
51 </pre>
53 EOT
54 ;;
55 hardware|modinfo=*)
56 #
57 # Hardware drivers, devices, filesystem, screen
58 #
59 TITLE="- Hardware"
60 xhtml_header
61 cat << EOT
62 <div id="wrapper">
63 <h2>`gettext "Drivers &amp; Devices"`</h2>
64 <p>`gettext "Manage your computer hardware`</p>
65 </div>
66 EOT
67 echo '<pre>'
68 fdisk -l | fgrep Disk
69 echo '</pre>'
70 echo '<h3>Filesystem usage statistics</h3>'
71 echo '<pre>'
72 df -h | grep ^/dev
73 echo '</pre>'
74 echo '<h3>Loaded kernel modules</h3>'
75 # We may want modinfi output
77 case "$QUERY_STRING" in
78 modinfo=*)
79 mod=${QUERY_STRING#modinfo=}
80 gettext "Detailled information for module:"; echo " $mod"
81 echo '<pre>'
82 modinfo $mod
83 echo '</pre>' ;;
84 rmmod=*)
85 mod=${QUERY_STRING#rmmod=}
86 modprobe -r $mod ;;
87 esac
88 table_start
89 cat << EOT
90 <tr class="thead">
91 <td>`gettext "Module"`</td>
92 <td>`gettext "Size"`</td>
93 <td>`gettext "Used"`</td>
94 <td>`gettext "by"`</td>
95 </tr>
96 EOT
97 # Get the list of modules and link to modinfo
98 lsmod | grep ^[a-z] | while read line
99 do
100 mod=`echo "$line" | awk '{print $1}'`
101 echo '<tr>'
102 echo "<td><a href='$SCRIPT_NAME?modinfo=$mod'>$mod</a></td>"
103 echo "$line" | awk '{print "<td>", $2, "</td>",
104 "<td>", $3, "</td>", "<td>", $4, "</td>"}'
105 echo '</tr>'
106 done
107 table_end
108 echo '<h3>lspci</h3>'
109 echo '<pre>'
110 lspci
111 echo '</pre>'
112 ;;
113 *)
114 #
115 # Default xHTML content
116 #
117 xhtml_header
118 case "$QUERY_STRING" in
119 gen-locale=*)
120 new_locale=${QUERY_STRING#gen-locale=} ;;
121 rdate)
122 echo "" ;;
123 esac
124 cat << EOT
125 <div id="wrapper">
126 <h2>`gettext "Host:"` `hostname`</h2>
127 <p>`gettext "SliTaz administration et configuration Panel"`<p>
128 </div>
130 <h3>`gettext "Summary"`</h3>
131 <div id="summary">
132 <p>
133 `gettext "Uptime:"` `uptime`
134 </p>
135 <p>
136 `gettext "Memory in Mb"`
137 `free -m | grep Mem: | awk \
138 '{print "| Total:", $2, "| Used:", $3, "| Free:", $4}'`
139 </p>
140 <!-- Close summary -->
141 </div>
143 <h4>`gettext "Network status"`</h4>
144 `list_network_interfaces`
146 <h4>`gettext "Filesystem usage statistics"`</h4>
147 <pre>
148 `df -h | grep ^/dev`
149 </pre>
150 EOT
151 ;;
152 esac
154 xhtml_footer
155 exit 0