waja ha revisionato questo gist 3 years ago. Vai alla revisione
1 file changed, 38 insertions
check_smart.conf
| @@ -87,12 +87,50 @@ apply Service "smart" { | |||
| 87 | 87 | ignore where host.vars.noagent | |
| 88 | 88 | } | |
| 89 | 89 | ||
| 90 | + | apply Service for (smart_device => config in host.vars.smart_devices) { | |
| 91 | + | import "local-generic-service" | |
| 92 | + | ||
| 93 | + | check_command = "check-smart" | |
| 94 | + | ||
| 95 | + | vars += config | |
| 96 | + | ||
| 97 | + | command_endpoint = host.name | |
| 98 | + | ||
| 99 | + | // notification tag | |
| 100 | + | vars.sections = [ "operatingsystem" ] # TODO GIT | |
| 101 | + | ||
| 102 | + | ignore where host.vars.nochecksmart | |
| 103 | + | ignore where host.vars.noagent | |
| 104 | + | ignore where typeof(config) != Dictionary | |
| 105 | + | } | |
| 106 | + | ||
| 90 | 107 | object Host "hostname" { | |
| 91 | 108 | import "linux-host" | |
| 92 | 109 | address 127.0.1.3 | |
| 93 | 110 | vars.smart_device = "/dev/sda" | |
| 94 | 111 | vars.smart_interface = "cciss,[0-5]" | |
| 95 | 112 | vars.smart_device_is_glob = true | |
| 113 | + | ||
| 114 | + | vars.smart_devices["smart - device megaraid,12"] = { | |
| 115 | + | smart_device = "/dev/sdb" | |
| 116 | + | smart_interface = "megaraid,12" | |
| 117 | + | smart_device_is_glob = false | |
| 118 | + | } | |
| 119 | + | vars.smart_devices["smart - device megaraid,13"] = { | |
| 120 | + | smart_device = "/dev/sdb" | |
| 121 | + | smart_interface = "megaraid,13" | |
| 122 | + | smart_device_is_glob = false | |
| 123 | + | } | |
| 124 | + | vars.smart_devices["smart - device megaraid,17"] = { | |
| 125 | + | smart_device = "/dev/sdb" | |
| 126 | + | smart_interface = "megaraid,17" | |
| 127 | + | smart_device_is_glob = false | |
| 128 | + | } | |
| 129 | + | vars.smart_devices["smart - device megaraid,18"] = { | |
| 130 | + | smart_device = "/dev/sdb" | |
| 131 | + | smart_interface = "megaraid,18" | |
| 132 | + | smart_device_is_glob = false | |
| 133 | + | } | |
| 96 | 134 | } | |
| 97 | 135 | ||
| 98 | 136 | object Endpoint "hostname" { | |
waja ha revisionato questo gist 3 years ago. Vai alla revisione
1 file changed, 103 insertions
check_smart.conf(file creato)
| @@ -0,0 +1,103 @@ | |||
| 1 | + | object CheckCommand "check-smart" { | |
| 2 | + | import "plugin-check-command" | |
| 3 | + | ||
| 4 | + | command = [ "/usr/lib/monitoring-plugins" + "/check_smart" ] | |
| 5 | + | ||
| 6 | + | arguments = { | |
| 7 | + | "--device" = { | |
| 8 | + | value = "$smart_device$" | |
| 9 | + | set_if = {{ macro("$smart_device_is_glob$") == false }} | |
| 10 | + | description = "A physical block device to be SMART monitored, eg /dev/sda. Pseudo-device /dev/bus/N is allowed." | |
| 11 | + | } | |
| 12 | + | "--global" = { | |
| 13 | + | value = "$smart_device$" | |
| 14 | + | set_if = {{ macro("$smart_device_is_glob$") == true }} | |
| 15 | + | description = "A glob expression of physical devices to be monitored, eg -g '/dev/sd[a-z]'." | |
| 16 | + | } | |
| 17 | + | "--interface" = { | |
| 18 | + | value = "$smart_interface$" | |
| 19 | + | 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" | |
| 20 | + | required = true | |
| 21 | + | } | |
| 22 | + | "--raw" = { | |
| 23 | + | value = "$smart_raw_list$" | |
| 24 | + | description = "List (comma separated, without spaces!) of SMART attributes to check for their raw values." | |
| 25 | + | } | |
| 26 | + | "--exclude" = { | |
| 27 | + | value = "$smart_exclude_list$" | |
| 28 | + | description = "List of (comma separated) SMART attributes which should be excluded (=ignored) from checks." | |
| 29 | + | } | |
| 30 | + | "--exclude-all" = { | |
| 31 | + | value = "$smart_exclude_all_list$" | |
| 32 | + | description = "List of (comma separated) SMART attributes which should be excluded (=ignored) completely, for both checks and performance data." | |
| 33 | + | } | |
| 34 | + | "--bad" = { | |
| 35 | + | value = "$smart_bad$" | |
| 36 | + | 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." | |
| 37 | + | } | |
| 38 | + | "--warn" = { | |
| 39 | + | value = "$smart_warn$" | |
| 40 | + | description = "Comma separated list of thresholds for ATA drives (e.g. `'Reallocated_Sector_Ct=10,Current_Pending_Sector=62'`)." | |
| 41 | + | } | |
| 42 | + | "--selftest" = { | |
| 43 | + | set_if = "$smart_selftest$" | |
| 44 | + | description = "If set to true, additionally check SMART's selftest log for errors." | |
| 45 | + | } | |
| 46 | + | "--ssd-lifetime" = { | |
| 47 | + | set_if = "$smart_ssd_lifetime$" | |
| 48 | + | description = "If set to true, additionally check SSD attribute Percent_Lifetime_Remain." | |
| 49 | + | } | |
| 50 | + | "--quiet" = { | |
| 51 | + | set_if = "$smart_quite$" | |
| 52 | + | description = "If set to true, additionally check SSD attribute Percent_Lifetime_Remain." | |
| 53 | + | } | |
| 54 | + | "--skip-self-assessment" = { | |
| 55 | + | set_if = "$smart_skip_self_assessment$" | |
| 56 | + | description = "If set to true, when faults are detected, only show failing drive(s) (only affects output when used with -g parameter)." | |
| 57 | + | } | |
| 58 | + | "--debug" = { | |
| 59 | + | set_if = "$smart_debug$" | |
| 60 | + | description = "If set to true, additionall debugging information is shown." | |
| 61 | + | } | |
| 62 | + | } | |
| 63 | + | vars.smart_device = "/dev/sda" | |
| 64 | + | vars.smart_interface = "auto" | |
| 65 | + | vars.smart_device_is_glob = false | |
| 66 | + | vars.smart_selftest = false | |
| 67 | + | vars.smart_ssd_lifetime = false | |
| 68 | + | vars.smart_quiet = false | |
| 69 | + | vars.smart_skip_self_assessment = false | |
| 70 | + | vars.smart_debug = false | |
| 71 | + | timeout = 60s | |
| 72 | + | } | |
| 73 | + | ||
| 74 | + | /* apply smart service check */ | |
| 75 | + | apply Service "smart" { | |
| 76 | + | import "local-generic-service" | |
| 77 | + | ||
| 78 | + | check_command = "check-smart" | |
| 79 | + | ||
| 80 | + | command_endpoint = host.name | |
| 81 | + | ||
| 82 | + | // notification tag | |
| 83 | + | vars.sections = [ "operatingsystem" ] # TODO GIT | |
| 84 | + | ||
| 85 | + | assign where host.vars.os == "Linux" && host.vars.smart_device | |
| 86 | + | ignore where host.vars.nochecksmart | |
| 87 | + | ignore where host.vars.noagent | |
| 88 | + | } | |
| 89 | + | ||
| 90 | + | object Host "hostname" { | |
| 91 | + | import "linux-host" | |
| 92 | + | address 127.0.1.3 | |
| 93 | + | vars.smart_device = "/dev/sda" | |
| 94 | + | vars.smart_interface = "cciss,[0-5]" | |
| 95 | + | vars.smart_device_is_glob = true | |
| 96 | + | } | |
| 97 | + | ||
| 98 | + | object Endpoint "hostname" { | |
| 99 | + | } | |
| 100 | + | object Zone "hostname" { | |
| 101 | + | endpoints = [ "hostname" ] | |
| 102 | + | parent = "master" | |
| 103 | + | } | |