Changes

From SME Server
Jump to navigationJump to search
no edit summary
Line 3: Line 3:     
==Uninterruptable Power Supply==
 
==Uninterruptable Power Supply==
 +
 
{{Level|Advanced}}
 
{{Level|Advanced}}
   Line 37: Line 38:  
====Serial Connection====
 
====Serial Connection====
   −
<ol></li><li>Find the configuration details for your model of UPS. Refer to:  http://www.networkupstools.org/stable-hcl.html and make note of the driver name and upstype number (if any) in the third column.  
+
<ol><li>Find the configuration details for your model of UPS. Refer to:  http://www.networkupstools.org/stable-hcl.html and make note of the driver name and upstype number (if any) in the third column.  
    
{{Warning box|Always use the serial cable supplied with the UPS.  Standard serial cables won't work with a serial UPS and have been known to cause damage to the UPS. Pay particular attention to any references to cable in in the UPS Model column.}}
 
{{Warning box|Always use the serial cable supplied with the UPS.  Standard serial cables won't work with a serial UPS and have been known to cause damage to the UPS. Pay particular attention to any references to cable in in the UPS Model column.}}
    
</li><li>From the console issue the following commands:
 
</li><li>From the console issue the following commands:
   
  config setprop nut Model <model>  
 
  config setprop nut Model <model>  
 
  config setprop nut Device <device>
 
  config setprop nut Device <device>
Line 311: Line 311:  
Issuing commands could shutdown your server unexpectedly!}}
 
Issuing commands could shutdown your server unexpectedly!}}
   −
<headertabs/>
+
<headertabs />
    
=Scheduling Events=
 
=Scheduling Events=
Line 330: Line 330:  
Create and edit a new file called 'NOTIFYCMD' with the following content:
 
Create and edit a new file called 'NOTIFYCMD' with the following content:
 
  NOTIFYCMD /usr/sbin/upssched
 
  NOTIFYCMD /usr/sbin/upssched
 +
 +
Expand the template:
 +
/sbin/e-smith/expand-template /etc/ups/upsmon.conf
    
Now create another a custom template directory
 
Now create another a custom template directory
Line 351: Line 354:  
AT ONBATT * START-TIMER shutdownnow 120
 
AT ONBATT * START-TIMER shutdownnow 120
 
to how many seconds after ONBATT signal you want to shut down
 
to how many seconds after ONBATT signal you want to shut down
 +
 +
Expand the template:
 +
/sbin/e-smith/expand-template /etc/ups/upssched.conf
    
Create and edit a new script file at:
 
Create and edit a new script file at:
Line 394: Line 400:  
         esac
 
         esac
   −
Now make it executable like all the other <tt>.cmd</tt> files with
+
Now make it executable by '''nut''' user
 
  chmod 754 /sbin/e-smith/nutUPS.cmd
 
  chmod 754 /sbin/e-smith/nutUPS.cmd
 +
chown root:nut /sbin/e-smith/nutUPS.cmd
    
Nut requires to use sudo for this process to work, so sudo needs configuring to enable the user nut. By default the /etc/sudoers file is not part of the SME Server template system. To workaround this create a custom template directory:
 
Nut requires to use sudo for this process to work, so sudo needs configuring to enable the user nut. By default the /etc/sudoers file is not part of the SME Server template system. To workaround this create a custom template directory:
Line 408: Line 415:     
Then run:
 
Then run:
  expand-template /etc/sudoers
+
  /sbin/e-smith/expand-template /etc/sudoers
    
Finally to complete the process:
 
Finally to complete the process:
 
  signal-event post-upgrade
 
  signal-event post-upgrade
 
  signal-event reboot
 
  signal-event reboot
 +
 +
While testing with the SMEServer v9.1 (circa March 2016), the above <tt>nutUPS.cmd</tt> script with entries in <tt>01CONFIG</tt> template fails due to lack of permissions at the <tt>shutdownnow</tt> case at:
 +
/usr/bin/sudo /sbin/e-smith/signal-event halt
 +
 +
Tweaking the <tt>/etc/sudoers</tt> did not mitigate it.
 +
 +
The error in the <tt>/var/log/messages</tt> is:
 +
<pre>
 +
Mar 14 13:22:16 svr01 upssched[3507]: Timer daemon started
 +
Mar 14 13:22:16 svr01 upssched[3507]: New timer: shutdownnow (120 seconds)
 +
Mar 14 13:25:16 svr01 upssched[3507]: Event: shutdownnow
 +
Mar 14 13:25:16 svr01 wall[3539]: wall: user nut broadcasted 1 lines (70 chars)
 +
Mar 14 13:25:16 svr01 upssched[3507]: exec_cmd(/sbin/e-smith/nutUPS.cmd shutdownnow) returned 1
 +
</pre>
 +
 +
However, the '''nut''' user has the necessary shutdown permissions:
 +
/usr/bin/sudo -u nut /usr/bin/sudo /sbin/e-smith/signal-event halt
    
=Configure Nut-cgi Monitor Scripts=
 
=Configure Nut-cgi Monitor Scripts=
Line 418: Line 442:  
The nut-cgi rpm contains scripts that can be run via the webserver to monitor the UPS(s).
 
The nut-cgi rpm contains scripts that can be run via the webserver to monitor the UPS(s).
   −
===Dowload and install===
+
===Download and install===
    
You have to enable the '''[[epel]]''' repositories.
 
You have to enable the '''[[epel]]''' repositories.
Line 534: Line 558:  
Now go to http://yourdomain.tld/nut to see the statistics and information for the UPS at localhost.
 
