2009-04-06 Sancho Lerena <slerena@artica.es>

* godmode/setup/setup.php
	* godmode/setup/setup_visuals.php
	* include/config_process.php,
	* include/functions_config.php: Added new parameter for status icons. 
	Old config (fontpath and attachment dir are now manageable in setup).

	* include/functions_ui.php,
	godmode/servers/modificar_server.php
	operation/agentes/status_monitor.php
	operation/agentes/estado_agente.php
	operation/agentes/bulbs.php
	operation/agentes/estado_monitores.php
	operation/agentes/tactical.php
	operation/servers/view_server.php: Added support for custom status
	images.

	* images/status_sets: Added three new status images pack: Default color
	icons, faces and color with text.
	
	* reporting/fgraph.php: Temporal FIX for problem in access graphs that
	takes 100% Apache CPU !!!. Need final fix for this.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1598 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2009-04-06 11:02:05 +00:00
parent a2c8fe5c43
commit cf98960e6c
56 changed files with 197 additions and 65 deletions

View File

@ -1,3 +1,27 @@
2009-04-06 Sancho Lerena <slerena@artica.es>
* godmode/setup/setup.php
* godmode/setup/setup_visuals.php
* include/config_process.php,
* include/functions_config.php: Added new parameter for status icons.
Old config (fontpath and attachment dir are now manageable in setup).
* include/functions_ui.php,
godmode/servers/modificar_server.php
operation/agentes/status_monitor.php
operation/agentes/estado_agente.php
operation/agentes/bulbs.php
operation/agentes/estado_monitores.php
operation/agentes/tactical.php
operation/servers/view_server.php: Added support for custom status
images.
* images/status_sets: Added three new status images pack: Default color
icons, faces and color with text.
* reporting/fgraph.php: Temporal FIX for problem in access graphs that
takes 100% Apache CPU !!!. Need final fix for this.
2009-04-03 Sancho Lerena <slerena@artica.es>
* include/functions_alerts.php: Fixed another notice.

View File

