Hallo Wiso!
Anbei ein php-script, welches ich mal gebaut habe, um eine Liste aller IP-Adresse in den CIs aufzulisten.
Vielleicht kannst Du den SQL-Code entsprechend anpassen....
Code: Select all
<?php
header('Content-type: text/html; charset=utf-8');
echo "IP-Liste KHWE-IT";
error_reporting(E_ALL);
define ( 'MYSQL_HOST', 'localhost' );
define ( 'MYSQL_BENUTZER', 'root' );
define ( 'MYSQL_KENNWORT', 'xxxx' );
define ( 'MYSQL_DATENBANK', 'otrs' );
$db_link
= mysql_connect (MYSQL_HOST, MYSQL_BENUTZER, MYSQL_KENNWORT);
if ( $db_link )
{
}
else
{
die('keine Verbindung möch: ' . mysql_error());
}
$db_sel = mysql_select_db( MYSQL_DATENBANK )
or die("Auswahl der Datenbank fehlgeschlagen");
$order= $_GET["order"];
if ($order == "")
{
$order = "1";
};
$sql="select t1.xml_content_value ip,t2.xml_content_value beschreibung,t3.name
name
from xml_storage t1,configitem_version t3,configitem t4,xml_storage t2
where t1.xml_content_key like '%NIC\'}[%IPAddress%Content%' and t1.xml_type in
('ITSM::ConfigItem::110','ITSM::ConfigItem::253','ITSM::ConfigItem::148','ITS
M::ConfigItem::32','ITSM::ConfigItem::161')
and t2.xml_content_key like '%Description%Content%' and t2.xml_type in ('IT
SM::ConfigItem::110','ITSM::ConfigItem::253','ITSM::ConfigItem::148','ITSM::Co
nfigItem::32','ITSM::ConfigItem::161')
and t1.xml_key=t2.xml_key
and t1.xml_key = t4.last_version_id
and t4.last_version_id=t3.id order by $order";
$db_erg=mysql_query($sql);
if ( ! $db_erg )
{
die('Ungueltige Abfrage: ' . mysql_error());
}
echo '<table border="1">';
echo "<thead>";
echo "<tr>";
echo '<td><a href="ipliste.php?order=1"> IP</a></td>';
echo '<td><a href="ipliste.php?order=2"> Beschreibung</a></td>';
echo '<td><a href="ipliste.php?order=3"> Name</a></td>';
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ($zeile = mysql_fetch_array( $db_erg, MYSQL_ASSOC))
{
echo "<tr>";
echo "<td>". $zeile['ip'] . "</td>";
echo "<td>". utf8_decode($zeile['beschreibung']) . "</td>";
echo "<td>". $zeile['name'] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
mysql_close($db_link );
?>
Gruß,
Thorsten