Merge branch 'develop' into feature/NewTreeView

Conflicts resolved:
	pandora_console/include/ajax/module.php
	pandora_console/include/functions_groups.php
This commit is contained in:
Alejandro Gallardo Escobar 2015-01-19 11:47:55 +01:00
commit 265dda2a3f
66 changed files with 1287 additions and 591 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 6.0dev-150108 Version: 6.0dev-150116
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="6.0dev-150108" pandora_version="6.0dev-150116"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -41,7 +41,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '6.0dev'; use constant AGENT_VERSION => '6.0dev';
use constant AGENT_BUILD => '150108'; use constant AGENT_BUILD => '150116';
# Commands to retrieve total memory information in kB # Commands to retrieve total memory information in kB
use constant TOTALMEMORY_CMDS => { use constant TOTALMEMORY_CMDS => {

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 6.0dev %define version 6.0dev
%define release 150108 %define release 150116
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 6.0dev %define version 6.0dev
%define release 150108 %define release 150116
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{150108} {150116}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("6.0dev(Build 150108)") #define PANDORA_VERSION ("6.0dev(Build 150116)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(6.0dev(Build 150108))" VALUE "ProductVersion", "(6.0dev(Build 150116))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 6.0dev-150108 Version: 6.0dev-150116
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="6.0dev-150108" pandora_version="6.0dev-150116"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -83,37 +83,75 @@ function whereis_the_command ($command) {
function main_net_tools () { function main_net_tools () {
$id_agente = get_parameter ("id_agente"); $id_agente = get_parameter ("id_agente");
$ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente"); $principal_ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente");
if ($ip == "") {
$list_address = db_get_all_rows_sql ("select id_a from taddress_agent where id_agent = " . $id_agente);
foreach ($list_address as $address){
$ids []= join(",",$address);
}
$ids_address = implode(",",$ids);
$ips = db_get_all_rows_sql ("select ip from taddress where id_a in (" . $ids_address . ")");
if ($ips == "") {
echo "<div class='error' style='margin-top:5px'>" . __('The agent hasn\'t got IP') . "</div>"; echo "<div class='error' style='margin-top:5px'>" . __('The agent hasn\'t got IP') . "</div>";
return; return;
} }
echo "
<script type='text/javascript'>
function mostrarColumns(ValueSelect){
value = ValueSelect.value;
if ( value==3 ) {
document.getElementById('netToolTable').width=800;
document.getElementById('snmpcolumn').style.display='block';
}
else{
document.getElementById('netToolTable').width=650;
document.getElementById('snmpcolumn').style.display='none';
}
}
</script>";
echo "<div>"; echo "<div>";
echo "<form name='actionbox' method='post'>"; echo "<form name='actionbox' method='post'>";
echo "<table class=databox width=650>"; echo "<table class=databox width=650 id=netToolTable>";
echo "<tr><td>"; echo "<tr><td>";
echo __("Operation"); echo __("Operation");
ui_print_help_tip(__('You can set the command path in the menu Administration -&gt; Extensions -&gt; Config Network Tools')); ui_print_help_tip(__('You can set the command path in the menu Administration -&gt; Extensions -&gt; Config Network Tools'));
echo "<td>"; echo "</td><td>";
echo "<select name='operation'>"; echo "<select name='operation' onChange='mostrarColumns(this);'>";
echo "<option value='1'>" . __("Traceroute"); echo "<option value='1'>" . __("Traceroute");
echo "<option value='2'>" . __("Ping host & Latency"); echo "<option value='2'>" . __("Ping host & Latency");
echo "<option value='3'>" . __("SNMP Interface status"); echo "<option value='3'>" . __("SNMP Interface status");
echo "<option value='4'>" . __("Basic TCP Port Scan"); echo "<option value='4'>" . __("Basic TCP Port Scan");
echo "<option value='5'>" . __("DiG/Whois Lookup"); echo "<option value='5'>" . __("DiG/Whois Lookup");
echo "</select>"; echo "</select>";
echo "</td>";
echo "<td>"; echo "<td>";
echo __("SNMP Community"); echo __("IP address");
echo "<td>"; echo "</td><td>";
echo "<select name='select_ips'>";
foreach($ips as $ip){
if ($ip['ip'] == $principal_ip){
echo "<option value='". $ip['ip'] ."' selected = 'selected'>" . $ip['ip'];
}else{
echo "<option value='". $ip['ip'] ."'>" . $ip['ip'];
}
}
echo "</select>";
echo "</td>";
echo "<td id='snmpcolumn' style=\"display:none;\">";
echo __("SNMP Community") . "&nbsp;";
echo "<input name=community type=text value='public'>"; echo "<input name=community type=text value='public'>";
echo "<td>"; echo "</td><td>";
echo "<input name=submit type=submit class='sub next' value='".__('Execute')."'>"; echo "<input name=submit type=submit class='sub next' value='".__('Execute')."'>";
echo "</td>";
echo "</tr></table>"; echo "</tr></table>";
echo "</form>"; echo "</form>";
$operation = get_parameter ("operation", 0); $operation = get_parameter ("operation", 0);
$community = get_parameter ("community", "public"); $community = get_parameter ("community", "public");
$ip = get_parameter("select_ips");
switch($operation) { switch($operation) {
case 1: case 1:

View File

@ -654,7 +654,7 @@ function process_upload_xml_component($xml) {
$tcp_send = $snmp_version; $tcp_send = $snmp_version;
$plugin_user = $auth_user; $plugin_user = $auth_user;
$plugin_pass = $auth_password; $plugin_pass = $auth_password;
$plugin_parameter = $auth_method; $plugin_parameters = $auth_method;
$custom_string_1 = $privacy_method; $custom_string_1 = $privacy_method;
$custom_string_2 = $privacy_pass; $custom_string_2 = $privacy_pass;
$custom_string_3 = $security_level; $custom_string_3 = $security_level;

View File

@ -20,10 +20,14 @@ function vnc_view() {
$display = get_parameter("display", 0); $display = get_parameter("display", 0);
echo "<form method=post>"; echo "<form method=post>";
echo __("VNC Display (:0 by default)"); echo "<table class=databox width=500>";
echo "<tr><td>";
echo __("VNC Display (:0 by default)") . "&nbsp;";
echo "<input type=text name=display value=$display>"; echo "<input type=text name=display value=$display>";
echo "<input type=submit value='".__("Send")."'>"; echo "</td><td>";
echo "</form>"; echo "<input type=submit class='sub next' value='".__("Send")."'>";
echo "</td>";
echo "</tr></table>";
$port = 5800 + $display; $port = 5800 + $display;
echo "<iframe src='http://$ipAgent:$port' width='100%' height=600>"; echo "<iframe src='http://$ipAgent:$port' width='100%' height=600>";
echo "</iframe>"; echo "</iframe>";

View File

@ -40,4 +40,4 @@ INSERT INTO ttipo_modulo VALUES (5,'generic_data_inc_abs',0,'Generic numeric inc
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tusuario` -- Table `tusuario`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
ALTER TABLE tusuario ADD COLUMN strict_acl NUMBER(5,0) DEFAULT 0; ALTER TABLE tusuario ADD COLUMN strict_acl NUMBER(5, 0) DEFAULT 0;

View File

@ -38,4 +38,4 @@ INSERT INTO "ttipo_modulo" VALUES (5,'generic_data_inc_abs',0,'Generic numeric i
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tusuario` -- Table `tusuario`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
ALTER TABLE "tusuario" ADD COLUMN "strict_acl" SMALLINT NOT NULL default 0; ALTER TABLE "tusuario" ADD COLUMN "strict_acl" SMALLINT DEFAULT 0;

View File

@ -208,7 +208,9 @@ if ($create_agent) {
array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value)); array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value));
} }
// Create address for this agent in taddress // Create address for this agent in taddress
agents_add_address ($id_agente, $direccion_agente); if ( $direccion_agente != ''){
agents_add_address ($id_agente, $direccion_agente);
}
$agent_created_ok = true; $agent_created_ok = true;

View File

@ -23,6 +23,7 @@ $ag_group = get_parameter ("ag_group_refresh", -1);
$sortField = get_parameter('sort_field'); $sortField = get_parameter('sort_field');
$sort = get_parameter('sort', 'none'); $sort = get_parameter('sort', 'none');
$recursion = get_parameter('recursion'); $recursion = get_parameter('recursion');
$disabled = get_parameter('disabled');
if ($ag_group == -1 ) if ($ag_group == -1 )
$ag_group = (int) get_parameter ("ag_group", -1); $ag_group = (int) get_parameter ("ag_group", -1);
@ -138,6 +139,16 @@ if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "PM"))
else else
$return_all_group = true; $return_all_group = true;
html_print_select_groups(false, "AR", $return_all_group, "ag_group", $ag_group, 'this.form.submit();', '', 0, false, false, true, '', false, 'width:100px;'); html_print_select_groups(false, "AR", $return_all_group, "ag_group", $ag_group, 'this.form.submit();', '', 0, false, false, true, '', false, 'width:100px;');
echo "<td>";
echo __('Show Agents') . '&nbsp;';
$fields = array(
2 => __('Everyone'),
1 => __('Only disabled'),
0 => __('Only enabled'),
);
html_print_select($fields,"disabled",$disabled,'this.form.submit()');
echo "</td>";
echo "<td>"; echo "<td>";
echo __('Recursion') . '&nbsp;'; echo __('Recursion') . '&nbsp;';
@ -247,6 +258,16 @@ if ($search != "") {
LIKE '%$search%' OR direccion LIKE '%$search%') "; LIKE '%$search%' OR direccion LIKE '%$search%') ";
} }
if ($disabled==1)
{
$search_sql = " AND disabled = ". $disabled . $search_sql;
}
else{
if ($disabled==0){
$search_sql = " AND disabled = 0" . $search_sql;
}
}
// Show only selected groups // Show only selected groups
if ($ag_group > 0) { if ($ag_group > 0) {
$sql = sprintf ('SELECT COUNT(*) $sql = sprintf ('SELECT COUNT(*)
@ -395,23 +416,23 @@ if (($config['dbtype'] == 'oracle') && ($agents !== false)) {
} }
// Prepare pagination // Prepare pagination
ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort", $offset); ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled", $offset);
if ($agents !== false) { if ($agents !== false) {
echo "<table cellpadding='4' id='agent_list' cellspacing='4' width='98%' class='databox'>"; echo "<table cellpadding='4' id='agent_list' cellspacing='4' width='98%' class='databox'>";
echo "<th>".__('Agent name') . ' ' . echo "<th>".__('Agent name') . ' ' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=name&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' . '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=name&sort=up&disabled=$disabled">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '</a>' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=name&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>'; '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=name&sort=down&disabled=$disabled">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . '</a>';
echo "</th>"; echo "</th>";
echo "<th title='".__('Remote agent configuration')."'>".__('R')."</th>"; echo "<th title='".__('Remote agent configuration')."'>".__('R')."</th>";
echo "<th>".__('OS'). ' ' . echo "<th>".__('OS'). ' ' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=os&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp)) . '</a>' . '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=os&sort=up&disabled=$disabled">' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp)) . '</a>' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=os&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown)) . '</a>'; '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=os&sort=down&disabled=$disabled">' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown)) . '</a>';
echo "</th>"; echo "</th>";
echo "<th>".__('Group'). ' ' . echo "<th>".__('Group'). ' ' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '</a>' . '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=up&disabled=$disabled">' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '</a>' .
'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . '</a>'; '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search .'&offset='.$offset.'&sort_field=group&sort=down&disabled=$disabled">' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . '</a>';
echo "</th>"; echo "</th>";
echo "<th>" . __('Description') . "</th>"; echo "<th>" . __('Description') . "</th>";
echo "<th>" . __('Actions') . "</th>"; echo "<th>" . __('Actions') . "</th>";
@ -529,18 +550,18 @@ if ($agents !== false) {
if ($agent['disabled']) { if ($agent['disabled']) {
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente& echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
enable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort''>". enable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled''>".
html_print_image('images/lightbulb_off.png', true, array('alt' => __('Enable agent'), 'title' => __('Enable agent'))) ."</a>"; html_print_image('images/lightbulb_off.png', true, array('alt' => __('Enable agent'), 'title' => __('Enable agent'))) ."</a>";
} }
else { else {
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente& echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
disable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort'>". disable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'>".
html_print_image('images/lightbulb.png', true, array('alt' => __('Disable agent'), 'title' => __('Disable agent'))) ."</a>"; html_print_image('images/lightbulb.png', true, array('alt' => __('Disable agent'), 'title' => __('Disable agent'))) ."</a>";
} }
if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) { if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
echo "&nbsp;&nbsp;<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente& echo "&nbsp;&nbsp;<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort'"; borrar_agente=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'";
echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
echo html_print_image('images/cross.png', true, array("border" => '0')) . "</a>"; echo html_print_image('images/cross.png', true, array("border" => '0')) . "</a>";
} }
@ -548,7 +569,7 @@ if ($agents !== false) {
echo "</td>"; echo "</td>";
} }
echo "</table>"; echo "</table>";
ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset); ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled", $offset);
echo "<table width='98%'><tr><td align='right'>"; echo "<table width='98%'><tr><td align='right'>";
} }
else { else {

View File

@ -462,7 +462,7 @@ html_print_table ($table_simple);
ui_toggle(html_print_table ($table_advanced, true), ui_toggle(html_print_table ($table_advanced, true),
__('Advanced options')); __('Advanced options'));
ui_toggle(html_print_table ($table_macros, true), ui_toggle(html_print_table ($table_macros, true),
__('Module macros') . ui_print_help_icon ('module_macros', true)); __('Custom macros') . ui_print_help_icon ('module_macros', true));
ui_toggle(html_print_table ($table_new_relations, true) . ui_toggle(html_print_table ($table_new_relations, true) .
html_print_table ($table_relations, true), __('Module relations')); html_print_table ($table_relations, true), __('Module relations'));

View File

@ -574,7 +574,7 @@ if (isset($module_macros)) {
} }
} }
} }
$table_macros->data[$macro_count][0] = '<span>'.__('Add module macro').'</span> <a href="javascript:add_macro();">'.html_print_image('images/add.png',true).'</a>'; $table_macros->data[$macro_count][0] = '<span>'.__('Custom macros').'</span> <a href="javascript:add_macro();">'.html_print_image('images/add.png',true).'</a>';
$table_macros->colspan[$macro_count][0] = 5; $table_macros->colspan[$macro_count][0] = 5;
$macro_count++; $macro_count++;

View File

@ -448,7 +448,7 @@ else {
} }
// Hash for auto-auth in public link // Hash for auto-auth in public link
$hash = md5($config["dbpass"] . $id_layout . $config["id_user"]); $hash = md5($config["dbpass"] . $idVisualConsole . $config["id_user"]);
$buttons = array(); $buttons = array();
@ -456,7 +456,7 @@ $buttons['consoles_list'] = array('active' => false,
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/map_builder&refr=' . $refr . '">' . 'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/map_builder&refr=' . $refr . '">' .
html_print_image ("images/visual_console.png", true, array ("title" => __('Visual consoles list'))) .'</a>'); html_print_image ("images/visual_console.png", true, array ("title" => __('Visual consoles list'))) .'</a>');
$buttons['public_link'] = array('active' => false, $buttons['public_link'] = array('active' => false,
'text' => '<a href="' . ui_get_full_url('operation/visual_console/public_console.php?hash='.$hash.'&id_layout='.$id_layout.'&id_user='.$config["id_user"]) . '">'. 'text' => '<a href="' . ui_get_full_url('operation/visual_console/public_console.php?hash='.$hash.'&id_layout='.$idVisualConsole.'&id_user='.$config["id_user"]) . '">'.
html_print_image ("images/camera_mc.png", true, array ("title" => __('Show link to public Visual Console'))).'</a>'); html_print_image ("images/camera_mc.png", true, array ("title" => __('Show link to public Visual Console'))).'</a>');
$buttons['data'] = array('active' => false, $buttons['data'] = array('active' => false,
'text' => '<a href="' . $url_base . $action . '&tab=data&id_visual_console=' . $idVisualConsole . '">' . 'text' => '<a href="' . $url_base . $action . '&tab=data&id_visual_console=' . $idVisualConsole . '">' .

View File

@ -94,7 +94,8 @@ if ($edit_filter > -2) {
$table->data[0][1] = html_print_input_text ('description', $description, '', 60, 100, true); $table->data[0][1] = html_print_input_text ('description', $description, '', 60, 100, true);
$table->data[1][0] = __('Filter'); $table->data[1][0] = __('Filter');
$table->data[1][1] = html_print_input_text ('filter', $filter, '', 60, 100, true); $table->data[1][1] = html_print_input_text ('filter', $filter, '', 60, 100, true);
$table->data[1][1] .= ui_print_help_tip (__("This field contains a substring, could be part of a IP address, a numeric OID, or a plain substring") . SEPARATOR_COLUMN, true);
echo '<form action="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_filters" method="post">'; echo '<form action="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_filters" method="post">';
html_print_input_hidden ('update_filter', $edit_filter); html_print_input_hidden ('update_filter', $edit_filter);
html_print_table ($table); html_print_table ($table);

View File

@ -450,7 +450,7 @@ if ($config['admin_can_make_admin']) {
if ($own_info['is_admin'] || $user_info['is_admin']) { if ($own_info['is_admin'] || $user_info['is_admin']) {
$table->data[6][1] = html_print_radio_button ('is_admin', 1, '', $user_info['is_admin'], true); $table->data[6][1] = html_print_radio_button ('is_admin', 1, '', $user_info['is_admin'], true);
$table->data[6][1] .= __('Administrator'); $table->data[6][1] .= __('Administrator');
$table->data[6][1] .= ui_print_help_tip (__("This user has permissions to manage all. This is admin user and overwrites all permissions given in profiles/groups"), true); $table->data[6][1] .= ui_print_help_tip (__("This user has permissions to manage all. An admin user should not requiere additional group permissions, except for using Enterprise ACL."), true);
$table->data[6][1] .= '<br />'; $table->data[6][1] .= '<br />';
} }
$table->data[6][1] .= html_print_radio_button ('is_admin', 0, '', $user_info['is_admin'], true); $table->data[6][1] .= html_print_radio_button ('is_admin', 0, '', $user_info['is_admin'], true);
@ -601,6 +601,7 @@ if (!empty ($id) && !$new_user) {
*/ */
$result = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id); $result = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id);
if ($result === false) { if ($result === false) {
$result = array (); $result = array ();
} }

View File

@ -79,7 +79,8 @@ if ($get_module_detail) {
if (defined ('METACONSOLE')) { if (defined ('METACONSOLE')) {
$server = metaconsole_get_connection ($server_name); $server = metaconsole_get_connection ($server_name);
$conexion = mysql_connect ($server['dbhost'], $server['dbuser'], $server['dbpass']); $conexion = mysql_connect ($server['dbhost'], $server['dbuser'],
$server['dbpass']);
$select_db = mysql_select_db ($server['dbname'], $conexion); $select_db = mysql_select_db ($server['dbname'], $conexion);
} }
else { else {
@ -112,25 +113,33 @@ if ($get_module_detail) {
SECONDS_2YEARS =>__('2 years'), SECONDS_2YEARS =>__('2 years'),
SECONDS_3YEARS =>__('3 years')); SECONDS_3YEARS =>__('3 years'));
$formtable->data[0][0] = html_print_radio_button_extended ("selection_mode", 'fromnow', '', $selection_mode, false, '', 'style="margin-right: 15px;"', true) . __("Choose a time from now"); $formtable->data[0][0] = html_print_radio_button_extended (
"selection_mode", 'fromnow', '', $selection_mode, false, '',
'style="margin-right: 15px;"', true) . __("Choose a time from now");
$formtable->data[0][1] = html_print_select ($periods, 'period', $period, '', '', 0, true, false, false); $formtable->data[0][1] = html_print_select ($periods, 'period', $period, '', '', 0, true, false, false);
$formtable->data[0][2] = ''; $formtable->data[0][2] = '';
$formtable->data[0][3] = "<a href='javascript: show_module_detail_dialog(" . $module_id .", ". $agentId.", \"" . $server_name . "\", 0, -1)'>". html_print_image ("images/refresh.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>"; $formtable->data[0][3] = "<a href='javascript: show_module_detail_dialog(" . $module_id .", ". $agentId.", \"" . $server_name . "\", 0, -1)'>". html_print_image ("images/refresh.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>";
$formtable->rowspan[0][3] = 2; $formtable->rowspan[0][3] = 2;
$formtable->cellstyle[0][3] = 'vertical-align: middle;'; $formtable->cellstyle[0][3] = 'vertical-align: middle;';
$formtable->data[1][0] = html_print_radio_button_extended ("selection_mode", 'range','', $selection_mode, false, '', 'style="margin-right: 15px;"', true) . __("Specify time range"); $formtable->data[1][0] = html_print_radio_button_extended(
"selection_mode", 'range','', $selection_mode, false, '',
'style="margin-right: 15px;"', true) . __("Specify time range");
$formtable->data[1][1] = __('Timestamp from:'); $formtable->data[1][1] = __('Timestamp from:');
$formtable->data[1][2] = html_print_input_text ('date_from', $date_from, '', 10, 10, true); $formtable->data[1][2] = html_print_input_text('date_from',
$formtable->data[1][2] .= html_print_input_text ('time_from', $time_from, '', 9, 7, true); $date_from, '', 10, 10, true);
$formtable->data[1][2] .= html_print_input_text('time_from',
$time_from, '', 9, 7, true);
$formtable->data[1][1] .= '<br />'; $formtable->data[1][1] .= '<br />';
$formtable->data[1][1] .= __('Timestamp to:'); $formtable->data[1][1] .= __('Timestamp to:');
$formtable->data[1][2] .= '<br />'; $formtable->data[1][2] .= '<br />';
$formtable->data[1][2] .= html_print_input_text ('date_to', $date_to, '', 10, 10, true); $formtable->data[1][2] .= html_print_input_text('date_to', $date_to,
$formtable->data[1][2] .= html_print_input_text ('time_to', $time_to, '', 9, 7, true); '', 10, 10, true);
$formtable->data[1][2] .= html_print_input_text('time_to', $time_to,
'', 9, 7, true);
html_print_table($formtable); html_print_table($formtable);
@ -145,136 +154,43 @@ if ($get_module_detail) {
$datetime_from = strtotime ($date_from . ' ' . $time_from); $datetime_from = strtotime ($date_from . ' ' . $time_from);
$datetime_to = strtotime ($date_to . ' ' . $time_to); $datetime_to = strtotime ($date_to . ' ' . $time_to);
if ($moduletype_name == "log4x") {
$table->width = "100%";
if ($selection_mode == "fromnow") {
$sql_body = sprintf ("FROM tagente_datos_log4x
WHERE id_agente_modulo = %d AND utimestamp > %d
ORDER BY utimestamp DESC", $module_id, get_system_time () - $period);
}
else {
$sql_body = sprintf ("FROM tagente_datos_log4x
WHERE id_agente_modulo = %d AND utimestamp >= %d
AND utimestamp <= %d
ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to);
}
$columns = array( $columns = array(
"Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "center" ), "Timestamp" => array(
"Sev" => array("severity", "modules_format_data", "align" => "center", "width" => "70px"), "utimestamp",
"Message"=> array("message", "modules_format_verbatim", "align" => "left", "width" => "45%"), "modules_format_timestamp",
"StackTrace" => array("stacktrace", "modules_format_verbatim", "align" => "left", "width" => "50%") "align" => "left"),
); "Data" => array(
} "datos",
else if (preg_match ("/string/", $moduletype_name)) { "modules_format_data",
"align" => "left"),
if ($selection_mode == "fromnow") { "Time" => array(
$sql_body = sprintf (" FROM tagente_datos_string "utimestamp",
WHERE id_agente_modulo = %d AND utimestamp > %d "modules_format_time",
ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); "align" => "center")
} );
else {
$sql_body = sprintf (" FROM tagente_datos_string if ($selection_mode == "fromnow") {
WHERE id_agente_modulo = %d AND utimestamp >= %d $date = get_system_time();
AND utimestamp <= %d $period = $period;
ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to);
}
$columns = array(
"Timestamp" => array(
"utimestamp",
"modules_format_timestamp",
"align" => "left"),
"Data" => array(
"datos",
"modules_format_data",
"align" => "left"),
"Time" => array(
"utimestamp",
"modules_format_time",
"align" => "center")
);
} }
else { else {
if ($selection_mode == "fromnow") { $date = $datetime_from;
$sql_body = sprintf (" FROM tagente_datos $period = $datetime_to - $datetime_from;
WHERE id_agente_modulo = %d
AND utimestamp > %d
ORDER BY utimestamp DESC", $module_id, get_system_time () - $period);
}
else {
$sql_body = sprintf (" FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp >= %d AND utimestamp <= %d
ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to);
}
$columns = array(
"Timestamp" => array(
"utimestamp",
"modules_format_timestamp",
"align" => "left"),
"Data" => array(
"datos",
"modules_format_data",
"align" => "left"),
"Time" => array(
"utimestamp",
"modules_format_time",
"align" => "center")
);
} }
$count = modules_get_agentmodule_data ($module_id, $period,
$date, true, $conexion);
$sql_body = io_safe_output($sql_body); $module_data = modules_get_agentmodule_data ($module_id, $period,
// Clean all codification characters $date, false, $conexion, 'DESC');
$sql = "SELECT * " . $sql_body; if (empty($module_data)) {
$result = array();
switch ($config['dbtype']) {
case "mysql":
$sql_count = "SELECT count(*) " . $sql_body;
break;
case "postgresql":
$sql_body = str_replace("ORDER BY utimestamp DESC",
"GROUP BY utimestamp ORDER BY utimestamp DESC",
$sql_body);
$sql_count = "SELECT count(DISTINCT utimestamp) " . $sql_body;
break;
case "oracle":
$sql_count = "SELECT count(*) " . $sql_body;
break;
} }
else {
$count = db_get_value_sql ($sql_count, $conexion); // Paginate the result
$result = array_slice($module_data, $offset, $block_size);
switch ($config["dbtype"]) {
case "mysql":
$sql .= " LIMIT " . $offset . "," . $block_size;
break;
case "postgresql":
$sql .= " LIMIT " . $block_size . " OFFSET " . $offset;
break;
case "oracle":
$set = array();
$set['limit'] = $block_size;
$set['offset'] = $offset;
$sql = oracle_recode_query ($sql, $set);
break;
}
$result = db_get_all_rows_sql ($sql, false, true, $conexion);
if ($result === false) {
$result = array ();
}
if (($config['dbtype'] == 'oracle') && ($result !== false)) {
for ($i=0; $i < count($result); $i++) {
unset($result[$i]['rnum']);
}
} }
$table->width = '98%'; $table->width = '98%';
@ -293,8 +209,8 @@ if ($get_module_detail) {
$index++; $index++;
} }
$id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', $id_type_web_content_string = db_get_value('id_tipo',
'nombre', 'web_content_string'); 'ttipo_modulo', 'nombre', 'web_content_string');
foreach ($result as $row) { foreach ($result as $row) {
$data = array (); $data = array ();

View File

@ -1,65 +0,0 @@
<?php
//Pandora FMS- http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// 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.
global $config;
require_once ($config['homedir'] . '/include/functions_tags.php');
$action = get_parameter('action');
switch($action) {
case 'get_tag_agents':
$id_tag = get_parameter('id_tag');
$id_user = get_parameter('id_user');
$keys_prefix = get_parameter('keys_prefix');
$only_meta = get_parameter('only_meta');
$agent_search = get_parameter('agent_search');
$assigned_server = get_parameter('assigned_server');
$show_void_agents = get_parameter('show_void_agents', false);
$no_filter_tag = get_parameter('no_filter_tag', false);
echo wizard_get_tag_agents($id_tag, $id_user, $keys_prefix, $agent_search, $only_meta, $assigned_server, $show_void_agents, $no_filter_tag);
break;
}
function wizard_get_tag_agents($id_tag, $id_user, $keys_prefix, $agent_search, $only_meta, $assigned_server, $show_void_agents, $no_filter_tag) {
global $config;
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$acltags = tags_get_user_module_and_tags($config['id_user']);
$filter['search'] = $agent_search;
$filter['show_void_agents'] = $show_void_agents;
$fields = array ('tagente.id_agente', 'tagente.nombre');
$agents = tags_get_all_user_agents ($id_tag, $id_user, $acltags, $filter, $fields, false, $strict_user);
// Add keys prefix
if (!empty($agents)) {
if ($keys_prefix !== "") {
foreach($agents as $k => $v) {
$agents_aux[$keys_prefix . $k] = $v;
//unset($agents[$k]);
}
}
$agents = $agents_aux;
}
echo json_encode ($agents);
return;
}
?>

View File

@ -22,7 +22,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC150108'; $build_version = 'PC150116';
$pandora_version = 'v6.0dev'; $pandora_version = 'v6.0dev';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -159,7 +159,6 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
if (($id_agent !== false) && ($idGroup !== false)) { if (($id_agent !== false) && ($idGroup !== false)) {
$groups = users_get_groups($config["id_user"]); $groups = users_get_groups($config["id_user"]);
//$where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo');
if ($idGroup != 0) { //All group if ($idGroup != 0) { //All group
$subQuery = 'SELECT id_agente_modulo $subQuery = 'SELECT id_agente_modulo
FROM tagente_modulo FROM tagente_modulo
@ -215,7 +214,6 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
$selectText = 'COUNT(talert_template_modules.id) AS count'; $selectText = 'COUNT(talert_template_modules.id) AS count';
} }
$sql = sprintf ("SELECT %s $sql = sprintf ("SELECT %s
FROM talert_template_modules FROM talert_template_modules
INNER JOIN tagente_modulo t2 INNER JOIN tagente_modulo t2
@ -227,7 +225,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
WHERE id_agent_module in (%s) %s %s %s", WHERE id_agent_module in (%s) %s %s %s",
$selectText, $subQuery, $where, $filter, $orderbyText); $selectText, $subQuery, $where, $filter, $orderbyText);
$alerts = db_get_all_rows_sql ($sql); $alerts = db_get_all_rows_sql ($sql);
if ($alerts === false) if ($alerts === false)
return array (); return array ();
@ -1183,8 +1181,6 @@ function agents_get_modules ($id_agent = null, $details = false,
break; break;
} }
//html_debug_print($sql);
$result = db_get_all_rows_sql ($sql); $result = db_get_all_rows_sql ($sql);
if (empty ($result)) { if (empty ($result)) {

View File

@ -1573,8 +1573,6 @@ function get_group_alerts($id_group, $filter = '', $options = false,
if ($id_group !== false) { if ($id_group !== false) {
$groups = users_get_groups($config["id_user"], "AR"); $groups = users_get_groups($config["id_user"], "AR");
//$where_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo');
if ($id_group != 0) { if ($id_group != 0) {
if (is_array($id_group)) { if (is_array($id_group)) {
if (in_array(0, $id_group)) { if (in_array(0, $id_group)) {
@ -1596,6 +1594,7 @@ function get_group_alerts($id_group, $filter = '', $options = false,
FROM tagente FROM tagente
WHERE WHERE
id_grupo IN (' . implode(',', $id_group) . '))'; id_grupo IN (' . implode(',', $id_group) . '))';
} }
} }
else { else {
@ -1666,7 +1665,7 @@ function get_group_alerts($id_group, $filter = '', $options = false,
WHERE id_agent_module in (%s) %s %s %s", WHERE id_agent_module in (%s) %s %s %s",
$selectText, $subQuery, $where, $filter, $orderbyText); $selectText, $subQuery, $where, $filter, $orderbyText);
$alerts = db_get_all_rows_sql ($sql); $alerts = db_get_all_rows_sql ($sql);
if ($alerts === false) if ($alerts === false)
return array (); return array ();

View File

@ -2369,7 +2369,9 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
} }
// Add tags condition to filter // Add tags condition to filter
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); $user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$acltags = tags_get_user_module_and_tags ($config['id_user'], $access = 'ER', $user_strict);
$tags_condition = " AND (".tags_get_acl_tags_event_condition($acltags, false, $user_strict).")";
//This will give the distinct id_agente, give the id_grupo that goes //This will give the distinct id_agente, give the id_grupo that goes
//with it and then the number of times it occured. GROUP BY statement //with it and then the number of times it occured. GROUP BY statement
@ -2463,7 +2465,9 @@ function grafico_eventos_total($filter = "", $width = 320, $height = 200) {
$filter = str_replace ( "\\" , "", $filter); $filter = str_replace ( "\\" , "", $filter);
// Add tags condition to filter // Add tags condition to filter
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); $user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$acltags = tags_get_user_module_and_tags ($config['id_user'], $access = 'ER', $user_strict);
$tags_condition = " AND (".tags_get_acl_tags_event_condition($acltags, false, $user_strict).")";
$filter .= $tags_condition; $filter .= $tags_condition;
$data = array (); $data = array ();

View File

@ -1218,14 +1218,12 @@ function groups_agent_total($group_array, $strict_user = false, $id_group_strict
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) { if ($strict_user) {
$tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo
WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))";
$sql = "SELECT COUNT(*) FROM tagente $sql = "SELECT COUNT(*) FROM tagente
WHERE tagente.disabled = 0 WHERE tagente.disabled = 0
AND id_grupo = ".$id_group_strict . AND id_grupo = ".$id_group_strict .
$tags_clause; $tags_clause;
$count = db_get_sql($sql); $count = db_get_sql($sql);
} else { } else {
@ -1397,7 +1395,6 @@ function groups_monitor_ok ($group_array, $strict_user = false, $id_group_strict
if ($strict_user) { if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
AND tagente_estado.estado = 0 AND tagente_estado.estado = 0
@ -1432,7 +1429,6 @@ function groups_monitor_critical ($group_array, $strict_user = false, $id_group_
if ($strict_user) { if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
@ -1467,7 +1463,6 @@ function groups_monitor_warning ($group_array, $strict_user = false, $id_group_s
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) { if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
@ -1537,7 +1532,6 @@ function groups_monitor_alerts ($group_array, $strict_user = false, $id_group_st
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) { if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$sql = "SELECT COUNT(talert_template_modules.id) $sql = "SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
@ -1549,9 +1543,7 @@ function groups_monitor_alerts ($group_array, $strict_user = false, $id_group_st
$tags_clause"; $tags_clause";
$count = db_get_sql ($sql); $count = db_get_sql ($sql);
return $count; return $count;
} else { } else {
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT(talert_template_modules.id) return db_get_sql ("SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
@ -1581,7 +1573,6 @@ function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_gr
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
if ($strict_user) { if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$sql = "SELECT COUNT(talert_template_modules.id) $sql = "SELECT COUNT(talert_template_modules.id)
@ -1805,6 +1796,8 @@ function groups_get_tree(&$groups, $parent = false) {
return $return; return $return;
} }
function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
global $config; global $config;
@ -1819,10 +1812,12 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
$propagate = db_get_value('propagate','tgrupo','id_grupo',$parent); $propagate = db_get_value('propagate','tgrupo','id_grupo',$parent);
if ($propagate == 1) { if ($propagate == 1) {
//$childrens_ids_parent = array($parent);
$hierarchy[] = $parent; $hierarchy[] = $parent;
$childrens = groups_get_childrens($parent); $childrens = groups_get_childrens($parent);
if (!empty($childrens)) { if (!empty($childrens)) {
foreach ($childrens as $child) { foreach ($childrens as $child) {
//$childrens_ids_parent[] = (int)$child['id_grupo'];
$hierarchy[] = (int)$child['id_grupo']; $hierarchy[] = (int)$child['id_grupo'];
} }
} }
@ -1900,6 +1895,23 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$i = 1; $i = 1;
$list[0]['_id_'] = 0; $list[0]['_id_'] = 0;
$list[0]['_name_'] = __('All'); $list[0]['_name_'] = __('All');
$list[0]['_agents_unknown_'] = 0;
$list[0]['_monitors_alerts_fired_'] = 0;
$list[0]['_total_agents_'] = 0;
$list[0]['_monitors_ok_'] = 0;
$list[0]['_monitors_critical_'] = 0;
$list[0]['_monitors_warning_'] = 0;
$list[0]['_monitors_unknown_'] = 0;
$list[0]['_monitors_not_init_'] = 0;
$list[0]['_agents_not_init_'] = 0;
if ($mode == 'tactical') {
$list[0]['_agents_ok_'] = 0;
$list[0]['_agents_warning_'] = 0;
$list[0]['_agents_critical_'] = 0;
$list[0]['_monitors_alerts_'] = 0;
}
} else { } else {
$i = 0; $i = 0;
} }
@ -1924,13 +1936,6 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"]; $list[$i]['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"];
$list[$i]['_total_agents_'] = $group_stat[0]["agents"]; $list[$i]['_total_agents_'] = $group_stat[0]["agents"];
if ($mode == 'tactical' || $mode == 'tree') {
$list[$i]['_agents_ok_'] = $group_stat[0]["normal"];
$list[$i]['_agents_warning_'] = $group_stat[0]["warning"];
$list[$i]['_agents_critical_'] = $group_stat[0]["critical"];
$list[$i]['_monitors_alerts_'] = $group_stat[0]["alerts"];
}
// This fields are not in database // This fields are not in database
$list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id); $list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id);
$list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id); $list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id);
@ -1939,6 +1944,62 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id); $list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id);
$list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id); $list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id);
if ($mode == 'tactical' || $mode == 'tree') {
$list[$i]['_agents_ok_'] = $group_stat[0]["normal"];
$list[$i]['_agents_warning_'] = $group_stat[0]["warning"];
$list[$i]['_agents_critical_'] = $group_stat[0]["critical"];
$list[$i]['_monitors_alerts_'] = $group_stat[0]["alerts"];
$list[$i]["_monitor_alerts_fire_count_"] = $group_stat[0]["alerts_fired"];
$list[$i]["_total_checks_"] = $group_stat[0]["modules"];
$list[$i]["_total_alerts_"] = $group_stat[0]["alerts"];
}
if ($mode == 'tactical') {
// Get total count of monitors for this group, except disabled.
$list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"];
// Calculate not_normal monitors
$list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"];
if ($list[$i]["_monitors_unknown_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
}
else {
$list[$i]["_monitor_health_"] = 100;
}
if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
}
else {
$list[$i]["_module_sanity_"] = 100;
}
if (isset($list[$i]["_alerts_"])) {
if ($list[$i]["_monitors_alerts_fired_"] > 0 && $list[$i]["_alerts_"] > 0) {
$list[$i]["_alert_level_"] = format_numeric (100 - ($list[$i]["_monitors_alerts_fired_"] / ($list[$i]["_alerts_"] / 100)), 1);
}
else {
$list[$i]["_alert_level_"] = 100;
}
}
else {
$list[$i]["_alert_level_"] = 100;
$list[$i]["_alerts_"] = 0;
}
$list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"];
if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
}
else {
$list[$i]["_global_health_"] = 100;
}
$list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1);
}
if ($returnAllGroup) { if ($returnAllGroup) {
$list[0]['_agents_unknown_'] += $group_stat[0]["unknown"]; $list[0]['_agents_unknown_'] += $group_stat[0]["unknown"];
$list[0]['_monitors_alerts_fired_'] += $group_stat[0]["alerts_fired"]; $list[0]['_monitors_alerts_fired_'] += $group_stat[0]["alerts_fired"];
@ -1948,7 +2009,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_'];
$list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_'];
$list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_']; $list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_'];
$list[0]['_agents_not_init'] += $list[$i]['_agents_not_init']; $list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_'];
if ($mode == 'tactical' || $mode == 'tree') { if ($mode == 'tactical' || $mode == 'tree') {
$list[0]['_agents_ok_'] += $group_stat[0]["normal"]; $list[0]['_agents_ok_'] += $group_stat[0]["normal"];
@ -1993,6 +2054,54 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[$i]['_agents_warning_'] = groups_agent_warning ($id, $user_strict, $id); $list[$i]['_agents_warning_'] = groups_agent_warning ($id, $user_strict, $id);
$list[$i]['_agents_critical_'] = groups_agent_critical ($id, $user_strict, $id); $list[$i]['_agents_critical_'] = groups_agent_critical ($id, $user_strict, $id);
$list[$i]['_monitors_alerts_'] = groups_monitor_alerts ($id, $user_strict, $id); $list[$i]['_monitors_alerts_'] = groups_monitor_alerts ($id, $user_strict, $id);
// TODO
//~ $list[$i]["_total_checks_"]
//~ $list[$i]["_total_alerts_"]
// Get total count of monitors for this group, except disabled.
$list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"];
// Calculate not_normal monitors
$list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"];
if ($list[$i]["_monitors_unknown_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
}
else {
$list[$i]["_monitor_health_"] = 100;
}
if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
}
else {
$list[$i]["_module_sanity_"] = 100;
}
if (isset($list[$i]["_alerts_"])) {
if ($list[$i]["_monitors_alerts_fired_"] > 0 && $list[$i]["_alerts_"] > 0) {
$list[$i]["_alert_level_"] = format_numeric (100 - ($list[$i]["_monitors_alerts_fired_"] / ($list[$i]["_alerts_"] / 100)), 1);
}
else {
$list[$i]["_alert_level_"] = 100;
}
}
else {
$list[$i]["_alert_level_"] = 100;
$list[$i]["_alerts_"] = 0;
}
$list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"];
if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
}
else {
$list[$i]["_global_health_"] = 100;
}
$list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1);
} }
if ($returnAllGroup) { if ($returnAllGroup) {
@ -2004,7 +2113,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
$list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_'];
$list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_'];
$list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_']; $list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_'];
$list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init']; $list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_'];
if ($mode == 'tactical' || $mode == 'tree') { if ($mode == 'tactical' || $mode == 'tree') {
$list[0]['_agents_ok_'] += $list[$i]['_agents_ok_']; $list[0]['_agents_ok_'] += $list[$i]['_agents_ok_'];
@ -2095,7 +2204,7 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
if ($id_user == false) { if ($id_user == false) {
$id_user = $config['id_user']; $id_user = $config['id_user'];
} }
$acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict); $acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict);
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
@ -2113,6 +2222,7 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
$result_list = array (); $result_list = array ();
foreach ($servers as $server) { foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR) { if (metaconsole_connect($server) != NOERR) {
continue; continue;
} }
@ -2120,6 +2230,7 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
foreach ($server_list as $server_item) { foreach ($server_list as $server_item) {
if (! isset ($result_list[$server_item['_name_']])) { if (! isset ($result_list[$server_item['_name_']])) {
$result_list[$server_item['_name_']] = $server_item; $result_list[$server_item['_name_']] = $server_item;
} }
else { else {
@ -2135,6 +2246,19 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
$result_list[$server_item['_name_']]['_agents_critical_'] += $server_item['_agents_critical_']; $result_list[$server_item['_name_']]['_agents_critical_'] += $server_item['_agents_critical_'];
$result_list[$server_item['_name_']]['_agents_warning_'] += $server_item['_agents_warning_']; $result_list[$server_item['_name_']]['_agents_warning_'] += $server_item['_agents_warning_'];
$result_list[$server_item['_name_']]['_monitors_alerts_'] += $server_item['_monitors_alerts_']; $result_list[$server_item['_name_']]['_monitors_alerts_'] += $server_item['_monitors_alerts_'];
$result_list[$server_item['_name_']]["_monitor_checks_"] += $server_item["_monitor_checks_"];
$result_list[$server_item['_name_']]["_monitor_not_normal_"] += $server_item["_monitor_not_normal_"];
$result_list[$server_item['_name_']]["_monitor_health_"] += $server_item["_monitor_health_"];
$result_list[$server_item['_name_']]["_module_sanity_"] += $server_item["_module_sanity_"];
$result_list[$server_item['_name_']]["_alerts_"] += $server_item["_alerts_"];
$result_list[$server_item['_name_']]["_alert_level_"] += $server_item["_alert_level_"];
$result_list[$server_item['_name_']]["_monitor_bad_"] += $server_item["_monitor_bad_"];
$result_list[$server_item['_name_']]["_global_health_"] += $server_item["_global_health_"];
$result_list[$server_item['_name_']]["_server_sanity_"] += $server_item["_server_sanity_"];
$result_list[$server_item['_name_']]["_monitor_alerts_fire_count_"] += $server_item["_monitor_alerts_fire_count_"];
$result_list[$server_item['_name_']]["_total_checks_"] += $server_item["_total_checks_"];
$result_list[$server_item['_name_']]["_total_alerts_"] += $server_item["_total_alerts_"];
} }
} }
} }

View File

@ -371,7 +371,7 @@ function html_print_select_groups($id_user = false, $privilege = "AR",
$keys_field = 'id_grupo', $strict_user = false) { $keys_field = 'id_grupo', $strict_user = false) {
global $config; global $config;
$fields = users_get_groups_for_select($id_user, $privilege, $fields = users_get_groups_for_select($id_user, $privilege,
$returnAllGroup, true, $id_group, $keys_field); $returnAllGroup, true, $id_group, $keys_field);

View File

@ -333,16 +333,6 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$node_ref[$agent['id_agente']] = $node_count; $node_ref[$agent['id_agente']] = $node_count;
// Save node parent information to define edges later
if ($agent['id_parent'] != "0" &&
array_key_exists($agent['id_parent'], $node_ref)) {
$parents[$node_count] = $node_ref[$agent['id_parent']];
}
else {
$orphans[$node_count] = 1;
}
$agent['id_node'] = $node_count; $agent['id_node'] = $node_count;
$agent['type'] = 'agent'; $agent['type'] = 'agent';
@ -389,6 +379,19 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
} }
} }
// Addded the relationship of parents of agents
foreach ($agents as $agent) {
if ($agent['id_parent'] != "0" &&
array_key_exists($agent['id_parent'], $node_ref)) {
$parents[$node_ref[$agent['id_agente']]] = $node_ref[$agent['id_parent']];
}
else {
$orphans[$node_ref[$agent['id_agente']]] = 1;
}
}
// Drop the modules without a partner if l2_network is true // Drop the modules without a partner if l2_network is true
// and the snmp interfaces token is false // and the snmp interfaces token is false
if ($l2_network) { if ($l2_network) {
@ -1554,6 +1557,27 @@ function networkmap_delete_networkmap ($id_networkmap) {
return @db_process_sql_delete ('tnetwork_map', array ('id_networkmap' => $id_networkmap)); return @db_process_sql_delete ('tnetwork_map', array ('id_networkmap' => $id_networkmap));
} }
/**
* Deletes a network map if the property is that user.
*
* @param string User id that call this funtion.
* @param int Map id to be deleted.
*
* @return bool True if the map was deleted, false the map is not yours.
*/
function networkmap_delete_user_networkmap ($id_user = '', $id_networkmap) {
if ($id_user == '') {
$id_user = $config['id_user'];
}
$id_networkmap = safe_int ($id_networkmap);
if (empty ($id_networkmap))
return false;
$networkmap = networkmap_get_networkmap ($id_networkmap);
if ($networkmap === false)
return false;
return @db_process_sql_delete ('tnetwork_map', array ('id_networkmap' => $id_networkmap, 'id_user' => $id_user));
}
/** /**
* Updates a network map. * Updates a network map.
* *

View File

@ -1563,7 +1563,7 @@ function reporting_get_stats_summary($data, $graph_width, $graph_height) {
return $output; return $output;
} }
function reporting_get_stats_alerts($data) { function reporting_get_stats_alerts($data, $links = false) {
global $config; global $config;
// Link URLS // Link URLS
@ -1581,8 +1581,13 @@ function reporting_get_stats_alerts($data) {
} }
else { else {
$urls = array(); $urls = array();
$urls['monitor_alerts'] = "index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60"; if ($links) {
$urls['monitor_alerts_fired'] = "index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60&filter=fired"; $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&pure=" . $config['pure'];
$urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&filter=fired&pure=" . $config['pure'];
} else {
$urls['monitor_alerts'] = "index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60";
$urls['monitor_alerts_fired'] = "index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60&filter=fired";
}
} }
// Alerts table // Alerts table
@ -8045,4 +8050,262 @@ function reporting_network_interfaces_table ($content, $report, $mini, $item_tit
} }
} }
} }
?>
function reporting_get_agents_by_status ($data, $graph_width = 250, $graph_height = 150, $links = false) {
global $config;
if ($links == false) {
$links = array();
}
$table_agent = html_get_predefined_table();
$agent_data = array();
$agent_data[0] = html_print_image('images/agent_critical.png', true, array('title' => __('Agents critical')));
$agent_data[1] = "<a style='color: #bc0000;' href='" . $links['agents_critical'] . "'><b><span style='font-size: 12pt; font-weight: bold; color: #bc0000;'>".format_numeric($data['agent_critical'])."</span></b></a>";
$agent_data[2] = html_print_image('images/agent_warning.png', true, array('title' => __('Agents warning')));
$agent_data[3] = "<a style='color: #aba900;' href='" . $links['agents_warning'] . "'><b><span style='font-size: 12pt; font-weight: bold; color: #aba900;'>".format_numeric($data['agent_warning'])."</span></b></a>";
$table_agent->data[] = $agent_data;
$agent_data = array();
$agent_data[0] = html_print_image('images/agent_ok.png', true, array('title' => __('Agents ok')));
$agent_data[1] = "<a style='color: #6ec300;' href='" . $links['agents_ok'] . "'><b><span style='font-size: 12pt; font-weight: bold; color: #6ec300;'>".format_numeric($data['agent_ok'])."</span></b></a>";
$agent_data[2] = html_print_image('images/agent_unknown.png', true, array('title' => __('Agents unknown')));
$agent_data[3] = "<a style='color: #886666;' href='" . $links['agents_unknown'] . "'><b><span style='font-size: 12pt; font-weight: bold; color: #886666;'>".format_numeric($data['agent_unknown'])."</span></b></a>";
$table_agent->data[] = $agent_data;
$agent_data = array();
$agent_data[0] = html_print_image('images/agent_notinit.png', true, array('title' => __('Agents not init')));
$agent_data[1] = "<a style='color: #729fcf;' href='" . $links['agents_not_init'] . "'><b><span style='font-size: 12pt; font-weight: bold; color: #729fcf;'>".format_numeric($data['agent_not_init'])."</span></b></a>";
$table_agent->data[] = $agent_data;
$agents_data = '<fieldset class="databox tactical_set">
<legend>' .
__('Agents by status') .
'</legend>' .
html_print_table($table_agent, true) . '</fieldset>';
return $agents_data;
}
function reporting_get_total_agents_and_monitors ($data, $graph_width = 250, $graph_height = 150) {
global $config;
$total_agent = $data['agent_ok'] + $data['agent_warning'] + $data['agent_critical'] + $data['gent_unknown'] + $data['agent_not_init'];
$total_module = $data['monitor_ok'] + $data['monitor_warning'] + $data['monitor_critical'] + $data['monitor_unknown'] + $data['monitor_not_init'];
$table_total = html_get_predefined_table();
$total_data = array();
$total_data[0] = html_print_image('images/agent.png', true, array('title' => __('Total agents')));
$total_data[1] = $total_agent <= 0 ? '-' : $total_agent;
$total_data[2] = html_print_image('images/module.png', true, array('title' => __('Monitor checks')));
$total_data[3] = $total_module <= 0 ? '-' : $total_module;
$table_total->data[] = $total_data;
$total_agent_module = '<fieldset class="databox tactical_set">
<legend>' .
__('Total agents and monitors') .
'</legend>' .
html_print_table($table_total, true) . '</fieldset>';
return $total_agent_module;
}
function reporting_get_total_servers ($num_servers) {
global $config;
$table_node = html_get_predefined_table();
$node_data = array();
$node_data[0] = html_print_image('images/server_export.png', true, array('title' => __('Nodes')));
$node_data[1] = "<b><span style='font-size: 12pt; font-weight: bold; color: black;'>".format_numeric($num_servers)."</span></b>";
$table_node->data[] = $node_data;
$node_overview = '<fieldset class="databox tactical_set">
<legend>' .
__('Node overview') .
'</legend>' .
html_print_table($table_node, true) . '</fieldset>';
return $node_overview;
}
function reporting_get_events ($data, $links = false) {
global $config;
$table_events->width = "100%";
$table_events->data[0][0] = html_print_image('images/agent_critical.png', true, array('title' => __('Critical events')));
$table_events->data[0][0] .= "&nbsp;&nbsp;&nbsp;"."<a style='color: #bc0000;' href='" . $links['critical'] . "'><b><span style='font-size: 12pt; font-weight: bold; color: #bc0000;'>".format_numeric($data['critical'])."</span></b></a>";
$table_events->data[0][1] = html_print_image('images/agent_warning.png', true, array('title' => __('Warning events')));
$table_events->data[0][1] .= "&nbsp;&nbsp;&nbsp;"."<a style='color: #aba900;' href='" . $links['warning'] . "'><b><span style='font-size: 12pt; font-weight: bold; color: #aba900;'>".format_numeric($data['warning'])."</span></b></a>";
$table_events->data[0][2] = html_print_image('images/agent_ok.png', true, array('title' => __('OK events')));
$table_events->data[0][2] .= "&nbsp;&nbsp;&nbsp;"."<a style='color: #6ec300;' href='" . $links['normal'] . "'><b><span style='font-size: 12pt; font-weight: bold; color: #6ec300;'>".format_numeric($data['normal'])."</span></b></a>";
$table_events->data[0][3] = html_print_image('images/agent_unknown.png', true, array('title' => __('Unknown events')));
$table_events->data[0][3] .= "&nbsp;&nbsp;&nbsp;"."<a style='color: #886666;' href='" . $links['unknown'] . "'><b><span style='font-size: 12pt; font-weight: bold; color: #886666;'>".format_numeric($data['unknown'])."</span></b></a>";
$table_events->data[0][4] = html_print_image('images/agent_notinit.png', true, array('title' => __('Not init events')));
$table_events->data[0][4] .= "&nbsp;&nbsp;&nbsp;"."<a style='color: #729fcf;' href='" . $links['not_init'] . "'><b><span style='font-size: 12pt; font-weight: bold; color: #729fcf;'>".format_numeric($data['not_init'])."</span></b></a>";
$event_view = '<fieldset class="databox tactical_set">
<legend>' .
__('Events by criticity') .
'</legend>' .
html_print_table($table_events, true) . '</fieldset>';
return $event_view;
}
function reporting_get_last_activity() {
global $config;
// Show last activity from this user
$table->width = '100%';
$table->data = array ();
$table->size = array ();
$table->size[2] = '150px';
$table->size[3] = '130px';
$table->size[5] = '200px';
$table->head = array ();
$table->head[0] = __('User');
$table->head[1] = '';
$table->head[2] = __('Action');
$table->head[3] = __('Date');
$table->head[4] = __('Source IP');
$table->head[5] = __('Comments');
$table->title = '<span>' . __('Last activity in Pandora FMS console') . '</span>';
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ("SELECT id_usuario,accion,fecha,ip_origen,descripcion,utimestamp
FROM tsesion
WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - " . SECONDS_1WEEK . ")
AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 5", $config["id_user"]);
break;
case "postgresql":
$sql = sprintf ("SELECT \"id_usuario\", accion, fecha, \"ip_origen\", descripcion, utimestamp
FROM tsesion
WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - " . SECONDS_1WEEK . ")
AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 5", $config["id_user"]);
break;
case "oracle":
$sql = sprintf ("SELECT id_usuario, accion, fecha, ip_origen, descripcion, utimestamp
FROM tsesion
WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - " . SECONDS_1WEEK . ")
AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", $config["id_user"]);
break;
}
$sessions = db_get_all_rows_sql ($sql);
if ($sessions === false)
$sessions = array ();
foreach ($sessions as $session) {
$data = array ();
switch ($config["dbtype"]) {
case "mysql":
case "oracle":
$session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen'];
break;
case "postgresql":
$session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen'];
break;
}
$data[0] = '<strong>' . $session_id_usuario . '</strong>';
$data[1] = ui_print_session_action_icon ($session['accion'], true);
$data[2] = $session['accion'];
$data[3] = ui_print_help_tip($session['fecha'], true) . human_time_comparation($session['utimestamp'], 'tiny');
$data[4] = $session_ip_origen;
$data[5] = io_safe_output ($session['descripcion']);
array_push ($table->data, $data);
}
return html_print_table ($table, true);
}
function reporting_get_event_histogram ($events) {
global $config;
include_once ('../../include/graphs/functions_gd.php');
$max_value = count($events);
$ttl = 1;
$urlImage = ui_get_full_url(false, true, false, false);
$colors = array(
EVENT_CRIT_MAINTENANCE => COL_MAINTENANCE,
EVENT_CRIT_INFORMATIONAL => COL_INFORMATIONAL,
EVENT_CRIT_NORMAL => COL_MINOR,
EVENT_CRIT_MINOR => COL_NORMAL,
EVENT_CRIT_WARNING => COL_WARNING,
EVENT_CRIT_MAJOR => COL_MAJOR,
EVENT_CRIT_CRITICAL => COL_CRITICAL
);
foreach ($events as $data) {
switch ($data['criticity']) {
case 0:
$color = EVENT_CRIT_MAINTENANCE;
break;
case 1:
$color = EVENT_CRIT_INFORMATIONAL;
break;
case 2:
$color = EVENT_CRIT_NORMAL;
break;
case 3:
$color = EVENT_CRIT_WARNING;
break;
case 4:
$color = EVENT_CRIT_CRITICAL;
break;
case 5:
$color = EVENT_CRIT_MINOR;
break;
case 6:
$color = EVENT_CRIT_MAJOR;
break;
case 20:
$color = EVENT_CRIT_NOT_NORMAL;
break;
case 34:
$color = EVENT_CRIT_WARNING_OR_CRITICAL;
break;
}
$graph_data[] = array(
'data' => $color,
'utimestamp' => 1
);
}
$table->width = '100%';
$table->data = array ();
$table->size = array ();
$table->head = array ();
$table->title = '<span>' . __('Events info (1hr.)') . '</span>';
$table->data[0][0] = "" ;
if (!empty($graph_data)) {
$slicebar = slicesbar_graph($graph_data, $max_value, 700, 25, $colors, $config['fontpath'], $config['round_corner'], $urlImage, $ttl);
$table->data[0][0] = $slicebar;
} else {
$table->data[0][0] = __('No events');
}
$event_graph = '<fieldset class="databox tactical_set">
<legend>' .
__('Events info (1hr)') .
'</legend>' .
html_print_table($table, true) . '</fieldset>';
return $event_graph;
}
?>

View File

@ -107,7 +107,7 @@ function tags_total_agents ($id_tag, $groups_and_tags = array()) {
* @return mixed Returns count of agents in normal status or false if they aren't. * @return mixed Returns count of agents in normal status or false if they aren't.
*/ */
function tags_agent_ok ($id_tag, $groups_and_tags = array()) { function tags_agent_ok ($id_tag, $groups_and_tags = array()) {
$groups_clause = ""; $groups_clause = "";
if (!empty($groups_and_tags)) { if (!empty($groups_and_tags)) {
$i = 0; $i = 0;
@ -556,12 +556,18 @@ function tags_update_policy_module_tag ($id_policy_module, $tags, $autocommit =
* *
* @return mixed Array with module tags or false if something goes wrong. * @return mixed Array with module tags or false if something goes wrong.
*/ */
function tags_get_module_tags ($id_agent_module) { function tags_get_module_tags ($id, $policy = false) {
if (empty($id_agent_module)) if (empty($id))
return false; return false;
$tags = db_get_all_rows_filter('ttag_module', if ($policy) {
array('id_agente_modulo' => $id_agent_module), false); $tags = db_get_all_rows_filter('ttag_policy_module',
array('id_policy_module' => $id), false);
}
else {
$tags = db_get_all_rows_filter('ttag_module',
array('id_agente_modulo' => $id), false);
}
if ($tags === false) if ($tags === false)
return array(); return array();
@ -859,7 +865,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
// Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression) // Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression)
if ($i == 0) if ($i == 0)
$condition .= ' ( '; $condition .= ' ( ';
// Group condition (The module belongs to an agent of the group X) // Group condition (The module belongs to an agent of the group X)
// Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition // Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition
@ -886,7 +892,8 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
$tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, $group_tags_query); $tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, $group_tags_query);
$condition .= "($group_condition AND \n$tags_condition)\n"; $condition .= "($group_condition AND \n$tags_condition)\n";
} }
$i++; $i++;
} }
@ -1058,7 +1065,7 @@ function tags_get_user_tags($id_user = false, $access = 'AR') {
if(empty($acl_column)) { if(empty($acl_column)) {
return array(); return array();
} }
$query = sprintf("SELECT count(*) $query = sprintf("SELECT count(*)
FROM tusuario_perfil, tperfil FROM tusuario_perfil, tperfil
WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND
@ -1067,7 +1074,7 @@ function tags_get_user_tags($id_user = false, $access = 'AR') {
$id_user, $acl_column); $id_user, $acl_column);
$profiles_without_tags = db_get_value_sql($query); $profiles_without_tags = db_get_value_sql($query);
if ($profiles_without_tags == 0) { if ($profiles_without_tags == 0) {
return $all_tags; return $all_tags;
} }
@ -1095,7 +1102,8 @@ function tags_get_user_tags($id_user = false, $access = 'AR') {
} }
$user_tags[$id] = $all_tags[$id]; $user_tags[$id] = $all_tags[$id];
} }
return $user_tags; return $user_tags;
} }
@ -1608,7 +1616,6 @@ function tags_monitors_fired_alerts ($id_tag, $groups_and_tags = array()) {
/* Return array with groups and their tags */ /* Return array with groups and their tags */
function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $strict_user = false) { function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $strict_user = false) {
global $config; global $config;
if ($id_user == false) { if ($id_user == false) {
@ -1756,7 +1763,7 @@ function tags_get_monitors_alerts ($id_tag, $groups_and_tags = array()) {
function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags = array(), $filter = false, $fields = false, $meta = true, $strict_user = true) { function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags = array(), $filter = false, $fields = false, $meta = true, $strict_user = true) {
global $config; global $config;
// Avoid mysql error // Avoid mysql error
if (empty($id_tag)) if (empty($id_tag))
return; return;
@ -1775,7 +1782,7 @@ function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags =
$groups_clause = ""; $groups_clause = "";
if ($strict_user) { if ($strict_user) {
if (!empty($groups_and_tags)) { if (!empty($groups_and_tags)) {
$groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo"); $groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo");
} }
} else { } else {
$groups_clause = " AND tagente.id_grupo IN (".implode(',',$groups_and_tags).")"; $groups_clause = " AND tagente.id_grupo IN (".implode(',',$groups_and_tags).")";
@ -1795,7 +1802,7 @@ function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags =
} }
} }
} }
$user_agents_sql = "SELECT ".$select_fields ." $user_agents_sql = "SELECT ".$select_fields ."
FROM tagente, tagente_modulo, ttag_module FROM tagente, tagente_modulo, ttag_module
WHERE tagente.id_agente = tagente_modulo.id_agente WHERE tagente.id_agente = tagente_modulo.id_agente
@ -1803,9 +1810,10 @@ function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags =
AND ttag_module.id_tag = " . $id_tag . AND ttag_module.id_tag = " . $id_tag .
$groups_clause . $search_sql . $void_agents . $groups_clause . $search_sql . $void_agents .
" ORDER BY tagente.nombre ASC"; " ORDER BY tagente.nombre ASC";
//return db_get_sql ($user_agents);
$user_agents = db_get_all_rows_sql($user_agents_sql); $user_agents = db_get_all_rows_sql($user_agents_sql);
if (!$meta){ if (!$meta){
$user_agents_aux = array(); $user_agents_aux = array();
if ($user_agents === false) { if ($user_agents === false) {

View File

@ -551,23 +551,24 @@ function treeview_printTree($type) {
$first = true; $first = true;
foreach ($list as $item) { foreach ($list as $item) {
$lessBranchs = 0; $lessBranchs = 0;
$tree_img_id = "tree_image_" . $type . "__" . $item['_id_'];
if ($first) { if ($first) {
if ($item != end($list)) { if ($item != end($list)) {
$img = html_print_image ("operation/tree/first_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image_" . $type . "_" . $item['_id_'], "pos_tree" => "0")); $img = html_print_image ("operation/tree/first_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "0"));
$first = false; $first = false;
} }
else { else {
$lessBranchs = 1; $lessBranchs = 1;
$img = html_print_image ("operation/tree/one_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image_" . $type . "_" . $item['_id_'], "pos_tree" => "1")); $img = html_print_image ("operation/tree/one_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "1"));
} }
} }
else { else {
if ($item != end($list)) if ($item != end($list))
$img = html_print_image ("operation/tree/closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image_" . $type . "_" . $item['_id_'], "pos_tree" => "2")); $img = html_print_image ("operation/tree/closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "2"));
else else
{ {
$lessBranchs = 1; $lessBranchs = 1;
$img = html_print_image ("operation/tree/last_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image_" . $type . "_" . $item['_id_'], "pos_tree" => "3")); $img = html_print_image ("operation/tree/last_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "3"));
} }
} }
@ -604,7 +605,7 @@ function treeview_printTree($type) {
echo ') '. "</a>"; echo ') '. "</a>";
echo "<div hiddenDiv='1' loadDiv='0' style='margin: 0px; padding: 0px;' class='tree_view' id='tree_div_" . $type . "_" . $id . "'></div>"; echo "<div hiddenDiv='1' loadDiv='0' style='margin: 0px; padding: 0px;' class='tree_view' id='tree_div_" . $type . "__" . $id . "'></div>";
echo "</li>\n"; echo "</li>\n";
} }
echo "</ul>\n"; echo "</ul>\n";

View File

@ -1243,7 +1243,7 @@ function ui_process_page_head ($string, $bitfield) {
$_GET['sec2'] == 'operation/snmpconsole/snmp_view' || $_GET['sec2'] == 'operation/snmpconsole/snmp_view' ||
$_GET['sec2'] == 'enterprise/dashboard/main_dashboard') { $_GET['sec2'] == 'enterprise/dashboard/main_dashboard') {
$query = ui_get_url_refresh (false); $query = ui_get_url_refresh (false, false);
$output .= '<meta http-equiv="refresh" content="' . $output .= '<meta http-equiv="refresh" content="' .
$config_refr . '; URL=' . $query . '" />'; $config_refr . '; URL=' . $query . '" />';
@ -1256,8 +1256,8 @@ function ui_process_page_head ($string, $bitfield) {
<meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="resource-type" content="document" /> <meta name="resource-type" content="document" />
<meta name="distribution" content="global" /> <meta name="distribution" content="global" />
<meta name="author" content="Sancho Lerena" /> <meta name="author" content="Pandora FMS Developer team" />
<meta name="copyright" content="This is GPL software. Created by Sancho Lerena and others" /> <meta name="copyright" content="(c) Artica Soluciones Tecnologicas" />
<meta name="keywords" content="pandora, monitoring, system, GPL, software" /> <meta name="keywords" content="pandora, monitoring, system, GPL, software" />
<meta name="robots" content="index, follow" /> <meta name="robots" content="index, follow" />
<link rel="icon" href="images/pandora.ico" type="image/ico" /> <link rel="icon" href="images/pandora.ico" type="image/ico" />
@ -2141,8 +2141,13 @@ function ui_toggle($code, $name, $title = '', $hidden_default = true, $return =
function ui_get_url_refresh ($params = false, $relative = true, $add_post = true) { function ui_get_url_refresh ($params = false, $relative = true, $add_post = true) {
// Agent selection filters and refresh // Agent selection filters and refresh
global $config; global $config;
$url = '';
// slerena, 8/Ene/2015 - Need to put index.php on URL which have it.
if (strpos($_SERVER['REQUEST_URI'], 'index.php') === false)
$url = '';
else
$url = 'index.php';
if (sizeof ($_REQUEST)) { if (sizeof ($_REQUEST)) {
//Some (old) browsers don't like the ?&key=var //Some (old) browsers don't like the ?&key=var
$url .= '?'; $url .= '?';
@ -2221,6 +2226,7 @@ function ui_get_url_refresh ($params = false, $relative = true, $add_post = true
} }
$url = htmlspecialchars ($url); $url = htmlspecialchars ($url);
if (! $relative) { if (! $relative) {
return ui_get_full_url ($url); return ui_get_full_url ($url);
} }

View File

@ -335,10 +335,10 @@ function visual_map_print_item($mode = "read", $layoutData,
} }
else if ($is_a_link_to_other_visualconsole) { else if ($is_a_link_to_other_visualconsole) {
if (empty($layout_data['id_metaconsole'])) { if (empty($layout_data['id_metaconsole'])) {
$url_vc = $config['homeurl'] . "index.php?sec=reporting&amp;sec2=operation/visual_console/render_view&amp;pure=" . $config["pure"] . "&amp;id=" . $layout_data["id_layout_linked"]; $url = $config['homeurl'] . "index.php?sec=reporting&amp;sec2=operation/visual_console/render_view&amp;pure=" . $config["pure"] . "&amp;id=" . $layoutData["id_layout_linked"];
} }
else { else {
$url_vc = "index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=1&id_visualmap=" . $layout_data["id_layout_linked"] . "&refr=0"; $url = "index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=1&id_visualmap=" . $layoutData["id_layout_linked"] . "&refr=0";
} }
} }
else { else {
@ -371,9 +371,24 @@ function visual_map_print_item($mode = "read", $layoutData,
break; break;
case GROUP_ITEM: case GROUP_ITEM:
$url = $config['homeurl'] . $is_a_link_to_other_visualconsole = false;
'index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=' . if ($layoutData['id_layout_linked'] != 0) {
$layoutData['id_group']; $is_a_link_to_other_visualconsole = true;
}
if ($is_a_link_to_other_visualconsole) {
if (empty($layout_data['id_metaconsole'])) {
$url = $config['homeurl'] . "index.php?sec=reporting&amp;sec2=operation/visual_console/render_view&amp;pure=" . $config["pure"] . "&amp;id=" . $layoutData["id_layout_linked"];
}
else {
$url = "index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=1&id_visualmap=" . $layoutData["id_layout_linked"] . "&refr=0";
}
}
else {
$url = $config['homeurl'] .
'index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=' .
$layoutData['id_group'];
}
break; break;
case LABEL: case LABEL:
if ($layoutData['id_layout_linked'] != 0) { if ($layoutData['id_layout_linked'] != 0) {
@ -1916,34 +1931,78 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) {
$id_layout = (int) $id_layout; $id_layout = (int) $id_layout;
$result = db_get_all_rows_filter ('tlayout_data', array ('id_layout' => $id_layout), $result = db_get_all_rows_filter ('tlayout_data',
array ('id_agente_modulo', 'parent_item', 'id_layout_linked', 'id_agent', 'type')); array ('id_layout' => $id_layout),
array (
'id_agente_modulo',
'id_group',
'parent_item',
'id_layout_linked',
'id_agent',
'type'));
if ($result === false) if ($result === false)
return VISUAL_MAP_STATUS_NORMAL; return VISUAL_MAP_STATUS_NORMAL;
foreach ($result as $rownum => $data) { foreach ($result as $data) {
if (($data["id_layout_linked"] == 0 && $data["id_agente_modulo"] == 0 && $data["id_agent"] == 0) || $data['type'] != 0) switch ($data['type']) {
continue; case GROUP_ITEM:
// Other Layout (Recursive!) if ($data["id_layout_linked"] == 0) {
if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) { $group_status = groups_get_status($data['id_group']);
$status = visual_map_get_layout_status ($data["id_layout_linked"], $depth); switch ($group_status) {
case AGENT_STATUS_ALERT_FIRED:
$status = VISUAL_MAP_STATUS_CRITICAL_ALERT;
break;
case AGENT_STATUS_CRITICAL:
$status = VISUAL_MAP_STATUS_CRITICAL_BAD;
break;
case AGENT_STATUS_WARNING:
$status = VISUAL_MAP_STATUS_WARNING;
break;
case AGENT_STATUS_UNKNOWN:
$status = VISUAL_MAP_STATUS_UNKNOWN;
break;
case AGENT_STATUS_NORMAL:
default:
$status = VISUAL_MAP_STATUS_NORMAL;
break;
}
}
else {
$status = visual_map_get_layout_status(
$data["id_layout_linked"], $depth);
}
break;
default:
if (($data["id_layout_linked"] == 0 &&
$data["id_agente_modulo"] == 0 &&
$data["id_agent"] == 0) ||
$data['type'] != 0)
continue;
// Other Layout (Recursive!)
if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) {
$status = visual_map_get_layout_status($data["id_layout_linked"], $depth);
}
// Module
elseif ($data["id_agente_modulo"] != 0) {
$status = modules_get_agentmodule_status($data["id_agente_modulo"]);
}
// Agent
else {
//--------------------------------------------------
// ADDED NO CHECK ACL FOR AVOID CHECK TAGS THAT
// MAKE VERY SLOW THE VISUALMAPS WITH ACL TAGS
//--------------------------------------------------
$status = agents_get_status($data["id_agent"], true);
}
break;
} }
// Module
elseif ($data["id_agente_modulo"] != 0) {
$status = modules_get_agentmodule_status ($data["id_agente_modulo"]);
}
// Agent
else {
//--------------------------------------------------
// ADDED NO CHECK ACL FOR AVOID CHECK TAGS THAT
// MAKE VERY SLOW THE VISUALMAPS WITH ACL TAGS
//--------------------------------------------------
$status = agents_get_status ($data["id_agent"], true);
}
if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD) if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD)
return VISUAL_MAP_STATUS_CRITICAL_BAD; return VISUAL_MAP_STATUS_CRITICAL_BAD;
if ($status > $temp_total) if ($status > $temp_total)
$temp_total = $status; $temp_total = $status;
} }

View File

@ -9,7 +9,7 @@ Next are described the fields that you should complete to add an Inventory Modul
<ul><b>Module:</b> Combo where you can choose the Inventory Module that you want to add. It will only show the modules which Operative System will match up with that from the agent.</ul> <ul><b>Module:</b> Combo where you can choose the Inventory Module that you want to add. It will only show the modules which Operative System will match up with that from the agent.</ul>
<ul><b>Target:</b> IP or servername from you want to get the inventory.</ul> <ul><b>Target:</b> IP or servername from you want to get the inventory.</ul>
<ul><b>Interval:</b> Combo where you choose the time interval in which the Inventory Module will ve executed.</ul> <ul><b>Interval:</b> Combo where you choose the time interval in which the Inventory Module will ve executed.</ul>
<ul><b>Username:</b> User that will ve used to execute the Inventory Module.</ul> <ul><b>Username:</b> User that will be used to execute the Inventory Module.</ul>
<ul><b>Password:</b> User Password that will be used to execute the Inventory Module.</ul> <ul><b>Password:</b> User Password that will be used to execute the Inventory Module.</ul>
<p>You can apply changes in all modules clicking in "Update all" when update any module. <p>You can apply changes in all modules clicking in "Update all" when update any module.

View File

@ -372,6 +372,9 @@ if (! isset ($config['id_user'])) {
case 'Dashboard': case 'Dashboard':
$_GET["sec"] = "dashboard"; $_GET["sec"] = "dashboard";
$_GET["sec2"] = ENTERPRISE_DIR.'/dashboard/main_dashboard'; $_GET["sec2"] = ENTERPRISE_DIR.'/dashboard/main_dashboard';
$id_dashboard_select =
db_get_value('id', 'tdashboard', 'name', $home_url);
$_GET['id_dashboard_select'] = $id_dashboard_select;
break; break;
case 'Visual console': case 'Visual console':
$_GET["sec"] = "visualc"; $_GET["sec"] = "visualc";

View File

@ -63,7 +63,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '6.0dev'; $version = '6.0dev';
$build = '150108'; $build = '150116';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -64,6 +64,7 @@ $tab = get_parameter_get ("tab", null);
$refr = (int)get_parameter('refr', 0); $refr = (int)get_parameter('refr', 0);
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
$url = 'index.php?sec=' . $sec . '&sec2=' . $sec2 . '&refr=' . $refr . $url = 'index.php?sec=' . $sec . '&sec2=' . $sec2 . '&refr=' . $refr .
'&filter=' . $filter . '&filter_standby=' . $filter_standby . '&filter=' . $filter . '&filter_standby=' . $filter_standby .
'&ag_group=' . $id_group .'&tag_filter=' .$tag_filter; '&ag_group=' . $id_group .'&tag_filter=' .$tag_filter;
@ -336,12 +337,11 @@ if (defined('METACONSOLE')) {
$alerts['alerts_simple'] = alerts_meta_get_alerts ($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user); $alerts['alerts_simple'] = alerts_meta_get_alerts ($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user);
$countAlertsSimple = alerts_meta_get_alerts ($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user); $countAlertsSimple = alerts_meta_get_alerts ($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user);
} }
else { else {
$id_groups = array_keys( $id_groups = array_keys(
users_get_groups($config["id_user"], 'AR', false)); users_get_groups($config["id_user"], 'AR', false));
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter);
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter);

View File

@ -52,93 +52,241 @@ if (isset ($_GET["update_netgroup"])) {
} }
} }
// Get group list that user has access
$groups_full = users_get_groups ($config['id_user'], "AR", true, true);
$groups = array();
foreach ($groups_full as $group) {
$groups[$group['id_grupo']]['name'] = $group['nombre'];
$groups[$group['id_grupo']]['parent'] = $group['parent'];
if ($group['id_grupo'] != 0) {
$groups[$group['parent']]['childs'][] = $group['id_grupo'];
$groups[$group['id_grupo']]['prefix'] = $groups[$group['parent']]['prefix'].'&nbsp;&nbsp;&nbsp;';
}
else {
$groups[$group['id_grupo']]['prefix'] = '';
}
if (!isset($groups[$group['id_grupo']]['childs'])) {
$groups[$group['id_grupo']]['childs'] = array();
}
}
if ($config["realtimestats"] == 0) { if ($config["realtimestats"] == 0) {
$updated_time = __('Last update') . " : " . $updated_time ="<a href='index.php?sec=estado&sec2=operation/agentes/tactical&force_refresh=1'>";
ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true); $updated_time .= __('Last update'). " : ". ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true);
$updated_time .= "</a>";
} }
else { else {
$updated_time = __("Updated at realtime"); $updated_time = __("Updated at realtime");
} }
// Header // Header
ui_print_page_header (__("Group view"), "images/group.png", false, "", false, $updated_time ); ui_print_page_header (__("Group view"), "images/group.png", false, "", false, $updated_time);
if (tags_has_user_acl_tags()) {
ui_print_tags_warning(); $strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
//Groups and tags
$result_groups = group_get_groups_list($config['id_user'], $strict_user, 'AR', true, true);
$count = count($result_groups);
if ($count == 1) {
if ($result_groups[0]['_id_'] == 0) {
unset($result_groups[0]);
}
} }
ui_pagination($count);
// Init vars if (!empty($result_groups)) {
$groups_info = array ();
$counter = 1;
$agents = agents_get_group_agents(array_keys($groups));
$offset = (int)get_parameter('offset', 0);
if (count($agents) > 0) {
$groups_get_groups_with_agent = groups_get_groups_with_agent($config['id_user'], "AR", true, true);
ui_pagination(count($groups_get_groups_with_agent));
echo '<table cellpadding="0" cellspacing="0" style="margin-top:10px;" class="databox" border="0" width="98%">'; echo '<table cellpadding="0" cellspacing="0" style="margin-top:10px;" class="databox" border="0" width="98%">';
echo "<tr>"; echo "<tr>";
echo "<th style='width: 26px;'>" . __("Force") . "</th>"; echo "<th style='width: 26px;'>" . __("Force") . "</th>";
//echo "<th style='width: 26px;'>" . __("Status") . "</th>"; echo "<th width='30%' style='min-width: 60px;'>" . __("Group") . "</th>";
echo "<th width='30%' style='min-width: 60px;'>" . __("Group") . "</th>"; echo "<th width='10%' style='min-width: 60px;'>" . __("Agents") . "</th>";
echo "<th width='10%' style='min-width: 60px;'>" . __("Agents") . "</th>"; echo "<th width='10%' style='min-width: 60px;'>" . __("Agent unknown") . "</th>";
echo "<th width='10%' style='min-width: 60px;'>" . __("Agent unknown") . "</th>"; echo "<th width='10%' style='min-width: 60px;'>" . __("Agents not init") . "</th>";
echo "<th width='10%' style='min-width: 60px;'>" . __("Agents not init") . "</th>"; echo "<th width='10%' style='min-width: 60px;'>" . __("Unknown") . "</th>";
echo "<th width='10%' style='min-width: 60px;'>" . __("Unknown") . "</th>"; echo "<th width='10%' style='min-width: 60px;'>" . __("Not Init") . "</th>";
echo "<th width='10%' style='min-width: 60px;'>" . __("Not Init") . "</th>"; echo "<th width='10%' style='min-width: 60px;'>" . __("Normal") . "</th>";
echo "<th width='10%' style='min-width: 60px;'>" . __("Normal") . "</th>"; echo "<th width='10%' style='min-width: 60px;'>" . __("Warning") . "</th>";
echo "<th width='10%' style='min-width: 60px;'>" . __("Warning") . "</th>"; echo "<th width='10%' style='min-width: 60px;'>" . __("Critical") . "</th>";
echo "<th width='10%' style='min-width: 60px;'>" . __("Critical") . "</th>"; echo "<th width='10%' style='min-width: 60px;'>" . __("Alert fired") . "</th>";
echo "<th width='10%' style='min-width: 60px;'>" . __("Alert fired") . "</th>";
foreach ($result_groups as $data) {
$printed_groups = array();
// Calculate entire row color
// For each valid group for this user, take data from agent and modules if ($data["_monitors_alerts_fired_"] > 0){
$table_rows = array(); $color_class = 'group_view_alrm';
foreach ($groups as $id_group => $group) { $status_image = ui_print_status_image ('agent_alertsfired_ball.png', "", true);
$rows = groups_get_group_row($id_group, $groups, $group, $printed_groups); }
if (!is_array_empty($rows)) { elseif ($data["_monitors_critical_"] > 0) {
$table_rows += $rows; $color_class = 'group_view_crit';
$status_image = ui_print_status_image ('agent_critical_ball.png', "", true);
}
elseif ($data["_monitors_warning_"] > 0) {
$color_class = 'group_view_warn';
$status_image = ui_print_status_image ('agent_warning_ball.png', "", true);
}
elseif (($data["_monitors_unknown_"] > 0) || ($data["_agents_unknown_"] > 0)) {
$color_class = 'group_view_unk';
$status_image = ui_print_status_image ('agent_no_monitors_ball.png', "", true);
}
elseif ($data["_monitors_ok_"] > 0) {
$color_class = 'group_view_ok';
$status_image = ui_print_status_image ('agent_ok_ball.png', "", true);
}
else {
$color_class = '';
$status_image = ui_print_status_image ('agent_no_data_ball.png', "", true);
}
echo "<tr style='height: 35px;'>";
// Force
echo "<td class='group_view_data' style='text-align: center; vertica-align: middle;'>";
if (!isset($data['_is_tag_']) && check_acl ($config['id_user'], $data['_id_'], "AW")) {
echo '<a href="index.php?sec=estado&sec2=operation/agentes/group_view&update_netgroup='.$data['_id_'].'">' .
html_print_image("images/target.png", true, array("border" => '0', "title" => __('Force'))) . '</a>';
}
echo "</td>";
$prefix = "";
if (!isset($data['_is_tag_'])) {
if ($data['_id_'] != 0) {
$prefix = '&nbsp;&nbsp;&nbsp;&nbsp;';
}
}
// Groupname
echo "<td>";
if (isset($data['_is_tag_'])) {
$deep = "";
$link = "";
} else {
$deep = groups_get_group_deep ($data['_id_']);
$link = "<a href='index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=".$data['_id_']."'>";
}
$group_name = "<b><span style='font-size: 7.5pt'>" . ui_print_truncate_text($data['_name_'], 50) . "</span></b>";
$item_icon = '';
if (isset($data['_iconImg_']) && !empty($data['_iconImg_']))
$item_icon = $data['_iconImg_'];
echo $link . $deep . $item_icon ."&nbsp;" . $group_name . "</a>";
echo "</td>";
// Total agents
echo "<td style='font-weight: bold; font-size: 18px;' align='center' class='$color_class'>";
if (isset($data['_is_tag_'])) {
$link = "";
} else {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=".$data['_id_']."'>";
}
if ($data["_total_agents_"] > 0) {
echo $link . $data["_total_agents_"] . "</a>";
}
echo "</td>";
// Agents unknown
echo "<td class='group_view_data group_view_data_unk $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'>";
if (isset($data['_is_tag_'])) {
$link = "";
} else {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=".$data['_id_']."&status=" . AGENT_STATUS_UNKNOWN ."'>";
}
if ($data["_agents_unknown_"] > 0) {
echo $link . $data["_agents_unknown_"] . "</a>";
}
echo "</td>";
// Agents not init
echo "<td class='group_view_data group_view_data_unk $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'>";
if (isset($data['_is_tag_'])) {
$link = "";
} else {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=".$data['_id_']."&status=" . AGENT_STATUS_NOT_INIT ."'>";
}
if ($data["_agents_not_init_"] > 0) {
echo $link . $data["_agents_not_init_"] . "</a>";
}
echo "</td>";
// Monitors unknown
echo "<td class='group_view_data group_view_data_unk $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'>";
if (!isset($data['_is_tag_'])) {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/status_monitor&ag_group=".$data['_id_']."&status=" . AGENT_MODULE_STATUS_UNKNOWN . "'>";
} else {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/status_monitor&tag_filter=".$data['_id_']."&status=" . AGENT_MODULE_STATUS_UNKNOWN . "'>";
}
if ($data["_monitors_unknown_"] > 0) {
echo $link . $data["_monitors_unknown_"] . "</a>";
}
echo "</td>";
// Monitors not init
echo "<td class='group_view_data group_view_data_unk $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'>";
if (!isset($data['_is_tag_'])) {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/status_monitor&ag_group=".$data['_id_']."&status=" . AGENT_MODULE_STATUS_NOT_INIT . "'>";
} else {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/status_monitor&tag_filter=".$data['_id_']."&status=" . AGENT_MODULE_STATUS_NOT_INIT . "'>";
}
if ($data["_monitors_not_init_"] > 0) {
echo $link . $data["_monitors_not_init_"] . "</a>";
}
echo "</td>";
// Monitors OK
echo "<td class='group_view_data group_view_data_ok $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'>";
if (!isset($data['_is_tag_'])) {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/status_monitor&ag_group=".$data['_id_']."&status=" . AGENT_MODULE_STATUS_NORMAL . "'>";
} else {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/status_monitor&tag_filter=".$data['_id_']."&status=" . AGENT_MODULE_STATUS_NORMAL . "'>";
}
if ($data["_monitors_ok_"] > 0) {
echo $link . $data["_monitors_ok_"] . "</a>";
}
echo "</td>";
// Monitors Warning
echo "<td class='group_view_data group_view_data_warn $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'>";
if (!isset($data['_is_tag_'])) {
$link = "<a class='group_view_data group_view_data_warn $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/status_monitor&ag_group=".$data['_id_']."&status=" . AGENT_MODULE_STATUS_WARNING . "'>";
} else {
$link = "<a class='group_view_data group_view_data_warn $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/status_monitor&tag_filter=".$data['_id_']."&status=" . AGENT_MODULE_STATUS_WARNING . "'>";
}
if ($data["_monitors_warning_"] > 0) {
echo $link . $data["_monitors_warning_"] . "</a>";
}
echo "</td>";
// Monitors Critical
echo "<td class='group_view_data group_view_data_crit $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'>";
if (!isset($data['_is_tag_'])) {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/status_monitor&ag_group=".$data['_id_']."&status=" . AGENT_MODULE_STATUS_CRITICAL_BAD . "'>";
} else {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/status_monitor&tag_filter=".$data['_id_']."&status=" . AGENT_MODULE_STATUS_CRITICAL_BAD . "'>";
}
if ($data["_monitors_critical_"] > 0) {
echo $link . $data["_monitors_critical_"] . "</a>";
}
echo "</td>";
// Alerts fired
echo "<td class='group_view_data group_view_data_alrm $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'>";
if (!isset($data['_is_tag_'])) {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/alerts_status&ag_group=".$data['_id_']."&filter=fired'>";
} else {
$link = "<a class='group_view_data $color_class' style='font-weight: bold; font-size: 18px; text-align: center;'
href='index.php?sec=estado&sec2=operation/agentes/alerts_status&tag_filter=".$data['_id_']."&filter=fired'>";
}
if ($data["_monitors_alerts_fired_"] > 0){
echo $link . $data["_monitors_alerts_fired_"] . "</a>";
}
echo '</td>';
echo "</tr>";
} }
} echo '</table>';
} else {
$table_rows = array_slice($table_rows, $offset, $config['block_size']);
foreach ($table_rows as $row) {
echo $row;
}
echo "</table>";
ui_pagination(count($groups_get_groups_with_agent));
}
else {
echo "<div class='nf'>" . __('There are no defined agents') . echo "<div class='nf'>" . __('There are no defined agents') .
"</div>"; "</div>";
} }
?>
?>

View File

@ -229,7 +229,7 @@ $combolist .= '</form>';
$buttons['combolist'] = $combolist; $buttons['combolist'] = $combolist;
if (check_acl ($config['id_user'], 0, "AW")) { if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) {
$buttons['addmap'] = array('active' => $activeTab == false, $buttons['addmap'] = array('active' => $activeTab == false,
'text' => '<a href="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;add_networkmap=1&amp;tab='.$activeTab.'&amp;pure='.$pure.'">' . 'text' => '<a href="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;add_networkmap=1&amp;tab='.$activeTab.'&amp;pure='.$pure.'">' .
html_print_image("images/add_mc.png", true, array ("title" => __('Add map'))) .'</a>'); html_print_image("images/add_mc.png", true, array ("title" => __('Add map'))) .'</a>');

View File

@ -38,23 +38,36 @@ if (is_ajax()) {
$delete_networkmaps = (bool) get_parameter('delete_networkmaps'); $delete_networkmaps = (bool) get_parameter('delete_networkmaps');
if ($delete_networkmaps) { if ($delete_networkmaps) {
if (! check_acl ($config['id_user'], 0, "AW")) { if ( check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM") ) {
db_pandora_audit("ACL Violation", if (check_acl ($config['id_user'], 0, "RW")) {
$result = false;
$results = array();
$ids_networkmap = (array) get_parameter ('ids_networkmap');
foreach ($ids_networkmap as $id) {
$results[$id] = (bool) networkmap_delete_user_networkmap($config['id_user'], $id);
}
echo json_encode($results);
return;
}else{
if (check_acl ($config['id_user'], 0, "RM")) {
$result = false;
$results = array();
$ids_networkmap = (array) get_parameter ('ids_networkmap');
foreach ($ids_networkmap as $id) {
$results[$id] = (bool) networkmap_delete_networkmap($id);
}
echo json_encode($results);
return;
}
}
}else{
db_pandora_audit("ACL Violation",
"Trying to access Networkmap deletion"); "Trying to access Networkmap deletion");
echo json_encode(-1); echo json_encode(-1);
return; return;
} }
$result = false;
$results = array();
$ids_networkmap = (array) get_parameter ('ids_networkmap');
foreach ($ids_networkmap as $id) {
$results[$id] = (bool) networkmap_delete_networkmap($id);
}
echo json_encode($results);
return;
} }
return; return;
@ -67,7 +80,13 @@ $id_networkmap = get_parameter ('id_networkmap', 0);
$delete_networkmap = get_parameter ('delete_networkmap', 0); $delete_networkmap = get_parameter ('delete_networkmap', 0);
if ($delete_networkmap) { if ($delete_networkmap) {
$result = networkmap_delete_networkmap($id_networkmap); if (check_acl ($config['id_user'], 0, "RW")) {
$result = networkmap_delete_user_networkmap($config['id_user'], $id_networkmap);
}else{
if (check_acl ($config['id_user'], 0, "RM")) {
$result = networkmap_delete_networkmap($id_networkmap);
}
}
$message = ui_print_result_message ($result, $message = ui_print_result_message ($result,
__('Network map deleted successfully'), __('Network map deleted successfully'),
__('Could not delete network map'), '', true); __('Could not delete network map'), '', true);
@ -132,7 +151,7 @@ $table->size[0] = '80%';
$table->size[1] = '60px'; $table->size[1] = '60px';
$table->size[2] = '30px'; $table->size[2] = '30px';
if (check_acl ($config["id_user"], 0, "AW")) { if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) {
$table->size[3] = '30px'; $table->size[3] = '30px';
$table->size[4] = '30px'; $table->size[4] = '30px';
} }
@ -141,7 +160,7 @@ $table->head = array();
$table->head[0] = __('Name'); $table->head[0] = __('Name');
$table->head[1] = __('Type'); $table->head[1] = __('Type');
$table->head[2] = __('Group'); $table->head[2] = __('Group');
if (check_acl ($config["id_user"], 0, "AW")) { if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) {
$table->head[3] = __('Edit'); $table->head[3] = __('Edit');
$table->head[4] = __('Delete'); $table->head[4] = __('Delete');
// Checkbox to select all the another checkboxes // Checkbox to select all the another checkboxes
@ -187,7 +206,7 @@ else {
$data[1] = $network_map['type']; $data[1] = $network_map['type'];
$data[2] = ui_print_group_icon ($network_map['id_group'], true); $data[2] = ui_print_group_icon ($network_map['id_group'], true);
if (check_acl ($config["id_user"], 0, "AW")) { if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) {
$data[3] = '<a href="index.php?sec=network&sec2=operation/agentes/networkmap&tab=edit&edit_networkmap=1&id_networkmap=' . $network_map['id_networkmap'] . '" alt="' . __('Config') . '">' . html_print_image("images/config.png", true) . '</a>'; $data[3] = '<a href="index.php?sec=network&sec2=operation/agentes/networkmap&tab=edit&edit_networkmap=1&id_networkmap=' . $network_map['id_networkmap'] . '" alt="' . __('Config') . '">' . html_print_image("images/config.png", true) . '</a>';
$data[4] = '<a href="index.php?sec=network&sec2=operation/agentes/networkmap_list&delete_networkmap=1&id_networkmap=' . $network_map['id_networkmap'] . '" alt="' . __('Delete') . '" onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' . html_print_image('images/cross.png', true) . '</a>'; $data[4] = '<a href="index.php?sec=network&sec2=operation/agentes/networkmap_list&delete_networkmap=1&id_networkmap=' . $network_map['id_networkmap'] . '" alt="' . __('Delete') . '" onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' . html_print_image('images/cross.png', true) . '</a>';
// The value of the checkbox will be the networkmap id to recover it in js to perform the massive deletion // The value of the checkbox will be the networkmap id to recover it in js to perform the massive deletion
@ -201,7 +220,7 @@ else {
} }
// Create networkmap form // Create networkmap form
if (check_acl ($config['id_user'], 0, "AW")) { if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) {
$table_manage = new StdClass(); $table_manage = new StdClass();
$table_manage->width = "100%"; $table_manage->width = "100%";
$table_manage->style = array(); $table_manage->style = array();
@ -349,4 +368,4 @@ if (check_acl ($config['id_user'], 0, "AW")) {
} }
} }
</script> </script>

View File

@ -907,6 +907,10 @@ if (! defined ('METACONSOLE')) {
'<a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=module_name&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleNameDown, "alt" => "down")) . '</a>'; '<a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=module_name&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleNameDown, "alt" => "down")) . '</a>';
} }
/*
$table->head[4] = __('Tags');
*/
$table->head[5] = __('Interval'); $table->head[5] = __('Interval');
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
$table->head[5] .= ' <a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=interval&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '</a>' . $table->head[5] .= ' <a href="index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=' . $refr . '&amp;offset=' . $offset . '&amp;ag_group=' . $ag_group . '&amp;ag_freestring=' . $ag_freestring . '&amp;ag_modulename=' . $ag_modulename . '&amp;status=' . $status . $ag_custom_fields_params . '&amp;sort_field=interval&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '</a>' .

View File

@ -32,6 +32,7 @@ if (! check_acl ($config['id_user'], 0, "AR")) {
} }
$is_admin = check_acl ($config['id_user'], 0, "PM"); $is_admin = check_acl ($config['id_user'], 0, "PM");
$user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$force_refresh = get_parameter ("force_refresh", ""); $force_refresh = get_parameter ("force_refresh", "");
if ($force_refresh == 1) { if ($force_refresh == 1) {
@ -49,10 +50,69 @@ else {
// Header // Header
ui_print_page_header (__("Tactical view"), "images/op_monitoring.png", false, "", false, $updated_time); ui_print_page_header (__("Tactical view"), "images/op_monitoring.png", false, "", false, $updated_time);
$data = reporting_get_group_stats();
if (tags_has_user_acl_tags()) { $all_data = group_get_groups_list($config['id_user'], $user_strict, 'AR', true, false, 'tactical');
ui_print_tags_warning();
$data = array();
$data['monitor_checks'] = 0;
$data['monitor_not_init'] = 0;
$data['monitor_unknown'] = 0;
$data['monitor_ok'] = 0;
$data['monitor_bad'] = 0;
$data['monitor_warning'] = 0;
$data['monitor_critical'] = 0;
$data['monitor_not_normal'] = 0;
$data['monitor_alerts'] = 0;
$data['monitor_alerts_fired'] = 0;
$data['monitor_alerts_fire_count'] = 0;
$data['total_agents'] = 0;
$data['total_alerts'] = 0;
$data['total_checks'] = 0;
$data['alerts'] = 0;
$data['agents_unknown'] = 0;
$data['monitor_health'] = 0;
$data['alert_level'] = 0;
$data['module_sanity'] = 0;
$data['server_sanity'] = 0;
$data['agent_ok'] = 0;
$data['agent_warning'] = 0;
$data['agent_critical'] = 0;
$data['agent_unknown'] = 0;
$data['agent_not_init'] = 0;
$data['global_health'] = 0;
foreach ($all_data as $item) {
$data['monitor_checks'] += $item['_monitor_checks_'];
$data['monitor_not_init'] += $item['_monitors_not_init_'];
$data['monitor_unknown'] += $item['_monitors_unknown_'];
$data['monitor_ok'] += $item['_monitors_ok_'];
$data['monitor_bad'] += $item['_monitor_bad_'];
$data['monitor_warning'] += $item['_monitors_warning_'];
$data['monitor_critical'] += $item['_monitors_critical_'];
$data['monitor_not_normal'] += $item['_monitor_not_normal_'];
$data['monitor_alerts'] += $item['_monitors_alerts_'];
$data['monitor_alerts_fired'] += $item['_monitors_alerts_fired_'];
if (isset($item['_total_agents_']))
$data['total_agents'] += $item['_total_agents_'];
if (isset($item['_total_alerts_']))
$data['total_alerts'] += $item['_total_alerts_'];
if (isset($item['_total_checks_']))
$data['total_checks'] += $item['_total_checks_'];
$data['alerts'] += $item['_alerts_'];
$data['agents_unknown'] += $item['_agents_unknown_'];
$data['monitor_health'] += $item['_monitor_health_'];
$data['alert_level'] += $item['_alert_level_'];
$data['module_sanity'] += $item['_module_sanity_'];
$data['server_sanity'] += $item['_server_sanity_'];
$data['agent_ok'] += $item['_agents_ok_'];
$data['agent_warning'] += $item['_agents_warning_'];
$data['agent_critical'] += $item['_agents_critical_'];
$data['agent_unknown'] += $item['_agents_unknown_'];
$data['agent_not_init'] += $item['_agents_not_init_'];
$data['global_health'] += $item['_global_health_'];
} }
echo '<table border=0 style="width:100%;"><tr>'; echo '<table border=0 style="width:100%;"><tr>';
@ -123,9 +183,11 @@ echo '<td style="vertical-align: top; width: 75%; padding-top: 0px;" id="rightco
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Last events information // Last events information
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND');
events_print_event_table ("estado<>1 $tags_condition", 10, "100%"); $acltags = tags_get_user_module_and_tags ($config['id_user'], $access = 'ER', $user_strict);
$tags_condition = tags_get_acl_tags_event_condition($acltags, false, $user_strict);
events_print_event_table ("estado<>1 AND ($tags_condition)", 10, "100%");
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Server information // Server information
@ -138,4 +200,4 @@ if ($is_admin) {
echo '</td>'; echo '</td>';
echo '</tr></table>'; echo '</tr></table>';
?> ?>

View File

@ -230,11 +230,12 @@ if (is_ajax ()) {
} }
$less = $lessBranchs; $less = $lessBranchs;
$tree_img_id = "tree_image" . $id . "_agent_" . $type . "_" . $row["server_name"] . "_" . $row["id_agente"];
if ($count != $countRows) if ($count != $countRows)
$img = html_print_image ("operation/tree/closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image" . $id . "_agent_" . $type . "_" . $row["id_agente"], "pos_tree" => "2")); $img = html_print_image ("operation/tree/closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "2"));
else { else {
$less = $less + 2; // $less = $less or 0b10 $less = $less + 2; // $less = $less or 0b10
$img = html_print_image ("operation/tree/last_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image" . $id . "_agent_" . $type . "_" . $row["id_agente"], "pos_tree" => "3")); $img = html_print_image ("operation/tree/last_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => $tree_img_id, "pos_tree" => "3"));
} }
echo "<li style='margin: 0; padding: 0;'>"; echo "<li style='margin: 0; padding: 0;'>";
echo "<a onfocus='JavaScript: this.blur()' echo "<a onfocus='JavaScript: this.blur()'
@ -268,7 +269,7 @@ if (is_ajax ()) {
html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => "")); html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => ""));
} }
echo "</a>"; echo "</a>";
echo "<div hiddenDiv='1' loadDiv='0' style='margin: 0px; padding: 0px;' class='tree_view' id='tree_div" . $id . "_agent_" . $type . "_" . $row["id_agente"] . "'></div>"; echo "<div hiddenDiv='1' loadDiv='0' style='margin: 0px; padding: 0px;' class='tree_view' id='tree_div" . $id . "_agent_" . $type . "_" . $row["server_name"] . "_" . $row["id_agente"] . "'></div>";
echo "</li>"; echo "</li>";
} }
@ -708,13 +709,11 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
* id_father int use in js and ajax php, its useful when you have a two subtrees with same agent for diferent each one * id_father int use in js and ajax php, its useful when you have a two subtrees with same agent for diferent each one
*/ */
function loadSubTree(type, div_id, less_branchs, id_father, server_name) { function loadSubTree(type, div_id, less_branchs, id_father, server_name) {
hiddenDiv = $('#tree_div' + id_father + '_' + type + '_' + div_id) var id = id_father + '_' + type + '_' + server_name + '_' + div_id;
.attr('hiddenDiv'); var hiddenDiv = $('#tree_div' + id).attr('hiddenDiv');
loadDiv = $('#tree_div' + id_father + '_' + type + '_' + div_id) var loadDiv = $('#tree_div' + id).attr('loadDiv');
.attr('loadDiv');
pos = parseInt($('#tree_image' + id_father + '_' + type + '_' + div_id) var pos = parseInt($('#tree_image' + id).attr('pos_tree'));
.attr('pos_tree'));
//If has yet ajax request running //If has yet ajax request running
if (loadDiv == 2) if (loadDiv == 2)
@ -723,12 +722,12 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
if (loadDiv == 0) { if (loadDiv == 0) {
//Put an spinner to simulate loading process //Put an spinner to simulate loading process
$('#tree_div' + id_father + '_' + type + '_' + div_id) $('#tree_div' + id)
.html("<img style='padding-top:10px;padding-bottom:10px;padding-left:20px;' src=images/spinner.gif>"); .html("<img style='padding-top:10px;padding-bottom:10px;padding-left:20px;' src=images/spinner.gif>");
$('#tree_div' + id_father + '_' + type + '_' + div_id) $('#tree_div' + id)
.show('normal'); .show('normal');
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 2); $('#tree_div'+id).attr('loadDiv', 2);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: <?php echo '"' . ui_get_full_url("ajax.php", false, false, false) . '"'; ?>, url: <?php echo '"' . ui_get_full_url("ajax.php", false, false, false) . '"'; ?>,
@ -745,9 +744,9 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
}, },
success: function(msg) { success: function(msg) {
if (msg.length != 0) { if (msg.length != 0) {
$('#tree_div'+id_father+'_'+type+'_'+div_id).hide(); $('#tree_div'+id).hide();
$('#tree_div'+id_father+'_'+type+'_'+div_id).html(msg); $('#tree_div'+id).html(msg);
$('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal'); $('#tree_div'+id).show('normal');
//change image of tree [+] to [-] //change image of tree [+] to [-]
<?php if (! defined ('METACONSOLE')) { <?php if (! defined ('METACONSOLE')) {
@ -759,20 +758,20 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
?> ?>
switch (pos) { switch (pos) {
case 0: case 0:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/first_expanded.png'); $('#tree_image'+id).attr('src',icon_path+'/first_expanded.png');
break; break;
case 1: case 1:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/one_expanded.png'); $('#tree_image'+id).attr('src',icon_path+'/one_expanded.png');
break; break;
case 2: case 2:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/expanded.png'); $('#tree_image'+id).attr('src',icon_path+'/expanded.png');
break; break;
case 3: case 3:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/last_expanded.png'); $('#tree_image'+id).attr('src',icon_path+'/last_expanded.png');
break; break;
} }
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddendiv',0); $('#tree_div'+id).attr('hiddendiv',0);
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 1); $('#tree_div'+id).attr('loadDiv', 1);
} }
// Refresh forced title callback to work with html code created dinamicly // Refresh forced title callback to work with html code created dinamicly
@ -790,22 +789,22 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
} }
?> ?>
if (hiddenDiv == 0) { if (hiddenDiv == 0) {
$('#tree_div'+id_father+'_'+type+'_'+div_id).hide('normal'); $('#tree_div'+id).hide('normal');
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv',1); $('#tree_div'+id).attr('hiddenDiv',1);
//change image of tree [-] to [+] //change image of tree [-] to [+]
switch (pos) { switch (pos) {
case 0: case 0:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/first_closed.png'); $('#tree_image'+id).attr('src',icon_path+'/first_closed.png');
break; break;
case 1: case 1:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/one_closed.png'); $('#tree_image'+id).attr('src',icon_path+'/one_closed.png');
break; break;
case 2: case 2:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/closed.png'); $('#tree_image'+id).attr('src',icon_path+'/closed.png');
break; break;
case 3: case 3:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/last_closed.png'); $('#tree_image'+id).attr('src',icon_path+'/last_closed.png');
break; break;
} }
} }
@ -813,21 +812,21 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
//change image of tree [+] to [-] //change image of tree [+] to [-]
switch (pos) { switch (pos) {
case 0: case 0:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/first_expanded.png'); $('#tree_image'+id).attr('src',icon_path+'/first_expanded.png');
break; break;
case 1: case 1:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/one_expanded.png'); $('#tree_image'+id).attr('src',icon_path+'/one_expanded.png');
break; break;
case 2: case 2:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/expanded.png'); $('#tree_image'+id).attr('src',icon_path+'/expanded.png');
break; break;
case 3: case 3:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src',icon_path+'/last_expanded.png'); $('#tree_image'+id).attr('src',icon_path+'/last_expanded.png');
break; break;
} }
$('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal'); $('#tree_div'+id).show('normal');
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv',0); $('#tree_div'+id).attr('hiddenDiv',0);
} }
} }
} }

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 6.0dev %define version 6.0dev
%define release 150108 %define release 150116
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 6.0dev %define version 6.0dev
%define release 150108 %define release 150116
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -1029,7 +1029,7 @@ CREATE TABLE tusuario (
metaconsole_agents_manager NUMBER(10, 0) default 0 NOT NULL, metaconsole_agents_manager NUMBER(10, 0) default 0 NOT NULL,
metaconsole_assigned_server NUMBER(10, 0) default 0 NOT NULL, metaconsole_assigned_server NUMBER(10, 0) default 0 NOT NULL,
metaconsole_access_node NUMBER(10, 0) default 0 NOT NULL, metaconsole_access_node NUMBER(10, 0) default 0 NOT NULL,
strict_acl NUMBER(5,0) unsigned NOT NULL DEFAULT 0, strict_acl NUMBER(5,0) NOT NULL DEFAULT 0,
CONSTRAINT t_usuario_metaconsole_access_cons CHECK (metaconsole_access IN ('basic','advanced')) CONSTRAINT t_usuario_metaconsole_access_cons CHECK (metaconsole_access IN ('basic','advanced'))
); );

