Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev.icinga.com #13717] Global Functions in ITL #4890

Closed
icinga-migration opened this issue Dec 21, 2016 · 2 comments
Closed

[dev.icinga.com #13717] Global Functions in ITL #4890

icinga-migration opened this issue Dec 21, 2016 · 2 comments
Labels
area/itl Template Library CheckCommands enhancement New feature or request

Comments

@icinga-migration
Copy link

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

Created by dgoetz on 2016-12-21 13:41:50 +00:00

Assignee: (none)
Status: New
Target Version: (none)
Last Update: 2016-12-21 13:41:50 +00:00 (in Redmine)

Backport?: Not yet backported
Include in Changelog: 1

I think there would be some advantages from collecting also community provided global functions in the ITL (like plugins-contrib.d/global-functions).

An example for time dependend thresholds without function:

apply Service "Disk - " for (disk in host.vars.disks) {
  check_command = "disk"
  vars.disk_partition = disk

  vars.disk_wfree = {{
   if (get_time_period("backup").is_inside) {
      return "85%"
    } else {
      return "97%"
    }
  }}
  vars.disk_cfree = {{
   if (get_time_period("backup").is_inside) {
      return "95%"
    } else {
      return "99%"
    }
  }}
}

And with function:

globals.timedependend_value = function(timeperiod, inside, outside) {
  if (get_time_period(timeperiod).is_inside) {
    return inside
  } else {
    return outside
  }
}

apply Service "Disk - " for (disk in host.vars.disks) {
  check_command = "disk"
  vars.disk_partition = disk

  vars.disk_wfree = {{ timedependend_value("backup","97%","85%") }}
  vars.disk_cfree = {{ timedependend_value("backup","99%","95%") }}
}

Would do you think about the idea? If you like it, how should documentation for this look like (inline and markdown) and what type of functions should be included?

@icinga-migration icinga-migration added the enhancement New feature or request label Jan 17, 2017
@dnsmichi dnsmichi added the area/itl Template Library CheckCommands label Feb 6, 2017
@dnsmichi
Copy link
Contributor

dnsmichi commented Nov 7, 2017

Needs to be discussed.

@htriem
Copy link
Contributor

htriem commented Jan 22, 2020

We should provide documentation examples, and help users on the community forums but at not this burden to our template library.

@htriem htriem closed this as completed Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/itl Template Library CheckCommands enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants