2012-12-19 Hirofumi Kosaka <kosaka@rworks.jp>
* include/functions_api.php: Added function 'api_get_pandora_servers'. * include/functions_servers.php: Fixed a type. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7304 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
2497dce981
commit
9a6378f694
|
@ -1,3 +1,10 @@
|
|||
2012-12-19 Hirofumi Kosaka <kosaka@rworks.jp>
|
||||
|
||||
* include/functions_api.php: Added function
|
||||
'api_get_pandora_servers'.
|
||||
|
||||
* include/functions_servers.php: Fixed a type.
|
||||
|
||||
2012-12-18 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||
|
||||
* include/functions_reporting.php
|
||||
|
|
|
@ -28,6 +28,7 @@ include_once($config['homedir'] . "/include/functions_events.php");
|
|||
include_once($config['homedir'] . "/include/functions_groups.php");
|
||||
include_once($config['homedir'] . "/include/functions_network_components.php");
|
||||
include_once($config['homedir'] . "/include/functions_netflow.php");
|
||||
include_once($config['homedir'] . "/include/functions_servers.php");
|
||||
enterprise_include_once ('include/functions_local_components.php');
|
||||
|
||||
/**
|
||||
|
@ -5668,4 +5669,68 @@ function api_set_validate_event_by_id ($id, $trash1, $trash2, $returnType) {
|
|||
returnData($returnType, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $trash1
|
||||
* @param $trash2
|
||||
* @param array $other it's array, but only <csv_separator> is available.
|
||||
* @param $returnType
|
||||
*
|
||||
*/
|
||||
// http://localhost/pandora_console/include/api.php?op=get&op2=pandora_servers&return_type=csv&apipass=1234&user=admin&pass=pandora
|
||||
function api_get_pandora_servers($trash1, $trash2, $other, $returnType) {
|
||||
|
||||
if (!isset($other['data'][0]))
|
||||
$separator = ';'; // by default
|
||||
else
|
||||
$separator = $other['data'][0];
|
||||
|
||||
$servers = servers_get_info ();
|
||||
|
||||
foreach ($servers as $server) {
|
||||
$dd = array (
|
||||
'name' => $server["name"],
|
||||
'status' => $server["status"],
|
||||
'type' => $server["type"],
|
||||
'master' => $server["master"],
|
||||
'modules' => $server["modules"],
|
||||
'modules_total' => $server["modules_total"],
|
||||
'lag' => $server["lag"],
|
||||
'module_lag' => $server["module_lag"],
|
||||
'threads' => $server["threads"],
|
||||
'queued_modules' => $server["queued_modules"],
|
||||
'keepalive' => $server['keepalive']
|
||||
);
|
||||
|
||||
// servers_get_info() returns "<a http:....>servername</a>" for recon server's name.
|
||||
// i don't know why and the following line is a temprary workaround...
|
||||
$dd["name"] = preg_replace( '/<[^>]*>/', "", $dd["name"]);
|
||||
|
||||
switch ($dd['type']) {
|
||||
case "snmp":
|
||||
case "event":
|
||||
$dd['modules'] = '';
|
||||
$dd['modules_total'] = '';
|
||||
$dd['lag'] = '';
|
||||
$dd['module_lag'] = '';
|
||||
break;
|
||||
case "export":
|
||||
$dd['lag'] = '';
|
||||
$dd['module_lag'] = '';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$returnVar[] = $dd;
|
||||
}
|
||||
|
||||
$data = array('type' => 'array', 'data' => $returnVar);
|
||||
|
||||
returnData($returnType, $data, $separator);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -240,7 +240,7 @@ function servers_get_info ($id_server = -1) {
|
|||
// ---------------------------------------------------------------
|
||||
|
||||
$server["lag"] = db_get_sql ("SELECT lag_time FROM tserver WHERE id_server = ".$server["id_server"]);
|
||||
$server["modulelag"] = db_get_sql ("SELECT lag_modules FROM tserver WHERE id_server = ".$server["id_server"]);
|
||||
$server["module_lag"] = db_get_sql ("SELECT lag_modules FROM tserver WHERE id_server = ".$server["id_server"]);
|
||||
$server["modules"] = db_get_sql ("SELECT my_modules FROM tserver WHERE id_server = ".$server["id_server"]);
|
||||
$server["modules_total"] = db_get_sql ("SELECT total_modules_running FROM tserver WHERE id_server = ".$server["id_server"]);
|
||||
|
||||
|
@ -543,4 +543,4 @@ function servers_get_status ($id_server) {
|
|||
$serverinfo = servers_get_info ($id_server);
|
||||
return $serverinfo[$id_server];
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue