2013-05-16 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_incidents.php, include/api.php,
	include/functions.php, include/functions_modules.php,
	include/graphs/flot/pandora.flot.js, include/functions_cron.php,
	include/functions_graph.php: improved the source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8140 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-05-16 09:19:16 +00:00
parent d3d36ae09e
commit 0fd149893e
8 changed files with 115 additions and 67 deletions

View File

@ -1,3 +1,10 @@
2013-05-16 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_incidents.php, include/api.php,
include/functions.php, include/functions_modules.php,
include/graphs/flot/pandora.flot.js, include/functions_cron.php,
include/functions_graph.php: improved the source code style.
2013-05-16 Miguel de Dios <miguel.dedios@artica.es>
* operation/agentes/stat_win.php: disabled show events when the

View File

@ -52,6 +52,7 @@ function cron_next_execution ($cron) {
$nex_time = cron_next_execution_date ($cron, $nex_time);
$nex_time_wd = $nex_time;
list ($nex_mon, $nex_wday) = explode (" ", date ("m w", $nex_time_wd));
do {
// Check the day of the week
if ($nex_wday == $wday) {
@ -61,9 +62,12 @@ function cron_next_execution ($cron) {
// Move to the next day of the month
$nex_time_wd += 86400;
list ($nex_mon_wd, $nex_wday) = explode (" ", date ("m w", $nex_time_wd));
} while ($mday == '*' && $nex_mon_wd == $nex_mon);
}
while ($mday == '*' && $nex_mon_wd == $nex_mon);
$count++;
} while ($count < 60);
}
while ($count < 60);
// Something went wrong, default to 5 minutes
return 300;
@ -149,7 +153,8 @@ function cron_next_execution_date ($cron, $cur_time = false) {
$nex_year++;
}
$count++;
} while ($count < 86400);
}
while ($count < 86400);
// Something went wrong, default to 5 minutes
return $cur_time + 300;

View File

@ -73,6 +73,7 @@ function incidents_print_priority_img ($id_priority, $return = false) {
if ($return === false) {
echo $img;
}
return $img;
}
@ -122,6 +123,7 @@ function incidents_print_status_img ($id_status, $return = false) {
if ($return === false) {
echo $img;
}
return $img;
}
@ -167,6 +169,7 @@ function incidents_process_chown ($id_incident, $owner = false) {
}
$id_incident = implode (",", $id_incident);
$sql = sprintf ("UPDATE tincidencia SET id_usuario = '%s' WHERE id_incidencia IN (%s)", $owner, $id_incident);
return db_process_sql ($sql);
}
@ -182,6 +185,7 @@ function incidents_get_author ($id_incident) {
if ($id_incident < 1) {
return "";
}
return (string) db_get_value ('id_creator', 'tincidencia', 'id_incidencia', (int) $id_incident);
}
@ -196,6 +200,7 @@ function incidents_get_owner ($id_incident) {
if ($id_incident < 1) {
return "";
}
return (string) db_get_value ('id_usuario', 'tincidencia', 'id_incidencia', (int) $id_incident);
}
@ -210,6 +215,7 @@ function incidents_get_lastupdate ($id_incident) {
if ($id_incident < 1) {
return "";
}
return (string) db_get_value ('id_lastupdate', 'tincidencia', 'id_incidencia', (int) $id_incident);
}
@ -225,6 +231,7 @@ function incidents_get_group ($id_incident) {
if ($id_incident < 1) {
return 0;
}
return (int) db_get_value ('id_grupo', 'tincidencia', 'id_incidencia', (int) $id_incident);
}
@ -419,6 +426,7 @@ function incidents_call_api($url, $postparameters = false) {
*/
function incidents_xml_to_array($xml) {
$xmlObj = simplexml_load_string($xml,'SimpleXMLElement',LIBXML_NOCDATA);
return json_decode(json_encode($xmlObj), true);
}

View File

@ -1449,8 +1449,15 @@ function modules_get_status($id_agent_module, $db_status, $data, &$status, &$tit
function modules_agents_unknown ($module_name) {
//TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT( DISTINCT tagente.id_agente) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.estado = 3 AND tagente_modulo.nombre = '$module_name'");
return db_get_sql ("SELECT COUNT( DISTINCT tagente.id_agente)
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0
AND tagente_estado.utimestamp != 0
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_estado.id_agente = tagente.id_agente
AND tagente_estado.estado = 3
AND tagente_modulo.nombre = '$module_name'");
}
// Get ok agents by using the status code in modules.
@ -1465,8 +1472,17 @@ function modules_agents_ok ($module_name) {
//Then we count the agents of the group selected to know how many agents are in OK status
//TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT(max_estado) FROM (SELECT MAX(tagente_estado.estado) as max_estado FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_modulo.nombre = '$module_name' GROUP BY tagente.id_agente HAVING max_estado = 0) AS S1");
return db_get_sql ("SELECT COUNT(max_estado)
FROM (
SELECT MAX(tagente_estado.estado) as max_estado
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0
AND tagente_estado.utimestamp != 0
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_estado.id_agente = tagente.id_agente
AND tagente_modulo.nombre = '$module_name'
GROUP BY tagente.id_agente HAVING max_estado = 0) AS S1");
}
// Get critical agents by using the status code in modules.
@ -1489,7 +1505,6 @@ function modules_agents_critical ($module_name) {
AND estado = 1
AND tagente_estado.id_agente = tagente.id_agente
AND tagente_modulo.nombre = '$module_name'");
}
// Get warning agents by using the status code in modules.
@ -1515,35 +1530,48 @@ function modules_agents_warning ($module_name) {
AND tagente_modulo.nombre = '$module_name'
GROUP BY tagente.id_agente
HAVING min_estado = 2) AS S1");
}
// Get unknown agents by using the status code in modules
function modules_group_agent_unknown ($module_group) {
return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo WHERE tagente.id_agente=tagente_modulo.id_agente AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_module_group = $module_group");
return db_get_sql ("SELECT COUNT(*)
FROM tagente, tagente_modulo
WHERE tagente.id_agente=tagente_modulo.id_agente
AND critical_count=0 AND warning_count=0
AND unknown_count>0 AND id_module_group = $module_group");
}
// Get ok agents by using the status code in modules.
function modules_group_agent_ok ($module_group) {
return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo WHERE tagente.id_agente=tagente_modulo.id_agente AND normal_count=total_count AND id_module_group = $module_group");
return db_get_sql ("SELECT COUNT(*)
FROM tagente, tagente_modulo
WHERE tagente.id_agente=tagente_modulo.id_agente
AND normal_count = total_count
AND id_module_group = $module_group");
}
// Get critical agents by using the status code in modules.
function modules_group_agent_critical ($module_group) {
return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo WHERE tagente.id_agente=tagente_modulo.id_agente AND critical_count>0 AND id_module_group = $module_group");
return db_get_sql ("SELECT COUNT(*)
FROM tagente, tagente_modulo
WHERE tagente.id_agente=tagente_modulo.id_agente
AND critical_count > 0 AND id_module_group = $module_group");
}
// Get warning agents by using the status code in modules.
function modules_group_agent_warning ($module_group) {
return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo WHERE tagente.id_agente=tagente_modulo.id_agente AND critical_count=0 AND warning_count>0 AND id_module_group = $module_group");
return db_get_sql ("SELECT COUNT(*)
FROM tagente, tagente_modulo
WHERE tagente.id_agente=tagente_modulo.id_agente
AND critical_count = 0 AND warning_count > 0
AND id_module_group = $module_group");
}
?>