Skip to content

Instantly share code, notes, and snippets.

@waja
Last active February 21, 2022 04:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waja/6d5e33c814a20d4834ac47adba92ee24 to your computer and use it in GitHub Desktop.
Save waja/6d5e33c814a20d4834ac47adba92ee24 to your computer and use it in GitHub Desktop.
example check_smart configuration for a icinga2
object CheckCommand "check-smart" {
import "plugin-check-command"
command = [ "/usr/lib/monitoring-plugins" + "/check_smart" ]
arguments = {
"--device" = {
value = "$smart_device$"
set_if = {{ macro("$smart_device_is_glob$") == false }}
description = "A physical block device to be SMART monitored, eg /dev/sda. Pseudo-device /dev/bus/N is allowed."
}
"--global" = {
value = "$smart_device$"
set_if = {{ macro("$smart_device_is_glob$") == true }}
description = "A glob expression of physical devices to be monitored, eg -g '/dev/sd[a-z]'."
}
"--interface" = {
value = "$smart_interface$"
description = "Drive's interface type, must be one of: auto, ata, scsi, nvme, 3ware,N, areca,N, hpt,L/M/N, cciss,N, megaraid,N, aacraid,N,N,N"
required = true
}
"--raw" = {
value = "$smart_raw_list$"
description = "List (comma separated, without spaces!) of SMART attributes to check for their raw values."
}
"--exclude" = {
value = "$smart_exclude_list$"
description = "List of (comma separated) SMART attributes which should be excluded (=ignored) from checks."
}
"--exclude-all" = {
value = "$smart_exclude_all_list$"
description = "List of (comma separated) SMART attributes which should be excluded (=ignored) completely, for both checks and performance data."
}
"--bad" = {
value = "$smart_bad$"
description = "Threshold value (integer) when to warn for N bad entries (ATA: Current Pending Sector, SCSI: Grown defect list). Note: Deprecated for ATA drives, use `smart_warn` instead. Continue to use this for SCSI drives."
}
"--warn" = {
value = "$smart_warn$"
description = "Comma separated list of thresholds for ATA drives (e.g. `'Reallocated_Sector_Ct=10,Current_Pending_Sector=62'`)."
}
"--selftest" = {
set_if = "$smart_selftest$"
description = "If set to true, additionally check SMART's selftest log for errors."
}
"--ssd-lifetime" = {
set_if = "$smart_ssd_lifetime$"
description = "If set to true, additionally check SSD attribute Percent_Lifetime_Remain."
}
"--quiet" = {
set_if = "$smart_quite$"
description = "If set to true, additionally check SSD attribute Percent_Lifetime_Remain."
}
"--skip-self-assessment" = {
set_if = "$smart_skip_self_assessment$"
description = "If set to true, when faults are detected, only show failing drive(s) (only affects output when used with -g parameter)."
}
"--debug" = {
set_if = "$smart_debug$"
description = "If set to true, additionall debugging information is shown."
}
}
vars.smart_device = "/dev/sda"
vars.smart_interface = "auto"
vars.smart_device_is_glob = false
vars.smart_selftest = false
vars.smart_ssd_lifetime = false
vars.smart_quiet = false
vars.smart_skip_self_assessment = false
vars.smart_debug = false
timeout = 60s
}
/* apply smart service check */
apply Service "smart" {
import "local-generic-service"
check_command = "check-smart"
command_endpoint = host.name
// notification tag
vars.sections = [ "operatingsystem" ] # TODO GIT
assign where host.vars.os == "Linux" && host.vars.smart_device
ignore where host.vars.nochecksmart
ignore where host.vars.noagent
}
apply Service for (smart_device => config in host.vars.smart_devices) {
import "local-generic-service"
check_command = "check-smart"
vars += config
command_endpoint = host.name
// notification tag
vars.sections = [ "operatingsystem" ] # TODO GIT
ignore where host.vars.nochecksmart
ignore where host.vars.noagent
ignore where typeof(config) != Dictionary
}
object Host "hostname" {
import "linux-host"
address 127.0.1.3
vars.smart_device = "/dev/sda"
vars.smart_interface = "cciss,[0-5]"
vars.smart_device_is_glob = true
vars.smart_devices["smart - device megaraid,12"] = {
smart_device = "/dev/sdb"
smart_interface = "megaraid,12"
smart_device_is_glob = false
}
vars.smart_devices["smart - device megaraid,13"] = {
smart_device = "/dev/sdb"
smart_interface = "megaraid,13"
smart_device_is_glob = false
}
vars.smart_devices["smart - device megaraid,17"] = {
smart_device = "/dev/sdb"
smart_interface = "megaraid,17"
smart_device_is_glob = false
}
vars.smart_devices["smart - device megaraid,18"] = {
smart_device = "/dev/sdb"
smart_interface = "megaraid,18"
smart_device_is_glob = false
}
}
object Endpoint "hostname" {
}
object Zone "hostname" {
endpoints = [ "hostname" ]
parent = "master"
}
@bodsch
Copy link

bodsch commented Feb 21, 2022

Meine CheckCommand Definition ist da "deutlich" kürzer :}
Deine ist umfangreich

object CheckCommand "check_smart" {
  import "plugin-check-command"
  command = [ PluginDir + "/check_smart.pl" ]
  arguments = {
    "--device" = "$smart_device$"
    "--interface" = "auto"
    "--warn" = {
      set_if = "$smart_warn$"
    }

  }
}
apply Service "" for (device => config in host.vars.smart) {
  import "generic-service"
  check_command = "check_smart"
  check_interval = 30m
  vars = {
    "smart_device" = device
  }

  assign where host.vars.smart
}
object Host "icinga.matrix.lan" {
  address = "192.168.0.5"
  display_name = "icinga.matrix.lan"
  zone = "master"
  address = "192.168.0.5"
  import "generic-host"
  vars = {
    smart = {
      "/dev/sda" = { }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment