2012-10-11 Miguel de Dios <miguel.dedios@artica.es>
* include/ajax/networkmap.ajax.php: added the code for the metaconsole in the call "get_networkmap_summary" and added the call "get_networkmap_summary_pandora_server" for the tooltips in the metaconsole networkmap in the pandoras children nodes. * include/functions_agents.php: improve the execution time and cleaned the code for the function "agents_get_modules". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7067 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
73bb12d30a
commit
55fe5262bc
|
@ -1,3 +1,13 @@
|
||||||
|
2012-10-11 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/ajax/networkmap.ajax.php: added the code for the
|
||||||
|
metaconsole in the call "get_networkmap_summary" and added the
|
||||||
|
call "get_networkmap_summary_pandora_server" for the tooltips in
|
||||||
|
the metaconsole networkmap in the pandoras children nodes.
|
||||||
|
|
||||||
|
* include/functions_agents.php: improve the execution time and
|
||||||
|
cleaned the code for the function "agents_get_modules".
|
||||||
|
|
||||||
2012-10-11 Junichi Satoh <junichi@rworks.jp>
|
2012-10-11 Junichi Satoh <junichi@rworks.jp>
|
||||||
|
|
||||||
* include/help/ja/help_response_parameters.php,
|
* include/help/ja/help_response_parameters.php,
|
||||||
|
|
|
@ -28,6 +28,9 @@ if (! check_acl ($config['id_user'], 0, "IR")) {
|
||||||
|
|
||||||
$action = get_parameter('action');
|
$action = get_parameter('action');
|
||||||
|
|
||||||
|
//error_reporting(E_ALL);
|
||||||
|
//ini_set("display_errors", 1);
|
||||||
|
|
||||||
switch($action) {
|
switch($action) {
|
||||||
case 'get_networkmap_summary':
|
case 'get_networkmap_summary':
|
||||||
$stats = get_parameter('stats', array());
|
$stats = get_parameter('stats', array());
|
||||||
|
@ -55,18 +58,45 @@ switch($action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($stats['agents'])) {
|
if (isset($stats['agents'])) {
|
||||||
|
if ($metaconsole) {
|
||||||
|
include_once ('include/functions_reporting.php');
|
||||||
|
|
||||||
|
$servers = db_get_all_rows_sql ("SELECT *
|
||||||
|
FROM tmetaconsole_setup");
|
||||||
|
if ($servers === false)
|
||||||
|
$servers = array();
|
||||||
|
|
||||||
|
$total_agents = 0;
|
||||||
|
|
||||||
|
foreach ($servers as $server) {
|
||||||
|
// If connection was good then retrieve all data server
|
||||||
|
if (metaconsole_load_external_db ($server)) {
|
||||||
|
$connection = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$connection = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($connection)
|
||||||
|
$data = reporting_get_group_stats();
|
||||||
|
|
||||||
|
metaconsole_restore_db();
|
||||||
|
|
||||||
|
$total_agents += $data["total_agents"];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$total_agents = format_numeric($total_agents);
|
||||||
|
|
||||||
|
$summary .= $total_agents .
|
||||||
|
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
||||||
|
' ' . __('Agents') . "<br>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
$summary .= count($stats['agents']) .
|
$summary .= count($stats['agents']) .
|
||||||
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
||||||
' ' . __('Agents') . "<br>";
|
' ' . __('Agents') . "<br>";
|
||||||
// TODO: GET STATUS OF THE AGENTS AND ADD IT TO SUMMARY
|
}
|
||||||
//~ $status_agents = array();
|
|
||||||
//~ foreach($stats['agents'] as $id_agent) {
|
|
||||||
//~ $st = agents_get_status($id_agent);
|
|
||||||
//~ if(!isset($status_agents[$st])) {
|
|
||||||
//~ $status_agents[$st] = 0;
|
|
||||||
//~ }
|
|
||||||
//~ $status_agents[$st] ++;
|
|
||||||
//~ }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($stats['modules'])) {
|
if (isset($stats['modules'])) {
|
||||||
|
@ -76,7 +106,62 @@ switch($action) {
|
||||||
|
|
||||||
echo '<h3>'.__('Map summary').'</h3><strong>'.$summary.'</strong>';
|
echo '<h3>'.__('Map summary').'</h3><strong>'.$summary.'</strong>';
|
||||||
break;
|
break;
|
||||||
|
case 'get_networkmap_summary_pandora_server':
|
||||||
|
$id_server = (int)get_parameter('id_server', 0);
|
||||||
|
$stats = get_parameter('stats', array());
|
||||||
|
$stats = json_decode(base64_decode($stats),true);
|
||||||
|
$metaconsole = (bool)get_parameter('metaconsole', false);
|
||||||
|
|
||||||
|
$hack_metaconsole = '';
|
||||||
|
if ($metaconsole) {
|
||||||
|
$hack_metaconsole = '../../';
|
||||||
|
}
|
||||||
|
|
||||||
|
$summary = '<br>';
|
||||||
|
|
||||||
|
if (isset($stats['agents'])) {
|
||||||
|
if ($metaconsole) {
|
||||||
|
include_once ('include/functions_reporting.php');
|
||||||
|
|
||||||
|
$servers = db_get_all_rows_sql ("SELECT *
|
||||||
|
FROM tmetaconsole_setup
|
||||||
|
WHERE id = " . $id_server);
|
||||||
|
if ($servers === false)
|
||||||
|
$servers = array();
|
||||||
|
|
||||||
|
$total_agents = 0;
|
||||||
|
|
||||||
|
foreach ($servers as $server) {
|
||||||
|
// If connection was good then retrieve all data server
|
||||||
|
if (metaconsole_load_external_db ($server)) {
|
||||||
|
$connection = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$connection = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($connection)
|
||||||
|
$data = reporting_get_group_stats();
|
||||||
|
|
||||||
|
metaconsole_restore_db();
|
||||||
|
|
||||||
|
$total_agents += $data["total_agents"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$total_agents = format_numeric($total_agents);
|
||||||
|
|
||||||
|
$summary .= $total_agents .
|
||||||
|
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
||||||
|
' ' . __('Agents') . "<br>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$summary .= count($stats['agents']) .
|
||||||
|
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
||||||
|
' ' . __('Agents') . "<br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '<h3>'.__('Map summary').'</h3><strong>'.$summary.'</strong>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -1097,19 +1097,20 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
|
||||||
function agents_get_modules ($id_agent = null, $details = false, $filter = false, $indexed = true, $get_not_init_modules = true, $noACLs = false) {
|
function agents_get_modules ($id_agent = null, $details = false, $filter = false, $indexed = true, $get_not_init_modules = true, $noACLs = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// TODO: Clean extra_sql
|
$userGroups = users_get_groups($config['id_user'], 'AR', false);
|
||||||
$policy_sql = '';
|
if (empty($userGroups)) {
|
||||||
|
|
||||||
if ($id_agent === null) {
|
|
||||||
//Extract the agents of group user.
|
|
||||||
$groups = users_get_groups(false, 'AR', false);
|
|
||||||
if(empty($groups)) {
|
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
$id_userGroups = $id_groups = array_keys($groups);
|
||||||
|
|
||||||
$id_groups = array_keys($groups);
|
// =================================================================
|
||||||
|
// When there is not a agent id. Get a agents of groups that the
|
||||||
$sql = "SELECT id_agente FROM tagente WHERE id_grupo IN (" . implode(',', $id_groups) . ")";
|
// user can read the agents.
|
||||||
|
// =================================================================
|
||||||
|
if ($id_agent === null) {
|
||||||
|
$sql = "SELECT id_agente
|
||||||
|
FROM tagente
|
||||||
|
WHERE id_grupo IN (" . implode(',', $id_groups) . ")";
|
||||||
$id_agent = db_get_all_rows_sql($sql);
|
$id_agent = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
if ($id_agent == false) {
|
if ($id_agent == false) {
|
||||||
|
@ -1123,18 +1124,13 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
||||||
$id_agent = $temp;
|
$id_agent = $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =================================================================
|
||||||
|
// Fixed strange values. Only array of ids or id as int
|
||||||
|
// =================================================================
|
||||||
if (!is_array($id_agent)) {
|
if (!is_array($id_agent)) {
|
||||||
$id_agent = safe_int ($id_agent, 1);
|
$id_agent = safe_int ($id_agent, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$userGroups = users_get_groups($config['id_user'], 'AR', false);
|
|
||||||
|
|
||||||
if(empty($userGroups)) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$id_userGroups = array_keys($userGroups);
|
|
||||||
|
|
||||||
$where = "(
|
$where = "(
|
||||||
1 = (
|
1 = (
|
||||||
SELECT is_admin
|
SELECT is_admin
|
||||||
|
@ -1158,7 +1154,6 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
||||||
FROM tperfil WHERE agent_view = 1
|
FROM tperfil WHERE agent_view = 1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
" . $policy_sql . "
|
|
||||||
)";
|
)";
|
||||||
|
|
||||||
if (! empty ($id_agent)) {
|
if (! empty ($id_agent)) {
|
||||||
|
|
Loading…
Reference in New Issue