137 lines
4.3 KiB
Perl
137 lines
4.3 KiB
Perl
#!/bin/perl
|
|
use strict;
|
|
use mysql;
|
|
use CGI qw(:standard);
|
|
|
|
my $edit = param('edit');
|
|
my $edit1 = param('edit1');
|
|
my $descr=param('descr');
|
|
my $typ=param('typ');
|
|
my $mf=param('mf');
|
|
my $mt=param('mt');
|
|
my $se=param('se');
|
|
my $sg=param('sg');
|
|
my $ss=param('ss');
|
|
my $st=param('st');
|
|
my $sp=param('sp');
|
|
my $sc=param('sc');
|
|
my $sm=param('sm');
|
|
|
|
my $dbh = DBI->connect("DBI:mysql:database=c2;host=localhost",'root','', {RaiseError => 1});
|
|
|
|
print header();
|
|
print "<html>\n";
|
|
print "<head>\n";
|
|
print "<style type='text/css'>\n";
|
|
#print "select { font-size:8pt }\n";
|
|
|
|
print "</style>\n";
|
|
|
|
print "</head>\n";
|
|
print "<body>\n";
|
|
print "<b><u>Alert editieren</u></b>\n";
|
|
if ($edit eq "") {
|
|
my $sth = $dbh->prepare("select ind,description,alert_type from alerts order by 'description'");
|
|
$sth->execute;
|
|
print "<form action='edit_alert.pl'>\n";
|
|
print "<table>\n";
|
|
while (my $ref = $sth->fetchrow_arrayref()) {
|
|
print "<tr>\n";
|
|
print "<td><input type='radio' name='edit' value='$ref->[0]'></td>\n";
|
|
print "<td><input type='text' readonly value='$ref->[1]'></td>\n";
|
|
print "<td><input type='text' readonly value='$ref->[2]'></td>\n";
|
|
print "</tr>\n";
|
|
}
|
|
print "<tr><td></td>\n<td><input type='submit' name='edit1' value='Edit'></td></tr>\n";
|
|
print "</table>\n";
|
|
print "</form>\n";
|
|
}
|
|
else {
|
|
if ($edit1 eq "Edit") {
|
|
my $sth = $dbh->prepare("select ind,description,alert_type,mail_from,mail_to,enterprise,generic,specific,destination,port,community,txt_msg from alerts where ind='$edit'");
|
|
$sth->execute;
|
|
while (my $ref = $sth->fetchrow_arrayref()) {
|
|
print "<form action='edit_alert.pl'>\n";
|
|
print "<table border='1'>\n";
|
|
print "<tr>\n<td>Description</td>\n";
|
|
print "<td><input name='descr' type='text' value='$ref->[1]'></td>\n";
|
|
print "</tr>\n";
|
|
|
|
#ääää
|
|
print "<tr>\n";
|
|
print "<td>Typ</td>\n";
|
|
print "<td><select name='typ'>\n";
|
|
if ($ref->[2] eq "mail") {
|
|
print "<option value='snmp'>SNMP</option>\n";
|
|
print "<option selected value='mail'>MAIL</option>\n";
|
|
}
|
|
if ($ref->[2] eq "snmp") {
|
|
print "<option selected value='snmp'>SNMP</option>\n";
|
|
print "<option value='mail'>MAIL</option>\n";
|
|
}
|
|
print "</td>\n";
|
|
print "</tr>\n";
|
|
|
|
print "<tr>\n";
|
|
print "<td>Mail: from</td>\n";
|
|
print "<td><input name='mf' type='text' value='$ref->[3]'></td>\n";
|
|
print "</tr>\n";
|
|
|
|
print "<tr>\n";
|
|
print "<td>Mail: to</td>\n";
|
|
print "<td><input name='mt' type='text' value='$ref->[4]'></td>\n";
|
|
print "</tr>\n";
|
|
|
|
print "<tr>\n";
|
|
print "<td>SNMP: Enterprise</td>\n";
|
|
print "<td><input name='se' type='text' value='$ref->[5]'></td>\n";
|
|
print "</tr>\n";
|
|
|
|
print "<tr>\n";
|
|
print "<td>SNMP: generic</td>\n";
|
|
print "<td><input name='sg' type='text' value='$ref->[6]'></td>\n";
|
|
print "</tr>\n";
|
|
|
|
print "<tr>\n";
|
|
print "<td>SNMP: specific</td>\n";
|
|
print "<td><input name='ss' type='text' value='$ref->[7]'></td>\n";
|
|
print "</tr>\n";
|
|
|
|
print "<tr>\n";
|
|
print "<td>SNMP: to</td>\n";
|
|
print "<td><input name='st' type='text' value='$ref->[8]'></td>\n";
|
|
print "</tr>\n";
|
|
|
|
print "<tr>\n";
|
|
print "<td>SNMP: Port</td>\n";
|
|
print "<td><input name='sp' type='text' value='$ref->[9]'></td>\n";
|
|
print "</tr>\n";
|
|
|
|
print "<tr>\n";
|
|
print "<td>SNMP: Community</td>\n";
|
|
print "<td><input name='sc' type='text' value='$ref->[10]'></td>\n";
|
|
print "</tr>\n";
|
|
|
|
print "<tr>\n";
|
|
print "<td>SNMP+Mail: Nachricht</td>\n";
|
|
print "<td><input name='sm' type='text' value='$ref->[11]'></td>\n";
|
|
print "</tr>\n";
|
|
print "</table>\n";
|
|
|
|
print "<input type='submit' name='edit1' value='Speichern'>\n";
|
|
print "<input type='hidden' name='edit' value='$edit'>\n";
|
|
print "</form>\n";
|
|
}
|
|
}
|
|
if ($edit1 eq "Speichern") {
|
|
#$dbh->do("update hosts set description='$descr', hostname='$hostn', ip='$ipadd', rw_community='$rwcom', ro_community='$rocom', snmp_port='$snmpp' where ind='$edit'");
|
|
#$dbh->do(
|
|
$dbh->do("update alerts set description='$descr', alert_type='$typ', mail_from='$mf', mail_to='$mt', enterprise='$se', generic='$sg', specific='$ss', destination='$st', port='$sp', community='$sc', txt_msg='$sm' where ind='$edit'");
|
|
print "<br>Gespeichert\n";
|
|
}
|
|
|
|
#print "Löschen durchgeführt!";
|
|
}
|
|
|
|
print "</body>\n";
|
|
print "</html>\n"; |