60 lines
1.8 KiB
Perl
60 lines
1.8 KiB
Perl
use DBI;
|
|
use strict;
|
|
|
|
# Variable für SQL Befehle
|
|
my $sql;
|
|
|
|
# DB Parameter
|
|
my ($db_user, $db_name, $db_pass, $db_host) = ('root', 'observium', 'lunakoshix', 'localhost');
|
|
|
|
# DB connect
|
|
my $dbh = DBI->connect("DBI:mysql:database=$db_name;host=$db_host", $db_user, $db_pass) or die "Cannot connect to DB\n";
|
|
|
|
open HTML, ">site.html";
|
|
printf HTML "<html>\n<head></head>\n<body>\n";
|
|
|
|
|
|
printf HTML "<form action='site.php' method='post'>\n";
|
|
|
|
printf HTML "<input type='text' name='hostname' list='hostnamelist' size='30'>\n<datalist id='hostnamelist'>";
|
|
$sql = "select hostname from devices
|
|
where devices.type = 'network'
|
|
order by hostname asc";
|
|
|
|
my $rows = $dbh->selectall_arrayref("$sql");
|
|
foreach (@$rows) {
|
|
# für jeden Eintrag
|
|
my $row=$_;
|
|
my $hostname=$row->[0];
|
|
printf HTML "<option value='$hostname'>\n";
|
|
}
|
|
printf HTML "</datalist>\n";
|
|
|
|
|
|
|
|
|
|
|
|
printf HTML "<input type='text' name='ifname' list='ifnamelist' size='30'>\n<datalist id='ifnamelist'>";
|
|
$sql = "select distinct port_label from ports
|
|
inner join devices on ports.device_id = devices.device_id
|
|
where devices.type = 'network'
|
|
order by port_label asc";
|
|
|
|
my $rows = $dbh->selectall_arrayref("$sql");
|
|
foreach (@$rows) {
|
|
# für jeden Eintrag
|
|
my $row=$_;
|
|
my $ifname=$row->[0];
|
|
printf HTML "<option value='$ifname'>\n";
|
|
}
|
|
printf HTML "</datalist>\n";
|
|
|
|
|
|
printf HTML "<input type=submit value='show'>\n";
|
|
printf HTML "</form>\n";
|
|
printf HTML "Wenn er Fokus auf einem Eingabefeld liegt, zeigt ein weiterer Klick alle Optionen.<br>\n";
|
|
printf HTML "Die Felder haben eine Autofilloption, d.h. einfach Tippen und es werden alle möglichen Treffer angezeigt.<br>\nDen gewünschten per Klick annehmen.<br>\n";
|
|
printf HTML "<br>\nSkripte unter root\@conlxsyslog03:/scripts/root/observium/port_config/\n";
|
|
printf HTML "</body>\n</html>";
|
|
close HTML;
|