Re: how to control how often smartd-runner fires.

Ray Andrews <[email protected]> Sun, 22 Jan 2017 20:17:30 -0800
Newsgroups gmane.linux.utilities.smartmontools
Message-ID <[email protected]>
On 19/01/17 11:08 AM, Carlos E. R. wrote:
>
>>   And you'd also think that there'd be a
>> utility that let you know which files were effected so that you could do
>> something about it.
>
> If you want the reverse, you have to scan all directory entries and all
> tables/lists of record locations, one by one, till you hit the one you
> search for. This is very disk intensive and slow. Sometimes the function
> does not exist at all.
Right, I can see that the system only really works one way.  But if one 
was doing a full 'badblocks' scan anyway then surely the information 
would be available at that time?  Nuts, even a raw dump of the block 
would give you some idea what's there.  That's how it used to work under 
DOS.

As to what Christian said:

"The '-M exec' script is only run on error conditions which also result
in a LOG_CRIT syslog message. For LOG_INFO messages issued by smartd,
see the configured syslog. On Debian/Ubuntu, this is usually
'/var/log/daemon.log'."

It seems counter intuitive. Why run smartd four times a day (or whatever) when there is no way to make the error visible more than (it seems) once or twice per day?  I did this experiment:

In smartd_warning.sh:

	# Export message with trailing newline
	export SMARTD_FULLMESSAGE="$fullmessage
	"
	export SMARTD_ERROR="${SMARTD_MESSAGE-[SMARTD_MESSAGE]}"

In smartd_runner:

	#!/bin/zsh

	tmp=$(tempfile)
	cat > $tmp

	# Show the time and date of the test, no newline:
	echo -n "$( date ):" >>! /var/lib/smartmontools/smartd-log

	# Retrieve prevous error message:
	SMARTD_PREVIOUS=$( cat /var/lib/smartmontools/smartd-previous )
	# SMARTD_ERROR set in smartd_warning.sh:
	if [ "$SMARTD_PREVIOUS" = "$SMARTD_ERROR" ]; then
	echo "IDENTICAL" >>! /var/lib/smartmontools/smartd-log
	# Nothing has changed so abort the notifier:
	return
	fi
	# Message is not identical so echo it to the log:
	echo "$SMARTD_ERROR" >>! /var/lib/smartmontools/smartd-log
	# And save it for the next comparison:
	echo "$SMARTD_PREVIOUS" >! /var/lib/smartmontools/smartd-previous

	# runs '/usr/bin/smart-notifier -> /usr/share/smart-notifier
	/smart-notifier' via '/etc/smartmontools/run.d/60smart-notifier'
	run-parts --report --lsbsysinit --arg=$tmp --arg="$1" \
     	--arg="$2" --arg="$3" -- /etc/smartmontools/run.d

	rm -f $tmp

And I get this:

	Thu Jan 19 12:02:27 PST 2017 Device: /dev/sdb [SAT], 77 Currently unreadable (pending) sectors
	Thu Jan 19 12:26:55 PST 2017:IDENTICAL
	Fri Jan 20 12:05:27 PST 2017:IDENTICAL
	Fri Jan 20 12:26:55 PST 2017:IDENTICAL
	Sat Jan 21 12:57:38 PST 2017:IDENTICAL
	Sun Jan 22 16:57:35 PST 2017:IDENTICAL

... So It seems I get one or two messages per day, sometimes about 20 minutes between them, and there is no way to control how many or when they show up?  Anyway the code above does at least filter out duplicate messages, but I'd expect to have that functionality available stock. If I didn't use smart-notifier, could I receive timely messages some other way?  That is, a message if needed every time smartd runs?







------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot