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

manager: send headers!
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Apr 01 15:24:43 2011 +0200 (2011-04-01)
parents 44490bf52c19
children 2adbda7368cd
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 *) su -c "cat $i" tux ;;
124 esac
125 cat <<EOT
126 </pre>
127 EOT
128 done
129 ;;
130 list) cat <<EOT
131 <h2>Files in $(GET list)</h2>
132 <pre>
133 $( su -c "cd $(GET list) && find * | xargs ls -ld" tux )
134 </pre>
135 EOT
136 ;;
137 leases) cat <<EOT
138 <h2>DHCP Leases</h2>
139 <pre>
140 $(cat /var/lib/misc/udhcpd.leases)
141 </pre>
142 EOT
143 ;;
144 httpinfo) cat <<EOT
145 <h2>HTTP Infos</h2>
146 <pre>
147 $(httpinfo)
148 </pre>
149 EOT
150 ;;
151 *) cat <<EOT
152 <a name="disk"></a>
153 <h2>Disk usage</h2>
154 <pre>
155 $(df -h | sed '/^rootfs/d' | grep '\(^/dev\|Filesystem\)')
156 </pre>
157 <a name="network"></a>
158 <h2>Network</h2>
159 <h3>Interfaces</h3>
160 <pre>
161 $(ifconfig)
162 </pre>
163 <h3>Routing table</h3>
164 <pre>
165 $(route)
166 </pre>
167 <h3>Connexions</h3>
168 <pre>
169 $(netstat -ap)
170 </pre>
171 EOT
172 [ -f /proc/net/ip_conntrack ] && cat <<EOT
173 <h3>Active connexions</h3>
174 <pre>
175 $(cat /proc/net/ip_conntrack)
176 </pre>
177 EOT
178 cat <<EOT
179 <h3>Arp table</h3>
180 <pre>
181 $(arp)
182 </pre>
183 <a name="processes"></a>
184 <h2>Processes</h2>
185 <h3>Memory</h3>
186 <pre>
187 $(free)
188 </pre>
189 <h3>Process list</h3>
190 <pre>
191 Uptime $(uptime | sed 's/^\s*//')
192 </pre>
193 <pre>
194 $(top -n1 -b)
195 </pre>
196 <a name="boot"></a>
197 <h2>Boot command args</h2>
198 <pre>
199 $(cat /proc/cmdline)
200 </pre>
201 <a name="users"></a>
202 <h2>Users</h2>
203 <pre>
204 $(last)
205 </pre>
206 EOT
207 ;;
208 esac
210 cat <<EOT
211 </div>
212 <!-- End content -->
213 <!-- Start of footer and copy notice -->
214 <div id="copy">
215 <p>
216 Copyright © $(date +%Y) <a href="http://www.slitaz.org/">SliTaz</a> -
218 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>
219 </p>
220 <!-- End of copy -->
221 </div>
223 </body>
224 </html>
225 EOT