68 lines
2.6 KiB
PHP
68 lines
2.6 KiB
PHP
<!-- root@conlxsyslog03:/scripts/root/observium/port_config/port_configs.php -->
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de-DE" lang="de-DE">
|
|
<head>
|
|
<title>Port Config</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
</head>
|
|
<body>
|
|
|
|
<?php
|
|
// Zeige Eingabefeld
|
|
if( $_GET["hostname"] == "" or $_GET["ifname"] == "" ) {
|
|
?>
|
|
|
|
<form action='port_configs.php' method='get'>
|
|
<input type='text' name='hostname' list='hostnamelist' size='30'>
|
|
<datalist id='hostnamelist'>
|
|
<?php
|
|
$pdo = new PDO('mysql:host=10.101.0.11;dbname=observium', 'root', 'lunakoshix');
|
|
$sql = "select hostname from devices where devices.type = 'network' order by hostname asc";
|
|
foreach ($pdo->query($sql) as $row) {
|
|
echo " <option value='$row[hostname]'>";
|
|
}
|
|
?>
|
|
|
|
</datalist>
|
|
<input type='text' name='ifname' list='ifnamelist' size='30'>
|
|
<datalist id='ifnamelist'>
|
|
<?php
|
|
$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";
|
|
foreach ($pdo->query($sql) as $row) {
|
|
echo " <option value='$row[port_label]'>";
|
|
}
|
|
?>
|
|
|
|
</datalist>
|
|
<input type=submit value='show'>
|
|
</form>
|
|
Wenn der Fokus auf einem Eingabefeld liegt, zeigt ein weiterer Klick alle Optionen<br>
|
|
Die Felder haben eine Autofilloption, d.h. einfach Tippen und es werden alle möglichen Treffer angezeigt.<br>
|
|
Den gewünschten per Klick annehmen<br>
|
|
<br>
|
|
Skripte unter root@conlxsyslog03:/scripts/root/observium/port_config/
|
|
<?php
|
|
}
|
|
else {
|
|
// Zeige Suchergebnis
|
|
echo "Hostname: $_GET[hostname] Interface: $_GET[ifname]<br>\n";
|
|
$if=$_GET['ifname'];
|
|
$line = file_get_contents("/home/rancid/var/rancid/network/configs/$_GET[hostname]");
|
|
$pattern = '#(interface ' . $if . '\n( (.*)\n)*)#i';
|
|
preg_match($pattern, $line, $match);
|
|
$str=$match[0];
|
|
if ($str == "") {
|
|
echo "<br><br>Prüfe deine Eingabe. Die Kombination von Hostname '$_GET[hostname]' und Interface '$if' scheint es nicht zu geben<br><br>\n";
|
|
} else {
|
|
$str2 = str_replace("\n","<br>\n",$str);
|
|
echo "<br><br>\n$str2\n<br><br>\n";
|
|
}
|
|
echo "<a href='port_configs.php'>back</a>";
|
|
?>
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
</body>
|
|
</html>
|