mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
2013-02-19 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_api.php, include/functions_agents.php, include/functions_config.php, include/ajax/reporting.ajax.php, include/functions_snmp_browser.php, operation/agentes/status_monitor.php: improved code style. * include/functions_graph.php, include/graphs/fgraph.php, include/graphs/flot/jquery.flot.pie.js, include/graphs/flot/jquery.flot.pie.min.js, include/graphs/flot/pandora.flot.js, include/graphs/functions_flot.php: fixed the pie graphs, added the expanded version of flot pie js file with some changes for the last version of jQuery. Fixes: #3604555 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7675 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
064f322e3d
commit
43d7cac813
@ -1,3 +1,20 @@
|
|||||||
|
2013-02-19 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/functions_api.php, include/functions_agents.php,
|
||||||
|
include/functions_config.php, include/ajax/reporting.ajax.php,
|
||||||
|
include/functions_snmp_browser.php,
|
||||||
|
operation/agentes/status_monitor.php: improved code style.
|
||||||
|
|
||||||
|
* include/functions_graph.php, include/graphs/fgraph.php,
|
||||||
|
include/graphs/flot/jquery.flot.pie.js,
|
||||||
|
include/graphs/flot/jquery.flot.pie.min.js,
|
||||||
|
include/graphs/flot/pandora.flot.js,
|
||||||
|
include/graphs/functions_flot.php: fixed the pie graphs, added the
|
||||||
|
expanded version of flot pie js file with some changes for the
|
||||||
|
last version of jQuery.
|
||||||
|
|
||||||
|
Fixes: #3604555
|
||||||
|
|
||||||
2013-02-18 Sergio Martin <sergio.martin@artica.es>
|
2013-02-18 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* include/functions_html.php
|
* include/functions_html.php
|
||||||
|
@ -148,14 +148,14 @@ if ($get_metaconsole_hash_data) {
|
|||||||
$server = enterprise_hook('metaconsole_get_connection', array($server_name));
|
$server = enterprise_hook('metaconsole_get_connection', array($server_name));
|
||||||
|
|
||||||
// Bad data
|
// Bad data
|
||||||
if (empty($server)){
|
if (empty($server)) {
|
||||||
echo '';
|
echo '';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deserialization of auth_token
|
// Deserialization of auth_token
|
||||||
$auth_serialized = json_decode($server['auth_token'] ,true);
|
$auth_serialized = json_decode($server['auth_token'] ,true);
|
||||||
|
|
||||||
$auth_token = '';
|
$auth_token = '';
|
||||||
|
|
||||||
if (is_array($auth_serialized)) {
|
if (is_array($auth_serialized)) {
|
||||||
@ -163,7 +163,7 @@ if ($get_metaconsole_hash_data) {
|
|||||||
$api_password = $auth_serialized["api_password"];
|
$api_password = $auth_serialized["api_password"];
|
||||||
$console_user = $auth_serialized["console_user"];
|
$console_user = $auth_serialized["console_user"];
|
||||||
$console_password = $auth_serialized["console_password"];
|
$console_password = $auth_serialized["console_password"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$pwd = $auth_token; // Create HASH login info
|
$pwd = $auth_token; // Create HASH login info
|
||||||
$user = $config["id_user"];
|
$user = $config["id_user"];
|
||||||
|
@ -708,7 +708,7 @@ function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed
|
|||||||
} else {
|
} else {
|
||||||
$where .= $filter;
|
$where .= $filter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty ($id_agent)) {
|
if (! empty ($id_agent)) {
|
||||||
// Get module_name-template repetitions over agents selected
|
// Get module_name-template repetitions over agents selected
|
||||||
@ -724,7 +724,7 @@ function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed
|
|||||||
AND id_agente IN (%s) %s group by nombre, id_alert_template %s'
|
AND id_agente IN (%s) %s group by nombre, id_alert_template %s'
|
||||||
, implode (",", (array) $id_agent)
|
, implode (",", (array) $id_agent)
|
||||||
, $where
|
, $where
|
||||||
,$group_by);
|
,$group_by);
|
||||||
|
|
||||||
$result_tmp = db_get_all_rows_sql ($sql);
|
$result_tmp = db_get_all_rows_sql ($sql);
|
||||||
|
|
||||||
@ -732,27 +732,27 @@ function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed
|
|||||||
if ($result_tmp != false) {
|
if ($result_tmp != false) {
|
||||||
|
|
||||||
foreach ($result_tmp as $module_template) {
|
foreach ($result_tmp as $module_template) {
|
||||||
|
|
||||||
$sql_modules = sprintf ('SELECT t1.id_agente_modulo
|
$sql_modules = sprintf ('SELECT t1.id_agente_modulo
|
||||||
FROM tagente_modulo t1, talert_template_modules t2
|
FROM tagente_modulo t1, talert_template_modules t2
|
||||||
WHERE t1.id_agente_modulo = t2.id_agent_module
|
WHERE t1.id_agente_modulo = t2.id_agent_module
|
||||||
AND delete_pending = 0
|
AND delete_pending = 0
|
||||||
AND t1.nombre = \'%s\' AND t2.id_alert_template = %s'
|
AND t1.nombre = \'%s\' AND t2.id_alert_template = %s'
|
||||||
, $module_template['nombre']
|
, $module_template['nombre']
|
||||||
, $module_template['id_alert_template']);
|
, $module_template['id_alert_template']);
|
||||||
|
|
||||||
$id_modules_template = db_get_all_rows_sql ($sql_modules);
|
$id_modules_template = db_get_all_rows_sql ($sql_modules);
|
||||||
|
|
||||||
if ($id_modules_template != false)
|
if ($id_modules_template != false)
|
||||||
foreach ($id_modules_template as $id_module_template)
|
foreach ($id_modules_template as $id_module_template)
|
||||||
$result[] = $id_module_template;
|
$result[] = $id_module_template;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
$sql = sprintf ('SELECT DISTINCT(t1.id_agente_modulo)
|
$sql = sprintf ('SELECT DISTINCT(t1.id_agente_modulo)
|
||||||
FROM tagente_modulo t1, talert_template_modules t2
|
FROM tagente_modulo t1, talert_template_modules t2
|
||||||
%s
|
%s
|
||||||
@ -761,7 +761,7 @@ function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed
|
|||||||
$result = db_get_all_rows_sql ($sql);
|
$result = db_get_all_rows_sql ($sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty ($result)) {
|
if (empty ($result)) {
|
||||||
return array ();
|
return array ();
|
||||||
}
|
}
|
||||||
@ -947,10 +947,10 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
|
|||||||
$search_sql .= ' AND UPPER(nombre) LIKE UPPER(\'' . $name . '\') ';
|
$search_sql .= ' AND UPPER(nombre) LIKE UPPER(\'' . $name . '\') ';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unset ($search["name"]);
|
unset ($search["name"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty ($search)) {
|
if (! empty ($search)) {
|
||||||
$search_sql .= ' AND '.db_format_array_where_clause_sql ($search);
|
$search_sql .= ' AND '.db_format_array_where_clause_sql ($search);
|
||||||
}
|
}
|
||||||
@ -978,7 +978,7 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
|
|||||||
|
|
||||||
if ($result === false)
|
if ($result === false)
|
||||||
return array (); //Return an empty array
|
return array (); //Return an empty array
|
||||||
|
|
||||||
$agents = array ();
|
$agents = array ();
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
switch ($case) {
|
switch ($case) {
|
||||||
@ -1550,7 +1550,7 @@ function agents_get_addresses ($id_agent) {
|
|||||||
*/
|
*/
|
||||||
function agents_get_status_from_counts($agent) {
|
function agents_get_status_from_counts($agent) {
|
||||||
// Check if in the data there are all the necessary values
|
// Check if in the data there are all the necessary values
|
||||||
if(!isset($agent['normal_count']) &&
|
if (!isset($agent['normal_count']) &&
|
||||||
!isset($agent['warning_count']) &&
|
!isset($agent['warning_count']) &&
|
||||||
!isset($agent['critical_count']) &&
|
!isset($agent['critical_count']) &&
|
||||||
!isset($agent['unknown_count']) &&
|
!isset($agent['unknown_count']) &&
|
||||||
@ -1558,7 +1558,7 @@ function agents_get_status_from_counts($agent) {
|
|||||||
!isset($agent['total_count'])) {
|
!isset($agent['total_count'])) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($agent['critical_count'] > 0) {
|
if($agent['critical_count'] > 0) {
|
||||||
return AGENT_MODULE_STATUS_CRITICAL_BAD;
|
return AGENT_MODULE_STATUS_CRITICAL_BAD;
|
||||||
}
|
}
|
||||||
@ -1593,7 +1593,7 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
|
|||||||
if (!$noACLs) {
|
if (!$noACLs) {
|
||||||
$modules = agents_get_modules ($id_agent, 'id_agente_modulo', array('disabled' => 0), true, false);
|
$modules = agents_get_modules ($id_agent, 'id_agente_modulo', array('disabled' => 0), true, false);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$filter_modules['id_agente'] = $id_agent;
|
$filter_modules['id_agente'] = $id_agent;
|
||||||
$filter_modules['disabled'] = 0;
|
$filter_modules['disabled'] = 0;
|
||||||
$filter_modules['delete_pending'] = 0;
|
$filter_modules['delete_pending'] = 0;
|
||||||
@ -1612,7 +1612,7 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
|
|||||||
|
|
||||||
$modules_status = array();
|
$modules_status = array();
|
||||||
$modules_async = 0;
|
$modules_async = 0;
|
||||||
foreach($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
$modules_status[] = modules_get_agentmodule_status($module);
|
$modules_status[] = modules_get_agentmodule_status($module);
|
||||||
|
|
||||||
$module_type = modules_get_agentmodule_type($module);
|
$module_type = modules_get_agentmodule_type($module);
|
||||||
@ -1847,7 +1847,8 @@ function agents_get_count_incidents ($id_agent) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db_get_value('count(*)', 'tincidencia', 'id_agent', $id_agent);
|
return db_get_value('count(*)', 'tincidencia', 'id_agent',
|
||||||
|
$id_agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1864,7 +1865,9 @@ function agents_monitor_critical ($id_agent, $filter="") {
|
|||||||
$filter = " AND ".$filter;
|
$filter = " AND ".$filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db_get_sql ("SELECT critical_count FROM tagente WHERE id_agente = $id_agent" . $filter);
|
return db_get_sql ("SELECT critical_count
|
||||||
|
FROM tagente
|
||||||
|
WHERE id_agente = $id_agent" . $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get warning monitors by using the status code in modules.
|
// Get warning monitors by using the status code in modules.
|
||||||
@ -1875,7 +1878,9 @@ function agents_monitor_warning ($id_agent, $filter="") {
|
|||||||
$filter = " AND ".$filter;
|
$filter = " AND ".$filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db_get_sql ("SELECT warning_count FROM tagente WHERE id_agente = $id_agent" . $filter);
|
return db_get_sql ("SELECT warning_count
|
||||||
|
FROM tagente
|
||||||
|
WHERE id_agente = $id_agent" . $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get unknown monitors by using the status code in modules.
|
// Get unknown monitors by using the status code in modules.
|
||||||
@ -1886,7 +1891,9 @@ function agents_monitor_unknown ($id_agent, $filter="") {
|
|||||||
$filter = " AND ".$filter;
|
$filter = " AND ".$filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db_get_sql ("SELECT unknown_count FROM tagente WHERE id_agente = $id_agent" . $filter);
|
return db_get_sql ("SELECT unknown_count
|
||||||
|
FROM tagente
|
||||||
|
WHERE id_agente = $id_agent" . $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get ok monitors by using the status code in modules.
|
// Get ok monitors by using the status code in modules.
|
||||||
@ -1896,7 +1903,9 @@ function agents_monitor_ok ($id_agent, $filter="") {
|
|||||||
$filter = " AND ".$filter;
|
$filter = " AND ".$filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db_get_sql ("SELECT normal_count FROM tagente WHERE id_agente = $id_agent" . $filter);
|
return db_get_sql ("SELECT normal_count
|
||||||
|
FROM tagente
|
||||||
|
WHERE id_agente = $id_agent" . $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1912,8 +1921,13 @@ function agents_monitor_disabled ($id_agent, $filter="") {
|
|||||||
if ($filter) {
|
if ($filter) {
|
||||||
$filter = " AND ".$filter;
|
$filter = " AND ".$filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo WHERE tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 1 AND tagente.id_agente = $id_agent".$filter);
|
return db_get_sql("
|
||||||
|
SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo)
|
||||||
|
FROM tagente, tagente_modulo
|
||||||
|
WHERE tagente_modulo.id_agente = tagente.id_agente
|
||||||
|
AND tagente_modulo.disabled = 1
|
||||||
|
AND tagente.id_agente = $id_agent".$filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1929,8 +1943,10 @@ function agents_monitor_notinit ($id_agent, $filter="") {
|
|||||||
if (!empty($filter)) {
|
if (!empty($filter)) {
|
||||||
$filter = " AND ".$filter;
|
$filter = " AND ".$filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db_get_sql ("SELECT notinit_count FROM tagente WHERE id_agente = $id_agent" . $filter);
|
return db_get_sql ("SELECT notinit_count
|
||||||
|
FROM tagente
|
||||||
|
WHERE id_agente = $id_agent" . $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1986,36 +1986,36 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
function api_set_new_local_component($id, $thrash1, $other, $thrash2) {
|
function api_set_new_local_component($id, $thrash1, $other, $thrash2) {
|
||||||
|
|
||||||
if ($id == ""){
|
if ($id == "") {
|
||||||
returnError('error_set_new_local_component', __('Error creating local component. Local component name cannot be left blank.'));
|
returnError('error_set_new_local_component', __('Error creating local component. Local component name cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($other['data'][1] == ""){
|
if ($other['data'][1] == "") {
|
||||||
returnError('error_set_new_local_component', __('Error creating local component. Local component group cannot be left blank.'));
|
returnError('error_set_new_local_component', __('Error creating local component. Local component group cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = array (
|
$values = array (
|
||||||
'description' => $other['data'][0],
|
'description' => $other['data'][0],
|
||||||
'id_network_component_group' => $other['data'][1]
|
'id_network_component_group' => $other['data'][1]
|
||||||
);
|
);
|
||||||
|
|
||||||
$name_check = enterprise_hook('local_components_get_local_components', array(array('name' => $id), 'name'));
|
$name_check = enterprise_hook('local_components_get_local_components', array(array('name' => $id), 'name'));
|
||||||
|
|
||||||
if ($name_check === ENTERPRISE_NOT_HOOK) {
|
if ($name_check === ENTERPRISE_NOT_HOOK) {
|
||||||
returnError('error_set_new_local_component', __('Error creating local component.'));
|
returnError('error_set_new_local_component', __('Error creating local component.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name_check !== false){
|
if ($name_check !== false) {
|
||||||
returnError('error_set_new_local_component', __('Error creating local component. This local component already exists.'));
|
returnError('error_set_new_local_component', __('Error creating local component. This local component already exists.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = enterprise_hook('local_components_create_local_component', array($id, $other['data'][3], $other['data'][1], $values));
|
$id = enterprise_hook('local_components_create_local_component', array($id, $other['data'][3], $other['data'][1], $values));
|
||||||
|
|
||||||
if (!$id)
|
if (!$id)
|
||||||
returnError('error_set_new_local_component', 'Error creating local component.');
|
returnError('error_set_new_local_component', 'Error creating local component.');
|
||||||
else
|
else
|
||||||
@ -2036,24 +2036,24 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2) {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
function api_get_module_value_all_agents($id, $thrash1, $other, $thrash2) {
|
function api_get_module_value_all_agents($id, $thrash1, $other, $thrash2) {
|
||||||
|
|
||||||
if ($id == ""){
|
if ($id == "") {
|
||||||
returnError('error_get_module_value_all_agents', __('Error getting module value from all agents. Module name cannot be left blank.'));
|
returnError('error_get_module_value_all_agents', __('Error getting module value from all agents. Module name cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id_module = db_get_value ('id_agente_modulo', 'tagente_modulo', 'nombre', $id);
|
$id_module = db_get_value ('id_agente_modulo', 'tagente_modulo', 'nombre', $id);
|
||||||
|
|
||||||
if ($id_module === false){
|
if ($id_module === false) {
|
||||||
returnError('error_get_module_value_all_agents', __('Error getting module value from all agents. Module name doesn\'t exists.'));
|
returnError('error_get_module_value_all_agents', __('Error getting module value from all agents. Module name doesn\'t exists.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = sprintf("SELECT agent.id_agente, agent.nombre, module_state.datos FROM tagente agent, tagente_modulo module, tagente_estado module_state WHERE agent.id_agente = module.id_agente AND module.id_agente_modulo=module_state.id_agente_modulo AND module.nombre = '%s'", $id);
|
$sql = sprintf("SELECT agent.id_agente, agent.nombre, module_state.datos FROM tagente agent, tagente_modulo module, tagente_estado module_state WHERE agent.id_agente = module.id_agente AND module.id_agente_modulo=module_state.id_agente_modulo AND module.nombre = '%s'", $id);
|
||||||
|
|
||||||
$module_values = db_get_all_rows_sql($sql);
|
$module_values = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
if (!$module_values){
|
if (!$module_values) {
|
||||||
returnError('error_get_module_value_all_agents', 'Error getting module values from all agents.');
|
returnError('error_get_module_value_all_agents', 'Error getting module values from all agents.');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -2093,7 +2093,7 @@ function api_set_create_alert_template($name, $thrash1, $other, $thrash3) {
|
|||||||
|
|
||||||
$type = $other['data'][0];
|
$type = $other['data'][0];
|
||||||
|
|
||||||
if ($other['data'][2] != ""){
|
if ($other['data'][2] != "") {
|
||||||
$values = array(
|
$values = array(
|
||||||
'description' => $other['data'][1],
|
'description' => $other['data'][1],
|
||||||
'id_alert_action' => $other['data'][2],
|
'id_alert_action' => $other['data'][2],
|
||||||
@ -2119,10 +2119,11 @@ function api_set_create_alert_template($name, $thrash1, $other, $thrash3) {
|
|||||||
'recovery_notify' => $other['data'][22],
|
'recovery_notify' => $other['data'][22],
|
||||||
'field2_recovery' => $other['data'][23],
|
'field2_recovery' => $other['data'][23],
|
||||||
'field3_recovery' => $other['data'][24],
|
'field3_recovery' => $other['data'][24],
|
||||||
'priority' => $other['data'][25],
|
'priority' => $other['data'][25],
|
||||||
'id_group' => $other['data'][26]
|
'id_group' => $other['data'][26]
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$values = array(
|
$values = array(
|
||||||
'description' => $other['data'][1],
|
'description' => $other['data'][1],
|
||||||
'field1' => $other['data'][3],
|
'field1' => $other['data'][3],
|
||||||
@ -2147,9 +2148,9 @@ function api_set_create_alert_template($name, $thrash1, $other, $thrash3) {
|
|||||||
'recovery_notify' => $other['data'][22],
|
'recovery_notify' => $other['data'][22],
|
||||||
'field2_recovery' => $other['data'][23],
|
'field2_recovery' => $other['data'][23],
|
||||||
'field3_recovery' => $other['data'][24],
|
'field3_recovery' => $other['data'][24],
|
||||||
'priority' => $other['data'][25],
|
'priority' => $other['data'][25],
|
||||||
'id_group' => $other['data'][26]
|
'id_group' => $other['data'][26]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$id_template = alerts_create_alert_template($template_name, $type, $values);
|
$id_template = alerts_create_alert_template($template_name, $type, $values);
|
||||||
@ -2181,41 +2182,49 @@ function api_set_create_alert_template($name, $thrash1, $other, $thrash3) {
|
|||||||
* @param $thrash3 Don't use
|
* @param $thrash3 Don't use
|
||||||
*/
|
*/
|
||||||
function api_set_update_alert_template($id_template, $thrash1, $other, $thrash3) {
|
function api_set_update_alert_template($id_template, $thrash1, $other, $thrash3) {
|
||||||
|
|
||||||
if ($id_template == "") {
|
if ($id_template == "") {
|
||||||
returnError('error_update_alert_template', __('Error updating alert template. Id_template cannot be left blank.'));
|
returnError('error_update_alert_template',
|
||||||
|
__('Error updating alert template. Id_template cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result_template = alerts_get_alert_template_name($id_template);
|
$result_template = alerts_get_alert_template_name($id_template);
|
||||||
|
|
||||||
if (!$result_template){
|
if (!$result_template) {
|
||||||
returnError('error_update_alert_template', __('Error updating alert template. Id_template doesn\'t exists.'));
|
returnError('error_update_alert_template',
|
||||||
|
__('Error updating alert template. Id_template doesn\'t exists.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields_template = array('name', 'type', 'description', 'id_alert_action', 'field1', 'field2', 'field3', 'value', 'matches_value',
|
$fields_template = array('name', 'type', 'description',
|
||||||
'max_value', 'min_value', 'time_threshold', 'max_alerts', 'min_alerts', 'time_from', 'time_to',
|
'id_alert_action', 'field1', 'field2', 'field3', 'value',
|
||||||
'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'recovery_notify',
|
'matches_value', 'max_value', 'min_value', 'time_threshold',
|
||||||
'field2_recovery', 'field3_recovery', 'priority', 'id_group');
|
'max_alerts', 'min_alerts', 'time_from', 'time_to', 'monday',
|
||||||
|
'tuesday', 'wednesday', 'thursday', 'friday', 'saturday',
|
||||||
|
'sunday', 'recovery_notify', 'field2_recovery',
|
||||||
|
'field3_recovery', 'priority', 'id_group');
|
||||||
|
|
||||||
$cont = 0;
|
$cont = 0;
|
||||||
foreach ($fields_template as $field){
|
foreach ($fields_template as $field) {
|
||||||
if ($other['data'][$cont] != ""){
|
if ($other['data'][$cont] != "") {
|
||||||
$values[$field] = $other['data'][$cont];
|
$values[$field] = $other['data'][$cont];
|
||||||
}
|
}
|
||||||
|
|
||||||
$cont++;
|
$cont++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id_template = alerts_update_alert_template($id_template, $values);
|
$id_template = alerts_update_alert_template($id_template, $values);
|
||||||
|
|
||||||
if (is_error($id_template)) {
|
if (is_error($id_template)) {
|
||||||
// TODO: Improve the error returning more info
|
// TODO: Improve the error returning more info
|
||||||
returnError('error_create_alert_template', __('Error updating alert template.'));
|
returnError('error_create_alert_template',
|
||||||
|
__('Error updating alert template.'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
returnData('string', array('type' => 'string', 'data' => __('Correct updating of alert template')));
|
returnData('string',
|
||||||
|
array('type' => 'string',
|
||||||
|
'data' => __('Correct updating of alert template')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2233,20 +2242,23 @@ function api_set_update_alert_template($id_template, $thrash1, $other, $thrash3)
|
|||||||
* @param $thrash3 Don't use
|
* @param $thrash3 Don't use
|
||||||
*/
|
*/
|
||||||
function api_set_delete_alert_template($id_template, $thrash1, $other, $thrash3) {
|
function api_set_delete_alert_template($id_template, $thrash1, $other, $thrash3) {
|
||||||
|
|
||||||
if ($id_template == "") {
|
if ($id_template == "") {
|
||||||
returnError('error_delete_alert_template', __('Error deleting alert template. Id_template cannot be left blank.'));
|
returnError('error_delete_alert_template',
|
||||||
|
__('Error deleting alert template. Id_template cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = alerts_delete_alert_template($id_template);
|
$result = alerts_delete_alert_template($id_template);
|
||||||
|
|
||||||
if ($result == 0) {
|
if ($result == 0) {
|
||||||
// TODO: Improve the error returning more info
|
// TODO: Improve the error returning more info
|
||||||
returnError('error_create_alert_template', __('Error deleting alert template.'));
|
returnError('error_create_alert_template',
|
||||||
|
__('Error deleting alert template.'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
returnData('string', array('type' => 'string', 'data' => __('Correct deleting of alert template.')));
|
returnData('string', array('type' => 'string',
|
||||||
|
'data' => __('Correct deleting of alert template.')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2263,23 +2275,24 @@ function api_set_delete_alert_template($id_template, $thrash1, $other, $thrash3)
|
|||||||
* @param $thrash3 Don't use.
|
* @param $thrash3 Don't use.
|
||||||
*/
|
*/
|
||||||
function api_get_all_alert_templates($thrash1, $thrash2, $other, $thrash3) {
|
function api_get_all_alert_templates($thrash1, $thrash2, $other, $thrash3) {
|
||||||
|
|
||||||
if (!isset($other['data'][0]))
|
if (!isset($other['data'][0]))
|
||||||
$separator = ';'; // by default
|
$separator = ';'; // by default
|
||||||
else
|
else
|
||||||
$separator = $other['data'][0];
|
$separator = $other['data'][0];
|
||||||
|
|
||||||
$filter_templates = false;
|
$filter_templates = false;
|
||||||
|
|
||||||
$template = alerts_get_alert_templates();
|
$template = alerts_get_alert_templates();
|
||||||
|
|
||||||
if ($template !== false) {
|
if ($template !== false) {
|
||||||
$data['type'] = 'array';
|
$data['type'] = 'array';
|
||||||
$data['data'] = $template;
|
$data['data'] = $template;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$template) {
|
if (!$template) {
|
||||||
returnError('error_get_all_alert_templates', __('Error getting all alert templates.'));
|
returnError('error_get_all_alert_templates',
|
||||||
|
__('Error getting all alert templates.'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
returnData('csv', $data, $separator);
|
returnData('csv', $data, $separator);
|
||||||
@ -2302,19 +2315,21 @@ function api_get_all_alert_templates($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
function api_get_alert_template($id_template, $thrash1, $other, $thrash3) {
|
function api_get_alert_template($id_template, $thrash1, $other, $thrash3) {
|
||||||
|
|
||||||
$filter_templates = false;
|
$filter_templates = false;
|
||||||
|
|
||||||
if ($id_template != "") {
|
if ($id_template != "") {
|
||||||
$result_template = alerts_get_alert_template_name($id_template);
|
$result_template = alerts_get_alert_template_name($id_template);
|
||||||
|
|
||||||
if (!$result_template){
|
if (!$result_template){
|
||||||
returnError('error_get_alert_template', __('Error getting alert template. Id_template doesn\'t exists.'));
|
returnError('error_get_alert_template',
|
||||||
|
__('Error getting alert template. Id_template doesn\'t exists.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$filter_templates = array('id' => $id_template);
|
$filter_templates = array('id' => $id_template);
|
||||||
}
|
}
|
||||||
|
|
||||||
$template = alerts_get_alert_templates($filter_templates, array('id', 'name', 'description', 'id_alert_action', 'type', 'id_group'));
|
$template = alerts_get_alert_templates($filter_templates,
|
||||||
|
array('id', 'name', 'description', 'id_alert_action', 'type', 'id_group'));
|
||||||
|
|
||||||
if ($template !== false) {
|
if ($template !== false) {
|
||||||
$data['type'] = 'array';
|
$data['type'] = 'array';
|
||||||
@ -2322,7 +2337,8 @@ function api_get_alert_template($id_template, $thrash1, $other, $thrash3) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$template) {
|
if (!$template) {
|
||||||
returnError('error_get_alert_template', __('Error getting alert template.'));
|
returnError('error_get_alert_template',
|
||||||
|
__('Error getting alert template.'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
returnData('csv', $data, ';');
|
returnData('csv', $data, ';');
|
||||||
|
@ -152,10 +152,10 @@ function config_update_config () {
|
|||||||
|
|
||||||
$inventory_changes_blacklist = get_parameter('inventory_changes_blacklist', array());
|
$inventory_changes_blacklist = get_parameter('inventory_changes_blacklist', array());
|
||||||
config_update_value ('inventory_changes_blacklist', implode(',',$inventory_changes_blacklist));
|
config_update_value ('inventory_changes_blacklist', implode(',',$inventory_changes_blacklist));
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'pass':
|
case 'pass':
|
||||||
if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {
|
if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {
|
||||||
config_update_value ('enable_pass_policy', get_parameter('enable_pass_policy'));
|
config_update_value ('enable_pass_policy', get_parameter('enable_pass_policy'));
|
||||||
config_update_value ('pass_size', get_parameter('pass_size'));
|
config_update_value ('pass_size', get_parameter('pass_size'));
|
||||||
@ -268,12 +268,12 @@ function config_update_config () {
|
|||||||
|
|
||||||
// Add new interval value if is provided
|
// Add new interval value if is provided
|
||||||
$interval_value = (float) get_parameter ('interval_value', 0);
|
$interval_value = (float) get_parameter ('interval_value', 0);
|
||||||
|
|
||||||
if($interval_value > 0) {
|
if ($interval_value > 0) {
|
||||||
$interval_unit = (int) get_parameter ('interval_unit');
|
$interval_unit = (int) get_parameter ('interval_unit');
|
||||||
$new_interval = $interval_value * $interval_unit;
|
$new_interval = $interval_value * $interval_unit;
|
||||||
|
|
||||||
if($interval_values === '') {
|
if ($interval_values === '') {
|
||||||
$interval_values = $new_interval;
|
$interval_values = $new_interval;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -284,21 +284,21 @@ function config_update_config () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete interval value if is required
|
// Delete interval value if is required
|
||||||
$interval_to_delete = (float) get_parameter('interval_to_delete');
|
$interval_to_delete = (float) get_parameter('interval_to_delete');
|
||||||
if($interval_to_delete > 0) {
|
if ($interval_to_delete > 0) {
|
||||||
$interval_values_array = explode(',',$interval_values);
|
$interval_values_array = explode(',',$interval_values);
|
||||||
foreach($interval_values_array as $k => $iva) {
|
foreach ($interval_values_array as $k => $iva) {
|
||||||
if($interval_to_delete == $iva) {
|
if ($interval_to_delete == $iva) {
|
||||||
unset($interval_values_array[$k]);
|
unset($interval_values_array[$k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$interval_values = implode(',',$interval_values_array);
|
$interval_values = implode(',',$interval_values_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
config_update_value ('interval_values', $interval_values);
|
config_update_value ('interval_values', $interval_values);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'net':
|
case 'net':
|
||||||
config_update_value ('netflow_path', get_parameter ('netflow_path'));
|
config_update_value ('netflow_path', get_parameter ('netflow_path'));
|
||||||
@ -309,15 +309,15 @@ function config_update_config () {
|
|||||||
config_update_value ('netflow_max_resolution', (int)get_parameter ('netflow_max_resolution'));
|
config_update_value ('netflow_max_resolution', (int)get_parameter ('netflow_max_resolution'));
|
||||||
config_update_value ('netflow_disable_custom_lvfilters', get_parameter ('netflow_disable_custom_lvfilters'));
|
config_update_value ('netflow_disable_custom_lvfilters', get_parameter ('netflow_disable_custom_lvfilters'));
|
||||||
config_update_value ('netflow_max_lifetime', (int) get_parameter ('netflow_max_lifetime'));
|
config_update_value ('netflow_max_lifetime', (int) get_parameter ('netflow_max_lifetime'));
|
||||||
break;
|
break;
|
||||||
case 'log':
|
case 'log':
|
||||||
config_update_value ('log_dir', get_parameter('log_dir'));
|
config_update_value ('log_dir', get_parameter('log_dir'));
|
||||||
config_update_value ('log_max_lifetime', (int)get_parameter('log_max_lifetime'));
|
config_update_value ('log_max_lifetime', (int)get_parameter('log_max_lifetime'));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enterprise_include_once('include/functions_policies.php');
|
enterprise_include_once('include/functions_policies.php');
|
||||||
@ -334,7 +334,7 @@ function config_process_config () {
|
|||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$configs = db_get_all_rows_in_table ('tconfig');
|
$configs = db_get_all_rows_in_table ('tconfig');
|
||||||
|
|
||||||
if (empty ($configs)) {
|
if (empty ($configs)) {
|
||||||
include ($config["homedir"]."/general/error_emptyconfig.php");
|
include ($config["homedir"]."/general/error_emptyconfig.php");
|
||||||
exit;
|
exit;
|
||||||
@ -497,11 +497,11 @@ function config_process_config () {
|
|||||||
if (!isset ($config["log_collector"])) {
|
if (!isset ($config["log_collector"])) {
|
||||||
config_update_value ('log_collector', 0);
|
config_update_value ('log_collector', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset ($config["log_dir"])) {
|
if (!isset ($config["log_dir"])) {
|
||||||
config_update_value ('log_dir', '/var/spool/pandora/data_in/log');
|
config_update_value ('log_dir', '/var/spool/pandora/data_in/log');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset ($config["log_max_lifetime"])) {
|
if (!isset ($config["log_max_lifetime"])) {
|
||||||
config_update_value ('log_max_lifetime', 15);
|
config_update_value ('log_max_lifetime', 15);
|
||||||
}
|
}
|
||||||
@ -612,11 +612,11 @@ function config_process_config () {
|
|||||||
if (!isset ($config['netflow_daemon'])) {
|
if (!isset ($config['netflow_daemon'])) {
|
||||||
config_update_value ( 'netflow_daemon', '/usr/bin/nfcapd');
|
config_update_value ( 'netflow_daemon', '/usr/bin/nfcapd');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset ($config['netflow_nfdump'])) {
|
if (!isset ($config['netflow_nfdump'])) {
|
||||||
config_update_value ( 'netflow_nfdump', '/usr/bin/nfdump');
|
config_update_value ( 'netflow_nfdump', '/usr/bin/nfdump');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset ($config['netflow_nfexpire'])) {
|
if (!isset ($config['netflow_nfexpire'])) {
|
||||||
config_update_value ( 'netflow_nfexpire', '/usr/bin/nfexpire');
|
config_update_value ( 'netflow_nfexpire', '/usr/bin/nfexpire');
|
||||||
}
|
}
|
||||||
@ -884,7 +884,7 @@ function config_process_config () {
|
|||||||
if (!isset($config['referer_security'])) {
|
if (!isset($config['referer_security'])) {
|
||||||
config_update_value ('referer_security', 0);
|
config_update_value ('referer_security', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($config['event_storm_protection'])) {
|
if (!isset($config['event_storm_protection'])) {
|
||||||
config_update_value ('event_storm_protection', 0);
|
config_update_value ('event_storm_protection', 0);
|
||||||
}
|
}
|
||||||
|
@ -1892,9 +1892,12 @@ function graph_events_validated($width = 300, $height = 200, $url = "", $meta =
|
|||||||
$data_graph = reporting_get_count_events_validated(
|
$data_graph = reporting_get_count_events_validated(
|
||||||
array('id_group' => array_keys(users_get_groups())));
|
array('id_group' => array_keys(users_get_groups())));
|
||||||
|
|
||||||
|
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
||||||
|
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false, false));
|
||||||
|
|
||||||
echo pie3d_graph(
|
echo pie3d_graph(
|
||||||
true, $data_graph, $width, $height, __("other"), "",
|
true, $data_graph, $width, $height, __("other"), "",
|
||||||
$config['homedir'] . "/images/logo_vertical_water.png",
|
$water_mark,
|
||||||
$config['fontpath'], $config['font_size']);
|
$config['fontpath'], $config['font_size']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1922,7 +1925,7 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
|
|||||||
$url = str_ireplace ($badstrings, "", $url);
|
$url = str_ireplace ($badstrings, "", $url);
|
||||||
|
|
||||||
// Choose the table where search if metaconsole or not
|
// Choose the table where search if metaconsole or not
|
||||||
if($meta) {
|
if ($meta) {
|
||||||
if($history) {
|
if($history) {
|
||||||
$event_table = 'tmetaconsole_event_history';
|
$event_table = 'tmetaconsole_event_history';
|
||||||
}
|
}
|
||||||
@ -1937,7 +1940,7 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
|
|||||||
$field_extra = '';
|
$field_extra = '';
|
||||||
$groupby_extra = '';
|
$groupby_extra = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
//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
|
||||||
//is required if both DISTINCT() and COUNT() are in the statement
|
//is required if both DISTINCT() and COUNT() are in the statement
|
||||||
@ -2008,7 +2011,7 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
|
|||||||
|
|
||||||
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
||||||
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false, false));
|
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false, false));
|
||||||
|
|
||||||
return pie3d_graph($config['flash_charts'], $data, $width, $height,
|
return pie3d_graph($config['flash_charts'], $data, $width, $height,
|
||||||
__('Other'), '', $water_mark,
|
__('Other'), '', $water_mark,
|
||||||
$config['fontpath'], $config['font_size']);
|
$config['fontpath'], $config['font_size']);
|
||||||
@ -2065,7 +2068,8 @@ function grafico_eventos_total($filter = "") {
|
|||||||
|
|
||||||
asort ($data);
|
asort ($data);
|
||||||
|
|
||||||
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
$water_mark = array(
|
||||||
|
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
||||||
'url' => ui_get_full_url("/images/logo_vertical_water.png"));
|
'url' => ui_get_full_url("/images/logo_vertical_water.png"));
|
||||||
|
|
||||||
return pie3d_graph($config['flash_charts'], $data, 320, 200,
|
return pie3d_graph($config['flash_charts'], $data, 320, 200,
|
||||||
@ -2094,10 +2098,12 @@ function grafico_eventos_usuario ($width, $height) {
|
|||||||
ORDER BY 1 DESC LIMIT %d', $max_items);
|
ORDER BY 1 DESC LIMIT %d', $max_items);
|
||||||
break;
|
break;
|
||||||
case "oracle":
|
case "oracle":
|
||||||
$sql = sprintf ('SELECT * FROM (SELECT COUNT(id_evento) events, id_usuario
|
$sql = sprintf ('SELECT *
|
||||||
FROM tevento
|
FROM (SELECT COUNT(id_evento) events, id_usuario
|
||||||
GROUP BY id_usuario
|
FROM tevento
|
||||||
ORDER BY 1 DESC) WHERE rownum <= %d', $max_items);
|
GROUP BY id_usuario
|
||||||
|
ORDER BY 1 DESC)
|
||||||
|
WHERE rownum <= %d', $max_items);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$events = db_get_all_rows_sql ($sql);
|
$events = db_get_all_rows_sql ($sql);
|
||||||
@ -2107,7 +2113,10 @@ function grafico_eventos_usuario ($width, $height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach($events as $event) {
|
foreach($events as $event) {
|
||||||
if($event['id_usuario'] == '0') {
|
if ($event['id_usuario'] == '0') {
|
||||||
|
$data[__('System')] = $event['events'];
|
||||||
|
}
|
||||||
|
elseif ($event['id_usuario'] == '') {
|
||||||
$data[__('System')] = $event['events'];
|
$data[__('System')] = $event['events'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2115,7 +2124,8 @@ function grafico_eventos_usuario ($width, $height) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
$water_mark = array(
|
||||||
|
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
||||||
'url' => ui_get_full_url("/images/logo_vertical_water.png"));
|
'url' => ui_get_full_url("/images/logo_vertical_water.png"));
|
||||||
|
|
||||||
return pie3d_graph($config['flash_charts'], $data, $width, $height,
|
return pie3d_graph($config['flash_charts'], $data, $width, $height,
|
||||||
|
@ -44,14 +44,15 @@ function snmp_browser_print_tree ($tree, $id = 0, $depth = 0, $last = 0, $last_a
|
|||||||
|
|
||||||
if ($depth > 0) {
|
if ($depth > 0) {
|
||||||
echo "<ul id='ul_$id' style='margin: 0; padding: 0; display: none'>\n";
|
echo "<ul id='ul_$id' style='margin: 0; padding: 0; display: none'>\n";
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
echo "<ul id='ul_$id' style='margin: 0; padding: 0;'>\n";
|
echo "<ul id='ul_$id' style='margin: 0; padding: 0;'>\n";
|
||||||
}
|
}
|
||||||
foreach ($tree['__LEAVES__'] as $level => $sub_level) {
|
foreach ($tree['__LEAVES__'] as $level => $sub_level) {
|
||||||
|
|
||||||
// Id used to expand leafs
|
// Id used to expand leafs
|
||||||
$sub_id = time() . rand(0, getrandmax());
|
$sub_id = time() . rand(0, getrandmax());
|
||||||
|
|
||||||
// Display the branch
|
// Display the branch
|
||||||
echo "<li id='li_$sub_id' style='margin: 0; padding: 0;'>";
|
echo "<li id='li_$sub_id' style='margin: 0; padding: 0;'>";
|
||||||
|
|
||||||
@ -70,12 +71,15 @@ function snmp_browser_print_tree ($tree, $id = 0, $depth = 0, $last = 0, $last_a
|
|||||||
if ($depth == 0 && $count == 0) {
|
if ($depth == 0 && $count == 0) {
|
||||||
if ($count == $total) {
|
if ($count == $total) {
|
||||||
html_print_image ("operation/tree/one_closed.png", false, array ("style" => 'vertical-align: middle;'));
|
html_print_image ("operation/tree/one_closed.png", false, array ("style" => 'vertical-align: middle;'));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
html_print_image ("operation/tree/first_closed.png", false, array ("style" => 'vertical-align: middle;'));
|
html_print_image ("operation/tree/first_closed.png", false, array ("style" => 'vertical-align: middle;'));
|
||||||
}
|
}
|
||||||
} else if ($count == $total) {
|
}
|
||||||
|
else if ($count == $total) {
|
||||||
html_print_image ("operation/tree/last_closed.png", false, array ("style" => 'vertical-align: middle;'));
|
html_print_image ("operation/tree/last_closed.png", false, array ("style" => 'vertical-align: middle;'));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
html_print_image ("operation/tree/closed.png", false, array ("style" => 'vertical-align: middle;'));
|
html_print_image ("operation/tree/closed.png", false, array ("style" => 'vertical-align: middle;'));
|
||||||
}
|
}
|
||||||
echo "</a>";
|
echo "</a>";
|
||||||
@ -85,12 +89,15 @@ function snmp_browser_print_tree ($tree, $id = 0, $depth = 0, $last = 0, $last_a
|
|||||||
if ($depth == 0 && $count == 0) {
|
if ($depth == 0 && $count == 0) {
|
||||||
if ($count == $total) {
|
if ($count == $total) {
|
||||||
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
|
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
html_print_image ("operation/tree/first_leaf.png", false, array ("style" => 'vertical-align: middle;'));
|
html_print_image ("operation/tree/first_leaf.png", false, array ("style" => 'vertical-align: middle;'));
|
||||||
}
|
}
|
||||||
} else if ($count == $total) {
|
}
|
||||||
|
else if ($count == $total) {
|
||||||
html_print_image ("operation/tree/last_leaf.png", false, array ("style" => 'vertical-align: middle;'));
|
html_print_image ("operation/tree/last_leaf.png", false, array ("style" => 'vertical-align: middle;'));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
html_print_image ("operation/tree/leaf.png", false, array ("style" => 'vertical-align: middle;'));
|
html_print_image ("operation/tree/leaf.png", false, array ("style" => 'vertical-align: middle;'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,11 +107,9 @@ function snmp_browser_print_tree ($tree, $id = 0, $depth = 0, $last = 0, $last_a
|
|||||||
echo "<a onfocus='javascript: this.blur();' href='javascript: snmpGet(\"" . addslashes($sub_level['__OID__']) . "\");'>";
|
echo "<a onfocus='javascript: this.blur();' href='javascript: snmpGet(\"" . addslashes($sub_level['__OID__']) . "\");'>";
|
||||||
html_print_image ("images/computer_error.png", false, array ("style" => 'vertical-align: middle;'));
|
html_print_image ("images/computer_error.png", false, array ("style" => 'vertical-align: middle;'));
|
||||||
echo "</a>";
|
echo "</a>";
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<span>' . $level . '</span>';
|
echo '<span>' . $level . '</span>';
|
||||||
if (isset ($sub_level['__VALUE__'])) {
|
if (isset ($sub_level['__VALUE__'])) {
|
||||||
echo '<span class="value" style="display: none;"> = ' . $sub_level['__VALUE__'] . '</span>';
|
echo '<span class="value" style="display: none;"> = ' . $sub_level['__VALUE__'] . '</span>';
|
||||||
}
|
}
|
||||||
@ -136,7 +141,7 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.') {
|
|||||||
// Call snmpwalk
|
// Call snmpwalk
|
||||||
$oid_tree = array('__LEAVES__' => array());
|
$oid_tree = array('__LEAVES__' => array());
|
||||||
exec ('snmpwalk -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v 1 ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid), $output, $rc);
|
exec ('snmpwalk -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v 1 ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid), $output, $rc);
|
||||||
|
|
||||||
//if ($rc != 0) {
|
//if ($rc != 0) {
|
||||||
// return __('No data');
|
// return __('No data');
|
||||||
//}
|
//}
|
||||||
@ -149,14 +154,14 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.') {
|
|||||||
}
|
}
|
||||||
$oid = trim($full_oid[0]);
|
$oid = trim($full_oid[0]);
|
||||||
$value = trim ($full_oid[1]);
|
$value = trim ($full_oid[1]);
|
||||||
|
|
||||||
// Parse the OID
|
// Parse the OID
|
||||||
$group = 0;
|
$group = 0;
|
||||||
$sub_oid = "";
|
$sub_oid = "";
|
||||||
$ptr = &$oid_tree['__LEAVES__'];
|
$ptr = &$oid_tree['__LEAVES__'];
|
||||||
|
|
||||||
for ($i = 0; $i < strlen ($oid); $i++) {
|
for ($i = 0; $i < strlen ($oid); $i++) {
|
||||||
|
|
||||||
// "X.Y.Z"
|
// "X.Y.Z"
|
||||||
if ($oid[$i] == '"') {
|
if ($oid[$i] == '"') {
|
||||||
$group = $group ^ 1;
|
$group = $group ^ 1;
|
||||||
@ -169,14 +174,15 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.') {
|
|||||||
if ($sub_oid == '') {
|
if ($sub_oid == '') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset ($ptr[$sub_oid]) || ! isset ($ptr[$sub_oid]['__LEAVES__'])) {
|
if (! isset ($ptr[$sub_oid]) || ! isset ($ptr[$sub_oid]['__LEAVES__'])) {
|
||||||
$ptr[$sub_oid]['__LEAVES__'] = array();
|
$ptr[$sub_oid]['__LEAVES__'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$ptr = &$ptr[$sub_oid]['__LEAVES__'];
|
$ptr = &$ptr[$sub_oid]['__LEAVES__'];
|
||||||
$sub_oid = '';
|
$sub_oid = '';
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if ($oid[$i] != '"') {
|
if ($oid[$i] != '"') {
|
||||||
$sub_oid .= $oid[$i];
|
$sub_oid .= $oid[$i];
|
||||||
}
|
}
|
||||||
@ -188,7 +194,7 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.') {
|
|||||||
$ptr = &$ptr[$sub_oid];
|
$ptr = &$ptr[$sub_oid];
|
||||||
$sub_oid = "";
|
$sub_oid = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return$oid_tree;
|
return$oid_tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +214,7 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid) {
|
|||||||
if ($target_oid == '') {
|
if ($target_oid == '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oid_data['oid'] = $target_oid;
|
$oid_data['oid'] = $target_oid;
|
||||||
exec ('snmpget -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -v1 -c ' . escapeshellarg($community) . " " . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid), $output, $rc);
|
exec ('snmpget -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -v1 -c ' . escapeshellarg($community) . " " . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid), $output, $rc);
|
||||||
if ($rc != 0) {
|
if ($rc != 0) {
|
||||||
@ -248,11 +254,12 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid) {
|
|||||||
if (preg_match ('/DESCRIPTION\s+\"(.*)\"/', $translate_output, $matches) == 1) {
|
if (preg_match ('/DESCRIPTION\s+\"(.*)\"/', $translate_output, $matches) == 1) {
|
||||||
$oid_data['description'] = $matches[1];
|
$oid_data['description'] = $matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
$full_value = explode (':', trim ($full_oid[1]));
|
$full_value = explode (':', trim ($full_oid[1]));
|
||||||
if (! isset ($full_value[1])) {
|
if (! isset ($full_value[1])) {
|
||||||
$oid_data['value'] = trim ($full_oid[1]);
|
$oid_data['value'] = trim ($full_oid[1]);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$oid_data['type'] = trim($full_value[0]);
|
$oid_data['type'] = trim($full_value[0]);
|
||||||
$oid_data['value'] = trim($full_value[1]);
|
$oid_data['value'] = trim($full_value[1]);
|
||||||
}
|
}
|
||||||
@ -269,59 +276,58 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid) {
|
|||||||
*/
|
*/
|
||||||
function snmp_browser_print_oid ($oid = array()) {
|
function snmp_browser_print_oid ($oid = array()) {
|
||||||
|
|
||||||
// OID information table
|
// OID information table
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->size = array ();
|
$table->size = array ();
|
||||||
$table->data = array ();
|
$table->data = array ();
|
||||||
|
|
||||||
foreach (array('oid', 'numeric_oid', 'value') as $key) {
|
foreach (array('oid', 'numeric_oid', 'value') as $key) {
|
||||||
if (! isset ($oid[$key])) {
|
if (! isset ($oid[$key])) {
|
||||||
$oid[$key] = '';
|
$oid[$key] = '';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$table->data[0][0] = '<strong>'.__('OID').'</strong>';
|
|
||||||
$table->data[0][1] = $oid['oid'];
|
$table->data[0][0] = '<strong>'.__('OID').'</strong>';
|
||||||
$table->data[1][0] = '<strong>'.__('Numeric OID').'</strong>';
|
$table->data[0][1] = $oid['oid'];
|
||||||
$table->data[1][1] = $oid['numeric_oid'];
|
$table->data[1][0] = '<strong>'.__('Numeric OID').'</strong>';
|
||||||
$table->data[2][0] = '<strong>'.__('Value').'</strong>';
|
$table->data[1][1] = $oid['numeric_oid'];
|
||||||
$table->data[2][1] = $oid['value'];
|
$table->data[2][0] = '<strong>'.__('Value').'</strong>';
|
||||||
$i = 3;
|
$table->data[2][1] = $oid['value'];
|
||||||
if (isset ($oid['type'])) {
|
$i = 3;
|
||||||
$table->data[$i][0] = '<strong>'.__('Type').'</strong>';
|
if (isset ($oid['type'])) {
|
||||||
$table->data[$i][1] = $oid['type'];
|
$table->data[$i][0] = '<strong>'.__('Type').'</strong>';
|
||||||
$i++;
|
$table->data[$i][1] = $oid['type'];
|
||||||
}
|
$i++;
|
||||||
if (isset ($oid['description'])) {
|
}
|
||||||
$table->data[$i][0] = '<strong>'.__('Description').'</strong>';
|
if (isset ($oid['description'])) {
|
||||||
$table->data[$i][1] = $oid['description'];
|
$table->data[$i][0] = '<strong>'.__('Description').'</strong>';
|
||||||
$i++;
|
$table->data[$i][1] = $oid['description'];
|
||||||
}
|
$i++;
|
||||||
if (isset ($oid['syntax'])) {
|
}
|
||||||
$table->data[$i][0] = '<strong>'.__('Syntax').'</strong>';
|
if (isset ($oid['syntax'])) {
|
||||||
$table->data[$i][1] = $oid['syntax'];
|
$table->data[$i][0] = '<strong>'.__('Syntax').'</strong>';
|
||||||
$i++;
|
$table->data[$i][1] = $oid['syntax'];
|
||||||
}
|
$i++;
|
||||||
if (isset ($oid['display_hint'])) {
|
}
|
||||||
$table->data[$i][0] = '<strong>'.__('Display hint').'</strong>';
|
if (isset ($oid['display_hint'])) {
|
||||||
$table->data[$i][1] = $oid['display_hint'];
|
$table->data[$i][0] = '<strong>'.__('Display hint').'</strong>';
|
||||||
$i++;
|
$table->data[$i][1] = $oid['display_hint'];
|
||||||
}
|
$i++;
|
||||||
if (isset ($oid['max_access'])) {
|
}
|
||||||
$table->data[$i][0] = '<strong>'.__('Max access').'</strong>';
|
if (isset ($oid['max_access'])) {
|
||||||
$table->data[$i][1] = $oid['max_access'];
|
$table->data[$i][0] = '<strong>'.__('Max access').'</strong>';
|
||||||
$i++;
|
$table->data[$i][1] = $oid['max_access'];
|
||||||
}
|
$i++;
|
||||||
if (isset ($oid['status'])) {
|
}
|
||||||
$table->data[$i][0] = '<strong>'.__('Status').'</strong>';
|
if (isset ($oid['status'])) {
|
||||||
$table->data[$i][1] = $oid['status'];
|
$table->data[$i][0] = '<strong>'.__('Status').'</strong>';
|
||||||
$i++;
|
$table->data[$i][1] = $oid['status'];
|
||||||
}
|
$i++;
|
||||||
|
}
|
||||||
echo '<a href="#" onClick="hideOIDData();">';
|
|
||||||
html_print_image ("images/cancel.png", false, array ("style" => 'vertical-align: middle;'), false);
|
echo '<a href="#" onClick="hideOIDData();">';
|
||||||
echo '</a>';
|
html_print_image ("images/cancel.png", false, array ("style" => 'vertical-align: middle;'), false);
|
||||||
html_print_table($table, false);
|
echo '</a>';
|
||||||
|
html_print_table($table, false);
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
?>
|
|
@ -436,13 +436,16 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
|
|||||||
function pie3d_graph($flash_chart, $chart_data, $width, $height,
|
function pie3d_graph($flash_chart, $chart_data, $width, $height,
|
||||||
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
||||||
$font_size = '', $ttl = 1, $legend_position = false) {
|
$font_size = '', $ttl = 1, $legend_position = false) {
|
||||||
|
|
||||||
return pie_graph('3d', $flash_chart, $chart_data, $width, $height,
|
return pie_graph('3d', $flash_chart, $chart_data, $width, $height,
|
||||||
$others_str, $homedir, $water_mark, $font, $font_size, $ttl, $legend_position);
|
$others_str, $homedir, $water_mark, $font, $font_size, $ttl,
|
||||||
|
$legend_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pie2d_graph($flash_chart, $chart_data, $width, $height,
|
function pie2d_graph($flash_chart, $chart_data, $width, $height,
|
||||||
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
||||||
$font_size = '', $ttl = 1, $legend_position = false) {
|
$font_size = '', $ttl = 1, $legend_position = false) {
|
||||||
|
|
||||||
return pie_graph('2d', $flash_chart, $chart_data, $width, $height,
|
return pie_graph('2d', $flash_chart, $chart_data, $width, $height,
|
||||||
$others_str, $homedir, $water_mark, $font, $font_size, $ttl, $legend_position);
|
$others_str, $homedir, $water_mark, $font, $font_size, $ttl, $legend_position);
|
||||||
}
|
}
|
||||||
@ -459,8 +462,8 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
|
|||||||
if (count($chart_data) > $max_values) {
|
if (count($chart_data) > $max_values) {
|
||||||
$chart_data_trunc = array();
|
$chart_data_trunc = array();
|
||||||
$n = 1;
|
$n = 1;
|
||||||
foreach($chart_data as $key => $value) {
|
foreach ($chart_data as $key => $value) {
|
||||||
if($n < $max_values) {
|
if ($n < $max_values) {
|
||||||
$chart_data_trunc[$key] = $value;
|
$chart_data_trunc[$key] = $value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
756
pandora_console/include/graphs/flot/jquery.flot.pie.js
Normal file
756
pandora_console/include/graphs/flot/jquery.flot.pie.js
Normal file
@ -0,0 +1,756 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin for rendering pie charts. The plugin assumes the data is
|
||||||
|
coming is as a single data value for each series, and each of those
|
||||||
|
values is a positive value or zero (negative numbers don't make
|
||||||
|
any sense and will cause strange effects). The data values do
|
||||||
|
NOT need to be passed in as percentage values because it
|
||||||
|
internally calculates the total and percentages.
|
||||||
|
|
||||||
|
* Created by Brian Medendorp, June 2009
|
||||||
|
* Updated November 2009 with contributions from: btburnett3, Anthony Aragues and Xavi Ivars
|
||||||
|
|
||||||
|
* Changes:
|
||||||
|
2009-10-22: lineJoin set to round
|
||||||
|
2009-10-23: IE full circle fix, donut
|
||||||
|
2009-11-11: Added basic hover from btburnett3 - does not work in IE, and center is off in Chrome and Opera
|
||||||
|
2009-11-17: Added IE hover capability submitted by Anthony Aragues
|
||||||
|
2009-11-18: Added bug fix submitted by Xavi Ivars (issues with arrays when other JS libraries are included as well)
|
||||||
|
|
||||||
|
|
||||||
|
Available options are:
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true/false
|
||||||
|
radius: 0-1 for percentage of fullsize, or a specified pixel length, or 'auto'
|
||||||
|
innerRadius: 0-1 for percentage of fullsize or a specified pixel length, for creating a donut effect
|
||||||
|
startAngle: 0-2 factor of PI used for starting angle (in radians) i.e 3/2 starts at the top, 0 and 2 have the same result
|
||||||
|
tilt: 0-1 for percentage to tilt the pie, where 1 is no tilt, and 0 is completely flat (nothing will show)
|
||||||
|
offset: {
|
||||||
|
top: integer value to move the pie up or down
|
||||||
|
left: integer value to move the pie left or right, or 'auto'
|
||||||
|
},
|
||||||
|
stroke: {
|
||||||
|
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#FFF')
|
||||||
|
width: integer pixel width of the stroke
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
show: true/false, or 'auto'
|
||||||
|
formatter: a user-defined function that modifies the text/style of the label text
|
||||||
|
radius: 0-1 for percentage of fullsize, or a specified pixel length
|
||||||
|
background: {
|
||||||
|
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#000')
|
||||||
|
opacity: 0-1
|
||||||
|
},
|
||||||
|
threshold: 0-1 for the percentage value at which to hide labels (if they're too small)
|
||||||
|
},
|
||||||
|
combine: {
|
||||||
|
threshold: 0-1 for the percentage value at which to combine slices (if they're too small)
|
||||||
|
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#CCC'), if null, the plugin will automatically use the color of the first slice to be combined
|
||||||
|
label: any text value of what the combined slice should be labeled
|
||||||
|
}
|
||||||
|
highlight: {
|
||||||
|
opacity: 0-1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
More detail and specific examples can be found in the included HTML file.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($)
|
||||||
|
{
|
||||||
|
function init(plot) // this is the "body" of the plugin
|
||||||
|
{
|
||||||
|
var canvas = null;
|
||||||
|
var target = null;
|
||||||
|
var maxRadius = null;
|
||||||
|
var centerLeft = null;
|
||||||
|
var centerTop = null;
|
||||||
|
var total = 0;
|
||||||
|
var redraw = true;
|
||||||
|
var redrawAttempts = 10;
|
||||||
|
var shrink = 0.95;
|
||||||
|
var legendWidth = 0;
|
||||||
|
var processed = false;
|
||||||
|
var raw = false;
|
||||||
|
|
||||||
|
// interactive variables
|
||||||
|
var highlights = [];
|
||||||
|
|
||||||
|
// add hook to determine if pie plugin in enabled, and then perform necessary operations
|
||||||
|
plot.hooks.processOptions.push(checkPieEnabled);
|
||||||
|
plot.hooks.bindEvents.push(bindEvents);
|
||||||
|
|
||||||
|
// check to see if the pie plugin is enabled
|
||||||
|
function checkPieEnabled(plot, options)
|
||||||
|
{
|
||||||
|
if (options.series.pie.show)
|
||||||
|
{
|
||||||
|
//disable grid
|
||||||
|
options.grid.show = false;
|
||||||
|
|
||||||
|
// set labels.show
|
||||||
|
if (options.series.pie.label.show=='auto')
|
||||||
|
if (options.legend.show)
|
||||||
|
options.series.pie.label.show = false;
|
||||||
|
else
|
||||||
|
options.series.pie.label.show = true;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.radius=='auto')
|
||||||
|
if (options.series.pie.label.show)
|
||||||
|
options.series.pie.radius = 3/4;
|
||||||
|
else
|
||||||
|
options.series.pie.radius = 1;
|
||||||
|
|
||||||
|
// ensure sane tilt
|
||||||
|
if (options.series.pie.tilt>1)
|
||||||
|
options.series.pie.tilt=1;
|
||||||
|
if (options.series.pie.tilt<0)
|
||||||
|
options.series.pie.tilt=0;
|
||||||
|
|
||||||
|
// add processData hook to do transformations on the data
|
||||||
|
plot.hooks.processDatapoints.push(processDatapoints);
|
||||||
|
plot.hooks.drawOverlay.push(drawOverlay);
|
||||||
|
|
||||||
|
// add draw hook
|
||||||
|
plot.hooks.draw.push(draw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bind hoverable events
|
||||||
|
function bindEvents(plot, eventHolder)
|
||||||
|
{
|
||||||
|
var options = plot.getOptions();
|
||||||
|
|
||||||
|
if (options.series.pie.show && options.grid.hoverable)
|
||||||
|
eventHolder.unbind('mousemove').mousemove(onMouseMove);
|
||||||
|
|
||||||
|
if (options.series.pie.show && options.grid.clickable)
|
||||||
|
eventHolder.unbind('click').click(onClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// debugging function that prints out an object
|
||||||
|
function alertObject(obj)
|
||||||
|
{
|
||||||
|
var msg = '';
|
||||||
|
function traverse(obj, depth)
|
||||||
|
{
|
||||||
|
if (!depth)
|
||||||
|
depth = 0;
|
||||||
|
for (var i = 0; i < obj.length; ++i)
|
||||||
|
{
|
||||||
|
for (var j=0; j<depth; j++)
|
||||||
|
msg += '\t';
|
||||||
|
|
||||||
|
if( typeof obj[i] == "object")
|
||||||
|
{ // its an object
|
||||||
|
msg += ''+i+':\n';
|
||||||
|
traverse(obj[i], depth+1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // its a value
|
||||||
|
msg += ''+i+': '+obj[i]+'\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
traverse(obj);
|
||||||
|
alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcTotal(data)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < data.length; ++i)
|
||||||
|
{
|
||||||
|
var item = parseFloat(data[i].data[0][1]);
|
||||||
|
if (item)
|
||||||
|
total += item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function processDatapoints(plot, series, data, datapoints)
|
||||||
|
{
|
||||||
|
if (!processed)
|
||||||
|
{
|
||||||
|
processed = true;
|
||||||
|
|
||||||
|
canvas = plot.getCanvas();
|
||||||
|
target = $(canvas).parent();
|
||||||
|
options = plot.getOptions();
|
||||||
|
|
||||||
|
plot.setData(combine(plot.getData()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupPie()
|
||||||
|
{
|
||||||
|
legendWidth = target.children().filter('.legend').children().width();
|
||||||
|
|
||||||
|
// calculate maximum radius and center point
|
||||||
|
maxRadius = Math.min(canvas.width,(canvas.height/options.series.pie.tilt))/2;
|
||||||
|
centerTop = (canvas.height/2)+options.series.pie.offset.top;
|
||||||
|
centerLeft = (canvas.width/2);
|
||||||
|
|
||||||
|
if (options.series.pie.offset.left=='auto')
|
||||||
|
if (options.legend.position.match('w'))
|
||||||
|
centerLeft += legendWidth/2;
|
||||||
|
else
|
||||||
|
centerLeft -= legendWidth/2;
|
||||||
|
else
|
||||||
|
centerLeft += options.series.pie.offset.left;
|
||||||
|
|
||||||
|
if (centerLeft<maxRadius)
|
||||||
|
centerLeft = maxRadius;
|
||||||
|
else if (centerLeft>canvas.width-maxRadius)
|
||||||
|
centerLeft = canvas.width-maxRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixData(data)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < data.length; ++i)
|
||||||
|
{
|
||||||
|
if (typeof(data[i].data)=='number')
|
||||||
|
data[i].data = [[1,data[i].data]];
|
||||||
|
else if (typeof(data[i].data)=='undefined' || typeof(data[i].data[0])=='undefined')
|
||||||
|
{
|
||||||
|
if (typeof(data[i].data)!='undefined' && typeof(data[i].data.label)!='undefined')
|
||||||
|
data[i].label = data[i].data.label; // fix weirdness coming from flot
|
||||||
|
data[i].data = [[1,0]];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function combine(data)
|
||||||
|
{
|
||||||
|
data = fixData(data);
|
||||||
|
calcTotal(data);
|
||||||
|
var combined = 0;
|
||||||
|
var numCombined = 0;
|
||||||
|
var color = options.series.pie.combine.color;
|
||||||
|
|
||||||
|
var newdata = [];
|
||||||
|
for (var i = 0; i < data.length; ++i)
|
||||||
|
{
|
||||||
|
// make sure its a number
|
||||||
|
data[i].data[0][1] = parseFloat(data[i].data[0][1]);
|
||||||
|
if (!data[i].data[0][1])
|
||||||
|
data[i].data[0][1] = 0;
|
||||||
|
|
||||||
|
if (data[i].data[0][1]/total<=options.series.pie.combine.threshold)
|
||||||
|
{
|
||||||
|
combined += data[i].data[0][1];
|
||||||
|
numCombined++;
|
||||||
|
if (!color)
|
||||||
|
color = data[i].color;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newdata.push({
|
||||||
|
data: [[1,data[i].data[0][1]]],
|
||||||
|
color: data[i].color,
|
||||||
|
label: data[i].label,
|
||||||
|
angle: (data[i].data[0][1]*(Math.PI*2))/total,
|
||||||
|
percent: (data[i].data[0][1]/total*100)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (numCombined>0)
|
||||||
|
newdata.push({
|
||||||
|
data: [[1,combined]],
|
||||||
|
color: color,
|
||||||
|
label: options.series.pie.combine.label,
|
||||||
|
angle: (combined*(Math.PI*2))/total,
|
||||||
|
percent: (combined/total*100)
|
||||||
|
});
|
||||||
|
return newdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw(plot, newCtx)
|
||||||
|
{
|
||||||
|
if (!target) return; // if no series were passed
|
||||||
|
ctx = newCtx;
|
||||||
|
|
||||||
|
setupPie();
|
||||||
|
var slices = plot.getData();
|
||||||
|
|
||||||
|
var attempts = 0;
|
||||||
|
while (redraw && attempts<redrawAttempts)
|
||||||
|
{
|
||||||
|
redraw = false;
|
||||||
|
if (attempts>0)
|
||||||
|
maxRadius *= shrink;
|
||||||
|
attempts += 1;
|
||||||
|
clear();
|
||||||
|
if (options.series.pie.tilt<=0.8)
|
||||||
|
drawShadow();
|
||||||
|
drawPie();
|
||||||
|
}
|
||||||
|
if (attempts >= redrawAttempts) {
|
||||||
|
clear();
|
||||||
|
target.prepend('<div class="error">Could not draw pie with labels contained inside canvas</div>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( plot.setSeries && plot.insertLegend )
|
||||||
|
{
|
||||||
|
plot.setSeries(slices);
|
||||||
|
plot.insertLegend();
|
||||||
|
}
|
||||||
|
|
||||||
|
// we're actually done at this point, just defining internal functions at this point
|
||||||
|
|
||||||
|
function clear()
|
||||||
|
{
|
||||||
|
ctx.clearRect(0,0,canvas.width,canvas.height);
|
||||||
|
target.children().filter('.pieLabel, .pieLabelBackground').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawShadow()
|
||||||
|
{
|
||||||
|
var shadowLeft = 5;
|
||||||
|
var shadowTop = 15;
|
||||||
|
var edge = 10;
|
||||||
|
var alpha = 0.02;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.radius>1)
|
||||||
|
var radius = options.series.pie.radius;
|
||||||
|
else
|
||||||
|
var radius = maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
if (radius>=(canvas.width/2)-shadowLeft || radius*options.series.pie.tilt>=(canvas.height/2)-shadowTop || radius<=edge)
|
||||||
|
return; // shadow would be outside canvas, so don't draw it
|
||||||
|
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(shadowLeft,shadowTop);
|
||||||
|
ctx.globalAlpha = alpha;
|
||||||
|
ctx.fillStyle = '#000';
|
||||||
|
|
||||||
|
// center and rotate to starting position
|
||||||
|
ctx.translate(centerLeft,centerTop);
|
||||||
|
ctx.scale(1, options.series.pie.tilt);
|
||||||
|
|
||||||
|
//radius -= edge;
|
||||||
|
for (var i=1; i<=edge; i++)
|
||||||
|
{
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(0,0,radius,0,Math.PI*2,false);
|
||||||
|
ctx.fill();
|
||||||
|
radius -= i;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawPie()
|
||||||
|
{
|
||||||
|
startAngle = Math.PI*options.series.pie.startAngle;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.radius>1)
|
||||||
|
var radius = options.series.pie.radius;
|
||||||
|
else
|
||||||
|
var radius = maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
// center and rotate to starting position
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(centerLeft,centerTop);
|
||||||
|
ctx.scale(1, options.series.pie.tilt);
|
||||||
|
//ctx.rotate(startAngle); // start at top; -- This doesn't work properly in Opera
|
||||||
|
|
||||||
|
// draw slices
|
||||||
|
ctx.save();
|
||||||
|
var currentAngle = startAngle;
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
{
|
||||||
|
slices[i].startAngle = currentAngle;
|
||||||
|
drawSlice(slices[i].angle, slices[i].color, true);
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// draw slice outlines
|
||||||
|
ctx.save();
|
||||||
|
ctx.lineWidth = options.series.pie.stroke.width;
|
||||||
|
currentAngle = startAngle;
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
drawSlice(slices[i].angle, options.series.pie.stroke.color, false);
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// draw donut hole
|
||||||
|
drawDonutHole(ctx);
|
||||||
|
|
||||||
|
// draw labels
|
||||||
|
if (options.series.pie.label.show)
|
||||||
|
drawLabels();
|
||||||
|
|
||||||
|
// restore to original state
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
function drawSlice(angle, color, fill)
|
||||||
|
{
|
||||||
|
if (angle<=0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fill)
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctx.strokeStyle = color;
|
||||||
|
ctx.lineJoin = 'round';
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
if (Math.abs(angle - Math.PI*2) > 0.000000001)
|
||||||
|
ctx.moveTo(0,0); // Center of the pie
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
//JQUERY 1.9 DOES NOT SUPPORT THE BROWSER
|
||||||
|
//PANDORA FMS TEAM DISABLED THIS LINES
|
||||||
|
//else if ($.browser.msie)
|
||||||
|
// angle -= 0.0001;
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
//ctx.arc(0,0,radius,0,angle,false); // This doesn't work properly in Opera
|
||||||
|
ctx.arc(0,0,radius,currentAngle,currentAngle+angle,false);
|
||||||
|
ctx.closePath();
|
||||||
|
//ctx.rotate(angle); // This doesn't work properly in Opera
|
||||||
|
currentAngle += angle;
|
||||||
|
|
||||||
|
if (fill)
|
||||||
|
ctx.fill();
|
||||||
|
else
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawLabels()
|
||||||
|
{
|
||||||
|
var currentAngle = startAngle;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.label.radius>1)
|
||||||
|
var radius = options.series.pie.label.radius;
|
||||||
|
else
|
||||||
|
var radius = maxRadius * options.series.pie.label.radius;
|
||||||
|
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
{
|
||||||
|
if (slices[i].percent >= options.series.pie.label.threshold*100)
|
||||||
|
drawLabel(slices[i], currentAngle, i);
|
||||||
|
currentAngle += slices[i].angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawLabel(slice, startAngle, index)
|
||||||
|
{
|
||||||
|
if (slice.data[0][1]==0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// format label text
|
||||||
|
var lf = options.legend.labelFormatter, text, plf = options.series.pie.label.formatter;
|
||||||
|
if (lf)
|
||||||
|
text = lf(slice.label, slice);
|
||||||
|
else
|
||||||
|
text = slice.label;
|
||||||
|
if (plf)
|
||||||
|
text = plf(text, slice);
|
||||||
|
|
||||||
|
var halfAngle = ((startAngle+slice.angle) + startAngle)/2;
|
||||||
|
var x = centerLeft + Math.round(Math.cos(halfAngle) * radius);
|
||||||
|
var y = centerTop + Math.round(Math.sin(halfAngle) * radius) * options.series.pie.tilt;
|
||||||
|
|
||||||
|
var html = '<span class="pieLabel" id="pieLabel'+index+'" style="position:absolute;top:' + y + 'px;left:' + x + 'px;">' + text + "</span>";
|
||||||
|
target.append(html);
|
||||||
|
var label = target.children('#pieLabel'+index);
|
||||||
|
var labelTop = (y - label.height()/2);
|
||||||
|
var labelLeft = (x - label.width()/2);
|
||||||
|
label.css('top', labelTop);
|
||||||
|
label.css('left', labelLeft);
|
||||||
|
|
||||||
|
// check to make sure that the label is not outside the canvas
|
||||||
|
if (0-labelTop>0 || 0-labelLeft>0 || canvas.height-(labelTop+label.height())<0 || canvas.width-(labelLeft+label.width())<0)
|
||||||
|
redraw = true;
|
||||||
|
|
||||||
|
if (options.series.pie.label.background.opacity != 0) {
|
||||||
|
// put in the transparent background separately to avoid blended labels and label boxes
|
||||||
|
var c = options.series.pie.label.background.color;
|
||||||
|
if (c == null) {
|
||||||
|
c = slice.color;
|
||||||
|
}
|
||||||
|
var pos = 'top:'+labelTop+'px;left:'+labelLeft+'px;';
|
||||||
|
$('<div class="pieLabelBackground" style="position:absolute;width:' + label.width() + 'px;height:' + label.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').insertBefore(label).css('opacity', options.series.pie.label.background.opacity);
|
||||||
|
}
|
||||||
|
} // end individual label function
|
||||||
|
} // end drawLabels function
|
||||||
|
} // end drawPie function
|
||||||
|
} // end draw function
|
||||||
|
|
||||||
|
// Placed here because it needs to be accessed from multiple locations
|
||||||
|
function drawDonutHole(layer)
|
||||||
|
{
|
||||||
|
// draw donut hole
|
||||||
|
if(options.series.pie.innerRadius > 0)
|
||||||
|
{
|
||||||
|
// subtract the center
|
||||||
|
layer.save();
|
||||||
|
innerRadius = options.series.pie.innerRadius > 1 ? options.series.pie.innerRadius : maxRadius * options.series.pie.innerRadius;
|
||||||
|
layer.globalCompositeOperation = 'destination-out'; // this does not work with excanvas, but it will fall back to using the stroke color
|
||||||
|
layer.beginPath();
|
||||||
|
layer.fillStyle = options.series.pie.stroke.color;
|
||||||
|
layer.arc(0,0,innerRadius,0,Math.PI*2,false);
|
||||||
|
layer.fill();
|
||||||
|
layer.closePath();
|
||||||
|
layer.restore();
|
||||||
|
|
||||||
|
// add inner stroke
|
||||||
|
layer.save();
|
||||||
|
layer.beginPath();
|
||||||
|
layer.strokeStyle = options.series.pie.stroke.color;
|
||||||
|
layer.arc(0,0,innerRadius,0,Math.PI*2,false);
|
||||||
|
layer.stroke();
|
||||||
|
layer.closePath();
|
||||||
|
layer.restore();
|
||||||
|
// TODO: add extra shadow inside hole (with a mask) if the pie is tilted.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- Additional Interactive related functions --
|
||||||
|
|
||||||
|
function isPointInPoly(poly, pt)
|
||||||
|
{
|
||||||
|
for(var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i)
|
||||||
|
((poly[i][1] <= pt[1] && pt[1] < poly[j][1]) || (poly[j][1] <= pt[1] && pt[1]< poly[i][1]))
|
||||||
|
&& (pt[0] < (poly[j][0] - poly[i][0]) * (pt[1] - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0])
|
||||||
|
&& (c = !c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findNearbySlice(mouseX, mouseY)
|
||||||
|
{
|
||||||
|
var slices = plot.getData(),
|
||||||
|
options = plot.getOptions(),
|
||||||
|
radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
{
|
||||||
|
var s = slices[i];
|
||||||
|
|
||||||
|
if(s.pie.show)
|
||||||
|
{
|
||||||
|
ctx.save();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0,0); // Center of the pie
|
||||||
|
//ctx.scale(1, options.series.pie.tilt); // this actually seems to break everything when here.
|
||||||
|
ctx.arc(0,0,radius,s.startAngle,s.startAngle+s.angle,false);
|
||||||
|
ctx.closePath();
|
||||||
|
x = mouseX-centerLeft;
|
||||||
|
y = mouseY-centerTop;
|
||||||
|
if(ctx.isPointInPath)
|
||||||
|
{
|
||||||
|
if (ctx.isPointInPath(mouseX-centerLeft, mouseY-centerTop))
|
||||||
|
{
|
||||||
|
//alert('found slice!');
|
||||||
|
ctx.restore();
|
||||||
|
return {datapoint: [s.percent, s.data], dataIndex: 0, series: s, seriesIndex: i};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// excanvas for IE doesn;t support isPointInPath, this is a workaround.
|
||||||
|
p1X = (radius * Math.cos(s.startAngle));
|
||||||
|
p1Y = (radius * Math.sin(s.startAngle));
|
||||||
|
p2X = (radius * Math.cos(s.startAngle+(s.angle/4)));
|
||||||
|
p2Y = (radius * Math.sin(s.startAngle+(s.angle/4)));
|
||||||
|
p3X = (radius * Math.cos(s.startAngle+(s.angle/2)));
|
||||||
|
p3Y = (radius * Math.sin(s.startAngle+(s.angle/2)));
|
||||||
|
p4X = (radius * Math.cos(s.startAngle+(s.angle/1.5)));
|
||||||
|
p4Y = (radius * Math.sin(s.startAngle+(s.angle/1.5)));
|
||||||
|
p5X = (radius * Math.cos(s.startAngle+s.angle));
|
||||||
|
p5Y = (radius * Math.sin(s.startAngle+s.angle));
|
||||||
|
arrPoly = [[0,0],[p1X,p1Y],[p2X,p2Y],[p3X,p3Y],[p4X,p4Y],[p5X,p5Y]];
|
||||||
|
arrPoint = [x,y];
|
||||||
|
// TODO: perhaps do some mathmatical trickery here with the Y-coordinate to compensate for pie tilt?
|
||||||
|
if(isPointInPoly(arrPoly, arrPoint))
|
||||||
|
{
|
||||||
|
ctx.restore();
|
||||||
|
return {datapoint: [s.percent, s.data], dataIndex: 0, series: s, seriesIndex: i};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseMove(e)
|
||||||
|
{
|
||||||
|
triggerClickHoverEvent('plothover', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClick(e)
|
||||||
|
{
|
||||||
|
triggerClickHoverEvent('plotclick', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// trigger click or hover event (they send the same parameters so we share their code)
|
||||||
|
function triggerClickHoverEvent(eventname, e)
|
||||||
|
{
|
||||||
|
var offset = plot.offset(),
|
||||||
|
canvasX = parseInt(e.pageX - offset.left),
|
||||||
|
canvasY = parseInt(e.pageY - offset.top),
|
||||||
|
item = findNearbySlice(canvasX, canvasY);
|
||||||
|
|
||||||
|
if (options.grid.autoHighlight)
|
||||||
|
{
|
||||||
|
// clear auto-highlights
|
||||||
|
for (var i = 0; i < highlights.length; ++i)
|
||||||
|
{
|
||||||
|
var h = highlights[i];
|
||||||
|
if (h.auto == eventname && !(item && h.series == item.series))
|
||||||
|
unhighlight(h.series);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// highlight the slice
|
||||||
|
if (item)
|
||||||
|
highlight(item.series, eventname);
|
||||||
|
|
||||||
|
// trigger any hover bind events
|
||||||
|
var pos = { pageX: e.pageX, pageY: e.pageY };
|
||||||
|
target.trigger(eventname, [ pos, item ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function highlight(s, auto)
|
||||||
|
{
|
||||||
|
if (typeof s == "number")
|
||||||
|
s = series[s];
|
||||||
|
|
||||||
|
var i = indexOfHighlight(s);
|
||||||
|
if (i == -1)
|
||||||
|
{
|
||||||
|
highlights.push({ series: s, auto: auto });
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
else if (!auto)
|
||||||
|
highlights[i].auto = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function unhighlight(s)
|
||||||
|
{
|
||||||
|
if (s == null)
|
||||||
|
{
|
||||||
|
highlights = [];
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof s == "number")
|
||||||
|
s = series[s];
|
||||||
|
|
||||||
|
var i = indexOfHighlight(s);
|
||||||
|
if (i != -1)
|
||||||
|
{
|
||||||
|
highlights.splice(i, 1);
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function indexOfHighlight(s)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < highlights.length; ++i)
|
||||||
|
{
|
||||||
|
var h = highlights[i];
|
||||||
|
if (h.series == s)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawOverlay(plot, octx)
|
||||||
|
{
|
||||||
|
//alert(options.series.pie.radius);
|
||||||
|
var options = plot.getOptions();
|
||||||
|
//alert(options.series.pie.radius);
|
||||||
|
|
||||||
|
var radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
octx.save();
|
||||||
|
octx.translate(centerLeft, centerTop);
|
||||||
|
octx.scale(1, options.series.pie.tilt);
|
||||||
|
|
||||||
|
for (i = 0; i < highlights.length; ++i)
|
||||||
|
drawHighlight(highlights[i].series);
|
||||||
|
|
||||||
|
drawDonutHole(octx);
|
||||||
|
|
||||||
|
octx.restore();
|
||||||
|
|
||||||
|
function drawHighlight(series)
|
||||||
|
{
|
||||||
|
if (series.angle < 0) return;
|
||||||
|
|
||||||
|
//octx.fillStyle = parseColor(options.series.pie.highlight.color).scale(null, null, null, options.series.pie.highlight.opacity).toString();
|
||||||
|
octx.fillStyle = "rgba(255, 255, 255, "+options.series.pie.highlight.opacity+")"; // this is temporary until we have access to parseColor
|
||||||
|
|
||||||
|
octx.beginPath();
|
||||||
|
if (Math.abs(series.angle - Math.PI*2) > 0.000000001)
|
||||||
|
octx.moveTo(0,0); // Center of the pie
|
||||||
|
octx.arc(0,0,radius,series.startAngle,series.startAngle+series.angle,false);
|
||||||
|
octx.closePath();
|
||||||
|
octx.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end init (plugin body)
|
||||||
|
|
||||||
|
// define pie specific options and their default values
|
||||||
|
var options = {
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: false,
|
||||||
|
radius: 'auto', // actual radius of the visible pie (based on full calculated radius if <=1, or hard pixel value)
|
||||||
|
innerRadius:0, /* for donut */
|
||||||
|
startAngle: 3/2,
|
||||||
|
tilt: 1,
|
||||||
|
offset: {
|
||||||
|
top: 0,
|
||||||
|
left: 'auto'
|
||||||
|
},
|
||||||
|
stroke: {
|
||||||
|
color: '#FFF',
|
||||||
|
width: 1
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
show: 'auto',
|
||||||
|
formatter: function(label, slice){
|
||||||
|
return '<div style="font-size:x-small;text-align:center;padding:2px;color:'+slice.color+';">'+label+'<br/>'+Math.round(slice.percent)+'%</div>';
|
||||||
|
}, // formatter function
|
||||||
|
radius: 1, // radius at which to place the labels (based on full calculated radius if <=1, or hard pixel value)
|
||||||
|
background: {
|
||||||
|
color: null,
|
||||||
|
opacity: 0
|
||||||
|
},
|
||||||
|
threshold: 0 // percentage at which to hide the label (i.e. the slice is too narrow)
|
||||||
|
},
|
||||||
|
combine: {
|
||||||
|
threshold: -1, // percentage at which to combine little slices into one larger slice
|
||||||
|
color: null, // color to give the new slice (auto-generated if null)
|
||||||
|
label: 'Other' // label to give the new slice
|
||||||
|
},
|
||||||
|
highlight: {
|
||||||
|
//color: '#FFF', // will add this functionality once parseColor is available
|
||||||
|
opacity: 0.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: "pie",
|
||||||
|
version: "1.0"
|
||||||
|
});
|
||||||
|
})(jQuery);
|
File diff suppressed because one or more lines are too long
@ -7,8 +7,7 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
|||||||
var labels = labels.split(separator);
|
var labels = labels.split(separator);
|
||||||
var data = values.split(separator);
|
var data = values.split(separator);
|
||||||
|
|
||||||
for( var i = 0; i<nseries; i++)
|
for (var i = 0; i < nseries; i++) {
|
||||||
{
|
|
||||||
data[i] = { label: labels[i], data: parseInt(data[i]) }
|
data[i] = { label: labels[i], data: parseInt(data[i]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,8 +22,10 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
|||||||
label_conf = {
|
label_conf = {
|
||||||
show: true,
|
show: true,
|
||||||
radius: 3/4,
|
radius: 3/4,
|
||||||
formatter: function(label, series){
|
formatter: function(label, series) {
|
||||||
return '<div style="font-size:'+font_size+'pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
return '<div style="font-size:' + font_size + 'pt;' +
|
||||||
|
'text-align:center;padding:2px;color:white;">' +
|
||||||
|
label + '<br/>' + Math.round(series.percent) + '%</div>';
|
||||||
},
|
},
|
||||||
background: {
|
background: {
|
||||||
opacity: 0.5,
|
opacity: 0.5,
|
||||||
@ -79,9 +80,9 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
$('#'+graph_id).bind('plothover', pieHover);
|
$('#' + graph_id).bind('plothover', pieHover);
|
||||||
$('#'+graph_id).bind('plotclick', pieClick);
|
$('#' + graph_id).bind('plotclick', pieClick);
|
||||||
$('#'+graph_id).bind('mouseout',resetInteractivity);
|
$('#' + graph_id).bind('mouseout',resetInteractivity);
|
||||||
|
|
||||||
function pieHover(event, pos, obj)
|
function pieHover(event, pos, obj)
|
||||||
{
|
{
|
||||||
@ -101,8 +102,9 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(water_mark) {
|
if (water_mark) {
|
||||||
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
set_watermark(graph_id, plot,
|
||||||
|
$('#watermark_image_' + graph_id).attr('src'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,9 +361,9 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
//~ index = item.dataIndex;
|
//~ index = item.dataIndex;
|
||||||
//~ $('#value_'+index+'_'+graph_id).css('font-weight', 'bold');
|
//~ $('#value_'+index+'_'+graph_id).css('font-weight', 'bold');
|
||||||
//~ }
|
//~ }
|
||||||
//~ });
|
//~ });
|
||||||
|
|
||||||
if(water_mark) {
|
if (water_mark) {
|
||||||
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -379,7 +381,7 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
|
|||||||
|
|
||||||
var datas = new Array();
|
var datas = new Array();
|
||||||
|
|
||||||
for(i=0;i<values.length;i++) {
|
for (i=0;i<values.length;i++) {
|
||||||
var serie = values[i].split(separator);
|
var serie = values[i].split(separator);
|
||||||
var aux = new Array();
|
var aux = new Array();
|
||||||
$.each(serie,function(i,v) {
|
$.each(serie,function(i,v) {
|
||||||
@ -853,59 +855,59 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
if(extra_show) {
|
if(extra_show) {
|
||||||
$('#extra_'+graph_id).html(extra_info);
|
$('#extra_'+graph_id).html(extra_info);
|
||||||
$('#extra_'+graph_id).css('display','');
|
$('#extra_'+graph_id).css('display','');
|
||||||
}
|
}
|
||||||
plot.highlight(item.series, item.datapoint);
|
plot.highlight(item.series, item.datapoint);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#extra_'+graph_id).html('');
|
$('#extra_'+graph_id).html('');
|
||||||
$('#extra_'+graph_id).css('display','none');
|
$('#extra_'+graph_id).css('display','none');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#overview_'+graph_id).bind('plothover', function (event, pos, item) {
|
$('#overview_'+graph_id).bind('plothover', function (event, pos, item) {
|
||||||
plot.setCrosshair({ x: pos.x, y: 0 });
|
plot.setCrosshair({ x: pos.x, y: 0 });
|
||||||
currentPlot = overview;
|
currentPlot = overview;
|
||||||
latestPosition = pos;
|
latestPosition = pos;
|
||||||
if (!updateLegendTimeout) {
|
if (!updateLegendTimeout) {
|
||||||
updateLegendTimeout = setTimeout(updateLegend, 50);
|
updateLegendTimeout = setTimeout(updateLegend, 50);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#'+graph_id).bind('mouseout',resetInteractivity);
|
$('#'+graph_id).bind('mouseout',resetInteractivity);
|
||||||
$('#overview_'+graph_id).bind('mouseout',resetInteractivity);
|
$('#overview_'+graph_id).bind('mouseout',resetInteractivity);
|
||||||
|
|
||||||
// Reset interactivity styles
|
// Reset interactivity styles
|
||||||
function resetInteractivity() {
|
function resetInteractivity() {
|
||||||
$('#timestamp_'+graph_id).hide();
|
$('#timestamp_'+graph_id).hide();
|
||||||
dataset = plot.getData();
|
dataset = plot.getData();
|
||||||
for (i = 0; i < dataset.length; ++i) {
|
for (i = 0; i < dataset.length; ++i) {
|
||||||
legends.eq(i).text(legends.eq(i).text().replace(/=.*/, ''));
|
legends.eq(i).text(legends.eq(i).text().replace(/=.*/, ''));
|
||||||
}
|
}
|
||||||
plot.clearCrosshair();
|
plot.clearCrosshair();
|
||||||
overview.clearCrosshair();
|
overview.clearCrosshair();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format functions
|
// Format functions
|
||||||
function xFormatter(v, axis) {
|
function xFormatter(v, axis) {
|
||||||
if(labels[v] == undefined) {
|
if(labels[v] == undefined) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return '<div style=font-size:'+font_size+'pt>'+labels[v]+'</div>';
|
return '<div style=font-size:'+font_size+'pt>'+labels[v]+'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function yFormatter(v, axis) {
|
function yFormatter(v, axis) {
|
||||||
var formatted = number_format(v,force_integer,unit);
|
var formatted = number_format(v,force_integer,unit);
|
||||||
|
|
||||||
return '<div style=font-size:'+font_size+'pt>'+formatted+'</div>';
|
return '<div style=font-size:'+font_size+'pt>'+formatted+'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function lFormatter(v, item) {
|
function lFormatter(v, item) {
|
||||||
return '<div style=color:#000;font-size:'+font_size+'pt>'+v+'</div>';
|
return '<div style=color:#000;font-size:'+font_size+'pt>'+v+'</div>';
|
||||||
// Prepared to turn series with a checkbox
|
// Prepared to turn series with a checkbox
|
||||||
//return '<div style=color:#000;font-size:'+font_size+'pt><input type="checkbox" id="' + graph_id + '_' + item.id +'" checked="checked" class="check_serie_'+graph_id+'">'+v+'</div>';
|
//return '<div style=color:#000;font-size:'+font_size+'pt><input type="checkbox" id="' + graph_id + '_' + item.id +'" checked="checked" class="check_serie_'+graph_id+'">'+v+'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepared to turn series with a checkbox
|
// Prepared to turn series with a checkbox
|
||||||
//~ $('.check_serie_'+graph_id).click(function() {
|
//~ $('.check_serie_'+graph_id).click(function() {
|
||||||
//~ // Format of the id is graph_3905jf93f03_serie_id
|
//~ // Format of the id is graph_3905jf93f03_serie_id
|
||||||
//~ id_clicked = this.id.split('_')[3];
|
//~ id_clicked = this.id.split('_')[3];
|
||||||
@ -948,10 +950,10 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
$('#menu_cancelzoom_'+graph_id).click(function() {
|
$('#menu_cancelzoom_'+graph_id).click(function() {
|
||||||
// cancel the zooming
|
// cancel the zooming
|
||||||
plot = $.plot($('#'+graph_id), data_base,
|
plot = $.plot($('#'+graph_id), data_base,
|
||||||
$.extend(true, {}, options, {
|
$.extend(true, {}, options, {
|
||||||
xaxis: { min: 0, max: max_x },
|
xaxis: { min: 0, max: max_x },
|
||||||
legend: { show: false }
|
legend: { show: false }
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$('#menu_cancelzoom_'+graph_id).attr('src',homeurl+'/images/zoom_cross.disabled.png');
|
$('#menu_cancelzoom_'+graph_id).attr('src',homeurl+'/images/zoom_cross.disabled.png');
|
||||||
overview.clearSelection();
|
overview.clearSelection();
|
||||||
@ -961,7 +963,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
// Adjust the menu image on top of the plot
|
// Adjust the menu image on top of the plot
|
||||||
$('#menu_overview_'+graph_id)[0].onload = function() {
|
$('#menu_overview_'+graph_id)[0].onload = function() {
|
||||||
// If there is no legend we increase top-padding to make space to the menu
|
// If there is no legend we increase top-padding to make space to the menu
|
||||||
if(legends.length == 0) {
|
if (legends.length == 0) {
|
||||||
$('#menu_'+graph_id).parent().css('padding-top',$('#menu_'+graph_id).css('height'));
|
$('#menu_'+graph_id).parent().css('padding-top',$('#menu_'+graph_id).css('height'));
|
||||||
}
|
}
|
||||||
// Add bottom margin in the legend
|
// Add bottom margin in the legend
|
||||||
@ -970,16 +972,16 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||||||
$('#legend_'+graph_id).css('margin-bottom', menu_height+legend_margin_bottom+'px');
|
$('#legend_'+graph_id).css('margin-bottom', menu_height+legend_margin_bottom+'px');
|
||||||
parent_height = parseInt($('#menu_'+graph_id).parent().css('height').split('px')[0]);
|
parent_height = parseInt($('#menu_'+graph_id).parent().css('height').split('px')[0]);
|
||||||
adjust_menu(graph_id, plot, parent_height);
|
adjust_menu(graph_id, plot, parent_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(water_mark) {
|
if (water_mark) {
|
||||||
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjust_menu(graph_id, plot, parent_height) {
|
function adjust_menu(graph_id, plot, parent_height) {
|
||||||
if($('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width') != undefined) {
|
if ($('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width') != undefined) {
|
||||||
left_ticks_width = $('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width').split('px')[0];
|
left_ticks_width = $('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width').split('px')[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -987,39 +989,40 @@ function adjust_menu(graph_id, plot, parent_height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var parent_height_new = 0;
|
var parent_height_new = 0;
|
||||||
|
|
||||||
var legend_height = parseInt($('#legend_'+graph_id).css('height').split('px')[0]) + parseInt($('#legend_'+graph_id).css('margin-top').split('px')[0]);
|
var legend_height = parseInt($('#legend_'+graph_id).css('height').split('px')[0]) + parseInt($('#legend_'+graph_id).css('margin-top').split('px')[0]);
|
||||||
if($('#overview_'+graph_id).css('display') == 'none') {
|
if ($('#overview_'+graph_id).css('display') == 'none') {
|
||||||
overview_height = 0;
|
overview_height = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
overview_height = parseInt($('#overview_'+graph_id).css('height').split('px')[0]) + parseInt($('#overview_'+graph_id).css('margin-top').split('px')[0]);
|
overview_height = parseInt($('#overview_'+graph_id).css('height').split('px')[0]) + parseInt($('#overview_'+graph_id).css('margin-top').split('px')[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#menu_'+graph_id).css('top',(-parent_height+legend_height-overview_height-7)+'px');
|
$('#menu_'+graph_id).css('top',
|
||||||
|
(-parent_height+legend_height-overview_height-7)+'px');
|
||||||
$('#menu_'+graph_id).css('left',plot.width()-(left_ticks_width/2));
|
$('#menu_'+graph_id).css('left',plot.width()-(left_ticks_width/2));
|
||||||
$('#menu_'+graph_id).show();
|
$('#menu_'+graph_id).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_watermark(graph_id, plot, watermark_src) {
|
function set_watermark(graph_id, plot, watermark_src) {
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = watermark_src;
|
img.src = watermark_src;
|
||||||
var context = plot.getCanvas().getContext('2d');
|
var context = plot.getCanvas().getContext('2d');
|
||||||
|
|
||||||
// Once it's loaded draw the image on the canvas.
|
// Once it's loaded draw the image on the canvas.
|
||||||
img.addEventListener('load', function () {
|
img.addEventListener('load', function () {
|
||||||
//~ // Now resize the image: x, y, w, h.
|
//~ // Now resize the image: x, y, w, h.
|
||||||
|
|
||||||
var down_ticks_height = 0;
|
var down_ticks_height = 0;
|
||||||
if($('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height') != undefined) {
|
if($('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height') != undefined) {
|
||||||
down_ticks_height = $('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height').split('px')[0];
|
down_ticks_height = $('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height').split('px')[0];
|
||||||
}
|
}
|
||||||
var left_pos = parseInt(context.canvas.width - 3) - $('#watermark_image_'+graph_id)[0].width;
|
var left_pos = parseInt(context.canvas.width - 3) - $('#watermark_image_'+graph_id)[0].width;
|
||||||
var top_pos = parseInt(context.canvas.height - down_ticks_height - 20) - $('#watermark_image_'+graph_id)[0].height;
|
var top_pos = parseInt(context.canvas.height - down_ticks_height - 20) - $('#watermark_image_'+graph_id)[0].height;
|
||||||
|
|
||||||
context.drawImage(this, left_pos, top_pos);
|
context.drawImage(this, left_pos, top_pos);
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_event_details (event_ids) {
|
function get_event_details (event_ids) {
|
||||||
@ -1048,12 +1051,12 @@ function get_event_details (event_ids) {
|
|||||||
|
|
||||||
function adjust_left_width_canvas(adapter_id, adapted_id) {
|
function adjust_left_width_canvas(adapter_id, adapted_id) {
|
||||||
adapter_left_margin = $('#'+adapter_id+' .yAxis .tickLabel').css('width');
|
adapter_left_margin = $('#'+adapter_id+' .yAxis .tickLabel').css('width');
|
||||||
|
|
||||||
adapted_pix = $('#'+adapted_id).css('width').split('px');
|
adapted_pix = $('#'+adapted_id).css('width').split('px');
|
||||||
new_adapted_width = parseInt(adapted_pix[0])-parseInt(adapter_left_margin);
|
new_adapted_width = parseInt(adapted_pix[0])-parseInt(adapter_left_margin);
|
||||||
|
|
||||||
$('#'+adapted_id).css('width',new_adapted_width);
|
$('#'+adapted_id).css('width',new_adapted_width);
|
||||||
|
|
||||||
$('#'+adapted_id).css('margin-left',adapter_left_margin);
|
$('#'+adapted_id).css('margin-left',adapter_left_margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1070,7 +1073,7 @@ function check_adaptions(graph_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function number_format(number, force_integer, unit) {
|
function number_format(number, force_integer, unit) {
|
||||||
if(force_integer) {
|
if (force_integer) {
|
||||||
if(Math.round(number) != number) {
|
if(Math.round(number) != number) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -1083,7 +1086,7 @@ function number_format(number, force_integer, unit) {
|
|||||||
|
|
||||||
var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
while(1){
|
while (1) {
|
||||||
if (number >= 1000) { //as long as the number can be divided by 1000
|
if (number >= 1000) { //as long as the number can be divided by 1000
|
||||||
pos++; //Position in array starting with 0
|
pos++; //Position in array starting with 0
|
||||||
number = number / 1000;
|
number = number / 1000;
|
||||||
|
@ -36,7 +36,7 @@ function include_javascript_dependencies_flot_graph($return = false) {
|
|||||||
<script language="javascript" type="text/javascript" src="'.
|
<script language="javascript" type="text/javascript" src="'.
|
||||||
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.min.js') .'"></script>
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.min.js') .'"></script>
|
||||||
<script language="javascript" type="text/javascript" src="'.
|
<script language="javascript" type="text/javascript" src="'.
|
||||||
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.pie.min.js') .'"></script>
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.pie.js') .'"></script>
|
||||||
<script language="javascript" type="text/javascript" src="'.
|
<script language="javascript" type="text/javascript" src="'.
|
||||||
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.crosshair.min.js') .'"></script>
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.crosshair.min.js') .'"></script>
|
||||||
<script language="javascript" type="text/javascript" src="'.
|
<script language="javascript" type="text/javascript" src="'.
|
||||||
@ -351,8 +351,8 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark,
|
|||||||
|
|
||||||
$separator = ';;::;;';
|
$separator = ';;::;;';
|
||||||
|
|
||||||
$labels = implode($separator,$labels);
|
$labels = implode($separator, $labels);
|
||||||
$values = implode($separator,$values);
|
$values = implode($separator, $values);
|
||||||
|
|
||||||
$return .= "<script type='text/javascript'>";
|
$return .= "<script type='text/javascript'>";
|
||||||
|
|
||||||
|
@ -108,7 +108,8 @@ else if ($modulegroup > -1) {
|
|||||||
|
|
||||||
// Module name selector
|
// Module name selector
|
||||||
if ($ag_modulename != "") {
|
if ($ag_modulename != "") {
|
||||||
$sql_conditions .= sprintf (" AND tagente_modulo.nombre = '%s'", $ag_modulename);
|
$sql_conditions .= sprintf (" AND tagente_modulo.nombre = '%s'",
|
||||||
|
$ag_modulename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Freestring selector
|
// Freestring selector
|
||||||
@ -691,10 +692,10 @@ else {
|
|||||||
$count_modules = 0;
|
$count_modules = 0;
|
||||||
foreach($servers as $server) {
|
foreach($servers as $server) {
|
||||||
// If connection was good then retrieve all data server
|
// If connection was good then retrieve all data server
|
||||||
if (metaconsole_connect($server) == NOERR){
|
if (metaconsole_connect($server) == NOERR) {
|
||||||
$connection = true;
|
$connection = true;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$connection = false;
|
$connection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user