Bonjour,
-- je suis débutant en xml / php. j'étudie une solution open source de collecte et d'analyse de logs. Je suis sur la partie Web. Je travaille sur debian Lenny (5.?) j'ai apache2 et php5. Je ne connais le type de navigateur que j'ai ...
-- sur l'interface Web, j'ai un menu "host" qui affiche la liste des machines qui sont monitorées, un menu "sensor" qui liste les sensors.
-- Mon problème : le menu host ne pose pas de problème. Il affiche bien la liste des machines dans un tableau ( code 1 ). Le menu sensor n'affiche pas la liste des sensors ( code 2). Le tableau est vide. Pourtant les sensorssont bien enregistrés dans la base de données et quand j'ai debogé : ils sont bien chargés en mémoire.
-- Est ce que quelqu'un peut m'aider : qu'est ce qui ne va pas dans le code 2.
Code 1 ( extrait du contenu de gethosts.php ) :
Code :
- $xml.= "<rows>\n";
- $xml.= "<page>$page</page>\n";
- $xml.= "<total>$total</total>\n";
- foreach($host_list as $host) {
- $ip = $host->get_ip();
- $xml.= "<row id='$ip'>";
- $name = "<a href=\"../report/index.php?host=$ip\">" . $host->get_hostname() . "</a>" . Host_os::get_os_pixmap($conn, $ip);
- $xml.= "<cell><![CDATA[" . $name . "]]></cell>";
- $xml.= "<cell><![CDATA[" . $ip . "]]></cell>";
- $xml.= "<cell><![CDATA[" . $host->get_asset() . "]]></cell>";
- $xml.= "<cell><![CDATA[" . $host->get_threshold_c() . "]]></cell>";
- $xml.= "<cell><![CDATA[" . $host->get_threshold_a() . "]]></cell>";
- $sensors = "";
- if ($sensor_list = $host->get_sensors($conn)) foreach($sensor_list as $sensor) {
- $sensors.= $sensor->get_sensor_name() . '<br/>';
- }
- $xml.= "<cell><![CDATA[" . utf8_encode($sensors) . "]]></cell>";
- $scantype = gettext("None" );
- if ($scan_list = Host_scan::get_list($conn, "WHERE host_ip = inet_aton('$ip')" )) {
- $scantype = "";
- foreach($scan_list as $scan) {
- $id = $scan->get_plugin_id();
- $plugin_name = "";
- if ($plugin_list = Plugin::get_list($conn, "WHERE id = $id" )) {
- $plugin_name.= $plugin_list[0]->get_name();
- $scantype.= ucfirst($plugin_name) . "<br>";
- } else {
- $scantype.= "$id<BR>";
- }
- }
- }
- $xml.= "<cell><![CDATA[" . $scantype . "]]></cell>";
- $xml.= "<cell><![CDATA[" . $host->get_alert() . "]]></cell>";
- $xml.= "<cell><![CDATA[" . $host->get_persistence() . "]]></cell>";
- $xml.= "<cell><![CDATA[" . $host->get_rrd_profile() . "]]></cell>";
- $desc = $host->get_descr();
- if ($desc == "" ) $desc = " ";
- $xml.= "<cell><![CDATA[" . utf8_encode($desc) . "]]></cell>";
- $rep = "";
- if ($linkedocs = Repository::have_linked_documents($conn, $ip, 'host')) $rep.= "<a href=\"../report/index.php?host=$ip\" class=\"blue\">[" . $linkedocs . "]</a> ";
- $rep.= "<a href=\"addrepository.php?id_host=" . $ip . "&name_host=" . $host->get_hostname() . "\" target=\"addcontent\"><img src=\"../repository/images/edit.gif\" border=0 align=\"absmiddle\"></a>";
- $rep.= "<a href=\"../repository/index.php\"><img src=\"../repository/images/editdocu.gif\" border=0 align=\"absmiddle\"></a>";
- $xml.= "<cell><![CDATA[" . utf8_encode($rep) . "]]></cell>";
- $xml.= "</row>\n";
- }
- $xml.= "</rows>\n";
- echo $xml;
|
Code 2 ( extrait de getsensors.php ) :
Code :
- foreach($sensor_list as $sensor) {
- $name = $sensor->get_name();
- $xml.= "<row id='$name'>";
- $ip = $sensor->get_ip();
- $ip = "<a href=\"sensor_plugins.php?sensor=$ip\">$ip</a>";
- $xml.= "<cell><![CDATA[" . $ip . "]]></cell>";
- $total_sensors++;
- $xml.= "<cell><![CDATA[" . $name . "]]></cell>";
- $xml.= "<cell><![CDATA[" . $sensor->get_priority() . "]]></cell>";
- $xml.= "<cell><![CDATA[" . $sensor->get_port() . "]]></cell>";
- $xml.= "<cell><![CDATA[" . $sensor->get_version() . "]]></cell>";
- if (in_array($sensor->get_ip() , $sensor_stack)) {
- $xml.= "<cell><![CDATA[<img src='../pixmaps/tables/tick.png'>]]></cell>";
- $active_sensors++;
- array_push($sensor_configured_stack, $sensor->get_ip());
- } elseif (in_array($sensor->get_ip() , $sensor_stack_off)) {
- $xml.= "<cell><![CDATA[<img src='../pixmaps/tables/warning.png' title='the following sensor(s) are being reported as enabled by the server but are not configured' alt='the following sensor(s) are being reported as enabled by the server but are not configured'>]]></cell>";
- } else {
- $xml.= "<cell><![CDATA[<img src='../pixmaps/tables/cross.png'>]]></cell>";
- }
- /*if ($use_munin==1)
- $xml .= "<cell><![CDATA[<a href=\"$munin_link\" target=\"_blank\"><img src='../pixmaps/chart_bar.png' border=0></a>]]></cell>";
- else
- $xml .= "<cell><![CDATA[<img src='../pixmaps/chart_bar_off.png'>]]></cell>"; */
- $desc = $sensor->get_descr();
- if ($desc == "" ) $desc = " ";
- $xml.= "<cell><![CDATA[" . utf8_encode($desc) . "]]></cell>";
- $xml.= "</row>\n";
- }
- $xml.= "</rows>\n";
- echo $xml;
|
Merci d'avance pour votre aide.