--- /usr/share/httpd/cgi-bin/monshow.cgi	Wed Sep  5 10:33:49 2001
+++ /webmin-0.87/mon/monshow.cgi	Mon Sep 10 13:28:48 2001
@@ -1,5 +1,6 @@
 #!/usr/bin/perl
 #
+# modified to customize for this webmin module of MON-dt 09th sept 2001
 # monshow - concise, user view-based opstatus summary
 #
 # Jim Trocki, trockij@transmeta.com
@@ -22,8 +23,18 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
+require './mon-lib.pl';
+&init_config();
+&header($text{'mon_status_title'}, "","monshow");
+print "<hr>\n";
+system("/bin/rm -f /webmin-0.87/mon/data/file 1>/dev/null 2>&1") if(-f "/webmin-0.87/mon/data/file");
+local $status = &backquote_logged("/etc/init.d/mon status 2>&1 </dev/null");
+if (!($status=~/running/)){
+	&error("$text{'err_monrun'} <a href='./'>Click here ...</a>");
+}
+#
+#
 use strict "vars";
-
 use Getopt::Long;
 use English;
 use CGI;
@@ -101,7 +112,8 @@
     "show-disabled"	=> 0,
     "bg"		=> "d5d5d5",
     "bg-ok"		=> "a0d0a0",
-    "bg-fail"		=> "e088b7",
+    "bg-fail"		=> "FF66FF",
+    "bg-disabled"	=> "FAEBD7",
     "bg-untested"	=> "e0e0e0",
     "table-color"	=> "cccccc",
 };
@@ -199,11 +211,14 @@
 
 if ($CGI)
 {
+#Content-type: text/html
     print <<EOF;
-Content-type: text/html
 
 $OUT_BUF
+<br><hr><br>
 EOF
+
+&footer("./","MON Index page");
 }
 
 else
@@ -334,7 +349,7 @@
     my @RC;
     my $view = 0;
 
-    my $RC = "/etc/mon/monshowrc";
+    my $RC = "/webmin-0.87/mon/monshowrc";
 
     if ($CGI)
     {
@@ -452,6 +467,7 @@
 		elsif ($cmd eq "bg") { }
 		elsif ($cmd eq "bg-ok") { }
 		elsif ($cmd eq "bg-fail") { }
+		elsif ($cmd eq "bg-disabled") { }
 		elsif ($cmd eq "bg-untested") { }
 		elsif ($cmd eq "table-color") { }
 		elsif ($cmd eq "html-header") { $html_header = 1; next; }
@@ -830,11 +846,10 @@
 	}
 
 	$OUT_BUF .= <<EOF;
-<h1><FONT FACE="sans-serif">Operational Status</font></h1>
 <body bgcolor="$CF->{'bg'}">
 
-<table width="100%">
-    <tr>
+<table width="100%" border>
+    <tr bgcolor=$CF->{'table-color'}>
 	<td>
 	    <table>
 		<tr>
@@ -866,25 +881,22 @@
 	</td>
 
 	<td>
-	    <table>
+	    <table cellpadding=2 cellspacing=3>
 		<tr>
-		    <td><FONT FACE="sans-serif">Color legend</FONT></td>
+		    <td><FONT FACE="sans-serif" size=+1><b>Color legend</b></FONT></td>
 		</tr>
 		<tr>
 		    <td bgcolor="$CF->{'bg-ok'}"> all is OK </td>
-		</tr>
-		<tr>
 		    <td bgcolor="$CF->{'bg-fail'}"> failure </td>
-		</tr>
-		<tr>
 		    <td bgcolor="$CF->{'bg-untested'}"> untested </td>
+		    <td bgcolor="$CF->{'bg-disabled'}"> disabled </td>
 		</tr>
 	    </table>
 	</td>
     </tr>
 </table>
 <p>
-<hr>
+<br>
 EOF
     }
 
@@ -1032,17 +1044,17 @@
     if ($CGI)
     {
 	$OUT_BUF .= <<EOF;
-
-<table cellpadding=2 cellspacing=1 bgcolor="#$CF->{'table-color'}" width="100%">
-    <th><FONT FACE="sans-serif">Dep</FONT>
-    <th><FONT FACE="sans-serif">Group</FONT>
-    <th><FONT FACE="sans-serif">Service</FONT>
-    <th><FONT FACE="sans-serif">Desc.</FONT>
-    <th><FONT FACE="sans-serif">Last check</FONT>
-    <th><FONT FACE="sans-serif">Next check</FONT>
-    <th><FONT FACE="sans-serif">Alerts</FONT>
-    <th><FONT FACE="sans-serif">Status</FONT>
-    <th><FONT FACE="sans-serif">Summary</FONT>
+	<h2><center>Full View </h2>(To Disable / View Details, Click on the link under Service column)</center>
+<table border cellpadding=2 cellspacing=1 bgcolor="#$CF->{'table-color'}" width="100%">
+    <th><FONT FACE="sans-serif" size=+1>Depends</FONT>
+    <th><FONT FACE="sans-serif" size=+1>Group</FONT>
+    <th><FONT FACE="sans-serif" size=+1>Service</FONT>
+    <th><FONT FACE="sans-serif" size=+1>Desc.</FONT>
+    <th><FONT FACE="sans-serif" size=+1>Last check</FONT>
+    <th><FONT FACE="sans-serif" size=+1>Next check</FONT>
+    <th><FONT FACE="sans-serif" size=+1>Alerts</FONT>
+    <th><FONT FACE="sans-serif" size=+1>Status</FONT>
+    <th><FONT FACE="sans-serif" size=+1>Summary</FONT>
 
 EOF
     }
@@ -1095,7 +1107,7 @@
 
 	$GROUP = $group;
 	$SERVICE = $service;
-	$DESC = $st->{"desc"}->{$group}->{$service};
+	$DESC = $st->{"desc"}->{$group}->{$service}."&nbsp;";
 
 
 	if ($TIME eq "")
@@ -1164,8 +1176,8 @@
     if ($CGI)
     {
 	$OUT_BUF .= <<EOF;
-</table>
-
+</table><br><br>
+<center><font color=red size=+1><b>Disabled Hosts/Watch/Services</b></font></center>
 EOF
     }
 }
@@ -1182,7 +1194,9 @@
 	{
 	    $OUT_BUF .= <<EOF;
 <br>
-Nothing is disabled.
+<center><table width=50% border>
+<tr align=center bgcolor="$CF->{'bg-ok'}">
+<td>Nothing is disabled</td></tr></table></center>
 <p>
 EOF
 	}
@@ -1200,9 +1214,10 @@
 	if ($CGI)
 	{
 	    $OUT_BUF .= <<EOF;
-
-<h2> Disabled Watches </h2>
-
+<br>
+<center><table width=100% border>
+<tr align=center bgcolor="$CF->{'table-color'}">
+<td width=50%><b>Disabled Watches</b></td><td>Click Link to Enable Desired Watch</td></tr>
 EOF
 	}
 
@@ -1215,7 +1230,7 @@
 	{
 	    if ($CGI)
 	    {
-	    	$OUT_BUF .= "$watch <br>\n";
+	    	$OUT_BUF .= "<tr bgcolor=$CF->{'bg-disabled'}><td>$watch</td><td><a href='moncmd.cgi?enable=watch&watch=$watch'>Enable Watch</a></td></tr>\n";
 	    }
 
 	    else
@@ -1223,6 +1238,10 @@
 		print "$watch\n";
 	    }
 	}
+	if ($CGI)
+        {
+               $OUT_BUF .= "</table></center>\n";
+        }
     }
 
     my @disabled_services;
@@ -1239,9 +1258,10 @@
 	if ($CGI)
 	{
 	    $OUT_BUF .= <<EOF;
-
-<h2> Disabled Services </h2>
-
+<br>
+<center><table width=100% border>
+<tr align=center bgcolor="$CF->{'table-color'}">
+<td width=50%><b>Disabled Services (Hostgroup -> Service) </b></td><td>Click Link to Enable Desired Service</td></tr>
 EOF
 	}
 
@@ -1253,7 +1273,9 @@
 	{
 	    if ($CGI)
 	    {
-	    	$OUT_BUF .= "$_ <br>\n";
+		my $aaa=$_;
+		$aaa=~s/\s+/ -> /;
+	    	$OUT_BUF .= "<tr bgcolor=$CF->{'bg-disabled'}><td>$aaa</td><td><a href='moncmd.cgi?enable=service&service=$_'>Enable Service</a></td></tr>\n";
 	    }
 
 	    else
@@ -1261,6 +1283,10 @@
 		print "$_\n";
 	    }
 	}
+        if ($CGI)
+        {
+           $OUT_BUF .= "</table></center>\n";
+        }
     }
 
     if (keys %{$disabled->{"hosts"}})