View File

@ -911,7 +911,7 @@ CREATE TABLE "tusuario" (
"metaconsole_assigned_server" INTEGER NOT NULL default 0, "metaconsole_assigned_server" INTEGER NOT NULL default 0,
"metaconsole_access_node" SMALLINT DEFAULT 0, "metaconsole_access_node" SMALLINT DEFAULT 0,
"metaconsole_access" type_tusuario_metaconsole_access default 'basic', "metaconsole_access" type_tusuario_metaconsole_access default 'basic',
"strict_acl" SMALLINT NOT NULL default 0 "strict_acl" SMALLINT DEFAULT 0
); );
-- ----------------------------------------------------- -- -----------------------------------------------------

View File

@ -38,7 +38,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('graph_res','5'), ('graph_res','5'),
('step_compact','1'), ('step_compact','1'),
('db_scheme_version','6.0dev'), ('db_scheme_version','6.0dev'),
('db_scheme_build','PD150108'), ('db_scheme_build','PD150116'),
('show_unknown','0'), ('show_unknown','0'),
('show_lastalerts','1'), ('show_lastalerts','1'),
('style','pandora'), ('style','pandora'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 6.0dev-150108 Version: 6.0dev-150116
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="6.0dev-150108" pandora_version="6.0dev-150116"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -264,88 +264,95 @@ sub pandora_server_tasks ($) {
my $counter = 0; my $counter = 0;
while ($RUN == 1) { while ($RUN == 1) {
eval{ eval{
# TASKS EXECUTED EVERY 5 SECONDS (Low latency tasks) if (pandora_is_master($pa_config) == 1) {
# --------------------------------------------------
if (($counter % 5) == 0) {
# Update forced alerts
pandora_exec_forced_alerts ($pa_config, $dbh);
# Rotate Log File # TASKS EXECUTED EVERY 5 SECONDS (Low latency tasks)
pandora_rotate_logfile($pa_config); # --------------------------------------------------
} if (($counter % 5) == 0) {
# TASKS EXECUTED EVERY 30 SECONDS (Mid latency tasks) # Update forced alerts
# --------------------------------------------------- pandora_exec_forced_alerts ($pa_config, $dbh);
if (($counter % 30) == 0) {
# Update module status and fired alert counts # Rotate Log File
my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count FROM tagente WHERE disabled = 0 AND (update_module_count=1 OR update_alert_count=1)'); pandora_rotate_logfile($pa_config);
foreach my $agent (@agents) {
logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10);
if ($agent->{'update_module_count'} == 1) {
pandora_update_agent_module_count ($dbh, $agent->{'id_agente'});
}
if ($agent->{'update_alert_count'} == 1) {
pandora_update_agent_alert_count ($dbh, $agent->{'id_agente'});
}
}
# Keepalive module control.(very DB intensive, not run frecuently
pandora_module_keep_alive_nd ($pa_config, $dbh);
# Set the status of unknown modules
pandora_module_unknown ($pa_config, $dbh);
# Set event storm protection
pandora_set_event_storm_protection (pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0));
}
# TASKS EXECUTED EVERY 60 SECONDS (High latency tasks)
# ----------------------------------------------------
if (($counter % 60) == 0) {
# Downtimes are executed only 30 x Server Threshold secs
pandora_planned_downtime ($pa_config, $dbh);
# Realtime stats (Only master server!) - ( VERY HEAVY !)
# Realtimestats == 1, generated by WEB Console, not by server!
if (defined($pa_config->{"realtimestats"}) && $pa_config->{"realtimestats"} == 0){
# Check if I need to refresh stats
my $last_execution_stats = get_db_value ($dbh, "SELECT MAX(utimestamp) FROM tgroup_stat");
if (!defined($last_execution_stats) || $last_execution_stats < (time() - $pa_config->{"stats_interval"})){
pandora_group_statistics ($pa_config, $dbh);
pandora_server_statistics ($pa_config, $dbh);
}
} }
# Event auto-expiry # TASKS EXECUTED EVERY 30 SECONDS (Mid latency tasks)
my $expiry_time = $pa_config->{"event_expiry_time"}; # ---------------------------------------------------
my $expiry_window = $pa_config->{"event_expiry_window"}; if (($counter % 30) == 0) {
if ($expiry_time > 0 && $expiry_window > 0 && $expiry_window > $expiry_time) {
my $time_ref = time ();
my $expiry_limit = $time_ref - $expiry_time;
my $expiry_window = $time_ref - $expiry_window;
db_do ($dbh, 'UPDATE tevento SET estado=1, ack_utimestamp=? WHERE estado=0 AND utimestamp < ? AND utimestamp > ?', $time_ref, $expiry_limit, $expiry_window);
}
}
# Pandora self monitoring
if (defined($pa_config->{"self_monitoring"})
&& $pa_config->{"self_monitoring"} == 1
&& $counter % $pa_config->{'self_monitoring_interval'} == 0) {
pandora_self_monitoring ($pa_config, $dbh);
}
# Avoid counter overflow # Update module status and fired alert counts
if ($counter > 10000){ my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count FROM tagente WHERE disabled = 0 AND (update_module_count=1 OR update_alert_count=1)');
$counter = 0; foreach my $agent (@agents) {
logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10);
if ($agent->{'update_module_count'} == 1) {
pandora_update_agent_module_count ($dbh, $agent->{'id_agente'});
}
if ($agent->{'update_alert_count'} == 1) {
pandora_update_agent_alert_count ($dbh, $agent->{'id_agente'});
}
}
# Keepalive module control.(very DB intensive, not run frecuently
pandora_module_keep_alive_nd ($pa_config, $dbh);
# Set the status of unknown modules
pandora_module_unknown ($pa_config, $dbh);
# Set event storm protection
pandora_set_event_storm_protection (pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0));
}
# TASKS EXECUTED EVERY 60 SECONDS (High latency tasks)
# ----------------------------------------------------
if (($counter % 60) == 0) {
# Downtimes are executed only 30 x Server Threshold secs
pandora_planned_downtime ($pa_config, $dbh);
# Realtime stats (Only master server!) - ( VERY HEAVY !)
# Realtimestats == 1, generated by WEB Console, not by server!
if (defined($pa_config->{"realtimestats"}) && $pa_config->{"realtimestats"} == 0){
# Check if I need to refresh stats
my $last_execution_stats = get_db_value ($dbh, "SELECT MAX(utimestamp) FROM tgroup_stat");
if (!defined($last_execution_stats) || $last_execution_stats < (time() - $pa_config->{"stats_interval"})){
pandora_group_statistics ($pa_config, $dbh);
pandora_server_statistics ($pa_config, $dbh);
}
}
# Event auto-expiry
my $expiry_time = $pa_config->{"event_expiry_time"};
my $expiry_window = $pa_config->{"event_expiry_window"};
if ($expiry_time > 0 && $expiry_window > 0 && $expiry_window > $expiry_time) {
my $time_ref = time ();
my $expiry_limit = $time_ref - $expiry_time;
my $expiry_window = $time_ref - $expiry_window;
db_do ($dbh, 'UPDATE tevento SET estado=1, ack_utimestamp=? WHERE estado=0 AND utimestamp < ? AND utimestamp > ?', $time_ref, $expiry_limit, $expiry_window);
}
}
# Pandora self monitoring
if (defined($pa_config->{"self_monitoring"})
&& $pa_config->{"self_monitoring"} == 1
&& $counter % $pa_config->{'self_monitoring_interval'} == 0) {
pandora_self_monitoring ($pa_config, $dbh);
}
# Avoid counter overflow
if ($counter > 10000){
$counter = 0;
}
else {
$counter++;
}
} }
else { else {
$counter++; # Do an additional sleep if we are not the master server
sleep ($pa_config->{'server_threshold'});
} }
}; };
@ -518,7 +525,7 @@ sub main() {
pandora_startup (); pandora_startup ();
# Start thread to execute server tasks on the master server # Start thread to execute server tasks on the master server
threads->create('pandora_server_tasks', (\%Config))->detach() if ($Config{"pandora_master"} == 1); threads->create('pandora_server_tasks', (\%Config))->detach();
# Generate 'going up' events # Generate 'going up' events
foreach my $server (@Servers) { foreach my $server (@Servers) {
@ -568,9 +575,11 @@ sub main() {
$server->update(); $server->update();
} }
# Not needed. The console assumes a server is down if it has not updated its status in the last 15 minutes. # Update fallen servers
## Update fallen servers db_do ($DBH, "UPDATE tserver SET status = 0 WHERE keepalive < ?", strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - $Config{'keepalive'})));
#db_do ($DBH, "UPDATE tserver SET status = 0 WHERE keepalive < ?", strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - $Config{'keepalive'})));
# Set the master server
pandora_set_master(\%Config, $DBH);
}; };
# Restart on error or auto restart # Restart on error or auto restart

View File

@ -78,8 +78,9 @@ dbhost 127.0.0.1
verbosity 3 verbosity 3
# Master Server, 1 if master server (normal mode), 0 for slave mode (slave in multi-server setup) # Master Server priority. The running server with the highest master value will
# be the master. Ties are broken at random. If set to 0, this server will
# never become master.
master 1 master 1
# Activate Pandora SNMP console (depending on snmptrapd) # Activate Pandora SNMP console (depending on snmptrapd)
@ -249,7 +250,7 @@ xprobe2 /usr/bin/xprobe2
nmap /usr/bin/nmap nmap /usr/bin/nmap
# Path to the fping binary. Used by the Enterprise ICMP Server. # Path to the fping binary. Used by the Enterprise ICMP Server.
fping /usr/bin/fping fping /usr/sbin/fping
# A value that specifies how aggressive nmap should be from 1 to 5. 1 means slower but more reliable, 5 means faster but less reliable. 2 by default. # A value that specifies how aggressive nmap should be from 1 to 5. 1 means slower but more reliable, 5 means faster but less reliable. 2 by default.
nmap_timing_template 2 nmap_timing_template 2

View File

@ -43,7 +43,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "6.0dev"; my $pandora_version = "6.0dev";
my $pandora_build = "150108"; my $pandora_build = "150116";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash
@ -850,8 +850,8 @@ sub pandora_load_config {
if ($pa_config->{"pandora_check"} == 1) { if ($pa_config->{"pandora_check"} == 1) {
print " [*] MD5 Security enabled.\n"; print " [*] MD5 Security enabled.\n";
} }
if ($pa_config->{"pandora_master"} == 1) { if ($pa_config->{"pandora_master"} != 0) {
print " [*] This server is running in MASTER mode.\n"; print " [*] This server is running with MASTER priority " . $pa_config->{"pandora_master"} . "\n";
} }
} }

