nihlaeth / nagios_check_smartmon Goto Github PK
View Code? Open in Web Editor NEWFork of https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_smartmon/details
License: GNU General Public License v2.0
Fork of https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_smartmon/details
License: GNU General Public License v2.0
Right now, root privileges are required. This is a problem, because I intend to use it with check_by_ssh. The user I assigned for this has limited privileges for obvious reasons. I thought to fix it by simply setting the setuid bit. Unfortunately (though with good reason) - this does not work on scripts, only on binaries.
cython --embed would be a possible solution, though I think it might be safer to provide a binary wrapper for smartctl. Needs further thought.
I've had disks fail with no indication save the error count in the smart log. This should be checked for!
Psutil reports partitions in use, and from there we extract the physical devices. If you use raid, encryption or lfs, the mapped devices are reported, and we can't get the physical devices from that through psutil.
Either we need to ls/grep from the dev directory for the actual physisal devices, which is bound to be buggy, or we accept the limitations of the -a/--all-disks option.
When I switched to subprocess, I assumed that a non-zero exit status would always mean some error in accessing the device or executing the command. However, when there's something wrong with the disk, smartctl indicates this in the return value as well.
Option:
We do it the easy way, we ignore the exit status and live with the fact that the parser will complain if command execution fails.
Option:
We interpret the exit status and only issue an error message & skip the parser if the command failed.
Colleagues,
plugin is hardcoded to expect "PASSED" in following code snippet
# check health status
if health_status != "PASSED":
return_status = 2
device_status += "CRITICAL: device does not pass health status "
Although in some cases smartctl reports "SMART Health Status: OK"
root@server:~# smartctl -H /dev/sdd
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-74-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART Health Status: OK
which leads to CRITICAL status.
Reproducible: always
root@gateway [~] # ./check_smartmon.py
: UNKNOWN: no such device foundUNKNOWN: smartctl parsing error
root@gateway [~] # ./check_smartmon.py /dev/sda
: UNKNOWN: no such device foundUNKNOWN: smartctl parsing error
root@gateway [~] # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 119.2G 0 disk
├─sda1 8:1 0 30G 0 part /
├─sda2 8:2 0 4G 0 part
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 85.2G 0 part
└─system-data 253:0 0 1.9T 0 lvm /data
sdb 8:16 0 1.8T 0 disk
└─system-data 253:0 0 1.9T 0 lvm /data
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.