Files
scripts-conlxsyslog03/root/observium/port_config/build_site.pl
conetadm 5718e70f15 init
2024-11-14 21:11:06 +01:00

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&ouml;glichen Treffer angezeigt.<br>\nDen gew&uuml;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;