2006-03-27 05:37:27 +02:00
|
|
|
<?php
|
|
|
|
|
2006-07-11 10:49:21 +02:00
|
|
|
// Pandora - the Free monitoring system
|
|
|
|
// ====================================
|
|
|
|
// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
|
|
|
|
// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es
|
|
|
|
// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-03-27 05:37:27 +02:00
|
|
|
|
2006-07-11 10:49:21 +02:00
|
|
|
// Load global vars
|
2006-03-27 05:37:27 +02:00
|
|
|
require("include/config.php");
|
2006-07-11 10:49:21 +02:00
|
|
|
|
2007-03-12 18:58:52 +01:00
|
|
|
$modules_server = 0;
|
|
|
|
$total_modules = 0;
|
|
|
|
$total_modules_data = 0;
|
|
|
|
|
2006-03-27 05:37:27 +02:00
|
|
|
if (comprueba_login() == 0) {
|
|
|
|
if ((give_acl($id_user, 0, "AR")==1) or (give_acl($id_user,0,"AW")) or (dame_admin($id_user)==1)) {
|
|
|
|
|
|
|
|
$sql='SELECT * FROM tserver';
|
|
|
|
|
2007-05-27 04:55:55 +02:00
|
|
|
echo "<h2>".$lang_label["view_servers"]." > ";
|
2007-04-11 05:12:48 +02:00
|
|
|
echo $lang_label["server_detail"]." <a href='help/".$help_code."/chap7.php#7' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h2>";
|
2006-03-27 05:37:27 +02:00
|
|
|
|
2007-03-12 18:58:52 +01:00
|
|
|
// Get total modules defined (network)
|
2007-02-22 20:48:12 +01:00
|
|
|
$sql1='SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo > 4';
|
|
|
|
$result1=mysql_query($sql1);
|
|
|
|
$row1=mysql_fetch_array($result1);
|
|
|
|
$total_modules = $row1[0];
|
|
|
|
|
2007-03-12 18:58:52 +01:00
|
|
|
// Get total modules defined (data)
|
|
|
|
$sql1='SELECT COUNT(processed_by_server) FROM tagente_estado WHERE processed_by_server LIKE "%_Data" ';
|
2007-04-11 05:12:48 +02:00
|
|
|
if ($result1=mysql_query($sql1)){
|
|
|
|
$row1=mysql_fetch_array($result1);
|
|
|
|
$total_modules_data = $row1[0];
|
|
|
|
} else
|
|
|
|
$total_modules_data = 0;
|
2007-03-12 18:58:52 +01:00
|
|
|
|
2006-03-27 05:37:27 +02:00
|
|
|
// Connect DataBase
|
|
|
|
$result=mysql_query($sql);
|
|
|
|
if (mysql_num_rows($result)){
|
2007-05-20 19:12:31 +02:00
|
|
|
echo "<table cellpadding='4' cellspacing='4' witdh='720' class='databox'>";
|
2006-12-07 19:53:43 +01:00
|
|
|
echo "<tr><th class='datos'>".$lang_label["name"]."</th>";
|
|
|
|
echo "<th class='datos'>".$lang_label['status']."</th>";
|
2007-02-22 20:48:12 +01:00
|
|
|
echo "<th class='datos'>".$lang_label['load']."</th>";
|
2007-03-12 18:58:52 +01:00
|
|
|
echo "<th class='datos'>".$lang_label['modules']."</th>";
|
|
|
|
echo "<th class='datos'>".$lang_label['lag']."</th>";
|
2006-12-07 19:53:43 +01:00
|
|
|
echo "<th class='datos'>".$lang_label['description']."</th>";
|
2007-03-28 18:07:29 +02:00
|
|
|
echo "<th class='datos' width=80>".$lang_label['type']."</th>";
|
2007-03-12 18:58:52 +01:00
|
|
|
// echo "<th class='datos'>".$lang_label['master']."</th>";
|
2007-02-22 20:48:12 +01:00
|
|
|
//echo "<th class='datos'>".$lang_label['checksum']."</th>";
|
|
|
|
//echo "<th class='datos'>".$lang_label['laststart']."</th>";
|
2007-03-28 18:07:29 +02:00
|
|
|
echo "<th class='datos'>".$lang_label['version']."</th>";
|
2006-12-07 19:53:43 +01:00
|
|
|
echo "<th class='datos'>".$lang_label['lastupdate']."</th>";
|
2006-07-17 18:06:04 +02:00
|
|
|
$color=1;
|
2006-03-27 05:37:27 +02:00
|
|
|
while ($row=mysql_fetch_array($result)){
|
2006-07-17 18:06:04 +02:00
|
|
|
if ($color == 1){
|
|
|
|
$tdcolor = "datos";
|
|
|
|
$color = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$tdcolor = "datos2";
|
|
|
|
$color = 1;
|
|
|
|
}
|
2007-03-12 18:58:52 +01:00
|
|
|
$id_server = $row["id_server"];
|
2006-03-27 05:37:27 +02:00
|
|
|
$name = $row["name"];
|
|
|
|
$address = $row["ip_address"];
|
|
|
|
$status = $row["status"];
|
|
|
|
$laststart = $row["laststart"];
|
|
|
|
$keepalive = $row["keepalive"];
|
|
|
|
$network_server = $row["network_server"];
|
|
|
|
$data_server = $row["data_server"];
|
|
|
|
$snmp_server = $row["snmp_server"];
|
2007-03-12 18:58:52 +01:00
|
|
|
$recon_server = $row["recon_server"];
|
2006-03-27 05:37:27 +02:00
|
|
|
$master = $row["master"];
|
|
|
|
$checksum = $row["checksum"];
|
|
|
|
$description = $row["description"];
|
2007-03-28 18:07:29 +02:00
|
|
|
$version = $row["version"];
|
2007-02-22 20:48:12 +01:00
|
|
|
|
|
|
|
$modules_server = 0;
|
2007-03-12 18:58:52 +01:00
|
|
|
if (($network_server == 1) OR ($data_server == 1))
|
|
|
|
if ($network_server == 1){
|
|
|
|
// Get total modules defined for this server (network modules)
|
|
|
|
$sql1='SELECT * FROM tagente where id_server = '.$row["id_server"];
|
|
|
|
$result1=mysql_query($sql1);
|
|
|
|
while ($row1=mysql_fetch_array($result1)){
|
|
|
|
$sql2='SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo > 4 AND id_agente = '.$row1["id_agente"];
|
|
|
|
$result2=mysql_query($sql2);
|
|
|
|
$row2=mysql_fetch_array($result2);
|
|
|
|
$modules_server = $modules_server + $row2[0];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Get total modules defined for this server (data modules)
|
2007-04-18 18:48:38 +02:00
|
|
|
$sql2 = "SELECT COUNT(running_by) FROM tagente_estado WHERE running_by = $id_server";
|
2007-03-12 18:58:52 +01:00
|
|
|
$result2=mysql_query($sql2);
|
|
|
|
$row2=mysql_fetch_array($result2);
|
|
|
|
$modules_server = $row2[0];
|
|
|
|
}
|
2006-03-27 05:37:27 +02:00
|
|
|
|
2006-07-17 18:06:04 +02:00
|
|
|
echo "<tr><td class='$tdcolor'>";
|
2007-03-19 20:39:40 +01:00
|
|
|
if ($recon_server == 1)
|
|
|
|
echo "<b><a href='index.php?sec=estado_server&sec2=operation/servers/view_server_detail&server_id=$id_server'>$name</a></b> ";
|
|
|
|
else
|
|
|
|
echo "<b>$name</b>";
|
2006-07-17 18:06:04 +02:00
|
|
|
echo "<td class='$tdcolor' align='middle'>";
|
2006-03-27 05:37:27 +02:00
|
|
|
if ($status ==0){
|
|
|
|
echo "<img src='images/dot_red.gif'>";
|
|
|
|
} else {
|
|
|
|
echo "<img src='images/dot_green.gif'>";
|
|
|
|
}
|
2006-07-17 18:06:04 +02:00
|
|
|
echo "<td class='$tdcolor' align='middle'>";
|
2007-03-12 18:58:52 +01:00
|
|
|
if (($network_server == 1) OR ($data_server == 1)){
|
|
|
|
// Progress bar calculations
|
|
|
|
if ($network_server == 1){
|
|
|
|
if ($total_modules == 0)
|
|
|
|
$percentil = 0;
|
2007-04-11 05:12:48 +02:00
|
|
|
if ($total_modules > 0)
|
|
|
|
$percentil = $modules_server / ($total_modules / 100);
|
|
|
|
else
|
|
|
|
$percentil = 0;
|
2007-03-12 18:58:52 +01:00
|
|
|
$total_modules_temp = $total_modules;
|
|
|
|
} else {
|
|
|
|
if ($total_modules_data == 0)
|
|
|
|
$percentil = 0;
|
|
|
|
else
|
|
|
|
$percentil = $modules_server / ($total_modules_data / 100);
|
|
|
|
$total_modules_temp = $total_modules_data;
|
|
|
|
}
|
2007-03-19 20:39:40 +01:00
|
|
|
} elseif ($recon_server == 1){
|
|
|
|
|
|
|
|
$sql2 = "SELECT COUNT(id_rt) FROM trecon_task WHERE id_network_server = $id_server";
|
|
|
|
$result2=mysql_query($sql2);
|
|
|
|
$row2=mysql_fetch_array($result2);
|
|
|
|
$modules_server = $row2[0];
|
|
|
|
|
|
|
|
$sql2 = "SELECT COUNT(id_rt) FROM trecon_task";
|
|
|
|
$result2=mysql_query($sql2);
|
|
|
|
$row2=mysql_fetch_array($result2);
|
|
|
|
$total_modules = $row2[0];
|
|
|
|
if ($total_modules == 0)
|
|
|
|
$percentil = 0;
|
2007-05-24 22:03:05 +02:00
|
|
|
else
|
|
|
|
$percentil = $modules_server / ($total_modules / 100);
|
2007-03-19 20:39:40 +01:00
|
|
|
$total_modules_temp = $total_modules;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
echo "-";
|
|
|
|
|
|
|
|
if (($network_server == 1) OR ($data_server == 1) OR ($recon_server == 1))
|
2007-03-12 18:58:52 +01:00
|
|
|
// Progress bar render
|
2007-03-28 18:07:29 +02:00
|
|
|
echo '<img src="reporting/fgraph.php?tipo=progress&percent='.$percentil.'&height=18&width=80">';
|
2007-03-19 20:39:40 +01:00
|
|
|
|
|
|
|
// Number of modules
|
2007-03-12 18:58:52 +01:00
|
|
|
echo "<td class='$tdcolor'>";
|
2007-03-19 20:39:40 +01:00
|
|
|
if (($recon_server ==1) OR ($network_server == 1) OR ($data_server == 1))
|
2007-03-12 18:58:52 +01:00
|
|
|
echo $modules_server . " / ". $total_modules_temp;
|
|
|
|
else
|
|
|
|
echo "-";
|
|
|
|
|
2007-03-19 20:39:40 +01:00
|
|
|
// LAG CHECK
|
2007-03-12 18:58:52 +01:00
|
|
|
echo "<td class='$tdcolor'>";
|
2007-03-19 20:39:40 +01:00
|
|
|
// Calculate lag: get oldest module of any proc_type, for this server,
|
2007-03-12 18:58:52 +01:00
|
|
|
// and calculate difference in seconds
|
|
|
|
// Get total modules defined for this server
|
|
|
|
if (($network_server == 1) OR ($data_server == 1)){
|
2007-03-19 20:39:40 +01:00
|
|
|
$sql1 = "SELECT utimestamp, current_interval FROM tagente_estado WHERE processed_by_server = '$name' AND estado < 100";
|
2007-04-11 05:12:48 +02:00
|
|
|
|
2007-03-12 18:58:52 +01:00
|
|
|
$nowtime = time();
|
|
|
|
$maxlag=0;
|
2007-04-11 05:12:48 +02:00
|
|
|
if ($result1=mysql_query($sql1))
|
|
|
|
while ($row1=mysql_fetch_array($result1)){
|
|
|
|
if (($row1["utimestamp"] + $row1["current_interval"]) < $nowtime)
|
|
|
|
$maxlag2 = $nowtime - ($row1["utimestamp"] + $row1["current_interval"]);
|
|
|
|
if ($maxlag2 > $maxlag)
|
|
|
|
$maxlag = $maxlag2;
|
|
|
|
}
|
2007-03-28 18:07:29 +02:00
|
|
|
if ($maxlag < 60)
|
|
|
|
echo $maxlag." sec";
|
|
|
|
elseif ($maxlag < 86400)
|
|
|
|
echo format_numeric($maxlag/60) . " min";
|
|
|
|
elseif ($maxlag > 86400)
|
|
|
|
echo "+1 ".$lang_label["day"];
|
2007-03-19 20:39:40 +01:00
|
|
|
} elseif ($recon_server == 1) {
|
|
|
|
$sql1 = "SELECT * FROM trecon_task WHERE id_network_server = $id_server";
|
|
|
|
$result1=mysql_query($sql1);
|
|
|
|
$nowtime = time();
|
2007-04-19 20:50:07 +02:00
|
|
|
$maxlag=0;$maxlag2=0;
|
2007-03-19 20:39:40 +01:00
|
|
|
while ($row1=mysql_fetch_array($result1)){
|
2007-04-19 20:50:07 +02:00
|
|
|
if (($row1["utimestamp"] + $row1["interval_sweep"]) < $nowtime){
|
2007-04-18 18:48:38 +02:00
|
|
|
$maxlag2 = $nowtime - ($row1["utimestamp"] + $row1["interval_sweep"]);
|
2007-03-19 20:39:40 +01:00
|
|
|
if ($maxlag2 > $maxlag)
|
|
|
|
$maxlag = $maxlag2;
|
2007-04-19 20:50:07 +02:00
|
|
|
}
|
2007-03-12 18:58:52 +01:00
|
|
|
}
|
2007-03-28 18:07:29 +02:00
|
|
|
if ($maxlag < 60)
|
|
|
|
echo $maxlag." sec";
|
|
|
|
elseif ($maxlag < 86400)
|
|
|
|
echo format_numeric($maxlag/60) . " min";
|
|
|
|
elseif ($maxlag > 86400)
|
|
|
|
echo "+1 ".$lang_label["day"];
|
2007-03-12 18:58:52 +01:00
|
|
|
} else
|
2007-03-28 18:07:29 +02:00
|
|
|
echo "--";
|
2006-07-17 18:06:04 +02:00
|
|
|
echo "<td class='".$tdcolor."f9'>".substr($description,0,25);
|
|
|
|
echo "<td class='$tdcolor' align='middle'>";
|
2006-03-27 05:37:27 +02:00
|
|
|
if ($network_server == 1){
|
2007-03-12 18:58:52 +01:00
|
|
|
echo " <img src='images/network.gif'>";
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
|
|
|
if ($data_server == 1){
|
2007-03-12 18:58:52 +01:00
|
|
|
echo " <img src='images/data.gif'>";
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
|
|
|
if ($snmp_server == 1){
|
2007-03-12 18:58:52 +01:00
|
|
|
echo " <img src='images/snmp.gif'>";
|
|
|
|
}
|
|
|
|
if ($recon_server == 1){
|
2007-04-29 15:19:45 +02:00
|
|
|
echo " <img src='images/recon.png'>";
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
|
|
|
if ($master == 1){
|
2007-03-12 18:58:52 +01:00
|
|
|
echo " <img src='images/master.gif'>";
|
|
|
|
}
|
|
|
|
if ($checksum == 1){
|
|
|
|
echo " <img src='images/binary.gif'>";
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
2007-02-22 20:48:12 +01:00
|
|
|
//echo "<td class='".$tdcolor."f9' align='middle'>"
|
|
|
|
//.substr($laststart,0,25)."</td>";
|
|
|
|
echo "<td class='".$tdcolor."f9' align='middle'>";
|
2007-03-28 18:07:29 +02:00
|
|
|
echo $version;
|
|
|
|
|
|
|
|
echo "<td class='".$tdcolor."f9' align='middle'>";
|
|
|
|
// if ($status ==0)
|
|
|
|
echo substr($keepalive,0,25)."</td>";
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
2007-05-20 19:12:31 +02:00
|
|
|
echo '</table>';
|
2007-04-29 15:19:45 +02:00
|
|
|
echo "<table cellpadding=2 cellspacing=0>";
|
|
|
|
echo "
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span class='net'>".$lang_label["network_server"]."</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span class='master'>".$lang_label["master"]."</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span class='data'>".$lang_label["data_server"]."</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span class='binary'>".$lang_label["md5_checksum"]."</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span class='snmp'>".$lang_label["snmp_console"]."</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span class='recon'>".$lang_label["recon_server"]."</span>
|
|
|
|
</td>
|
|
|
|
</tr>";
|
|
|
|
echo "</table>";
|
2006-12-07 19:53:43 +01:00
|
|
|
} else {
|
|
|
|
echo "<div class='nf'>".$lang_label["no_server"]."</div>";
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
|
|
|
|
2006-12-07 19:53:43 +01:00
|
|
|
} else {
|
2006-03-27 05:37:27 +02:00
|
|
|
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent view");
|
|
|
|
require ("general/noaccess.php");
|
2006-12-07 19:53:43 +01:00
|
|
|
}
|
2007-04-29 15:19:45 +02:00
|
|
|
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
2007-04-18 18:48:38 +02:00
|
|
|
?>
|