@ -84,7 +84,7 @@ if (isset($_GET["server"])) {
$table->width = "90%";
$table->class = "databox";
$table->align = array ('',"center","center","center","center","center","center","center");
$table->head = array (__('Name'),__('Status'),__('IP Address'),__('Description'),__('Type'),__('Started'),__('Updated'),__('Delete'));
$table->head = array (__('Name'),__('Status'),__('Description'),__('Type'),__('Started'),__('Updated'),__('Delete'));
foreach ($result as $row) {
$server = "";
@ -104,10 +104,16 @@ if (isset($_GET["server"])) {
$server .= '<img src="images/binary.png" />&nbsp;';
}
if ($row['status'] == 0) {
$server_status = print_status_image(STATUS_SERVER_DOWN, '', true);
} else {
$server_status = print_status_image(STATUS_SERVER_OK, '', true);
}
$table->data[] = array (
'<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server='.$row["id_server"].'"><b>'.$row["name"].'</b></a>',
'<img src="images/dot_'.(($row["status"] == 0) ? 'red' : 'green').'.png">',
$row["ip_address"],
$server_status,
substr($row["description"],0,25),
$server,
human_time_comparation ($row["laststart"]),

View File

@ -93,6 +93,14 @@ $table->data[19][1] = print_checkbox ('https', 1, $config["https"], true);
$table->data[20][0] = __('Compact CSS and JS into header');
$table->data[20][1] = print_checkbox ('compact_header', 1, $config["compact_header"], true);
$table->data[25][0] = __('Font path');
$table->data[25][1] = print_input_text ('fontpath', $config["fontpath"], '', 50, 255, true);
$table->data[26][0] = __('Attachment store');
$table->data[26][1] = print_input_text ('attachment_store', $config["attachment_store"], '', 50, 255, true);
enterprise_hook ('load_snmpforward_enterprise');
echo '<form id="form_setup" method="POST" action="index.php?sec=gsetup&amp;sec2=godmode/setup/setup">';

View File

@ -72,6 +72,14 @@ $table->data[7][1] = print_input_text ('block_size', $config["block_size"], '',
$table->data[8][0] = __('Use round corners');
$table->data[8][1] = print_checkbox ('round_corner', 1, $config["round_corner"], true);
$table->data[9][0] = __('Status Icon set');
$iconsets["default"] = __('Colors (Default)');
$iconsets["faces"] = __('Faces');
$iconsets["color_text"] = __('Color and text');
$table->data[9][1] = print_select ($iconsets, 'status_images_set', $config["status_images_set"], '', '', '', true);
echo '<form id="form_setup" method="POST" action="index.php?sec=gsetup&amp;sec2=godmode/setup/setup_visuals">';
print_input_hidden ('update_config', 1);
print_table ($table);

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -22,18 +22,6 @@ $pandora_version = 'v3.0-dev';
$config['start_time'] = microtime (true);
// Next is the directory where "/attachment" directory is placed, to upload files stores.
// This MUST be writtable by http server user, and should be in pandora root.
// By default, Pandora adds /attachment to this, so by default is the pandora console home dir
$config['attachment_store'] = $config['homedir'].'/attachment';
// Default font used for graphics (a Free TrueType font included with Pandora FMS)
$config['fontpath'] = $config['homedir'].'/reporting/FreeSans.ttf';
// Style (pandora by default)
$config['style'] = 'pandora';
//Non-persistent connection. If you want persistent conn change it to mysql_pconnect()
$config['dbconnection'] = mysql_connect ($config["dbhost"], $config["dbuser"], $config["dbpass"]);
if (! $config['dbconnection']) {

View File

@ -107,6 +107,7 @@ function update_config () {
update_config_value ('https', (bool) get_parameter ('https'));
update_config_value ('compact_header', (bool) get_parameter ('compact_header'));
update_config_value ('round_corner', (bool) get_parameter ('round_corner'));
update_config_value ('status_images_set', (string) get_parameter ('status_images_set', $config["status_images_set"]));
}
/**
@ -212,6 +213,10 @@ function process_config () {
update_config_value ('compact_header', false);
}
if (!isset ($config['status_images_set'])) {
update_config_value ('status_images_set', 'default');
}
if (isset ($_SESSION['id_usuario']))
$config["id_user"] = $_SESSION["id_usuario"];
@ -225,6 +230,22 @@ function process_config () {
require_once ($config["homedir"]."/include/auth/".$config["auth"]["scheme"].".php");
}
// Next is the directory where "/attachment" directory is placed, to upload files stores.
// This MUST be writtable by http server user, and should be in pandora root.
// By default, Pandora adds /attachment to this, so by default is the pandora console home dir
if (!isset ($config['attachment_store'])) {
update_config_value ( 'attachment_store', $config['homedir'].'/attachment');
}
if (!isset ($config['fontpath'])) {
update_config_value ( 'fontpath', $config['homedir'].'/reporting/FreeSans.ttf');
}
if (!isset ($config['style'])) {
update_config_value ( 'style', 'pandora');
}
/* Finally, check if any value was overwritten in a form */
update_config ();
}

View File

@ -325,22 +325,23 @@ function format_alert_row ($alert, $compound = false, $agent = true, $url = '')
$data[3] = print_timestamp ($alert["last_fired"], true);
$options = array ();
$options["height"] = 18;
$options["width"] = 40;
$status = STATUS_ALERT_NOT_FIRED;
$title = "";
if ($alert["times_fired"] > 0) {
$options["src"] = "images/pixel_red.png";
$options["title"] = __('Alert fired').' '.$alert["times_fired"].' '.__('times');
$status = STATUS_ALERT_FIRED;
$title = __('Alert fired').' '.$alert["times_fired"].' '.__('times');
} elseif ($alert["disabled"] > 0) {
$options["src"] = "images/pixel_gray.png";
$options["title"] = __('Alert disabled');
$status = STATUS_ALERT_DISABLED;
$title = __('Alert disabled');
} else {
$options["src"] = "images/pixel_green.png";
$options["title"] = __('Alert not fired');
$status = STATUS_ALERT_NOT_FIRED;
$title = __('Alert not fired');
}
$data[4] = print_image ($options["src"], true, $options);
$data[4] = print_status_image($status, $title, true);
if ($compound) {
$data[5] = print_checkbox ("validate_compound[]", $alert["id"], false, true);
@ -1011,4 +1012,56 @@ function format_filesize ($bytes) {
return format_numeric ($bytes / pow ($con, $log), 1).' '.$strs[$log];
}
/**
* Returns the current path to the selected image set to show the
* status of agents and alerts.
*
* @return array An array with the image path, image width and image height.
*/
function get_status_images_path()
{
global $config;
$imageset = $config["status_images_set"];
if (strpos($imageset, ",") === false) $imageset .= ",40x18";
list($imageset, $sizes) = split(",", $imageset, 2);
if (strpos($sizes, "x") === false) $sizes .= "x18";
list($imagewidth, $imageheight) = split("x", $sizes, 2); // 40x18
$imagespath = "images/status_sets/$imageset";
return array($imagespath);
}
define('STATUS_MODULE_OK', 'module_ok.png');
define('STATUS_MODULE_CRITICAL', 'module_critical.png');
define('STATUS_MODULE_WARNING', 'module_warning.png');
define('STATUS_AGENT_CRITICAL', 'agent_critical.png');
define('STATUS_AGENT_WARNING', 'agent_warning.png');
define('STATUS_AGENT_DOWN', 'agent_down.png');
define('STATUS_AGENT_OK', 'agent_ok.png');
define('STATUS_AGENT_NO_DATA', 'agent_no_data.png');
define('STATUS_AGENT_NO_MONITORS', 'agent_no_monitors.png');
define('STATUS_ALERT_FIRED', 'alert_fired.png');
define('STATUS_ALERT_NOT_FIRED', 'alert_not_fired.png');
define('STATUS_ALERT_DISABLED', 'alert_disabled.png');
define('STATUS_SERVER_OK', 'server_ok.png');
define('STATUS_SERVER_DOWN', 'server_down.png');
function print_status_image($type, $title = "", $return = false)
{
list($imagepath) = get_status_images_path();
$imagepath .= "/" . $type;
return print_image ($imagepath, $return, array ("border" => 0, "title" => $title));
}
?>

View File

@ -16,25 +16,24 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
echo "
<table cellpadding='3' cellspacing='3'>
<tr><td class='f9i'>
<img src='images/pixel_green.png' width=40 height=18> ".__('All Monitors OK')."</td>
<td class='f9i'>
<img src='images/pixel_red.png' width=40 height=18> ".__('At least one monitor fails')."</td>
<td class='f9i'>
<img src='images/pixel_yellow.png' width=40 height=18> ".__('Change between Green/Red state')."</td>
<td class='f9i'>
<img src='images/pixel_red.png' width=20 height=10> ".__('Alert fired')."</td>
<tr><td class='f9i'>
<img src='images/pixel_gray.png' width=40 height=18> ".__('Agent without monitors')."</td>
<td class='f9i'>
<img src='images/pixel_blue.png' width=40 height=18> ".__('Agent without data')."</td>
<td class='f9i'>
<img src='images/pixel_fucsia.png' width=40 height=18> ".__('Agent down')."</td>
<td class='f9i'>
<img src='images/pixel_green.png' width=20 height=10> ".__('Alert not fired')."</td>
<tr>
<td class='f9i'>" . print_status_image(STATUS_AGENT_OK, __('All Monitors OK'), true) . __('All Monitors OK') . "</td>
<td class='f9i'>" . print_status_image(STATUS_MODULE_CRITICAL, __('At least one monitor fails'), true) . __('At least one monitor fails') . "</td>
<td class='f9i'>" . print_status_image(STATUS_MODULE_WARNING, __('Change between Green/Red state'), true) . __('Change between Green/Red state') . "</td>
<td class='f9i'>" . print_status_image(STATUS_ALERT_FIRED, __('Alert fired'), true) . __('Alert fired') . "</td>
<td class='f9i'>" . print_status_image(STATUS_ALERT_DISABLED, __('Alert disabled'), true) . __('Alerts disabled') . "</td>
<tr>
<td class='f9i'>" . print_status_image(STATUS_AGENT_NO_MONITORS, __('Agent without monitors'), true) . __('Agent without monitors') . "</td>
<td class='f9i'>" . print_status_image(STATUS_AGENT_NO_DATA, __('Agent without data'), true) . __('Agent without data') . "</td>
<td class='f9i'>" . print_status_image(STATUS_AGENT_DOWN, __('Agent down'), true) . __('Agent down') . "</td>
<td class='f9i'>" . print_status_image(STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true) . __('Alert not fired') . "</td>
</tr>
</table>
";

View File

@ -304,31 +304,32 @@ if ($agents !== false) {
if ($monitor_down > 0)
echo " <span class='grey'> : ".$monitor_down."</span>";
echo "</td>";
echo "<td class='$tdcolor' align='center'>";
if ($numero_modulos > 0){
if ($agent_down > 0) {
echo '<img src="images/pixel_fucsia.png" width="40" height="18" title="'.__('Agent down').'" />';
print_status_image(STATUS_AGENT_DOWN, __('Agent down'));
} elseif ($monitor_critical > 0) {
echo '<img src="images/pixel_red.png" width="40" height="18" title="'.__('At least one module in CRITICAL status').'" />';
print_status_image(STATUS_AGENT_CRITICAL, __('At least one module in CRITICAL status'));
} elseif ($monitor_warning > 0) {
echo '<img src="images/pixel_yellow.png" width="40" height="18" title="'.__('At least one module in WARNING status').'" />';
print_status_image(STATUS_AGENT_WARNING, __('At least one module in WARNING status'));
} else {
echo '<img src="images/pixel_green.png" width="40" height="18" title="'.__('All Monitors OK').'" />';
print_status_image(STATUS_AGENT_OK, __('All Monitors OK'));
}
} else {
echo '<img src="images/pixel_blue.png" width="40" height="18" title="'.__('Agent without data').'" />';
print_status_image(STATUS_AGENT_NO_DATA, __('Agent without data'));
}
// checks if an alert was fired recently
echo "<td class='$tdcolor' align='center'>";
if (give_disabled_group ($id_grupo)) {
echo "<img src='images/pixel_gray.png' width=20 height=9>";
print_status_image(STATUS_ALERT_DISABLED, __('Alert disabled'));
} else {
if (check_alert_fired ($id_agente) == 1)
echo '<img src="images/pixel_red.png" width="20" height="9" title="'.__('Alert fired').'" />';
print_status_image(STATUS_ALERT_FIRED, __('Alert fired'));
else
echo '<img src="images/pixel_green.png" width="20" height="9" title="'.__('Alert not fired').'" />';
print_status_image(STATUS_ALERT_NOT_FIRED, __('Alert not fired'));
}
echo "</td>";
echo "<td class='$tdcolor'>";

View File

@ -54,6 +54,8 @@ $table->head[4] = __('Status');
$table->head[5] = __('Interval');
$table->head[6] = __('Last contact');
$table->align = array("left","left","left","left","center");
foreach ($modules as $module) {
$data = array ();
if (($module["id_modulo"] != 1) && ($module["id_tipo_modulo"] != 100)) {
@ -72,20 +74,31 @@ foreach ($modules as $module) {
$data[2] = substr ($module["nombre"], 0, 25);
$data[3] = substr ($module["descripcion"], 0, 35);
$status = STATUS_MODULE_WARNING;
$title = "";
if ($module["estado"] == 2) {
$data[4] = '<img src="images/pixel_yellow.png" width="40" height="18" title="'.__('WARNING'). ' : ';
$status = STATUS_MODULE_WARNING;
$title = __('WARNING');
} elseif ($module["estado"] == 1) {
$data[4] = '<img src="images/pixel_red.png" width="40" height="18" title="'.__('CRITICAL'). ' : ';
$status = STATUS_MODULE_CRITICAL;
$title = __('CRITICAL');
} else {
$data[4] = '<img src="images/pixel_green.png" width="40" height="18" title="'.__('NORMAL'). ' : ';
$status = STATUS_MODULE_OK;
$title = __('NORMAL');
}
if (is_numeric($module["datos"])) {
$data[4] .= format_for_graph($module["datos"]). '">';
$title .= " : " . format_for_graph($module["datos"]);
} else {
$data[4] .= substr(salida_limpia($module["datos"]),0,42) . '">';
$title .= " : " . substr(salida_limpia($module["datos"]),0,42);
}
$data[4] = print_status_image($status, $title, true);
if ($module["module_interval"] > 0) {
$data[5] = $module["module_interval"];

View File

@ -233,11 +233,11 @@ foreach ($result as $row) {
$data[4] = $row["agent_interval"];
if ($row["estado"] == 0) {
$data[5] = '<img src="images/pixel_green.png" width="40" height="18" title="'.$row["datos"].'">';
$data[5] = print_status_image(STATUS_MODULE_OK, $row["datos"], true);
} elseif ($row["estado"] == 1) {
$data[5] = '<img src="images/pixel_red.png" width="40" height="18" title="'.$row["datos"].'">';
$data[5] = print_status_image(STATUS_MODULE_CRITICAL, $row["datos"], true);
} else {
$data[5] = '<img src="images/pixel_yellow.png" width="40" height="18" title="'.$row["datos"].'">';
$data[5] = print_status_image(STATUS_MODULE_WARNING, $row["datos"], true);
}
$seconds = get_system_time () - $row["utimestamp"];

View File

@ -185,9 +185,9 @@ foreach ($serverinfo as $server) {
$data[0] = $server["name"];
if ($server["status"] == 0){
$data[1] = print_image ("images/pixel_red.png", true, array ("width" => 20, "height" => 20));
$data[1] = print_status_image(STATUS_SERVER_DOWN, '', true);
} else {
$data[1] = print_image ("images/pixel_green.png", true, array ("width" => 20, "height" => 20));
$data[1] = print_status_image(STATUS_SERVER_OK, '', true);
}
$data[2] = print_image ("reporting/fgraph.php?tipo=progress&percent=".$server["load"]."&height=20&width=80",

View File

@ -65,9 +65,9 @@ foreach ($servers as $server) {
$data[0] = "<b>".$server['name']."</b>";
if ($server['status'] == 0) {
$data[1] = print_image ("images/pixel_red.png", true, array ("width" => 10, "height" => 10));
$data[1] = print_status_image(STATUS_SERVER_DOWN, '', true);
} else {
$data[1] = print_image ("images/pixel_green.png", true, array ("width" => 10, "height" => 10));
$data[1] = print_status_image(STATUS_SERVER_OK, '', true);
}
// Load

View File

@ -429,6 +429,11 @@ function graphic_agentmodules ($id_agent, $width, $height) {
function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
global $config;
/* BROKEN: Need to fix, it gets 100% CPU of Apache !!!*/
$data = array();
/*
$resolution = $config["graph_res"] * ($period * 2 / $width); // Number of "slices" we want in graph
@ -450,9 +455,15 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
"utimestamp < $date"),
array ('utimestamp'));
if ($result === false)
$result = array ();
// SEEMS that problem is below
// it get's 100% cpu on apache and problem is localed here, I don't exactly
// why or what is happening here, but i'm sure that the problem is here.
$max_value = 0;
foreach ($result as $access) {
$utimestamp = $access['utimestamp'];
@ -463,7 +474,7 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
}
}
}
*/
$engine = get_graph_engine ($period);
$engine->width = $width;