Skip to content
This repository has been archived by the owner on Apr 16, 2018. It is now read-only.

[dev.icinga.com #11028] multi line argument in icinga2::object::apply_service #342

Open
icinga-migration opened this issue Jan 25, 2016 · 0 comments
Labels

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/11028

Created by tepe on 2016-01-25 10:41:51 +00:00

Assignee: (none)
Status: New
Target Version: (none)
Last Update: 2016-01-25 10:41:51 +00:00 (in Redmine)


Hey,

I would like to use an icinga function for nrpe_arguments.

https://github.com/Icinga/puppet-icinga2/blob/develop/templates/object\_apply\_service.conf.erb

<%- if vars.any? -%>
vars += <%= scope.function_icinga2_config_value([vars]) %> <%- end -%>

example:
icinga2::object::apply_service {"check_load": display_name => 'load', check_command => 'nrpe', vars => { nrpe_command => 'check_load', nrpe_arguments => '{{ if (host.vars.cpu){ var warn=host.vars.cpu*1.5 + "," + host.vars.cpu*1.7 + "," + host.vars.cpu*1.9 var crit=host.vars.cpu*3 + "," + host.vars.cpu*3.5 + "," + host.vars.cpu*4 return warn + "!" + crit }else{ return "2,3,3.5!4,4.5,5" } }}', }, assign_where => 'host.vars.os == "Linux"', ignore_where => 'host.vars.zone == "uri" || host.name == "localhost"', }

result:
@~# cat /etc/icinga2/objects/applys/check_load.conf
/****

  • WARNING: This service definition is automatically generated by Puppet.
  • ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
    */

/****

  • A object definition that applys services to hosts. You can create your
  • own configuration files in the conf.d directory (e.g. one per host).
  • By default all *.conf files in this directory are included.

*/

apply Service "check_load" to Host {
import "generic-service"
display_name = "load"
assign where host.vars.os "Linux"
ignore where host.vars.zone "uri" || host.name == "localhost"
check_command = "nrpe"
vars += {
"nrpe_arguments" = "{{\n \tif (host.vars.cpu){\n \t\tvar warn=host.vars.cpu*1.5 + \",\" + host.vars.cpu*1.7 + \",\" + host.vars.cpu*1.9\n \t\tvar crit=host.vars.cpu*3 + \",\" + host.vars.cpu*3.5 + \",\" + host.vars.cpu*4\n \t\treturn warn + \"!\" + crit\n \t\t}else{\n \t\treturn \"2,3,3.5!4,4.5,5\n \t\t}\n \t}}"
"nrpe_command" = "check_load"
}
enable_notifications = true
}@

This result is unuseable for icinga2, check_load does not work. Follow works fine:
@/****

  • WARNING: This service definition is automatically generated by Puppet.
  • ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
    */

/****

  • A object definition that applys services to hosts. You can create your
  • own configuration files in the conf.d directory (e.g. one per host).
  • By default all *.conf files in this directory are included.

*/

apply Service "check_load" to Host {
import "generic-service"
display_name = "load"
assign where host.vars.os "Linux"
ignore where host.vars.zone "uri" || host.name == "localhost"
check_command = "nrpe"
vars += {
"nrpe_arguments" = {{ if (host.vars.cpu){
var warn=host.vars.cpu*1.5 + "," + host.vars.cpu*1.7 + "," + host.vars.cpu*1.9
var crit=host.vars.cpu*3 + "," + host.vars.cpu*3.5 + "," + host.vars.cpu*4
return warn + "!" + crit
}else{
return "2,3,3.5!4,4.5,5"
}
}}
"nrpe_command" = "check_load"
}
enable_notifications = true
}@

Perhaps a bug or I use icinga2::object::apply_service in a wrong way.

Viele Gruesse,
thomas.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant