[Nut-upsuser] Plea for a more loquacious nut

Roger Price roger at rogerprice.org
Wed Dec 4 20:35:20 UTC 2013


I would like nut to become more loquacious, and to log a much more 
complete report of its activity.  At present nut reports that its 
components have started operation but does not automatically log their 
activity when UPS's switch between OB and OL.  I believe that this 
under-reporting of important facts is too minimalist - it would be better 
for system administrators and for the nut support team if a much more 
complete report were available of all OB/OL activity by each component.

Looking at the source code, it seems that much of what is needed is 
already in place, but behind "if" conditions that ensure that little or 
nothing gets through.  Long ago I wrote software, including a compiler, 
but my C programming is limited to a class exercise many many years ago, 
and its based on this "experience" that I'm guessing that in upssched.c 
function exec_cmd the code

   snprintf(buf, sizeof(buf), "%s %s", cmdscript, cmd);
   err = system(buf);
   if (WIFEXITED(err)) {
 	if (WEXITSTATUS(err)) {
 		upslogx(LOG_INFO, "exec_cmd(%s) returned %d", buf, WEXITSTATUS(err));
 	}

attempts to send a command to the operating system, possibly to execute a 
Bash script.  If system(buf) fails, the tests block the error message. 
Surely the error message is essential.  An unattended box is now in an 
emergency situation.  After the inevitable IT failure the system should be 
auditable to discover what went wrong and what should be done to prevent 
it happening in the future.  Such an audit expects to find "exec_cmd(%s) 
returned %d" in the log.

"But these problems should be found by testing!", one might argue. 
Firstly, the testing would be facilitated by this error message, and 
secondly, no amount of testing will ever cover every situation met in the 
real world.

I believe nut would be improved by

1. Logging a summary of the state of the nut system and the UPS's every 24 
hours.

2. Automatically logging a record of driver, upsd, upsmon and upssched 
activity for each OB/OL change.

3. Replacing the upsmon NOTIFYFLAG "SYSLOG" by "NOSYSLOG".  All 
notifications are logged unless the sysadmin explicitly calls for no 
logging.

Roger



More information about the Nut-upsuser mailing list