improved agent_module report (CSV)

This commit is contained in:
fbsanchez 2020-10-21 13:23:17 +02:00
parent 42cca865ac
commit 6b25ae6004
3 changed files with 78 additions and 10 deletions

View File

@ -1342,6 +1342,73 @@ function get_priority_name($priority)
}
/**
* Translates status into string.
*
* @param integer $status Agent status.
*
* @return string Translation.
*/
function get_agent_status_string($status)
{
switch ($status) {
case AGENT_STATUS_CRITICAL:
return __('CRITICAL');
case AGENT_STATUS_WARNING:
return __('WARNING');
case AGENT_STATUS_ALERT_FIRED:
return __('ALERT FIRED');
case AGENT_STATUS_NOT_INIT:
return __('NO DATA');
case AGENT_STATUS_NORMAL:
return __('NORMAL');
case AGENT_STATUS_UNKNOWN:
default:
return __('UNKNOWN');
}
}
/**
* Translates status into string.
*
* @param integer $status Module status.
*
* @return string Translation.
*/
function get_module_status_string($status)
{
switch ($status) {
case AGENT_MODULE_STATUS_CRITICAL_BAD:
return __('CRITICAL');
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
return __('ALERT FIRED');
case AGENT_MODULE_STATUS_WARNING:
return __('WARNING');
case AGENT_MODULE_STATUS_UNKNOWN:
return __('UNKNOWN');
case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_NOT_INIT:
return __('NO DATA');
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case AGENT_MODULE_STATUS_NORMAL:
default:
return __('NORMAL');
}
}
/**
* Get priority class (CSS class) from priority value.
*

View File

@ -19,17 +19,18 @@
require_once $config['homedir'].'/include/functions.php';
require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_users.php';/**
* Return the agent if exists in the DB.
*
* @param integer $id_agent The agent id.
* @param boolean $show_disabled Show the agent found althought it is disabled. By default false.
* @param boolean $force_meta
*
* @return boolean The result to check if the agent is in the DB.
*/
require_once $config['homedir'].'/include/functions_users.php';
/**
* Return the agent if exists in the DB.
*
* @param integer $id_agent The agent id.
* @param boolean $show_disabled Show the agent found althought it is disabled. By default false.
* @param boolean $force_meta
*
* @return boolean The result to check if the agent is in the DB.
*/
function agents_get_agent($id_agent, $show_disabled=true, $force_meta=false)
{
$agent = db_get_row_filter(

View File

@ -88,7 +88,7 @@ if (is_ajax()) {
if ($get_agents_group_json) {
$id_group = (int) get_parameter('id_group');
$recursion = (bool) get_parameter('recursion');
$recursion = (get_parameter_switch('recursion', 'false') === 'true');
$id_os = get_parameter('id_os', '');
$agent_name = get_parameter('name', '');