87 lines
2.6 KiB
Perl
87 lines
2.6 KiB
Perl
#!/bin/perl
|
|
use strict;
|
|
use mysql;
|
|
use CGI qw(:standard);
|
|
|
|
my $ind = param('ind');
|
|
my $akt = param('akt');
|
|
my $deakt = param('deakt');
|
|
|
|
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>Todo aktivieren/deaktivieren</u></b><br><br>\n";
|
|
if ($ind eq "") {
|
|
my $sth = $dbh->prepare("select ind,t_host,t_service,t_check,t_alert,t_description from todos order by 'ind'");
|
|
$sth->execute;
|
|
|
|
print "<table>\n";
|
|
while (my $ref = $sth->fetchrow_arrayref()) {
|
|
print "<form action='chg_todo.pl'>\n";
|
|
print "<tr>\n";
|
|
|
|
print "<td><input type='hidden' name='ind' value='$ref->[0]'></td>\n";
|
|
|
|
#HOST
|
|
my $sth_host = $dbh->prepare("select hostname,ip from hosts where ind='$ref->[1]'");
|
|
$sth_host->execute;
|
|
while (my $ref_host = $sth_host->fetchrow_arrayref()) {
|
|
print "<td><input type='text' readonly value='$ref_host->[0] ($ref_host->[1])'></td>\n";
|
|
}
|
|
|
|
#SERVICE
|
|
my $sth_desc = $dbh->prepare("select distinct description from services where service_ind='$ref->[2]'");
|
|
$sth_desc->execute;
|
|
while (my $ref_desc = $sth_desc->fetchrow_arrayref()) {
|
|
print "<td><input type='text' readonly value='$ref_desc->[0]'></td>\n";
|
|
}
|
|
|
|
#CHECK
|
|
my $sth_check = $dbh->prepare("select description from checks where ind='$ref->[3]'");
|
|
$sth_check->execute;
|
|
while (my $ref_check = $sth_check->fetchrow_arrayref()) {
|
|
print "<td><input type='text' readonly value='$ref_check->[0]'></td>\n";
|
|
}
|
|
|
|
#ALERT
|
|
my $sth_alert = $dbh->prepare("select description from alerts where ind='$ref->[4]'");
|
|
$sth_alert->execute;
|
|
while (my $ref_alert = $sth_alert->fetchrow_arrayref()) {
|
|
print "<td><input type='text' readonly value='$ref_alert->[0]'></td>\n";
|
|
}
|
|
|
|
#DESCRIPTION
|
|
print "<td><input type='text' readonly value='$ref->[5]'></td>\n";
|
|
|
|
print "<td><input type='submit' name='akt' value='aktivieren'></td>\n";
|
|
print "<td><input type='submit' name='deakt' value='deaktivieren'></td>\n";
|
|
|
|
print "</tr>\n";
|
|
print "</form>\n";
|
|
}
|
|
print "</table>\n";
|
|
}
|
|
else {
|
|
#$dbh->do("delete from todos where ind='$del'");
|
|
|
|
if ($akt eq "aktivieren") {
|
|
$dbh->do("update todos set t_active = '1' where ind ='$ind'");
|
|
print "<br>Todo aktiviert!\n";
|
|
}
|
|
if ($deakt eq "deaktivieren") {
|
|
$dbh->do("update todos set t_active = '0' where ind ='$ind'");
|
|
print "<br>Todo deaktiviert!\n";
|
|
}
|
|
}
|
|
|
|
print "</body>\n";
|
|
print "</html>\n"; |