On 24/10/2016 22:05, Antony Stone wrote:
For example - disk usage - I'm reading section 12.1.7 "disk" of
http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/plugin-check-
commands and it tells me "The check_disk plugin checks the amount of used disk
space..." and says that the default warning threshold is 20% free space, and
the default critical threshold is 10% free space.

Sure enough, if I set up a service check with »check_command = "disk"« and no
other parameters, then it alerts with the above thresholds.

However, if I run a direct command to run /usr/lib/nagios/plugins/check_disk
then it tells me "check_disk: Could not parse arguments" and indicates that "-
w limit -c limit" are required parameters.

So, I'm trying to work out where the 10% and 20% default thresholds are
defined.

Well, I would run this:

# icinga2 object list -t CheckCommand -n disk

which would tell you something like this:
Object 'disk' of type 'CheckCommand':
  % declared in '/usr/share/icinga2/include/command-plugins.conf', lines 
958:1-958:26
  * __name = "disk"
...
  * vars
    * disk_cfree = "10%"
      % = modified in '/usr/share/icinga2/include/command-plugins.conf', lines 
1110:2-1110:24
    * disk_exclude_type = [ "none", "tmpfs", "sysfs", "proc", "devtmpfs", "devfs", "mtmfs", 
"tracefs", "cgroup", "fuse.gvfsd-fuse" ]
      % = modified in '/usr/share/icinga2/include/command-plugins.conf', lines 
1114:2-1114:132
    * disk_inode_cfree = "10%"
      % = modified in '/usr/share/icinga2/include/command-plugins.conf', lines 
1112:2-1112:30
    * disk_inode_wfree = "20%"
      % = modified in '/usr/share/icinga2/include/command-plugins.conf', lines 
1111:2-1111:30
    * disk_megabytes = true
      % = modified in '/usr/share/icinga2/include/command-plugins.conf', lines 
1113:2-1113:27
    * disk_wfree = "20%"
      % = modified in '/usr/share/icinga2/include/command-plugins.conf', lines 
1109:2-1109:24

And of course look at the definition in the mentioned file /usr/share/icinga2/include/command-plugins.conf for the exact definition.

The background reason for this is a little more complicated - I have some
hosts where I can run standard Icinga checks (because Icinga is installed on
them) and others where I need to use check_by_ssh (because I can install the
plugins but I can't install Icinga itself).

I'm trying to find a way to define the SSH-based checks using the same
thresholds as the standard checks, and I've gone a long way to being able to
say "run these checks on this group of hosts" with a transparent test in the
background to see whether the check can be run directly or needs converting
into a by_ssh check, but in the latter case I am still having to define my own
default thresholds, and I want to know where I can find these defined for the
standard checks so I can simply re-use them (or re-use the current values if
someone has redefined them for certain cases).

Well, that's pretty straight forward as you have to use the "disk" definition and supplement it with the by_ssh definition. For instance like this:

object CheckCommand "by_ssh_disk" {
  import "disk"

  vars.by_ssh_command = command
  vars.by_ssh_arguments = arguments

  import "by_ssh"

  vars.by_ssh_logname = "icinga"
  vars.by_ssh_quiet = true
}

So basically it loads everything from "disk" into "by_ssh_disk", then saves the command and arguments from the "disk" definition into the by_ssh_command and by_ssh_arguments variables and then loads the rest for the by_ssh definition and defines some defaults which we need.

This way you use the same definitions as "disk" for "by_ssh_disk" and can override anything you like, e.g.:

apply Service for (disk => config in host.vars.disks) {
  import "generic-service"

  check_command = "by_ssh_disk"
  vars += config

  ignore where host.name == NodeName
}

apply Service for (disk => config in host.vars.disks) {
  import "generic-service"

  check_command = "disk"
  vars += config

  assign where host.name == NodeName
}

Which would use "disk" for the local (icinga) host and by_ssh_disk for all other hosts.

Hope this helps...

Gerald
_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to