wok-tiny view manager/stuff/var/www/index.sh @ rev 47

manager: fix boot.log ouput
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Apr 30 15:39:10 2011 +0200 (2011-04-30)
parents ad4637f89bde
children
line source
1 #!/bin/sh
3 . /usr/bin/httpd_helper.sh
5 cpu()
6 {
7 grep '^model name' /proc/cpuinfo | head -n 1 | \
8 sed -e 's/.*Intel(R) //' -e 's/.*AMD //' -e 's/.*: //' \
9 -e 's/@//' -e 's/(R)//' -e 's/(TM)//' -e 's/CPU //' -e 's/Processor //'
10 }
12 header
14 cat <<EOT
15 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
16 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
17 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
18 <head>
19 <title>status tiny server $(hostname) - $HTTP_HOST
20 </title>
21 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
22 <meta name="description" content="Tiny server manager" />
23 <meta name="expires" content="never" />
24 <meta name="modified" content="2008-03-05 16:33:00" />
25 <link rel="shortcut icon" href="css/favicon.ico" />
26 <link rel="stylesheet" type="text/css" href="css/slitaz.css" />
27 </head>
28 <body bgcolor="#ffffff">
29 <div id="header">
30 <a name="top"></a>
31 <!-- Access -->
32 <div id="access">
33 $([ -d /var/www/wiki ] && echo "<a href="/wiki/index.sh" title="Wiki">Wiki</a> |")
34 $([ -n "$GET__NAMES" ] && echo "<a href="$SCRIPT_NAME" title="Status">Status</a> |")
35 <a href="adm/index.sh?/sbin/poweroff" title="Poweroff">Power down</a> |
36 <a href="adm/index.sh?/sbin/reboot" title="Reboot">Reboot</a>
37 </div>
38 <a href="http://www.slitaz.org/"><img id="logo"
39 src="css/pics/website/logo.png" title="www.slitaz.org"
40 alt="www.slitaz.org"
41 style="border: 0px solid ; width: 200px; height: 74px;" /></a>
42 <p id="titre">#!/tinyserver/status</p>
44 </div>
45 <!-- Navigation menu -->
46 <div id="nav">
48 <div class="nav_box">
49 <h4>Services</h4>
51 <!-- Start content -->
52 <table>
53 EOT
55 for svr in $( . ../../etc/rcS.conf ; cd /usr/sbin ; ls pppd 2> /dev/null ; echo $RUN_DAEMONS | sed 's/ /\n/g' | sort) ; do
56 status="<td>$svr</td><td><a href=\"adm/index.sh?stop=$svr\">stop</a></td><td><a href=\"adm/index.sh?restart=$svr\">restart</a></td>"
57 grep -vs ^\# /etc/inetd.conf | grep -q $(which $svr) &&
58 [ -n "$(ps | grep -v grep | grep /usr/sbin/inetd)" ] ||
59 [ -n "$(ps | grep -v grep | grep $(which $svr) )" ] ||
60 status="<td><strike>$svr</strike></td><td><a href=\"adm/index.sh?start=$svr\">start</a></td><td></td>"
61 case "$svr" in
62 pppd) info="<td><a href=\"$SCRIPT_NAME?show=/etc/ppp/scripts/ppp-on,/etc/ppp/scripts/ppp-on-dialer,/etc/ppp/options\">scripts</a></td>";;
63 tftpd) info="<td><a href=\"$SCRIPT_NAME?list=/boot\">files</a></td>";;
64 ftpd) info="<td><a href=\"$SCRIPT_NAME?list=/var/ftp\">files</a></td>";;
65 udhcpd) info="<td><a href=\"$SCRIPT_NAME?leases\">leases</a></td>";;
66 httpd) info="<td><a href=\"$SCRIPT_NAME?httpinfo\">info</a></td>";;
67 *) info="<td></td>";;
68 esac
69 echo -e " <tr>\n $status$info\n </tr>"
70 done
71 cat <<EOT
72 </table>
73 </div>
75 <div class="nav_box">
76 <h4>Log files</h4>
77 <table>
78 EOT
79 for i in $(ls /var/log); do
80 case "$i" in
81 boot-time|wtmp) continue;;
82 esac
83 cat <<EOT
84 <tr>
85 <td><a href="$SCRIPT_NAME?show=/var/log/$i" title="Show file /var/log/$i">
86 $i</a></td><td>$(du -h /var/log/$i | cut -f1)</td>
87 </tr>
88 EOT
89 done
90 cat <<EOT
91 </table>
92 </div>
94 <div class="nav_box">
95 <h4>Configuration files</h4>
96 <table>
97 EOT
98 for i in $(cd /etc ; ls *.conf); do
99 cat <<EOT
100 <tr>
101 <td><a href="$SCRIPT_NAME?show=/etc/$i" title="Show file /etc/$i">
102 $i</a></td><td>$(du -h /etc/$i | cut -f1)</td>
103 </tr>
104 EOT
105 done
106 cat <<EOT
107 </table>
108 </div>
110 </div>
112 <div id="content">
113 <h4>$(date) - $(hostname) - $(cpu) - $HTTP_HOST</h4>
114 EOT
115 case "$GET__NAMES" in
116 show) for i in $(GET show | sed 's/,/ /g'); do
117 cat <<EOT
118 <h2>File $i</h2>
119 <pre>
120 EOT
121 case "$i" in
122 /etc/ppp*) cat $i ;;
123 *boot.log) sed -e s'/\[^Gm]*.//g' \
124 -e ':a;s/^\(.\{1,68\}\)\(\[ [A-Za-z]* \]\)/\1 \2/;ta' $i ;;
125 *) su -c "cat $i" tux ;;
126 esac
127 cat <<EOT
128 </pre>
129 EOT
130 done
131 ;;
132 list) cat <<EOT
133 <h2>Files in $(GET list)</h2>
134 <pre>
135 $( su -c "cd $(GET list) && find * | xargs ls -ld" tux )
136 </pre>
137 EOT
138 ;;
139 leases) cat <<EOT
140 <h2>DHCP Leases</h2>
141 <pre>
142 $(cat /var/lib/misc/udhcpd.leases)
143 </pre>
144 EOT
145 ;;
146 httpinfo) cat <<EOT
147 <h2>HTTP Infos</h2>
148 <pre>
149 $(httpinfo)
150 </pre>
151 EOT
152 ;;
153 *) cat <<EOT
154 <a name="disk"></a>
155 <h2>Disk usage</h2>
156 <pre>
157 $(df -h | sed '/^rootfs/d' | grep '\(^/dev\|Filesystem\)')
158 </pre>
159 <a name="network"></a>
160 <h2>Network</h2>
161 <h3>Interfaces</h3>
162 <pre>
163 $(ifconfig)
164 </pre>
165 <h3>Routing table</h3>
166 <pre>
167 $(route)
168 </pre>
169 <h3>Connexions</h3>
170 <pre>
171 $(netstat -ap)
172 </pre>
173 EOT
174 [ -f /proc/net/ip_conntrack ] && cat <<EOT
175 <h3>Active connexions</h3>
176 <pre>
177 $(cat /proc/net/ip_conntrack)
178 </pre>
179 EOT
180 cat <<EOT
181 <h3>Arp table</h3>
182 <pre>
183 $(arp)
184 </pre>
185 <a name="processes"></a>
186 <h2>Processes</h2>
187 <h3>Memory</h3>
188 <pre>
189 $(free)
190 </pre>
191 <h3>Process list</h3>
192 <pre>
193 Uptime $(uptime | sed 's/^\s*//')
194 </pre>
195 <pre>
196 $(top -n1 -b)
197 </pre>
198 <a name="boot"></a>
199 <h2>Boot command args</h2>
200 <pre>
201 $(cat /proc/cmdline)
202 </pre>
203 <a name="users"></a>
204 <h2>Users</h2>
205 <pre>
206 $(last)
207 </pre>
208 EOT
209 ;;
210 esac
212 cat <<EOT
213 </div>
214 <!-- End content -->
215 <!-- Start of footer and copy notice -->
216 <div id="copy">
217 <p>
218 Copyright © $(date +%Y) <a href="http://www.slitaz.org/">SliTaz</a> -
220 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>
221 </p>
222 <!-- End of copy -->
223 </div>
225 </body>
226 </html>
227 EOT