warning/MacroProcessor: Macro is not defined

Hi all,

I’m getting the following messages in the Icinga log:
< [2022-11-09 09:07:57 -0600] warning/MacroProcessor: Macro ‘hamode’ is not defined.

The command is the following:
object CheckCommand “template.test” {
import “plugin-check-command”
command = [ PluginDir + “/template.test”, “-H”, “$address$”, “-m”, “$mode$”, “-ha”, “$hamode$” ]
}

  • Version used
    r2.10.4-1

  • Operating System and version
    Red Hat Enterprise Linux Server release 7.9

  • Enabled features
    Disabled features: debuglog elasticsearch gelf graphite opentsdb perfdata syslog
    Enabled features: api checker command compatlog ido-mysql influxdb livestatus mainlog notification statusdata

  • Icinga Web 2 version and modules (System - About)
    Icinga Web 2 Version 2.6.2

  • Config validation
    It’s OK: [2022-11-10 02:23:22 -0600] information/cli: Finished validating the configuration file(s).

How can I “define” the macro?

Thank you very much,
Regards.

you definded a checkcommand and most likely used in in a service or host as a check command.

in order to use the a macro in an check command you have to define it like that:
vars.hamode = “your-hamode”

object Host "wp1.example.com" {
  import "web-server"
  import "wp-server"

  vars.webserver_type = "nginx" //overrides attribute from base template

  address = "192.168.56.201"
}

=> Monitoring Basics - Icinga 2

Thanks for the answer @moreamazingnick ! Yes, I have the following components:

– A command:
object CheckCommand “test.command” {
import “plugin-check-command”
command = [ PluginDir + “/test”, “-H”, “$address$”, “-m”, “$mode$”, “-ha”, “$hamode$” ]
}

– A service:
apply Service “HA_MODE” {
import “generic-service”
import “generic-service-vars”
check_command = “test.command”
vars.address = host.address
vars.hamode = “$host.vars.test.template.hamode$”
assign where “test.template” in host.templates
}

– A host:
object Host “host” {
import “generic-host”
import “test.template”
vars.test.template.hamode = “mode”
}

And in the Icinga2’s log appears the following lines:
[2022-11-10 05:36:21 -0600] warning/MacroProcessor: Macro ‘hamode’ is not defined.
Context:
(0) Resolving macros for string ‘$hamode$’

I’m not sure what I need to stop these messages. The monitoring is working correctly.

Thanks,
Regards!

– A service:
apply Service “HA_MODE” {
  import “generic-service”
  import “generic-service-vars”
  check_command = “test.command”
  vars.address = host.address
  vars.hamode = “$host.vars.hamode$”
  assign where “test.template” in host.templates
}

object Host “host” {
  import “generic-host”
  import “test.template”
  vars.hamode = “mode”
}

Thanks, that’s work, although if I add a “.field” more is not working… for example:
– A service:
apply Service “HA_MODE” {
import “generic-service”
import “generic-service-vars”
check_command = “test.command”
vars.address = host.address
vars.field.hamode = “$host.vars.field.hamode$”
assign where “test.template” in host.templates
}

object Host “host” {
import “generic-host”
import “test.template”
vars.field.hamode = “mode”
}

Is this a limitation of Icinga? I don’t see anything in the documentation.

vars is something like a dictionary in python
look at this:
https://icinga.com/docs/icinga-2/latest/doc/03-monitoring-basics/#custom-variables

and since it’s the solution to your problem hit the solution button :slight_smile: