check_smart.pl issue

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
tommi3s
Posts: 4
Joined: Tue Feb 27, 2018 7:33 am

check_smart.pl issue

Post by tommi3s »

Hello everyone,

at the moment I have a problem by running this smart check plugin. When I run it via shell on the given host it returns the result without an issue (as root).
But when I run it via root cronjob ( I write the cron output into a text file to prepare the output in a selfmade script which is handled via NRPE) I got always
"Unknown: No health status line found"
But I don´t get it why this happens, the script should be executed with the same root rights.
Any ideas?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: check_smart.pl issue

Post by mcapra »

I'm going to assume the check_smart.pl script you are using was acquired from here:
https://exchange.nagios.org/directory/P ... v2/details

Can you share the full command you are executing from the CLI of the remote machine?

For these sorts of problems, it's almost always something to do with the execution environment. It's likely the SMART command you're manually running as root via the shell has a totally different $PATH than your cron's environment. My guess is your cron's environment is missing some critical $PATH definition for your SMART command, specifically the smartctl command is not included in cron's path.

A simple solution might be to physically alter the check_smart.pl script to use a different SMART command. You could change this definition:

Code: Select all

my $smart_command = 'sudo smartctl';
To instead point to the actual binary (sudo /usr/bin/whatever/smartctl) rather than relying on $PATH to resolve smartctl.
Former Nagios employee
https://www.mcapra.com/
kyang

Re: check_smart.pl issue

Post by kyang »

Thanks for the help @mcapra!
Locked