From 65033788f05550d90f2358d5f9bf274f35f1c485 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 17 Mar 2017 09:37:10 +0100 Subject: [PATCH] Added macro _agentos_ --- pandora_console/include/help/en/help_alert_macros.php | 1 + pandora_console/include/help/es/help_alert_macros.php | 1 + pandora_console/include/help/ja/help_alert_macros.php | 1 + pandora_server/lib/PandoraFMS/Core.pm | 1 + pandora_server/lib/PandoraFMS/DB.pm | 11 +++++++++++ 5 files changed, 15 insertions(+) diff --git a/pandora_console/include/help/en/help_alert_macros.php b/pandora_console/include/help/en/help_alert_macros.php index 6753e2c59a..544fd5ec36 100644 --- a/pandora_console/include/help/en/help_alert_macros.php +++ b/pandora_console/include/help/en/help_alert_macros.php @@ -25,6 +25,7 @@ Besides the defined module macros, the following macros are available:
  • _agentdescription_: Description of the agent that triggered the alert.
  • _agentgroup_: Agent’s group name.
  • _agentstatus_: Current agent status.
  • +
  • _agentos_: Agent's operative system.
  • _address_: Address of the agent that triggered the alert.
  • _timestamp_: Time and date on which the alert was triggered (yy-mm-dd hh:mm:ss).
  • _timezone_: Timezone that is represented on _timestamp_.
  • diff --git a/pandora_console/include/help/es/help_alert_macros.php b/pandora_console/include/help/es/help_alert_macros.php index f4c8f476d9..335d583d5a 100644 --- a/pandora_console/include/help/es/help_alert_macros.php +++ b/pandora_console/include/help/es/help_alert_macros.php @@ -25,6 +25,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
  • _agentdescription_: Descripción del agente que disparó la alerta.
  • _agentgroup_: Nombre del grupo del agente.
  • _agentstatus_: Estado actual del agente.
  • +
  • _agentos_: Sistema operativo del agente.
  • _address_: Dirección del agente que disparó la alerta.
  • _timestamp_: Hora y fecha en que se disparó la alerta.
  • _timezone_: Area Nombre _timestamp_ que representa en.
  • diff --git a/pandora_console/include/help/ja/help_alert_macros.php b/pandora_console/include/help/ja/help_alert_macros.php index 15b892651c..cd1e2534cf 100644 --- a/pandora_console/include/help/ja/help_alert_macros.php +++ b/pandora_console/include/help/ja/help_alert_macros.php @@ -25,6 +25,7 @@
  • _agentdescription_ : 発生したアラートの説明
  • _agentgroup_ : エージェントグループ名
  • _agentstatus_ : エージェントの現在の状態
  • +
  • _agentos_: Agent's operative system
  • _address_ : アラートが発生したエージェントのアドレス
  • _timestamp_ : アラートが発生した日時 (yy-mm-dd hh:mm:ss).
  • _timezone_: _timestamp_ で使用されるタイムゾーン名.
  • diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 19717beae2..ad58be775a 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -980,6 +980,7 @@ sub pandora_execute_action ($$$$$$$$$;$) { _agentdescription_ => (defined ($agent)) ? $agent->{'comentarios'} : '', _agentgroup_ => (defined ($group)) ? $group->{'nombre'} : '', _agentstatus_ => undef, + _agentos_ => (defined ($agent)) ? get_os_name($dbh, $agent->{'id_os'}) : '', _address_ => (defined ($agent)) ? $agent->{'direccion'} : '', _timestamp_ => (defined($timestamp)) ? $timestamp : strftime ("%Y-%m-%d %H:%M:%S", localtime()), _timezone_ => strftime ("%Z", localtime()), diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 1c831e3b02..7774048357 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -72,6 +72,7 @@ our @EXPORT = qw( get_module_name get_nc_profile_name get_os_id + get_os_name get_plugin_id get_profile_id get_priority_name @@ -249,6 +250,16 @@ sub get_os_id ($$) { return defined ($rc) ? $rc : -1; } +######################################################################## +## Return OS name given the OS id. +######################################################################## +sub get_os_name ($$) { + my ($dbh, $os_id) = @_; + + my $rc = get_db_value ($dbh, "SELECT name FROM tconfig_os WHERE id_os = ?", $os_id); + return defined ($rc) ? $rc : -1; +} + ########################################################################## ## SUB get_agent_name (agent_id) ## Return agent group id, given "agent_id"