tazpanel rev 161

Add report creation (to help debbuging)
author Christophe Lincoln <pankso@slitaz.org>
date Thu Apr 21 17:21:12 2011 +0200 (2011-04-21)
parents fa2ea2d2ece4
children f60dbe1151cb
files index.cgi lib/libtazpanel styles/default/images/monitor.png
line diff
     1.1 --- a/index.cgi	Wed Apr 20 20:17:46 2011 +0100
     1.2 +++ b/index.cgi	Thu Apr 21 17:21:12 2011 +0200
     1.3 @@ -56,10 +56,15 @@
     1.4  		#
     1.5  		# Handle files
     1.6  		#
     1.7 -		TITLE="- File"
     1.8 -		xhtml_header
     1.9  		file="$(GET file)"
    1.10 -		echo "<h2>$file</h2>"
    1.11 +		case $file in
    1.12 +			*.html)
    1.13 +				cat $file && exit 0 ;;
    1.14 +			*)
    1.15 +				TITLE="- File"
    1.16 +				xhtml_header
    1.17 +				echo "<h2>$file</h2>" ;;
    1.18 +		esac
    1.19  		if [ "$(GET action)" == "edit" ]; then
    1.20  			cat <<EOT
    1.21  <form method="post" action="$SCRIPT_NAME?file=$file">
    1.22 @@ -112,6 +117,83 @@
    1.23  		echo '<pre>'
    1.24  		httpinfo
    1.25  		echo '</pre>' ;;
    1.26 +	*\ report\ *)
    1.27 +		TITLE="- $(gettext "System report")"
    1.28 +		output=/var/cache/slitaz/sys-report.html
    1.29 +		xhtml_header
    1.30 +		echo "<h2>$(gettext "Reporting to:") $output</h2>"
    1.31 +		echo '<pre>'
    1.32 +		gettext "Creating report header...  "
    1.33 +		cat > $output << EOT
    1.34 +<!DOCTYPE html>
    1.35 +<html xmlns="http://www.w3.org/1999/xhtml">
    1.36 +<head>
    1.37 +	<title>SliTaz system report</title>
    1.38 +	<style type="text/css">
    1.39 +		body { padding: 20px 60px; font-size: 13px; } h1, h2 { color: #444; }
    1.40 +		pre { background: #f1f1f1; border: 1px solid #ddd;
    1.41 +			padding: 10px; border-radius: 4px; }
    1.42 +	</style>
    1.43 +</head>
    1.44 +<body>
    1.45 +EOT
    1.46 +		ok_status
    1.47 +		gettext "Creating system summary... "
    1.48 +		cat >> $output << EOT
    1.49 +<h1>SliTaz system report</h1>
    1.50 +Date: $(date)
    1.51 +<pre>
    1.52 +uptime   :$(uptime)
    1.53 +cmdline  : $(cat /proc/cmdline)
    1.54 +version  : $(cat /etc/slitaz-release)
    1.55 +packages : $(ls /var/lib/tazpkg/installed | wc -l) installed
    1.56 +kernel   : $(uname -r)
    1.57 +</pre>
    1.58 +EOT
    1.59 +		ok_status
    1.60 +		gettext "Getting hardware info...   "
    1.61 +		cat >> $output << EOT
    1.62 +<h2>free</h2>
    1.63 +<pre>
    1.64 +$(free)
    1.65 +</pre>
    1.66 +
    1.67 +<h2>lspci -k</h2>
    1.68 +<pre>
    1.69 +$(lspci -k)
    1.70 +</pre>
    1.71 +
    1.72 +<h2>lsusb</h2>
    1.73 +<pre>
    1.74 +$(lsusb)
    1.75 +</pre>
    1.76 +
    1.77 +<h2>lsmod</h2>
    1.78 +<pre>
    1.79 +$(lsmod)
    1.80 +</pre>
    1.81 +
    1.82 +EOT
    1.83 +		ok_status
    1.84 +		gettext "Getting networking info... "
    1.85 +		cat >> $output << EOT
    1.86 +<h2>ifconfig -a</h2>
    1.87 +<pre>
    1.88 +$(ifconfig -a)
    1.89 +</pre>
    1.90 +EOT
    1.91 +		ok_status
    1.92 +		gettext "Creating report footer...  "
    1.93 +		cat cat >> $output << EOT
    1.94 +</body>
    1.95 +</html>
    1.96 +EOT
    1.97 +		ok_status
    1.98 +		echo '</pre>'
    1.99 +		echo "<p><a class='button' href='$SCRIPT_NAME?file=$output'>
   1.100 +			$(gettext "View report")</a>"
   1.101 +		gettext "This report can be attached with a bug report on: "
   1.102 +		echo '<a href="http://bugs.slitaz.org/">bugs.slitaz.org</a></p>' ;;
   1.103  	*)
   1.104  		#
   1.105  		# Default xHTML content
   1.106 @@ -125,19 +207,20 @@
   1.107  	<p>$(gettext "SliTaz administration and configuration Panel")<p>
   1.108  </div>
   1.109  <div id="actions">
   1.110 -	<a class="button" href="$SCRIPT_NAME?top">$(gettext "Process activity")</a>
   1.111 +	<a class="button" href="$SCRIPT_NAME?top">
   1.112 +		<img src="$IMAGES/monitor.png" />$(gettext "Process activity")</a>
   1.113 +	<a class="button" href="$SCRIPT_NAME?report">
   1.114 +		<img src="$IMAGES/text.png" />$(gettext "Create a report")</a>
   1.115  </div>
   1.116  
   1.117  <h3>$(gettext "Summary")</h3>
   1.118  <div id="summary">
   1.119 -	<p>
   1.120 -		$(gettext "Uptime:") $(uptime)
   1.121 -	</p>
   1.122 -	<p>
   1.123 -		$(gettext "Memory in Mb")
   1.124 -		$(free -m | grep Mem: | awk \
   1.125 -		'{print "| Total:", $2, "| Used:", $3, "| Free:", $4}')
   1.126 -	</p>
   1.127 +<pre>
   1.128 +$(gettext "Uptime       :")$(uptime)
   1.129 +$(gettext "Memory in Mb :") $(free -m | grep Mem: | awk \
   1.130 +	'{print "Total:", $2, "Used:", $3, "Free:", $4}')
   1.131 +$(gettext "Linux kernel :") $(uname -r)
   1.132 +</pre>
   1.133  <!-- Close summary -->
   1.134  </div>
   1.135  
     2.1 --- a/lib/libtazpanel	Wed Apr 20 20:17:46 2011 +0100
     2.2 +++ b/lib/libtazpanel	Thu Apr 21 17:21:12 2011 +0200
     2.3 @@ -57,6 +57,10 @@
     2.4  	sed s"#[^']*#$date : \0#" >> $LOG_FILE
     2.5  }
     2.6  
     2.7 +ok_status() {
     2.8 +	echo "[<span class='diff-add'> OK </span>]"
     2.9 +}
    2.10 +
    2.11  # Network interface status
    2.12  interface_status() {
    2.13  	if 	ifconfig | grep -A 1 $i | grep -q inet; then
     3.1 Binary file styles/default/images/monitor.png has changed