From 01148749a6e57186877e3578431612c62e348c89 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 14 Oct 2019 17:10:48 +0200 Subject: [PATCH] Added secondarygroups macro and updated spanish, english and japanses wiki --- 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 | 2 ++ pandora_server/lib/PandoraFMS/Core.pm | 10 ++++++++++ 4 files changed, 14 insertions(+) diff --git a/pandora_console/include/help/en/help_alert_macros.php b/pandora_console/include/help/en/help_alert_macros.php index 9d730cfcc9..2a16e0b182 100644 --- a/pandora_console/include/help/en/help_alert_macros.php +++ b/pandora_console/include/help/en/help_alert_macros.php @@ -77,6 +77,7 @@ Besides the defined module macros, the following macros are available:
  • _policy_: Name of the policy that the module belongs to (if applies).
  • _prevdata_: Module previous data before the alert has been triggered.
  • _rca_: Root cause analysis chain (only for services).
  • +
  • _secondarygroups_: List of all secondary groups of the agent.
  • _server_ip_: Ip of server assigned to agent.
  • _server_name_: Name of server assigned to agent.
  • _target_ip_: IP address for the module’s target.
  • diff --git a/pandora_console/include/help/es/help_alert_macros.php b/pandora_console/include/help/es/help_alert_macros.php index 75e627f19a..e4fa442b2c 100644 --- a/pandora_console/include/help/es/help_alert_macros.php +++ b/pandora_console/include/help/es/help_alert_macros.php @@ -77,6 +77,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
  • _policy_: Nombre de la política a la que pertenece el módulo (si aplica).
  • _prevdata_: Dato previo antes de disparase la alerta.
  • _rca_: Cadena de análasis de causa raíz (sólo para servicios).
  • +
  • _secondarygroups_: Lista de todos los grupos secundarios del agente.
  • _server_ip_: Ip del servidor al que el agente está asignado.
  • _server_name_: Nombre del servidor al que el agente está asignado.
  • _target_ip_: Dirección IP del objetivo del módulo.
  • diff --git a/pandora_console/include/help/ja/help_alert_macros.php b/pandora_console/include/help/ja/help_alert_macros.php index 36ff609741..65f598fc8b 100644 --- a/pandora_console/include/help/ja/help_alert_macros.php +++ b/pandora_console/include/help/ja/help_alert_macros.php @@ -77,11 +77,13 @@
  • _policy_ : モジュールが属するポリシー名 (存在する場合)
  • _prevdata_ : アラートを発報する前のモジュールデータ
  • _rca_: Root cause analysis chain (only for services).
  • +
  • _secondarygroups_: エージェントのすべてのセカンダリグループのリスト
  • _server_ip_ : エージェントが割り当てられているサーバ IP。
  • _server_name_ : エージェントが割り当てられているサーバ名。
  • _target_ip_ : モジュールの対象IPアドレス
  • _target_port_ : モジュールの対象ポート
  • _timestamp_ : アラートが発生した日時 (yy-mm-dd hh:mm:ss).
  • +エージェントのすべてのセカンダリグループのリスト
  • _timezone_: _timestamp_ で使用されるタイムゾーン名.
  • 例: Agent _agent_ has fired alert _alert_ with data _data_ diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index ef8a9c18bf..94c107f8e3 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1125,6 +1125,7 @@ sub pandora_execute_action ($$$$$$$$$;$) { _name_tag_ => undef, _all_address_ => undef, '_address_\d+_' => undef, + _secondarygroups_ => undef, ); if ((defined ($extra_macros)) && (ref($extra_macros) eq "HASH")) { @@ -4114,6 +4115,15 @@ sub on_demand_macro($$$$$$;$) { } return(defined($field_value)) ? $field_value : ''; + } elsif ($macro eq '_secondarygroups_') { + my $field_value = ''; + + my @groups = get_db_rows ($dbh, 'SELECT tg.nombre from tagent_secondary_group as tsg INNER JOIN tgrupo tg ON tsg.id_group = tg.id_grupo WHERE tsg.id_agent = ?', $module->{'id_agente'}); + foreach my $element (@groups) { + $field_value .= $element->{'nombre'} .","; + } + chop($field_value); + return(defined($field_value)) ? '('.$field_value.')' : ''; } }