@@ -1268,9 +1294,10 @@
 	if ($CGI)
 	{
 	    $OUT_BUF .= <<EOF;
-
-<h2> Disabled Hosts </h2>
-
+<br>
+<center><table width=100% border>
+<tr align=center bgcolor="$CF->{'table-color'}">
+<td width=50%><b>Disabled Hosts (Hostgroup -> Host)</b><td>Click Link to Enable Desired Host</td></td></tr>
 EOF
 	}
 
@@ -1287,7 +1314,9 @@
 	    }
 	    if ($CGI)
 	    {
-		$OUT_BUF .= sprintf ("%-15s %s <br>\n", $group, "@HOSTS");
+		foreach my $sdd(@HOSTS){
+			$OUT_BUF .= sprintf ("<tr bgcolor=$CF->{'bg-disabled'}><td>%-15s -> %s </td><td><a href='moncmd.cgi?enable=host&host=$sdd'>Enable Host</a></td></tr>\n", $group, $sdd);
+		}
 	    }
 
 	    else
@@ -1295,6 +1324,10 @@
 		printf ("%-15s %s\n", $group, "@HOSTS");
 	    }
 	}
+        if ($CGI)
+        {
+           $OUT_BUF .= "</table></center>\n";
+        }
     }
 }
 
@@ -1376,27 +1409,32 @@
     {
     $OUT_BUF .= <<EOF;
 
-<h2><FONT FACE="sans-serif">Detail for $group/$service</font></h2>
+<h1><center><FONT FACE="sans-serif">Detail for $group/$service</font></h1>(Click the link to Disable Watch/Service/Hosts )</center>
 
-<table width="100%">
-    <tr $bgcolor>
-    	<td align=right width="15%"> <b> Description: </b> <td> $st->{desc}->{$group}->{$service}
+<table width="100%" border>
     <tr $bgcolor>
-	<td align=right width="15%"> <b> Summary: </b> <td> $sref->{last_summary}
+    	<td align=right width="15%"> <b> Description: </b> <td> $st->{desc}->{$group}->{$service}&nbsp;<td bgcolor="#FFFF00"><a href='moncmd.cgi?disable=service&service=$group $service'>Disable Service</a> 
     <tr $bgcolor>
-	<td align=right width="15%"> <b> Hosts: </b> <td> @{$st->{groups}->{$group}}
+	<td align=right width="15%"> <b> Summary: </b> <td> $sref->{last_summary}&nbsp;<td bgcolor="#FFFF00">&nbsp;
     <tr $bgcolor>
-	<td valign=top align=right width="15%"> <b> Detail: </b>
+	<td align=right width="15%"> <b> Hosts: </b> <td> @{$st->{groups}->{$group}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Note: * indicates disabled host)<td bgcolor="#FFFF00">
+EOF
+	foreach $_(@{$st->{groups}->{$group}}){
+		$OUT_BUF .= sprintf ("%s <a href='moncmd.cgi?disable=host&host=$_'>Disable Host: $_</a><br>");
+	}
+$OUT_BUF .= <<EOF;    
+<tr $bgcolor>
+	<td valign=top align=right width="15%"> <b> Detail: </b>&nbsp;
 	<td>
 	<pre>
 $sref->{last_detail}
-	</pre>
+	</pre><td bgcolor="#FFFF00"><a href='moncmd.cgi?disable=watch&watch=$group'>Disable Watch</a>
 </table>
 EOF
 
 	if ($d->{"ack"}){
 	    $OUT_BUF .= <<EOF;
-<table width="100%">
+<table width="100%" border>
     <tr>
     	<td align=right width="15%"> <h2>Acknowledgment of failure</h2> </td>
     <tr>
@@ -1407,7 +1445,7 @@
 	}
 
 	$OUT_BUF .= <<EOF;
-<table cellpadding=2 cellspacing=1 bgcolor="#CCCCCC" width="100%">
+<table cellpadding=2 cellspacing=1 bgcolor="#CCCCCC" width="100%" border>
 EOF
 
 	#
@@ -1484,7 +1522,7 @@
 
     	$OUT_BUF .= <<EOF;
 <p>
-<a href="$ENV{SCRIPT_NAME}">Back to summary table</a>
+<hr><a href="$ENV{SCRIPT_NAME}">Back to summary table</a>
 <p>
 
 EOF
@@ -1595,3 +1633,4 @@
 	}
     }
 }
+