View File

@ -165,6 +165,7 @@ our @EXPORT = qw(
pandora_get_module_phone_tags pandora_get_module_phone_tags
pandora_get_module_email_tags pandora_get_module_email_tags
pandora_get_os pandora_get_os
pandora_is_master
pandora_mark_agent_for_alert_update pandora_mark_agent_for_alert_update
pandora_mark_agent_for_module_update pandora_mark_agent_for_module_update
pandora_module_keep_alive pandora_module_keep_alive
@ -189,6 +190,7 @@ our @EXPORT = qw(
pandora_reset_server pandora_reset_server
pandora_server_keep_alive pandora_server_keep_alive
pandora_set_event_storm_protection pandora_set_event_storm_protection
pandora_set_master
pandora_update_agent pandora_update_agent
pandora_update_agent_address pandora_update_agent_address
pandora_update_agent_alert_count pandora_update_agent_alert_count
@ -225,6 +227,9 @@ our @AlertStatus = ('Execute the alert', 'Do not execute the alert', 'Do not exe
# Event storm protection (no alerts or events) # Event storm protection (no alerts or events)
our $EventStormProtection :shared = 0; our $EventStormProtection :shared = 0;
# Current master server
my $Master :shared = 0;
########################################################################## ##########################################################################
# Return the agent given the IP address. # Return the agent given the IP address.
########################################################################## ##########################################################################
@ -4221,6 +4226,43 @@ sub pandora_self_monitoring ($$) {
close (XMLFILE); close (XMLFILE);
} }
##########################################################################
=head2 C<< set_master (I<$pa_config>, I<$dbh>) >>
Set the current master server.
=cut
##########################################################################
sub pandora_set_master ($$) {
my ($pa_config, $dbh) = @_;
my $current_master = get_db_value ($dbh, 'SELECT name FROM tserver
WHERE master <> 0 AND status = 1
ORDER BY master DESC LIMIT 1');
return unless defined($current_master) and ($current_master ne $Master);
logger($pa_config, "Server $current_master is the current master.", 1);
$Master = $current_master;
}
##########################################################################
=head2 C<< is_master (I<$pa_config>) >>
Returns 1 if this server is the current master, 0 otherwise.
=cut
##########################################################################
sub pandora_is_master ($) {
my ($pa_config) = @_;
if ($Master eq $pa_config->{'servername'}) {
return 1;
}
return 0;
}
########################################################################## ##########################################################################
=head2 C<< pandora_module_unknown (I<$pa_config>, I<$dbh>) >> =head2 C<< pandora_module_unknown (I<$pa_config>, I<$dbh>) >>

View File

@ -96,7 +96,7 @@ sub data_producer ($) {
my @rows; my @rows;
my $network_filter = enterprise_hook ('get_network_filter', [$pa_config]); my $network_filter = enterprise_hook ('get_network_filter', [$pa_config]);
if ($pa_config->{'pandora_master'} == 0) { if (pandora_is_master($pa_config) == 0) {
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
FROM tagente, tagente_modulo, tagente_estado FROM tagente, tagente_modulo, tagente_estado
WHERE server_name = ? WHERE server_name = ?

View File

@ -96,7 +96,7 @@ sub data_producer ($) {
my @tasks; my @tasks;
my @rows; my @rows;
if ($pa_config->{'pandora_master'} != 1) { if (pandora_is_master($pa_config) == 0) {
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
FROM tagente, tagente_modulo, tagente_estado FROM tagente, tagente_modulo, tagente_estado
WHERE server_name = ? WHERE server_name = ?

View File

@ -92,7 +92,7 @@ sub data_producer ($) {
my @tasks; my @tasks;
my @rows; my @rows;
if ($pa_config->{'pandora_master'} != 1) { if (pandora_is_master($pa_config) == 0) {
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo,
tagente_modulo.flag, last_execution_try tagente_modulo.flag, last_execution_try
FROM tagente, tagente_modulo, tagente_estado FROM tagente, tagente_modulo, tagente_estado

View File

@ -94,7 +94,7 @@ sub data_producer ($) {
my @tasks; my @tasks;
my @rows; my @rows;
if ($pa_config->{'pandora_master'} != 1) { if (pandora_is_master($pa_config) == 0) {
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
FROM tagente, tagente_modulo, tagente_estado FROM tagente, tagente_modulo, tagente_estado
WHERE server_name = ? WHERE server_name = ?

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 6.0dev %define version 6.0dev
%define release 150108 %define release 150116
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 6.0dev %define version 6.0dev
%define release 150108 %define release 150116
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "6.0dev PS150108"; my $version = "6.0dev PS150116";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -34,7 +34,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "6.0dev PS150108"; my $version = "6.0dev PS150116";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -2997,7 +2997,7 @@ sub cli_get_agent_modules() {
exist_check($id_agent,'agent',$agent_name); exist_check($id_agent,'agent',$agent_name);
my $modules = pandora_get_agent_modules ($dbh, $id_agent); my $modules = pandora_get_agent_modules ($dbh, $id_agent);
if(scalar(@{$modules}) == 0) { if(scalar(@{$modules}) == 0) {
print_log "[INFO] The agent '$agent_name' have not modules\n\n"; print_log "[INFO] The agent '$agent_name' have not modules\n\n";
} }
@ -3008,49 +3008,56 @@ sub cli_get_agent_modules() {
} }
} }
############################################################################## ########################################################################
# Show all the modules of a policy # Show all the modules of a policy
# Related option: --get_policy_modules # Related option: --get_policy_modules
############################################################################## ########################################################################
sub cli_get_policy_modules() { sub cli_get_policy_modules() {
my $policy_name = @ARGV[2]; my $policy_name = @ARGV[2];
my $policy_id = enterprise_hook('get_policy_id',[$dbh, safe_input($policy_name)]); my $policy_id = enterprise_hook('get_policy_id',
exist_check($policy_id,'policy',$policy_name); [$dbh, safe_input($policy_name)]);
exist_check($policy_id, 'policy', $policy_name);
my $policy_modules = enterprise_hook('get_policy_modules',[$dbh, $policy_id]); my $policy_modules = enterprise_hook(
exist_check(scalar(@{$policy_modules})-1,'modules in policy',$policy_name); 'get_policy_modules', [$dbh, $policy_id]);
if (defined($policy_modules)) {
exist_check(scalar(@{$policy_modules}) - 1, 'modules in policy',
$policy_name);
}
print "id_policy_module, module_name\n"; print "id_policy_module, module_name\n";
foreach my $module (@{$policy_modules}) { foreach my $module (@{$policy_modules}) {
print $module->{'id'}.",".safe_output($module->{'name'})."\n"; print $module->{'id'} . "," . safe_output($module->{'name'}) . "\n";
} }
} }
############################################################################## ########################################################################
# Show all the policies (without parameters) or the policies of given agent # Show all the policies (without parameters) or the policies of given
# agent.
# Related option: --get_policies # Related option: --get_policies
############################################################################## ########################################################################
sub cli_get_policies() { sub cli_get_policies() {
my $agent_name = @ARGV[2]; my $agent_name = @ARGV[2];
my $policies; my $policies;
if(defined($agent_name)) { if (defined($agent_name)) {
my $id_agent = get_agent_id($dbh,$agent_name); my $id_agent = get_agent_id($dbh,$agent_name);
exist_check($id_agent,'agent',$agent_name); exist_check($id_agent,'agent',$agent_name);
$policies = enterprise_hook('get_agent_policies',[$dbh,$id_agent]); $policies = enterprise_hook('get_agent_policies', [$dbh,$id_agent]);
if(scalar(@{$policies}) == 0) { if (scalar(@{$policies}) == 0) {
print_log "[INFO] No policies found on agent '$agent_name'\n\n"; print_log "[INFO] No policies found on agent '$agent_name'\n\n";
exit; exit;
} }
} }
else { else {
$policies = enterprise_hook('get_policies',[$dbh]); $policies = enterprise_hook('get_policies', [$dbh]);
if(scalar(@{$policies}) == 0) { if (scalar(@{$policies}) == 0) {
print_log "[INFO] No policies found\n\n"; print_log "[INFO] No policies found\n\n";
exit; exit;
} }

View File

@ -14,7 +14,7 @@ if [ $# -lt 2 ]
then then
echo " " echo " "
echo "Syntax error: " echo "Syntax error: "
echo "SNMP Trap generator <# traps> <target ip> [<source_ip>]" echo "SNMP Trap generator use: ./snmptrap_gen.sh <# No traps> <target ip> [<source_ip>]"
echo "If <source_ip> is not provided, it will forge fake IP's" echo "If <source_ip> is not provided, it will forge fake IP's"
echo " " echo " "
exit -1 exit -1