|
From: Bob T. <bt...@us...> - 2004-02-09 06:56:23
|
Update of /cvsroot/benson/benson3/scripts/cgi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26165 Modified Files: alertview.cgi.tmpl Log Message: Made quite a few changes to the alerview.cgi script. Index: alertview.cgi.tmpl =================================================================== RCS file: /cvsroot/benson/benson3/scripts/cgi/alertview.cgi.tmpl,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** alertview.cgi.tmpl 12 Dec 2003 19:14:28 -0000 1.2 --- alertview.cgi.tmpl 9 Feb 2004 06:53:13 -0000 1.3 *************** *** 1,4 **** --- 1,5 ---- #!/usr/local/bin/perl -I/tmp/benson3/lib/perl/ + use DBI; use CGI; use Benson; *************** *** 16,19 **** --- 17,21 ---- my $queue = new Benson; my $query = new CGI; + my $dbh = DBI->connect($queue->get("DBIConnectString"), $queue->get("DBIUsername"),$queue->get("DBIPassword")); my $webserver_url = $queue->get("WebserverURL"); *************** *** 47,50 **** --- 49,54 ---- + + my $date_and_time = "null"; *************** *** 55,58 **** --- 59,121 ---- my %alertlist = %{$alerts_ref}; + my $action = $query->param("action") || "alertview"; + + + if($action eq "acksup") { + $| = 1; + print <<EOT; + Content-type: text/html + + <html> + <title>Performing actions...</title> + <body bgcolor="#FFFFFF"> + <h1>Performing actions...</h1> + <pre> + EOT + my @names = $query->param; + foreach my $name (sort @names) { + my $value = $query->param($name); + if($value eq "on") { + my ($attr, $val) = split /\:/, $name, 2; + if($attr eq "id") { + foreach my $key (keys %{$alerts_ref}) { + if($alerts_ref->{$key}->{first_id} eq $val) { + foreach my $sub_alert (@{$alerts_ref->{$key}->{sub_alerts}}) { + print "Acknowledging alert ($val)......"; + $queue->acknowledge(identity => $sub_alert->{identity}); + print "done\n"; + } + last; + } + } + } + if($attr eq "sup") { + print "Suppressing host ($val)......"; + $queue->submit(subsystem => "Benson", + severity => "informational", + message => "suppress agent:$val duration:3600 reason:Temporarily suppressed for problem resolution"); + print "done\n"; + } + if($attr eq "sup_rem") { + print "Removing suppression for host ($val)......"; + $queue->submit(subsystem => "Benson", + severity => "informational", + message => "suppress_remove identity:$val"); + print "done\n"; + } + } + } + print <<EOT; + </pre> + <script language="JavaScript"> + window.location = "$webserver_url/cgi-bin/alertview.cgi?sort_type=$sort_type&sort_field=$sort_field"; + </script> + </body> + </html> + EOT + exit; + } + + sub by_field { my ($a_agent, $a_severity, $a_subsystem, $a_message) = split /\:/, $a; *************** *** 169,177 **** <b>Alert View</b><br> Current Time (as of refresh): <b>$date_and_time</b> <table border="1" bgcolor="#FFFFF0" width="100%"> <tr> <td background="/images/header.gif" align="center"><font color="#FFFFFF"><b>+/-</b></font></td> ! <td background="/images/header.gif" align="center"><font color="#FFFFFF"><b>ACK</b><input type="button" ! value="X" onclick="javascript: toggle(this);"></font></td> <td background="/images/header.gif" align="center"><font color="#FFFFFF"><b>SUP</b></font></td> <td background="/images/header.gif" align="right"><font color="#FFFFFF"><b>Agent</b>$agent_img_field</font></td> --- 232,242 ---- <b>Alert View</b><br> Current Time (as of refresh): <b>$date_and_time</b> + <input type="hidden" name="sort_field" value="$sort_field"> + <input type="hidden" name="sort_type" value="$sort_type"> + <input type="hidden" name="action" value="acksup"> <table border="1" bgcolor="#FFFFF0" width="100%"> <tr> <td background="/images/header.gif" align="center"><font color="#FFFFFF"><b>+/-</b></font></td> ! <td background="/images/header.gif" align="center"><font color="#FFFFFF"><b>ACK</b><input type="button" value="X" onclick="javascript: toggle(this);"></font></td> <td background="/images/header.gif" align="center"><font color="#FFFFFF"><b>SUP</b></font></td> <td background="/images/header.gif" align="right"><font color="#FFFFFF"><b>Agent</b>$agent_img_field</font></td> *************** *** 214,216 **** --- 279,354 ---- <input type="submit" value="Acknowledge/Suppress"> <hr> + <b>Suppressed Hosts</b> + <table bgcolor="#FFFFF0" border="1"> + <tr> + <td background="/images/header.gif" align="center"><font color="#FFFFFF"><b>+/-</b></font></td> + <td background="/images/header.gif" align="right"><font color="#FFFFFF"><b>Agent</b></font></td> + <td background="/images/header.gif" align="right"><font color="#FFFFFF"><b>Start Time</b></font></td> + <td background="/images/header.gif" align="right"><font color="#FFFFFF"><b>End Time</b></font></td> + <td background="/images/header.gif" align="right"><font color="#FFFFFF"><b>Reason</b></font></td> + <td background="/images/header.gif" align="right"><font color="#FFFFFF"><b>REM</b></font></td> + </tr> + EOT + + my $sql_suppress = <<EOSQL; + SELECT + suppress_id, + agent, + starttime, + endtime, + reason + FROM + suppress + WHERE + endtime > now() + AND + remove = 'N' + EOSQL + + my $sth = $dbh->prepare($sql_suppress); + my $rc = $sth->execute(); + while(my $row = $sth->fetchrow_hashref()) { + my $id = $row->{suppress_id}; + my $agent = $row->{agent}; + my $starttime = $row->{starttime}; + my $endtime = $row->{endtime}; + my $reason = $row->{reason}; + print <<EOT + <tr> + <td align="center"><b>(?)</b></td> + <td>$agent</td> + <td>$starttime</td> + <td>$endtime</td> + <td>$reason</td> + <td><input type="checkbox" name="sup_rem:$id"></td> + </tr> + EOT + } + + + print <<EOT; + </table> + <input type="submit" value="Remove Suppression"> + <hr> + <table width="100%"> + <tr> + <td align="left"> + <i><font size="1"> + <a href="http://benson.sourceforge.net/">Benson Distributed Monitoring System</a><br> + Copyright © 1999, 2000, 2001, 2002, 2003, 2004 by Bob Tribit<br> + <br> + This program is distributed in the hope that it will be useful,<br> + but WITHOUT ANY WARRANTY; without even the implied warranty of<br> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br> + <a href="http://www.fsf.org/">GNU</a> <a href="http://www.gnu.org/licenses/gpl.html">General Public License</a> for more + details. + </font></i> + </td> + <td align="right"> + fortune.pl goes here + </td> + </tr> + </table> + </body> + </html> EOT |