2014-07-23 Miguel de Dios <miguel.dedios@artica.es>

* extensions/module_groups.php, extensions/agents_alerts.php,
	include/functions_agents.php, operation/agentes/exportdata.php: tiny
	fixes for the improve the support of postgreSQL databases.
	
	* include/functions_db.php: fix blank screen when the connection
	fail, now it shows the error message again.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10353 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2014-07-24 08:40:59 +00:00
parent f0d2ccf98d
commit 4afc69698e
6 changed files with 41 additions and 13 deletions

View File

@ -1,3 +1,12 @@
2014-07-23 Miguel de Dios <miguel.dedios@artica.es>
* extensions/module_groups.php, extensions/agents_alerts.php,
include/functions_agents.php, operation/agentes/exportdata.php: tiny
fixes for the improve the support of postgreSQL databases.
* include/functions_db.php: fix blank screen when the connection
fail, now it shows the error message again.
2014-07-23 Miguel de Dios <miguel.dedios@artica.es>
* include/config_process.php, operation/agentes/status_monitor.php,

View File

@ -174,7 +174,8 @@ function mainAgentsAlerts() {
if (!empty($templates)) {
$sql = sprintf('SELECT id, name
FROM talert_templates WHERE id IN (%s)',implode(',',array_keys($templates)));
FROM talert_templates
WHERE id IN (%s)',implode(',',array_keys($templates)));
$templates_raw = db_get_all_rows_sql($sql);
}
@ -225,7 +226,7 @@ function mainAgentsAlerts() {
if($anyfired) {
$cellstyle = 'background:'.COL_ALERTFIRED.';';
}
echo '<td style="text-align:center;'.$cellstyle.'"> ';
$uniqid = uniqid();
@ -266,8 +267,11 @@ function print_alerts_summary_modal_window($id, $alerts) {
$data[0] = modules_get_agentmodule_name ($alert['id_agent_module']);
$actions = alerts_get_alert_agent_module_actions ($alert['id']);
$actionDefault = db_get_value_sql("SELECT id_alert_action FROM talert_templates WHERE id = " . $alert['id_alert_template']);
$actionDefault = db_get_value_sql("
SELECT id_alert_action
FROM talert_templates
WHERE id = " . $alert['id_alert_template']);
$actionText = '';
@ -284,10 +288,13 @@ function print_alerts_summary_modal_window($id, $alerts) {
}
else {
if (!empty($actionDefault)) {
$actionText = db_get_sql ("SELECT name FROM talert_actions WHERE id = $actionDefault"). " <i>(".__("Default") . ")</i>";
$actionText = db_get_sql ("SELECT name
FROM talert_actions
WHERE id = $actionDefault") .
" <i>(" . __("Default") . ")</i>";
}
}
$data[1] = $actionText;
$data[2] = ui_print_timestamp ($alert["last_fired"], true);

View File

@ -141,7 +141,8 @@ function mainModuleGroups() {
GROUP BY estado";
break;
case "postgresql":
$sql = "SELECT COUNT(id_agente) AS count, case utimestamp when 0 then 5 else estado end as estado
$sql = "SELECT COUNT(id_agente) AS count,
case utimestamp when 0 then 5 else estado end as estado
FROM tagente_estado
WHERE id_agente IN
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled = 0)
@ -149,7 +150,7 @@ function mainModuleGroups() {
(SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_module_group = %d AND disabled = 0 AND delete_pending = 0)
GROUP BY estado";
GROUP BY estado, utimestamp";
break;
case "oracle":
$sql = "SELECT COUNT(id_agente) AS count, case when utimestamp = 0 then 5 else estado end estado
@ -185,7 +186,8 @@ function mainModuleGroups() {
//Metaobject use in html_print_table
$table = null;
$table->align[0] = 'right'; //Align to right the first column.
$table->style[0] = 'color: #ffffff; background-color: #778866; font-weight: bolder;';
$table->style[0] = 'color: #ffffff; '.
'background-color: #778866; font-weight: bolder;';
$table->head = $head;
$table->width = '98%';
@ -201,7 +203,7 @@ function mainModuleGroups() {
foreach ($modelGroups as $idModelGroup => $modelGroup) {
$fired = false;
$query = sprintf($sql,$idAgentGroup, $idModelGroup);
$query = sprintf($sql, $idAgentGroup, $idModelGroup);
$rowsDB = db_get_all_rows_sql ($query);

View File

@ -360,6 +360,11 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
}
}
//Fix for postgresql
if (empty($filter['id_agente'])) {
unset($filter['id_agente']);
}
$where = db_format_array_where_clause_sql ($filter, 'AND', '');
$where_nogroup = db_format_array_where_clause_sql ($filter_nogroup, 'AND', '');
@ -412,6 +417,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
return $sql;
else
$agents = db_get_all_rows_sql($sql);
break;
case "oracle":
$set = array();

View File

@ -65,7 +65,8 @@ function db_connect($host = null, $db = null, $user = null, $pass = null, $port
if ($return === false) {
if ($critical) {
$login_screen = 'error_authconfig';
require($config['homeurl'] . '/general/error_screen.php');
require($config['homedir'] . '/general/error_screen.php');
exit;
}
else if ($error == 0) {

View File

@ -40,10 +40,13 @@ $agentName = get_parameter_post ('agent', 0);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$agents = agents_get_agents(
array('nombre LIKE "' . $agentName . '"'), array ('id_agente'));
break;
case "postgresql":
$agents = agents_get_agents(
array('nombre LIKE \'' . $agentName . '\''), array ('id_agente'));
break;
case "oracle":
$agents = agents_get_agents(
array('nombre LIKE \'%' . $agentName . '%\''), array ('id_agente'));
@ -198,7 +201,7 @@ if (empty($export_btn)) {
$table->data[0][0] = '<b>'.__('Group').'</b>';
$groups = users_get_groups ($config['id_user'], "RR", users_can_manage_group_all());
$table->data[0][1] = html_print_select_groups($config['id_user'],
"RR", users_can_manage_group_all(), "group", $group, '', '', 0, true, false, true,
'w130', false);