Now go to http://yourdomain.tld/nut to see the statistics and information for the UPS at localhost.
   −
By editing /etc/ups/hosts.conf and adding additional network UPS details, nut-cgi can be used to monitor more than one UPS. By the modification above, only the localhost is monitored.
+
By editing <tt>/etc/ups/hosts.conf</tt> and adding additional network UPS details, nut-cgi can be used to monitor more than one UPS. By the modification above, only the localhost is monitored.
   −
=Aditional Information=
+
=Additional Information=
   −
There are template fragments in /etc/e-smith/templates/etc/ups that control the config files located in /etc/ups. The default settings should be OK for most situations. The <tt>/etc/nut.conf</tt> file must be manually edited like <tt>mode=standalone</tt> as the templates do not touch this file.
+
There are template fragments in /etc/e-smith/templates/etc/ups that control the config files located in /etc/ups. The default settings should be OK for most situations. The <tt>/etc/nut.conf</tt> file must be manually edited like <tt>mode=standalone</tt> as the templates do not touch this file. In this case it would be:
 +
sed -e 's/^MODE.*/MODE=standalone/' -i /etc/ups/nut.conf
    
By default, NUT is configured for a USB connected UPS in Master mode, but is disabled. When enabled, NUT will monitor the UPS and take various actions when certain notifications are received. This is controlled by the '''/etc/ups/upsmon.conf''' file which among other things lists the notifications and the actions to be taken for each. For example an ''On Battery'' event is captured by the '''NOTIFYFLAG ONBATT''' entry and the following '''SYSLOG+WALL+EXEC''' command string. This string tells '''upsmon''' to write the event to the System Log, broadcast a message to all users via Wall, and execute the command denoted by the '''NOTIFYCMD''' entry.
 
By default, NUT is configured for a USB connected UPS in Master mode, but is disabled. When enabled, NUT will monitor the UPS and take various actions when certain notifications are received. This is controlled by the '''/etc/ups/upsmon.conf''' file which among other things lists the notifications and the actions to be taken for each. For example an ''On Battery'' event is captured by the '''NOTIFYFLAG ONBATT''' entry and the following '''SYSLOG+WALL+EXEC''' command string. This string tells '''upsmon''' to write the event to the System Log, broadcast a message to all users via Wall, and execute the command denoted by the '''NOTIFYCMD''' entry.
Line 556: Line 581:  
  man upsd
 
  man upsd
 
  man nutupsdrv
 
  man nutupsdrv
 +
 +
==Timeout Issues==
 +
 +
If you have comms problems like this you can add a custom timeout:
 +
 +
"USBDEVFS_CONTROL failed cmd blazer_usb rqt 33 rq 9 len 8 ret -110"
 +
 +
Add a new config item. The default is 2
 +
 +
config setprop nut pollInterval 4
 +
 +
Modify the template
 +
 +
mkdir -p /etc/e-smith/templates-custom/etc/ups/ups.conf
 +
cp /etc/e-smith/templates/etc/ups/ups.conf/UPS /etc/e-smith/templates-custom/etc/ups/ups.conf/UPS
 +
nano /etc/e-smith/templates-custom/etc/ups/ups.conf/UPS
 +
 +
Add the bits between the # comments
 +
 +
{
 +
    my $model = $nut{Model} || "usbhid-ups";
 +
    my $device = $nut{Device} || "/var/lib/ups/hiddev0";
 +
    my $type = $nut{Type};
 +
    my $mfr = $nut{mfr};
 +
    my $mdl = $nut{mdl};
 +
 +
    # Add this
 +
    my $poll = $nut{pollInterval} || '2';
 +
    if ($poll ne '2') {
 +
      $OUT .= "pollinterval = $poll\n";
 +
    }
 +
    # ends here
 +
 +
    $OUT .= "[UPS]\n";
 +
    $OUT .= "\tdriver = $model\n";
 +
 +
expand-template /etc/ups/ups.conf
 +
cat /etc/ups/ups.conf
 +
 +
You should see something like this:
 +
 +
# Copyright (C) 1999-2006 Mitel Networks Corporation
 +
#------------------------------------------------------------
 +
pollinterval = 4
 +
[UPS]
 +
 +
Restart nut
 +
 +
service nut restart
 +
 +
Now check to see the correct timeout:
 +
 +
upsc UPS | grep driver.parameter.pollinterval
 +
 +
driver.parameter.pollinterval: 4
 +
 +
To reset either delete the key, or set it to the default of 2
 +
 +
==Further reading==
    
The NUT website is here: [http://www.networkupstools.org/ NUT]
 
The NUT website is here: [http://www.networkupstools.org/ NUT]
Line 571: Line 655:     
Nut is a Software well documented, you can find the [http://www.networkupstools.org/docs/user-manual.chunked/index.html TOC here] and with [http://www.networkupstools.org/docs/user-manual.chunked/ar01s02.html an overview]
 
Nut is a Software well documented, you can find the [http://www.networkupstools.org/docs/user-manual.chunked/index.html TOC here] and with [http://www.networkupstools.org/docs/user-manual.chunked/ar01s02.html an overview]
<noinclude>[[Category:Howto]]</noinclude>
+
<noinclude>
<noinclude>[[Category:Administration]]</noinclude>
+
[[Category:Howto]]
 +
</noinclude>
 +
<noinclude>
 +
[[Category:Administration]]
 +
</noinclude>
 +
__FORCETOC__

Navigation menu