2008-11-11 Evi Vanoost <vanooste@rcbi.rochester.edu>

* operation/servers/view_server.php: Small language fix

        * operation/agentes/tactical.php: Rewrite using new functions and
        cleaner html. More understandable and outsourced calculations to
        get_group_stats

        * include/styles/pandora.css: Clean up CSS deprecated in other files

        * include/javascript/pandora.js: Noticed a small style difference

        * include/help/en/help_serverlag.php: Hopefully this makes server lag
        somewhat more understandable (I didn't know what it was)

        * include/functions_reporting.php: Renamed general_stats to
        get_group_stats and made it accept arrays. Also added ACL check and
        an easier output format. All calculations are now done here.

        * include/functions_html.php: print_table would always reset
        cellpaddings and cellspacing from 0 to 4. Fixed it

        * include/functions_db.php: Deprecated server_status for
        get_server_info. Added get_server_info which accepts single values or
        arrays of servers to be checked.

        * include/functions.php: Removed clean_output_breaks. Use built-in
        function nl2br() for that instead. They're faster and cross-platform

        * general/logon_ok.php: Same as tactical.php (both had to be updated)

        * ChangeLog: Somebody started using spaces instead of tabs?

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1241 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2008-11-11 14:24:34 +00:00
parent 5009f2377e
commit b4d7cf4acc
11 changed files with 582 additions and 592 deletions

View File

@ -1,7 +1,40 @@
2008-11-11 Evi Vanoost <vanooste@rcbi.rochester.edu>
* operation/servers/view_server.php: Small language fix
* operation/agentes/tactical.php: Rewrite using new functions and
cleaner html. More understandable and outsourced calculations to
get_group_stats
* include/styles/pandora.css: Clean up CSS deprecated in other files
* include/javascript/pandora.js: Noticed a small style difference
* include/help/en/help_serverlag.php: Hopefully this makes server lag
somewhat more understandable (I didn't know what it was)
* include/functions_reporting.php: Renamed general_stats to
get_group_stats and made it accept arrays. Also added ACL check and
an easier output format. All calculations are now done here.
* include/functions_html.php: print_table would always reset
cellpaddings and cellspacing from 0 to 4. Fixed it
* include/functions_db.php: Deprecated server_status for
get_server_info. Added get_server_info which accepts single values or
arrays of servers to be checked.
* include/functions.php: Removed clean_output_breaks. Use built-in
function nl2br() for that instead. They're faster and cross-platform
* general/logon_ok.php: Same as tactical.php (both had to be updated)
* ChangeLog: Somebody started using spaces instead of tabs?
2008-11-11 Sancho Lerena <slerena@artica.es> 2008-11-11 Sancho Lerena <slerena@artica.es>
* extensions/update_manager/lib/libupdate_manager_client.php: * extensions/update_manager/lib/libupdate_manager_client.php:
Connection XML/RPC timeout incremented to 10. Connection XML/RPC timeout incremented to 10.
2008-11-11 Ramon Novoa <rnovoa@artica.es> 2008-11-11 Ramon Novoa <rnovoa@artica.es>
@ -21,8 +54,8 @@
Thanks to Esben for reporting this bug that was introduced Thanks to Esben for reporting this bug that was introduced
only few days before closing 2.0 version :( only few days before closing 2.0 version :(
* include/funcions_db.php: Reference to inexistant table * include/funcions_db.php: Reference to inexistant table
tagent_data_image has been deleted and fixed notice. tagent_data_image has been deleted and fixed notice.
* install.php: Fixed default var for homeurl. * install.php: Fixed default var for homeurl.

View File

@ -17,151 +17,125 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require ("include/functions_reporting.php"); require_once ("include/config.php");
check_login ();
/* Call all extensions login function */ /* Call all extensions login function */
extensions_call_login_function (); extensions_call_login_function ();
echo "<div class='jus'>"; require_once ("include/functions_reporting.php");
$nick = $_SESSION['id_usuario'];
echo '<div class="msg" style="width:700px;">';
echo "<h1>" . __('Welcome to Pandora FMS Web Console') . "</h1>"; echo "<h1>" . __('Welcome to Pandora FMS Web Console') . "</h1>";
echo "<p>"; echo "<p>";
echo __('This is the Web Management System for Pandora FMS. From here you can manage its agents, alerts and incidents. Session is open while activity exists.'); echo __('This is the Web Management System for Pandora FMS. From here you can manage its agents, alerts and incidents. Session is open while activity exists.');
echo "</p>"; echo "</p>";
echo '</div>';
// Private messages pending to read ! // Private messages pending to read !
$sql = sprintf ("SELECT COUNT(id_mensaje) FROM tmensajes WHERE id_usuario_destino='%s' AND estado='FALSE';", $config["id_user"]);
$sql = sprintf ("SELECT COUNT(id_mensaje) AS count FROM tmensajes WHERE id_usuario_destino='%s' AND estado='FALSE';",$nick);
$resultado = get_db_sql ($sql); $resultado = get_db_sql ($sql);
if ($resultado != 0) { if ($resultado > 0) {
echo "<h2>". __('You have ') . ' echo '<h2>'.__('You have ').'<a href="index.php?sec=messages&sec2=operation/messages/message">'.$resultado.
<a href="index.php?sec=messages&sec2=operation/messages/message">' '<img src="images/email.png" border="0" />'.__(' unread message(s).').'</a></h2>';
.$resultado . ' <img src="images/email.png" border="0">'
.__(' unread message(s).') . '</a></h2>';
} }
echo "<table width=95%>";
echo "<tr><td valign='top'>";
// Site news ! // Site news !
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo '<div style="width:350px; float:left; padding-right: 30px;" id="leftcolumn">';
echo '<h2>' . __('Site news') . '</h2>'; echo '<h2>' . __('Site news') . '</h2>';
$sql_news = "SELECT subject,timestamp,text,author FROM tnews ORDER by timestamp DESC LIMIT 3"; $sql = "SELECT subject,timestamp,text,author FROM tnews ORDER by timestamp DESC LIMIT 3";
if ($result_news = mysql_query ($sql_news)){ $news = get_db_all_rows_sql ($sql);
echo '<table cellpadding="4" cellspacing="4" width="270" class="databox">'; if ($news !== false) {
while ($row = mysql_fetch_array ($result_news)) { echo '<table cellpadding="4" cellspacing="4" class="databox">';
echo '<tr>'; foreach ($news as $article) {
echo "<th><b>".$row["subject"]."</b>"; echo '<tr><th><b>'.$article["subject"].'</b></th></tr>';
echo "<tr><td>".__('by')." <b>".$row["author"]. "</b> ".__('At')." <i>".$row["timestamp"]."</i>"; echo '<tr><td>'.__('by').' <b>'.$article["author"].'</b> '.__('at').' <i>'.$article["timestamp"].'</i></td></tr>';
echo '<tr><td class=datos>'; echo '<tr><td class="datos">';
echo clean_output_breaks($row["text"]); echo nl2br ($article["text"]);
echo '</td></tr>';
} }
echo "</table>"; echo '</table>';
} else {
echo '<div>'.__('No news articles at this moment').'</div>';
} }
echo "<td align='center'>"; echo '</div>';
// Site stats // Site stats
// Summary echo '<div style="width:300px; float:left; padding-left: 30px;" id="rightcolumn">';
// ~~~~~~~~~~~~~~~ $data = get_group_stats (0);
$data = general_stats ($config['id_user'],0);
$monitor_checks = $data[0];
$monitor_ok = $data[1];
$monitor_bad = $data[2];
$monitor_unknown = $data[3];
$monitor_alert = $data[4];
$total_agents = $data[5];
$data_checks = $data[6];
$data_unknown = $data[7];
$data_alert = $data[8];
$data_alert_total = $data[9];
$monitor_alert_total = $data[10];
$data_not_init = $data[11];
$monitor_not_init = $data[12];
// Calculate global indicators
$total_checks = $data_checks + $monitor_checks; $table->class = "databox";
if ($total_checks > 0) $table->cellpadding = 4;
$notinit_percentage = (($data_not_init + $monitor_not_init) / ($total_checks / 100)); $table->cellspacing = 4;
else $table->head = array ();
$notinit_percentage = 0; $table->data = array ();
$table->width = "100%";
$module_sanity = format_numeric (100 - $notinit_percentage); $table->data[0][0] ='<b>'.__('Monitor health').'</b>';
$total_alerts = $data_alert + $monitor_alert; $table->data[1][0] = '<img src="reporting/fgraph.php?tipo=progress&height=20&width=280&mode=0&percent='.$data["monitor_health"].'" title="'.$data["monitor_health"].'% '.__('of monitors up').'" />';
$total_fired_alerts = $monitor_alert_total+$data_alert_total;
if ( $total_fired_alerts > 0) { $table->data[2][0] = '<b>'.__('Data health').'</b>';
$alert_level = format_numeric (100 - ($total_alerts / ($total_fired_alerts / 100))); $table->data[3][0] = '<img src="reporting/fgraph.php?tipo=progress&height=20&width=280&mode=0&percent='.$data["data_health"].'" title="'.$data["data_health"].'% '.__('of data modules up').'" />';
} else {
$alert_level = 100; $table->data[4][0] = '<b>'.__('Global health').'</b>';
$table->data[5][0] = '<img src="reporting/fgraph.php?tipo=progress&height=20&width=280&mode=0&percent='.$data["global_health"].'" title="'.$data["global_health"].'% '.__('of total modules up').'" />';
$table->data[6][0] = '<b>'.__('Module sanity').'</b>';
$table->data[7][0] = '<img src="reporting/fgraph.php?tipo=progress&height=20&width=280&mode=0&percent='.$data["module_sanity"].'" title="'.$data["module_sanity"].'% '.__('of total modules inited').'" />';
$table->data[8][0] = '<b>'.__('Alert level').'</b>';
$table->data[9][0] = '<img src="reporting/fgraph.php?tipo=progress&height=20&width=280&mode=0&percent='.$data["alert_level"].'" title="'.$data["alert_level"].'% '.__('of defined alerts not fired').'" />';
print_table ($table);
unset ($table);
echo '<table class="databox" cellpadding="4" cellspacing="4" width="100%">';
echo '<thead><th colspan="2">'.__('Pandora FMS Overview').'</th></thead><tbody>';
$cells = array ();
$cells[0][0] = __('Total agents');
$cells[0][1] = $data["total_agents"];
$cells[0]["color"] = "#000";
$cells[0]["href"] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60";
$cells[1][0] = __('Total checks');
$cells[1][1] = $data["total_checks"];
$cells[1]["color"] = "#000";
$cells[1]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1";
$cells[2][0] = __('Modules Down');
$cells[2][1] = $data["total_down"];
$cells[2]["color"] = "#f00";
$cells[2]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=0";
$cells[3][0] = __('Alerts defined');
$cells[3][1] = $data["total_alerts"];
$cells[3]["color"] = "#000";
$cells[3]["href"] = "index.php?sec=estado&sec2=operation/agentes/estado_alertas&refr=60";
$cells[4][0] = __('Users defined');
$cells[4][1] = count (list_users ());
$cells[4]["color"] = "#000";
$cells[4]["href"] = "index.php?sec=usuarios&sec2=operation/users/user";
foreach ($cells as $key => $row) {
//Switch class around
$class = (($key % 2) ? "datos2" : "datos");
echo '<tr><td class="'.$class.'"><b>'.$row[0].'</b></td>';
if ($row[1] === 0) {
$row[1] = "-";
}
echo '<td class="'.$class.'" style="text-align:right;"><a class="big_data" href="'.$row["href"].'" style="color: '.$row["color"].';">'.$row[1].'</a></td></tr>';
} }
if ($monitor_checks > 0){ echo '</tbody></table>';
$monitor_health = format_numeric (100 - (($monitor_bad + $monitor_unknown) / ($monitor_checks/100)), 1); echo '</div><div style="clear:both;">&nbsp;</div>'; //Clear the floats
} else { echo '<div id="activity" style="width:700px;">';
$monitor_health = 100;
}
if ($data_checks > 0) {
$data_health = format_numeric ((($data_checks - ($data_unknown + $data_alert)) / $data_checks ) * 100, 1);
} else {
$data_health = 100;
}
if ($data_checks != 0 || $data_checks != 0) {
$global_health = format_numeric ((($data_health * $data_checks) + ($monitor_health * $monitor_checks)) / $total_checks);
} else {
$global_health = 100;
}
if ($global_health < 0)
$global_health;
echo "<table class='databox' celldpadding=4 cellspacing=4 width=250>";
echo "<tr><td colspan='2'>".__('Monitor health')."</th>";
echo "<tr><td colspan='2'><img src='reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent=$monitor_health' title='$monitor_health % ".__('of monitors UP')."'>";
echo "<tr><td colspan='2'>".__('Data health')."</th>";
echo "<tr><td colspan='2'><img src='reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent=$data_health' title='$data_health % ".__('of modules with updated data')."'>";
echo "<tr><td colspan='2'>".__('Global health')."</th>";
echo "<tr><td colspan='2'><img src='reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent=$global_health' title='$global_health % ".__('of modules with good data')."'>";
echo "<tr><td colspan='2'>".__('Module sanity')."</th>";
echo "<tr><td colspan='2'><img src='reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent=$module_sanity ' title='$module_sanity % ".__('of well initialized modules')."'>";
echo "<tr><td colspan='2'>".__('Alert level')."</th>";
echo "<tr><td colspan='2'><img src='reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent=$alert_level' title='$alert_level % ".__('of non-fired alerts')."'>";
echo "</table>";
$query1 = "SELECT COUNT(id_usuario) FROM tusuario";
$users_defined = get_db_sql ($query1);
echo "<table class='databox' celldpadding=4 cellspacing=4 width=250>";
echo "<th colspan=2>".__('Pandora FMS Overview')."</th>";
echo "<tr><td class='datos2'><b>".__('Total agents')."</b></td>";
echo "<td class='datos2' style='font: bold 2em Arial, Sans-serif; color: #000;'>".$total_agents."</td>";
echo "</tr><tr><td class='datos'><b>".__('Total checks')."</b></td>";
echo "<td class='datos' style='font: bold 2em Arial, Sans-serif; color: #000;'>".$total_checks."</td>";
echo "</tr><tr><td class='datos2'><b>".__('Monitor BAD')."</b></td>";
echo "<td class='datos2' style='font: bold 2em Arial, Sans-serif; color: #f00;'>";
if ($monitor_bad > 0)
echo $monitor_bad;
else
echo "-";
echo "</td></tr><tr><td class='datos'><b>".__('Alerts defined')."</b></td>";
echo "<td class='datos' style='font: bold 2em Arial, Sans-serif; color: #000;'>".$total_alerts."</td>";
echo "</tr><tr><td class='datos2'><b>".__('Total users')."</b></td>";
echo "<td class='datos2' style='font: bold 2em Arial, Sans-serif; color: #000;'>".$users_defined."</td>";
echo "</tr></table>";
echo "</table>";
echo "<div id='activity'>";
// Show last activity from this user // Show last activity from this user
echo "<h2>" . __('This is your last activity in Pandora FMS console') . "</h2>"; echo "<h2>" . __('This is your last activity in Pandora FMS console') . "</h2>";
$color = 1;
$table->width = '700px'; $table->width = '700px';
$table->data = array (); $table->data = array ();
$table->size = array (); $table->size = array ();
@ -174,28 +148,26 @@ $table->head[2] = __('Date');
$table->head[3] = __('Source IP'); $table->head[3] = __('Source IP');
$table->head[4] = __('Comments'); $table->head[4] = __('Comments');
$sql = sprintf ("SELECT ID_usuario,accion,fecha,IP_origen,descripcion $sql = sprintf ("SELECT id_usuario,accion,fecha,ip_origen,descripcion
FROM `tsesion` FROM tsesion
WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - 604800) WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - 604800)
AND `ID_usuario` = '%s' ORDER BY `fecha` DESC LIMIT 5", AND `id_usuario` = '%s' ORDER BY `fecha` DESC LIMIT 5", $config["id_user"]);
$nick);
$sessions = get_db_all_rows_sql ($sql); $sessions = get_db_all_rows_sql ($sql);
if ($sessions === false) if ($sessions === false)
$sessions = array (); $sessions = array ();
foreach ($sessions as $session) { foreach ($sessions as $session) {
$data = array (); $data = array ();
$data[0] = '<strong>'.$session['ID_usuario'].'</strong>'; $data[0] = '<strong>'.$session['id_usuario'].'</strong>';
$data[1] = $session['accion']; $data[1] = $session['accion'];
$data[2] = $session['fecha']; $data[2] = $session['fecha'];
$data[3] = $session['IP_origen']; $data[3] = $session['ip_origen'];
$data[4] = $session['descripcion']; $data[4] = $session['descripcion'];
array_push ($table->data, $data); array_push ($table->data, $data);
} }
print_table ($table); print_table ($table);
echo "</div>"; // activity echo "</div>"; // activity
echo '</div>'; // class "jus"
?> ?>

View File

@ -89,18 +89,6 @@ function salida_limpia ($string) {
strtr ($string, $trans)); strtr ($string, $trans));
} }
/**
* Replace all \n characters with <br /> to show line breaks in HTML code.
*
* @param string String to replace the characters
*
* @return The string with the characters replaced.
*/
function clean_output_breaks ($string){
$myoutput = salida_limpia ($string);
return preg_replace ('/\n/',"<br />", $myoutput);
}
/** /**
* Cleans a string to be shown in a graphic. * Cleans a string to be shown in a graphic.
* *

View File

@ -2186,90 +2186,16 @@ function smal_event_table ($filter = "", $limit = 10, $width = 440) {
/** /**
* *DEPRECATED* use get_server_info instead
* Get statistical information for a given server * Get statistical information for a given server
* *
* @param id_server * @param id_server
* *
* @return : Serverifo array with following keys: * @return : Serverinfo array
type - Type of server (descriptive)
modules - Modules running on this server
module_lag - Number of modules of time
lag - Lag time in sec
*/ */
function server_status ($id_server) { function server_status ($id_server) {
$server = get_db_row_sql ( "SELECT * FROM tserver WHERE id_server = $id_server" ); $serverinfo = get_server_info ($id_server);
$serverinfo = array(); return $serverinfo[$id_server];
if ($server["network_server"] == 1)
$serverinfo["type"] = "network";
elseif ($server["data_server"] == 1)
$serverinfo["type"] = "data";
elseif ($server["plugin_server"] == 1)
$serverinfo["type"] = "plugin";
elseif ($server["wmi_server"] == 1)
$serverinfo["type"] = "wmi";
elseif ($server["recon_server"] == 1)
$serverinfo["type"] = "recon";
elseif ($server["snmp_server"] == 1)
$serverinfo["type"] = "snmp";
elseif ($server["prediction_server"] == 1)
$serverinfo["type"] = "prediction";
// Get type of modules that runs this server
$sql = sprintf ("SELECT DISTINCT(id_modulo)
FROM tagente_estado, tagente_modulo
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_estado.running_by = %d
ORDER BY tagente_modulo.id_agente_modulo",
$id_server);
$moduletype = get_db_all_rows_sql ($sql);
if ($moduletype) {
$serverinfo["modules"] = get_db_sql ("SELECT COUNT(*)
FROM tagente_estado, tagente_modulo
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_estado.running_by = $id_server");
$serverinfo["module_lag"] = get_db_sql ("SELECT COUNT(*)
FROM tagente_estado, tagente_modulo, tagente
WHERE tagente_estado.last_execution_try > 0
AND tagente_estado.running_by = $id_server
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200)");
// Lag over 1200 seconds is not lag, is module without contacting data in several time.or with a
// 1200 sec is 20 min
$serverinfo["lag"] = get_db_sql ("SELECT MAX(tagente_estado.last_execution_try - tagente_estado.current_interval)
FROM tagente_estado, tagente_modulo, tagente
WHERE tagente_estado.last_execution_try > 0
AND tagente_estado.running_by = $id_server
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200)");
if ($serverinfo["lag"] == "")
$serverinfo["lag"] = 0;
else
$serverinfo["lag"] = $serverinfo["lag"] ;
} else {
$serverinfo["modules_total"] = 0;
$serverinfo["modules"] = 0;
$serverinfo["module_lag"] = 0;
$serverinfo["lag"] = 0;
}
$nowtime = time();
if ($serverinfo["lag"] != 0){
$serverinfo["lag"] = $nowtime - $serverinfo["lag"];
}
return $serverinfo;
} }
/* /*
@ -2376,4 +2302,97 @@ function delete_agent ($id_agents) {
return true; return true;
} }
} }
/**
* This function will get all the server information in an array or a specific server
*
* @param $id_server: An optional integer or array of integers to select specific servers
*
* @return false in case the server doesn't exist or an array with info
*
**/
function get_server_info ($id_server = -1) {
if (is_array ($id_server)) {
$select_id = " WHERE id_server IN (".implode (",", $id_server).")";
} elseif ($id_server > 0) {
$select_id = " WHERE id_server IN (".(int) $id_server.")";
} else {
$select_id = "";
}
$sql = "SELECT * FROM tserver".$select_id;
$result = get_db_all_rows_sql ($sql);
if (empty ($result)) {
return false;
}
$return = array ();
foreach ($result as $server) {
if ($server["network_server"] == 1) {
$server["type"] = "network";
} elseif ($server["data_server"] == 1) {
$server["type"] = "data";
} elseif ($server["plugin_server"] == 1) {
$server["type"] = "plugin";
} elseif ($server["wmi_server"] == 1) {
$server["type"] = "wmi";
} elseif ($server["recon_server"] == 1) {
$server["type"] = "recon";
} elseif ($server["snmp_server"] == 1) {
$server["type"] = "snmp";
} elseif ($server["prediction_server"] == 1) {
$server["type"] = "prediction";
} else {
$server["type"] = "unknown";
}
$server["modules"] = get_db_sql ("SELECT COUNT(*) FROM tagente_estado, tagente_modulo
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_estado.running_by = ".$server["id_server"]);
$server["module_lag"] = get_db_sql ("SELECT COUNT(*) FROM tagente_estado, tagente_modulo, tagente
WHERE tagente_estado.last_execution_try > 0
AND tagente_estado.running_by = ".$server["id_server"]."
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200)");
// Lag over 1200 seconds is not lag, is module without contacting data in several time.or with a
// 1200 sec is 20 min
$server["lag"] = get_db_sql ("SELECT MAX(tagente_estado.last_execution_try - tagente_estado.current_interval)
FROM tagente_estado, tagente_modulo, tagente
WHERE tagente_estado.last_execution_try > 0
AND tagente_estado.running_by = ".$server["id_server"]."
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200)");
if (empty ($server["lag"])) {
$server["lag"] = 0;
} else {
$server["lag"] = time () - $server["lag"];
}
//Push the raw data on the return stack
$return[$server["id_server"]] = $server;
}
return $return;
}
/**
* This function will return the number of all agent modules in the database
*
* @return integer with the number of agent modules
*
* TODO: Filter? Implement when necessary
**/
function get_agentmodule_count () {
return (int) get_db_sql ("SELECT COUNT(*) FROM tagente_modulo");
}
?> ?>

View File

@ -369,11 +369,11 @@ function print_table (&$table, $return = false) {
$table->tablealign = 'center'; $table->tablealign = 'center';
} }
if (empty ($table->cellpadding)) { if (!isset ($table->cellpadding)) {
$table->cellpadding = '4'; $table->cellpadding = '4';
} }
if (empty ($table->cellspacing)) { if (!isset ($table->cellspacing)) {
$table->cellspacing = '4'; $table->cellspacing = '4';
} }
@ -384,8 +384,8 @@ function print_table (&$table, $return = false) {
$tableid = empty ($table->id) ? 'table'.$table_count : $table->id; $tableid = empty ($table->id) ? 'table'.$table_count : $table->id;
$output .= '<table width="'.$table->width.'" '; $output .= '<table width="'.$table->width.'" ';
$output .= " cellpadding=\"$table->cellpadding\" cellspacing=\"$table->cellspacing\" "; $output .= ' cellpadding="'.$table->cellpadding.'" cellspacing="'.$table->cellspacing.'"';
$output .= " border=\"$table->border\" class=\"$table->class\" id=\"$tableid\" >\n"; $output .= ' border="'.$table->border.'" class="'.$table->class.'" id="'.$tableid.'">';
$countcols = 0; $countcols = 0;
if (!empty ($table->head)) { if (!empty ($table->head)) {
$countcols = count ($table->head); $countcols = count ($table->head);

View File

@ -114,129 +114,168 @@ function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value
} }
/** /**
* Get a general stats info. * Get general stats info on a group
* *
* @param id_user
* @param id_group * @param id_group
* *
* @return * @return
*/ */
function general_stats ($id_user, $id_group = 0) { function get_group_stats ($id_group) {
if ($id_group <= 0) global $config;
// Get group list that user has access
$mis_grupos = list_group2 ($id_user);
else
$mis_grupos[0] = $id_group;
$contador_grupo = 0;
$contador_agente = 0;
$array_index = 0;
$monitor_checks = 0; $groups = array_keys (get_user_groups ($config["id_user"]));
$monitor_ok = 0; if ($id_group > 0 && in_array ($groups, $id_group)) {
$monitor_bad = 0; //If a group is selected, and we have permissions to it then we don't need to look for them
$monitor_unknown =0; $groups = array ();
$monitor_alert = 0; $groups[0] = $id_group;
$monitor_not_init=0;
$total_agents = 0;
$data_checks = 0;
$data_unknown =0;
$data_not_init = 0;
$data_alert = 0;
$data_alert_total = 0;
$monitor_alert_total = 0;
$ahora=date("Y-m-d H:i:s");
$ahora_sec = strtotime($ahora);
// Prepare data to show
// For each valid group for this user, take data from agent and modules
foreach ($mis_grupos as $migrupo) {
if ($migrupo != "") {
$existen_agentes = 0;
$sql0 = "SELECT COUNT(id_agente) FROM tagente WHERE id_grupo = $migrupo AND disabled = 0";
$result0 = mysql_query ($sql0);
$row0 = mysql_fetch_array ($result0);
$total_agents = $total_agents + $row0[0];
if ($row0[0] > 0)
$existen_agentes = 1;
// SQL Join to get monitor status for agents belong this group
$sql1 = "SELECT tagente.id_agente, tagente_estado.estado, tagente_estado.datos, tagente_estado.current_interval, tagente_estado.utimestamp, tagente_estado.id_agente_modulo, tagente_modulo.id_tipo_modulo FROM tagente, tagente_estado, tagente_modulo WHERE tagente.disabled = 0 AND tagente.id_grupo = $migrupo AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 ";
if ($result1 = mysql_query ($sql1)){
while ($row1 = mysql_fetch_array ($result1)) {
$id_agente = $row1[0];
$estado = $row1[1];
$datos = $row1[2];
$module_interval = $row1[3];
$utimestamp = $row1[4];
$seconds = $ahora_sec - $utimestamp;
$id_agente_modulo = $row1[5];
$module_type = $row1[6];
if (($module_type < 21) OR ($module_type == 100))
$async = 0;
else
$async = 1;
if ($estado != 100){
// Monitor check
$monitor_checks++;
if ($utimestamp == 0)
$monitor_not_init++;
elseif ($seconds >= ($module_interval*2))
$monitor_unknown++;
elseif ($datos != 0) {
$monitor_ok++;
} else {
$monitor_bad++;
}
// Alert
if ($utimestamp != 0){
$sql2 = "SELECT times_fired FROM talerta_agente_modulo WHERE id_agente_modulo = $id_agente_modulo";
if ($result2 = mysql_query ($sql2)){
if ($row2 = mysql_fetch_array ($result2)){
$monitor_alert_total++;
if ($row2[0] > 0)
$monitor_alert++;
}
}
}
} else {
// Data check
if ($utimestamp == 0)
$data_not_init++;
elseif (($seconds >= ($module_interval*2)) AND ($async == 0))
$data_unknown++;
$data_checks++;
// Alert
if ($utimestamp != 0){
$sql2 = "SELECT times_fired FROM talerta_agente_modulo WHERE id_agente_modulo = $id_agente_modulo";
if ($result2 = mysql_query ($sql2)){
if ($row2 = mysql_fetch_array ($result2)) {
$data_alert_total++;
if ($row2[0] > 0)
$data_alert++;
}
}
}
}
}
}
}
} }
//Select all modules in group
$sql = sprintf ("SELECT tagente.id_agente, tagente_estado.estado, tagente_estado.datos, tagente_estado.current_interval, tagente_estado.utimestamp,
tagente_estado.id_agente_modulo, tagente_modulo.id_tipo_modulo FROM tagente, tagente_estado, tagente_modulo
WHERE tagente.disabled = 0 AND tagente.id_grupo IN (%s)
AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0", implode (",",$groups));
$result = get_db_all_rows_sql ($sql);
if ($result === false)
$result = array ();
$data = array (); $data = array ();
$data[0] = $data['monitor_checks'] = $monitor_checks; $data["monitor_checks"] = 0;
$data[1] = $data['monitor_ok'] = $monitor_ok; $data["monitor_not_init"] = 0;
$data[2] = $data['monitor_bad'] = $monitor_bad; $data["monitor_unknown"] = 0;
$data[3] = $data['monitor_unknown'] = $monitor_unknown; $data["monitor_ok"] = 0;
$data[4] = $data['monitor_alert'] = $monitor_alert; $data["monitor_down"] = 0;
$data[5] = $data['total_agents'] = $total_agents; $data["monitor_alerts"] = 0;
$data[6] = $data['data_checks'] = $data_checks; $data["monitor_alerts_fired"] = 0;
$data[7] = $data['data_unknown'] = $data_unknown; $data["monitor_alerts_fire_count"] = 0;
$data[8] = $data['data_alert'] = $data_alert; $data["data_checks"] = 0;
$data[9] = $data['data_alert_total'] = $data_alert_total; $data["data_not_init"] = 0;
$data[10] = $data['monitor_alert_total'] = $monitor_alert_total; $data["data_unknown"] = 0;
$data[11] = $data['data_not_iniv'] = $data_not_init; $data["data_ok"] = 0;
$data[12] = $data['monitor_not_init'] = $monitor_not_init; $data["data_down"] = 0;
$data["data_alerts"] = 0;
$data["data_alerts_fired"] = 0;
$data["data_alerts_fire_count"] = 0;
$cur_time = time ();
foreach ($result as $row) {
$last_update = $cur_time - $row["utimestamp"];
if ($row["estado"] != 100) {
//This module is a monitor (remote)
$data["monitor_checks"]++;
//Check whether it's down, not init, unknown or OK
if ($last_update == $cur_time) {
//The utimestamp is 0 and has never been updated
$data["monitor_not_init"]++;
} elseif ($last_update >= ($row["current_interval"] * 2)) {
//The utimestamp is greater than 2x the interval (it has timed out)
$data["monitor_unknown"]++;
} elseif ($row["datos"] != 0) {
//Status is something
$data["monitor_ok"]++;
} else {
//Otherwise it's down
$data["monitor_down"]++;
}
$sql = sprintf ("SELECT times_fired FROM talerta_agente_modulo WHERE id_agente_modulo = %d", $row["id_agente_modulo"]);
$fired = get_db_sql ($sql);
if ($fired !== false) {
$data["monitor_alerts"]++;
if ($fired > 0) {
$data["monitor_alerts_fired"]++;
$data["monitor_alerts_fire_count"] += $fired;
}
}
} else {
//This module is a data check (agent)
$data["data_checks"]++;
//Check whether it's down, not init, unknown or OK
if ($last_update == $cur_time) {
//The utimestamp is 0 and has never been updated
$data["data_not_init"]++;
} elseif ($last_update >= ($row["current_interval"] * 2)) {
//The utimestamp is greater than 2x the interval (it has timed out)
$data["data_unknown"]++;
} elseif ($row["datos"] != 0) {
//Status is something
$data["data_ok"]++;
} else {
//Otherwise it's down
$data["data_down"]++;
}
$sql = sprintf ("SELECT times_fired FROM talerta_agente_modulo WHERE id_agente_modulo = %d", $row["id_agente_modulo"]);
$fired = get_db_sql ($sql);
if ($fired !== false) {
$data["data_alerts"]++;
if ($fired > 0) {
$data["data_alerts_fired"]++;
$data["data_alerts_fire_count"] += $fired;
}
}
} //End module check
} //End foreach module
$data["total_agents"] = count (get_agents_in_group ($groups));
$data["total_checks"] = $data["data_checks"] + $data["monitor_checks"];
$data["total_ok"] = $data["data_ok"] + $data["monitor_ok"];
$data["total_alerts"] = $data["data_alerts"] + $data["monitor_alerts"];
$data["total_alerts_fired"] = $data["data_alerts_fired"] + $data["monitor_alerts_fired"];
$data["total_alerts_fire_count"] = $data["data_alerts_fire_count"] + $data["monitor_alerts_fire_count"];
$data["monitor_bad"] = $data["monitor_down"] + $data["monitor_unknown"];
$data["data_bad"] = $data["data_down"] + $data["data_unknown"];
$data["total_bad"] = $data["data_bad"] + $data["monitor_bad"];
$data["total_not_init"] = $data["data_not_init"] + $data["monitor_not_init"];
$data["total_down"] = $data["data_down"] + $data["monitor_down"];
/*
Monitor health (percentage)
Data health (percentage)
Global health (percentage)
Module sanity (percentage)
Alert level (percentage)
Server Sanity 0% Uninitialized modules
*/
if ($data["monitor_bad"] > 0 && $data["monitor_checks"]) {
$data["monitor_health"] = format_numeric (100 - ($data["monitor_bad"] / ($data["monitor_checks"] / 100)), 1);
} else {
$data["monitor_health"] = 100;
}
if ($data["data_bad"] > 0 && $data["data_checks"] > 0) {
$data["data_health"] = format_numeric (100 - ($data["data_bad"] / ($data["data_checks"] / 100)), 1);
} else {
$data["data_health"] = 100;
}
if ($data["total_bad"] > 0 && $data["total_checks"] > 0) {
$data["global_health"] = format_numeric (100 - ($data["total_bad"] / ($data["total_checks"] / 100)), 1);
} else {
$data["global_health"] = 100;
}
if ($data["total_not_init"] > 0 && $data["total_checks"] > 0) {
$data["module_sanity"] = format_numeric (100 - ($data["total_not_init"] / ($data["total_checks"] / 100)), 1);
} else {
$data["module_sanity"] = 100;
}
if ($data["total_alerts_fired"] > 0 && $data["total_alerts"] > 0) {
$data["alert_level"] = format_numeric (100 - ($data["total_alerts_fired"] / ($data["total_alerts"] / 100)), 1);
} else {
$data["alert_level"] = 100;
}
$data["server_sanity"] = 100 - $data["module_sanity"];
return $data; return $data;
} }

View File

@ -0,0 +1,2 @@
<h1>Server Lag</h1>
<p>Server lag has 2 values. The first value (usually the larger one) shows how much seconds the modules are in the queue for that server, the second value show how many modules are in the queue.</p>

View File

@ -14,7 +14,7 @@ function winopeng (url, wid) {
status =wid; status =wid;
} }
function pandora_help(help_id) { function pandora_help (help_id) {
open ("general/pandora_help.php?id="+help_id, "pandorahelp", "width=650,height=500,status=0,toolbar=0,menubar=0,scrollbars=1,location=0"); open ("general/pandora_help.php?id="+help_id, "pandorahelp", "width=650,height=500,status=0,toolbar=0,menubar=0,scrollbars=1,location=0");
} }

View File

@ -306,9 +306,6 @@ td.datos3 {
td.datos_id { td.datos_id {
color: #1a313a; color: #1a313a;
} }
td.datos_jus, td.datos2_jus {
text-align: justify;
}
.bg { /* op menu */ .bg { /* op menu */
background-color: #786; background-color: #786;
} }
@ -336,10 +333,6 @@ td.datos_jus, td.datos2_jus {
.f9i, .redi { .f9i, .redi {
font-style: italic; font-style: italic;
} }
.jus {
text-align: justify;
width: 700px;
}
.tit { .tit {
padding-top: 3px; padding-top: 3px;
} }
@ -730,15 +723,9 @@ div#main_pure {
padding: 20px; padding: 20px;
} }
/* big_data is used in tactical and logon_ok */
td.big_data {
font-size: 2em;
font-weight: bold;
}
a.big_data { a.big_data {
text-decoration: none; font: bold 1em Arial, Sans-serif; text-decoration: none; font: bold 2em Arial, Sans-serif;
color: #000;
} }
.notify { .notify {
@ -746,4 +733,4 @@ a.big_data {
text-align: center; text-align: center;
font-weight: bold; font-weight: bold;
padding: 8px; padding: 8px;
} }

View File

@ -18,7 +18,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Load global vars // Load global vars
require ("include/config.php"); require_once ("include/config.php");
check_login (); check_login ();
@ -29,274 +29,224 @@ if (give_acl ($config['id_user'], 0, "AR") != 1) {
exit; exit;
} }
require ("include/functions_reporting.php"); require_once ("include/functions_reporting.php");
echo "<h2>".__('Pandora Agents')." &gt; ";
echo __('Tactical view')."</h2>";
$data = general_stats ($config['id_user'],-1); //This is an intermediary function to print out a set of cells
$monitor_checks = $data[0]; //Cells is an array with the explanation, value, link and color
$monitor_ok = $data[1]; function print_cells_temp ($cells) {
foreach ($cells as $key => $row) {
$monitor_bad = $data[2]; //Switch class around
$monitor_unknown = $data[3]; $class = (($key % 2) ? "datos2" : "datos");
$monitor_alert = $data[4]; echo '<tr><td class="'.$class.'"><b>'.$row[0].'</b></td>';
$total_agents = $data[5]; if ($row[1] === 0) {
$data_checks = $data[6]; $row[1] = "-";
$data_unknown = $data[7]; }
$data_alert = $data[8]; echo '<td class="'.$class.'" style="text-align:right;"><a class="big_data" href="'.$row["href"].'" style="color: '.$row["color"].';">'.$row[1].'</a></td></tr>';
$data_alert_total = $data[9]; }
$monitor_alert_total = $data[10];
$data_not_init = $data[11];
$monitor_not_init = $data[12];
// Calculate global indicators
$total_checks = $data_checks + $monitor_checks;
if($total_checks != 0){
$notinit_percentage = (($data_not_init + $monitor_not_init) / ($total_checks / 100));
} else {
$notinit_percentage = 0;
} }
$module_sanity = format_numeric (100 - $notinit_percentage);
$total_alerts = $data_alert + $monitor_alert;
$total_fired_alerts = $monitor_alert_total+$data_alert_total;
if ($total_fired_alerts > 0)
$alert_level = format_numeric (100 - ($total_alerts / ($total_fired_alerts / 100)));
else
$alert_level = 100;
if ($monitor_checks > 0){
$monitor_health = format_numeric ( 100- (($monitor_bad + $monitor_unknown) / ($monitor_checks/100)) , 1);
} else
$monitor_health = 100;
if ($data_checks > 0){
$data_health = format_numeric ( (($data_checks -($data_unknown + $data_alert)) / $data_checks ) * 100,1);;
} else
$data_health = 100;
if ($data_health < 0)
$data_health =0;
if (($data_checks != 0) OR ($data_checks != 0)){
$global_health = format_numeric ((($data_health * $data_checks) + ($monitor_health * $monitor_checks)) / $total_checks);
} else
$global_health = 100;
if ($global_health < 0) echo "<h2>".__('Pandora Agents')." &gt; ".__('Tactical view')."</h2>";
$global_health;
$data = get_group_stats (0);
echo '<div style="width:265px; float:left; padding-right: 40px;" id="leftcolumn">';
// Monitor checks // Monitor checks
// ~~~~~~~~~~~~~~~
echo "<table width=770 border=0>";
echo "<tr><td valign=top>";
echo "<table class='databox' celldpadding=4 cellspacing=4 width=250>";
// Summary $table->width = "100%";
$table->class = "databox";
$table->cellpadding = 0;
$table->cellspacing = 0;
$table->border = 0;
$table->head = array ();
$table->data = array ();
$table->style = array ();
echo "<tr><td colspan='2'><b>".__('Monitor health')."</th>"; $table->style[0] = "padding-top:4px; padding-bottom:4px;";
echo "<tr><td colspan='2'><img src='reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent=$monitor_health' title='$monitor_health % ".__('of monitors UP')."'>"; $table->data[0][0] ='<b>'.__('Monitor health').'</b>';
echo "<tr><td colspan='2'><b>".__('Data health')."</th>";
echo "<tr><td colspan='2'><img src='reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent=$data_health' title='$data_health % ".__('of modules with updated data')."'>";
echo "<tr><td colspan='2'><b>".__('Global health')."</th>";
echo "<tr><td colspan='2'><img src='reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent=$global_health' title='$global_health % ".__('of modules with good data')."'>";
echo "<tr><td colspan='2'><b>".__('Module sanity')."</th>";
echo "<tr><td colspan='2'><img src='reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent=$module_sanity ' title='$module_sanity % ".__('of well initialized modules')."'>";
echo "<tr><td colspan='2'><b>".__('Alert level')."</th>";
echo "<tr><td colspan='2'><img src='reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent=$alert_level' title='$alert_level % ".__('of non-fired alerts')."'>";
echo "<br><br>";
// Monitor checks $table->style[1] = "padding-top:4px; padding-bottom:4px;";
echo "<tr>"; $table->data[1][0] = '<img src="reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent='.$data["monitor_health"].'" title="'.$data["monitor_health"].'% '.__('of monitors up').'" />';
echo "<th colspan=2>".__('Monitor checks')."</th>";
echo "<tr><td class=datos2><b>".__('Monitor checks')."</b></td>";
echo "<td style='font: bold 2em Arial;' class='datos2'>";
echo "<a class='big_data' href='index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1'>";
echo $monitor_checks."</A></td>";
// Monitor OK $table->style[2] = "padding-top:4px; padding-bottom:4px;";
echo "<tr><td class=datos><b>".__('Monitor OK')."</b></td>"; $table->data[2][0] = '<b>'.__('Data health').'</b>';
echo "<td style='font: bold 2em Arial' class='datos'>";
echo "<a style='color:#0f0;' class='big_data' href='index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1'>";
if ($monitor_ok > 0)
echo $monitor_ok;
else
echo "-";
echo "</A>";
// Monitor BAD $table->style[3] = "padding-top:4px; padding-bottom:4px;";
echo "<tr><td class=datos2><b>".__('Monitor BAD')."</b></td>"; $table->data[3][0] = '<img src="reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent='.$data["data_health"].'" title="'.$data["data_health"].'% '.__('of data modules up').'" />';
echo "<td class='datos2' style='font: bold 2em Arial' >";
echo "<a style='color:#f00;' class='big_data' href='index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=0'>";
if ($monitor_bad > 0)
echo $monitor_bad;
else
echo "-";
echo "</A>";
echo "</td></tr>"; $table->style[4] = "padding-top:4px; padding-bottom:4px;";
$table->data[4][0] = '<b>'.__('Global health').'</b>';
// Monitor unknown $table->style[5] = "padding-top:4px; padding-bottom:4px;";
echo "<tr><td class=datos>"; $table->data[5][0] = '<img src="reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent='.$data["global_health"].'" title="'.$data["global_health"].'% '.__('of total modules up').'" />';
echo "<b>".__('Monitor Unknown')."</b></td>";
echo "<td class='datos' style='font: bold 2em Arial' >"; $table->style[6] = "padding-top:4px; padding-bottom:4px;";
echo "<a style='color:#aaa;' class='big_data' href='index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=2'>"; $table->data[6][0] = '<b>'.__('Module sanity').'</b>';
if ($monitor_unknown > 0)
echo $monitor_unknown;
else
echo "-";
echo "</A>";
echo "</td></tr><tr><td class=datos2><b>".__('Monitor Not Init')."</b></td>"; $table->style[7] = "padding-top:4px; padding-bottom:4px;";
echo "<td class=datos2 style='font: bold 2em Arial, Sans-serif; color: #FF8C00;'>"; $table->data[7][0] = '<img src="reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent='.$data["module_sanity"].'" title="'.$data["module_sanity"].'% '.__('of total modules inited').'" />';
if ($monitor_not_init> 0)
echo $monitor_not_init;
else
echo "-";
echo "<tr><td class=datos><b>".__('Alerts Fired')."</b></td>"; $table->style[8] = "padding-top:4px; padding-bottom:4px;";
echo "<td class=datos style='font: bold 2em Arial'>"; $table->data[8][0] = '<b>'.__('Alert level').'</b>';
echo "<a style=color:#f00' class='big_data' href='index.php?sec=eventos&sec2=operation/events/events&search=&event_type=alert_fired'>";
if ($monitor_alert > 0)
echo $monitor_alert;
else
echo "-";
echo "</A>";
echo "<tr><td class=datos2><b>".__('Alerts Total')."</b></td>";
echo "<td class=datos2 style='font: bold 2em Arial'>".$monitor_alert_total;
$table->style[9] = "padding-top:4px; padding-bottom:4px;";
$table->data[9][0] = '<img src="reporting/fgraph.php?tipo=progress&height=20&width=260&mode=0&percent='.$data["alert_level"].'" title="'.$data["alert_level"].'% '.__('of defined alerts not fired').'" />';
print_table ($table);
unset ($table);
// Data checks echo '<table class="databox" cellpadding="4" cellspacing="4" style="width:100%;">';
// ~~~~~~~~~~~~~~~ echo '<tr><th colspan="2">'.__('Monitor checks').'</th></tr>';
$cells = array ();
$cells[0][0] = __('Monitor checks');
$cells[0][1] = $data["monitor_checks"];
$cells[0]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1"; //All
$cells[0]["color"] = "#000";
echo "<tr><th colspan=2>".__('Data Checks')."</th>"; $cells[1][0] = __('Monitors good');
echo "<tr><td class=datos2><b>".__('Data Checks')."</b></td>"; $cells[1][1] = $data["monitor_ok"];
echo "<td class=datos2 style='font: bold 2em Arial'>".$data_checks; $cells[1]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1"; //Up
echo "<tr><td class=datos><b>".__('Data Unknown')."</b></td>"; $cells[1]["color"] = "#000";
echo "<td class=datos style='font: bold 2em Arial; color: #aaa;'>";
if ($data_unknown > 0)
echo $data_unknown;
else
echo "-";
echo "<tr><td class=datos2><b>".__('Data Not Init')."</b></td>";
echo "<td class=datos2 style='font: bold 2em Arial'>";
if ($data_not_init > 0)
echo $data_not_init;
else
echo "-";
echo "<tr><td class=datos><b>".__('Alerts Fired')."</b></td>";
$cells[2][0] = __('Monitors down');
$cells[2][1] = $data["monitor_down"];
$cells[2]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=0"; //Down
$cells[2]["color"] = "#f00";
$cells[3][0] = __('Monitors unknown');
$cells[3][1] = $data["monitor_unknown"];
$cells[3]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=2"; //Unknown
$cells[3]["color"] = "#C0C0C0";
echo "<td class=datos style='font: bold 2em Arial'>"; $cells[4][0] = __('Monitors not init');
echo "<a style=color:#f00' class='big_data' href='index.php?sec=eventos&sec2=operation/events/events&search=&event_type=alert_fired'>"; $cells[4][1] = $data["monitor_not_init"];
if ($data_alert > 0) $cells[4]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=2"; //Unknown
echo $data_alert; $cells[4]["color"] = "#f00";
else
echo "-";
echo "</A>";
echo "<tr><td class=datos2><b>".__('Alerts Total'); $cells[5][0] = __('Alerts defined');
echo "<td class=datos2 style='font: bold 2em Arial'>".$data_alert_total; $cells[5][1] = $data["monitor_alerts"];
$cells[5]["href"] = "index.php?sec=estado&sec2=operation/agentes/estado_alertas&refr=60"; //All alerts defined
$cells[5]["color"] = "#000";
$cells[6][0] = __('Alerts fired');
$cells[6][1] = $data["monitor_alerts_fired"];
$cells[6]["href"] = "index.php?sec=eventos&sec2=operation/events/events&search=&event_type=alert_fired"; //Fired alert events
$cells[6]["color"] = "#f00";
// Summary print_cells_temp ($cells);
// ~~~~~~~~~~~~~~~
echo '<tr><th colspan="2">'.__('Data checks').'</th></tr>';
$cells = array ();
$cells[0][0] = __('Data checks');
$cells[0][1] = $data["data_checks"];
$cells[0]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1"; //All
$cells[0]["color"] = "#000";
$cells[1][0] = __('Data good');
$cells[1][1] = $data["data_ok"];
$cells[1]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1"; //Up
$cells[1]["color"] = "#000";
$cells[2][0] = __('Data down');
$cells[2][1] = $data["data_down"];
$cells[2]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=0"; //Down
$cells[2]["color"] = "#f00";
$cells[3][0] = __('Data unknown');
$cells[3][1] = $data["data_unknown"];
$cells[3]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=2"; //Unknown
$cells[3]["color"] = "#C0C0C0";
$cells[4][0] = __('Data not init');
$cells[4][1] = $data["data_not_init"];
$cells[4]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=2"; //Unknown
$cells[4]["color"] = "#f00";
$cells[5][0] = __('Alerts defined');
$cells[5][1] = $data["data_alerts"];
$cells[5]["href"] = "index.php?sec=estado&sec2=operation/agentes/estado_alertas&refr=60"; //All alerts defined
$cells[5]["color"] = "#000";
$cells[6][0] = __('Alerts fired');
$cells[6][1] = $data["data_alerts_fired"];
$cells[6]["href"] = "index.php?sec=eventos&sec2=operation/events/events&search=&event_type=alert_fired"; //Fired alert events
$cells[6]["color"] = "#f00";
echo "<tr><th colspan='2'>".__('Summary')."</th>"; print_cells_temp ($cells);
echo "<tr><td class='datos2'><b>".__('Total Agents')."</b></td>";
echo "<td class='datos2' style='font: bold 2em Arial, Sans-serif;'>".$total_agents; echo '<tr><th colspan="2">'.__('Summary').'</th></tr>';
echo "<tr><td class='datos'><b>".__('Total Checks')."</b></td>";
echo "<td class='datos' style='font: bold 2em Arial, Sans-serif;'>".$total_checks;
echo "<tr><td class='datos2'><b>".__('Server Sanity')."</b></td>"; $cells = array ();
echo "<td class='datos2' style='font: bold 1em Arial, Sans-serif;'>"; $cells[0][0] = __('Total Agents');
echo format_numeric($notinit_percentage); $cells[0][1] = $data["total_agents"];
echo "% ".__('Uninitialized modules'); $cells[0]["color"] = "#000";
$cells[0]["href"] = "index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60";
$cells[1][0] = __('Total Checks');
$cells[1][1] = $data["total_checks"];
$cells[1]["color"] = "#000";
$cells[1]["href"] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1";
$cells[2][0] = __('Uninitialized modules');
$cells[2][1] = $data["server_sanity"] . "%";
$cells[2]["color"] = "#000";
$cells[2]["href"] = "index.php?sec=estado_server&sec2=operation/servers/view_server&refr=60";
print_cells_temp ($cells);
echo "</table>"; echo "</table>";
echo '</div>'; //Left column
echo "<td valign='top'>"; echo '<div style="width: 450px; float:left;" id="rightcolumn">';
// Server information // Server information
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$total_modules = (int) get_db_sql ("SELECT COUNT(*)
FROM tagente_modulo
WHERE tagente_modulo.disabled = 0");
$sql='SELECT * FROM tserver'; echo '<table class="databox" cellpadding="4" cellspacing="4" style="width:100%;">';
$result=mysql_query($sql); echo '<thead><tr><th colspan="4">'.__('Tactical server information').'</th></tr>';
if (mysql_num_rows($result)){ echo '<tr><th style="font-weight:none;">'.__('Name').'</th><th style="font-weight:none;">'.__('Status').'</th><th style="font-weight:none;">'.__('Load').'</th><th style="font-weight:none;">'.__('Lag').pandora_help ("serverlag", true).'</th></tr></thead><tbody>';
echo "<table cellpadding='4' cellspacing='4' witdh='440' class='databox'>";
echo "<tr><th colspan=5>";
echo __('Tactical server information');
echo "<tr><td class='datos3'>".__('Name')."</th>";
echo "<td class='datos3'>".__('Status')."</th>";
echo "<td class='datos3'>".__('Load')."</th>";
echo "<td class='datos3'>".__('Modules')."</th>";
echo "<td class='datos3'>".__('LAG')."</th>";
$color=1;
while ($row=mysql_fetch_array($result)){
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
$id_server = $row["id_server"];
$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"];
$recon_server = $row["recon_server"];
$master = $row["master"];
$checksum = $row["checksum"];
$description = $row["description"];
$version = $row["version"];
$modules_server = 0;
$serverinfo = server_status ($id_server); $serverinfo = get_server_info ();
$total_modules = get_agentmodule_count ();
$cells = array ();
// Name of server foreach ($serverinfo as $server_id => $server_info) {
echo "<tr><td class='$tdcolor'>"; $data = array ();
echo $name; $data[0] = $server_info["name"];
// Status if ($server_info["status"] == 0){
echo "<td class='$tdcolor' align='middle'>"; $data[1] = '<img src="images/pixel_red.png" width="20" height="20" />';
if ($status ==0){ } else {
echo "<img src='images/pixel_red.png' width=20 height=20>"; $data[1] = '<img src="images/pixel_green.png" width="20" height="20" />';
} else {
echo "<img src='images/pixel_green.png' width=20 height=20>";
}
// Load
echo "<td class='$tdcolor' align='middle'>";
if ($total_modules > 0)
$percentil = $serverinfo["modules"] / ($total_modules / 100);
else
$percentil = 0;
if ($percentil > 100)
$percentil = 100;
// Progress bar render
echo '<img src="reporting/fgraph.php?tipo=progress&percent='.$percentil.'&height=18&width=80">';
// Modules
echo "<td class='$tdcolor' align='middle'>";
echo $serverinfo["modules"] . " ".__('of')." ". $total_modules;
// Lag
echo "<td class='$tdcolor' align='middle'>";
echo human_time_description_raw ($serverinfo["lag"]) . " / ". $serverinfo["module_lag"];
} }
echo '</table>';
if ($server_info["modules"] > 0 && $total_modules > 0) {
$percent = $server_info["modules"] / ($total_modules / 100);
} else {
$percent = 0;
}
$data[2] = '<img src="reporting/fgraph.php?tipo=progress&percent='.$percent.'&height=18&width=80" title="'.$server_info["modules"]." ".__('of')." ".$total_modules.'" />';
// Event information $data[3] = $server_info["lag"]." / ".$server_info["module_lag"];
smal_event_table ("", 10, 440);
array_push ($cells, $data);
} }
echo "</table>";
foreach ($cells as $key => $row) {
//Switch class around
$class = (($key % 2) ? "datos2" : "datos");
echo '<tr>
<td class="'.$class.'">'.$row[0].'</td>
<td class="'.$class.'" style="text-align:center;">'.$row[1].'</td>
<td class="'.$class.'" style="text-align:center;">'.$row[2].'</td>
<td class="'.$class.'" style="text-align:right;">'.$row[3].'</td>
</tr>';
}
echo '</tbody></table>';
?> smal_event_table ("", 10, 450);
echo '</div>';
?>

View File

@ -23,7 +23,7 @@ check_login ();
if (! give_acl ($config['id_user'], 0, "AR") && ! give_acl ($config['id_user'], 0, "AW")) { if (! give_acl ($config['id_user'], 0, "AR") && ! give_acl ($config['id_user'], 0, "AW")) {
audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation", audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation",
"Trying to access Agent view"); "Trying to access Server view");
require ("general/noaccess.php"); require ("general/noaccess.php");
return; return;
} }