Changes

From SME Server
Jump to navigationJump to search
m
no edit summary
Line 114: Line 114:     
====Connecting multiple UPS's====
 
====Connecting multiple UPS's====
To be added http://bugs.contribs.org/show_bug.cgi?id=629
+
As reference to http://bugs.contribs.org/show_bug.cgi?id=629 and https://bugs.koozali.org/show_bug.cgi?id=626#c2
   −
<tabs container>
+
1- you will need to do<syntaxhighlight lang="bash">
<tab name="SME 9">
+
mkdir -p /etc/e-smith/templates-custom/ups/ups.conf/
 +
cp /etc/e-smith/templates/ups/ups.conf/UPS /etc/e-smith/templates-custom/ups/ups.conf/UPS2
 +
</syntaxhighlight>then edit content to replace the header to UPS2 and Model and Device to Model2 and Device2
   −
{{Warning box|Be sure to have e-smith-nutUPS-2.4.0-9.el6.sme.noarch or higher to carry on with these instructions. If you get a lower version, just follow SME8 instruction.}}
     −
rpm -qa e-smith-nutUPS
+
2- Then you need to do<syntaxhighlight lang="bash">
 +
mkdir -p /etc/e-smith/templates-custom/ups/upsmon.conf/
 +
cp /etc/e-smith/templates/ups/upsmon.conf/MONITOR /etc/e-smith/templates-custom/ups/ups.conf/MONITOR2
 +
</syntaxhighlight>Then edit it to change UPS to UPS2.  Then you set Device2 and Model2.
   −
If you get NUT running with administrative privileges modification from sme8 instruction, you need to remove the custom template created for this. These variables are taken in charge by the new package.
     −
First you need to delete the custom template file.( This command delete the directory, be sure you don't have personal file present. If the case, delete manualy the file created for administrative privileges )
  −
  −
rm -rf /etc/e-smith/templates-custom/etc/ups/upsd.users
     −
Now, to get '''upsd''' to recognise the modification of user, we need to expand the template and reload the '''upsd''' configuration
+
3- Repeat the steps 1 and 2 for as many UPS you have, then finish by<syntaxhighlight lang="bash">
+
signal-event console-save
/sbin/e-smith/expand-template /etc/ups/upsd.users
+
</syntaxhighlight>
/usr/sbin/upsd -c reload
      
===UPS Variables and Commands===
 
===UPS Variables and Commands===
Line 141: Line 140:     
====UPS Administrative Privileges====
 
====UPS Administrative Privileges====
 
+
<tabs container>
You should check your new password ( AdminPass ) to run '''upserw''' & '''upscmd'''. Of course, you could change your password for a easier one to use.
+
<tab name="SME 10">
 +
You should check your new password ( AdminPass ) to run '''upsrw''' & '''upscmd'''. Of course, you could change your password for a easier one to use.
    
  config show nut
 
  config show nut
Line 165: Line 165:  
}}
 
}}
   −
==== UPS access ====
+
</tab>
 +
<tab name="SME 9">
   −
The access of the ups is controled by database properties. The default propertie is set to localhost and give permission to run '''upsrw''' & '''upscmd''' from localhost only if administrative privileges is set to enabled as above. No slave ups could be connected in this mode. Three choices is available to set access.
+
{{Warning box|Be sure to have e-smith-nutUPS-2.4.0-9.el6.sme.noarch or higher to carry on with these instructions. If you get a lower version, just follow SME8 instruction.}}
    +
rpm -qa e-smith-nutUPS
   −
* localhost: the ups access is only from the local machine ( UPS master ).
+
If you get NUT running with administrative privileges modification from sme8 instruction, you need to remove the custom template created for this. These variables are taken in charge by the new package.
   −
* private: the ups access is from your local machine and local network as per define in server-manager panel.
+
First you need to delete the custom template file.( This command delete the directory, be sure you don't have personal file present. If the case, delete manualy the file created for administrative privileges )
 +
 +
rm -rf /etc/e-smith/templates-custom/etc/ups/upsd.users
   −
* public: the ups access is similar to localhost.  
+
Now, to get '''upsd''' to recognise the modification of user, we need to expand the template and reload the '''upsd''' configuration
 +
 +
/sbin/e-smith/expand-template /etc/ups/upsd.users
 +
/usr/sbin/upsd -c reload
      −
To set access properties in the database ( example: localhost )
     −
config setprop nut access localhost 
+
You should check your new password ( AdminPass ) to run '''upsrw''' & '''upscmd'''. Of course, you could change your password for a easier one to use.
/sbin/e-smith/expand-template /etc/ups/upsd.conf
  −
  /usr/sbin/upsd -c reload
     −
In localhost or public mode ( no remote access ), access to your ups is ( UPS name is '''UPS''' )
+
  config show nut
  UPS@localhost
     −
In private mode,  access to your ups is ( UPS name is '''UPS''' )
+
To set new admin password in database. The new password would be admin ( change it to suit your need )
UPS@localhost or UPS@192.168.1.1 ( ups master IP )
  −
slave ups get access with UPS@192.168.1.1 ( ups master IP )
  −
==Setting UPS Variables==
  −
In order to set UPS variables it is necessary to have enabled the administrative privileges as above first and you get the possibility to run command from slave ups if access is set to private as above.
     −
In the examples below, it is assumed your UPS name is '''UPS''', that it is local, that the administrative user is '''admin''' and password '''admin'''. You can verify your UPS name via:
+
config setprop nut AdminPass admin  
upsc -l
     −
To view a complete list of the UPS variables, both informational and modifiable
+
To enabled administrative privileges and run command to ups.
upsc UPS
     −
To determine the modifiable variables for your UPS, their current settings and their available setting values execute the command:
+
  config setprop nut AdminUser enabled
  upsrw UPS
     −
You can now modify the variables you wish using a command similar to the following (Note the order of the arguments is important, and you may need quotes around the value being set, "20"):
+
Now, to get '''upsd''' to recognise admin modification for administrative privileges we expand the template and reload the '''upsd''' configuration
upsrw -s battery.charge.low=20 -u admin -p admin UPS
     −
For remote host (slave UPS ), we need to add the IP from master UPS to run command.
+
/sbin/e-smith/expand-template /etc/ups/upsd.users
  upsrw -s battery.charge.low=20 -u admin -p admin UPS@192.168.2.1
+
  /usr/sbin/upsd -c reload
   −
Where the value after '''-s''' should be one of the parameters identified by the '''upsrw ups''' command. You can of course verify your changes using   
+
{{Note box|To disabled the administrative privileges once you have changed the UPS parameters or issued commands as required, issue the commands
upsrw UPS
+
  config setprop nut AdminUser disabled
or
+
  /sbin/e-smith/expand-template /etc/ups/upsd.users
upsc UPS
+
  /usr/sbin/upsd -c reload
 
+
}}
After you are done, clean up by disabling the '''upsc''' administrative privileges:
  −
{{Warning box|Make sure you understand the meaning or the UPS variables and their available setting options. Verify that your changes meet your intended behaviour!}}
  −
 
  −
More information on upsrw can be found at:
  −
 
  −
- Manual page: man upsrw
  −
 
  −
====Issuing UPS Commands====
  −
In order to issue UPS commands it is necessary to have enabled the administrative privileges as above first and you get the possibility to run command from slave ups if access is set to private as above.
  −
 
  −
In the examples below, it is assumed your UPS name is '''UPS''', that it is local, that the administrative user is '''admin''' and password '''admin'''. You can verify your UPS name via:
  −
upsc -l
  −
 
  −
To view a complete list of available commands for your UPS:
  −
  upscmd -l UPS
  −
 
  −
You can now issue a command to the localhost UPS with similar to the following:
  −
  upscmd -u admin -p admin UPS test.battery.start
  −
 
  −
For remote host (slave UPS ), we need to add the IP from master UPS to run command.
  −
  upscmd -u admin -p admin UPS@192.168.2.1 test.battery.start
  −
 
  −
Where the command '''test.battery.start''' is a valid command for your UPS as previously determined by '''upscmd -l UPS'''. Depending upon the command issued you may get broadcast messages and emails relating to and confirming what the UPS is doing.
  −
 
  −
After you are done, clean up by disabling the '''upsc''' administrative privileges:
  −
{{Warning box|Before issuing any commands verify what they do for your particular UPS via the relevant documentation and ensure that the command meets your intended behavioural requirement!
  −
 
  −
Issuing commands could shutdown your server unexpectedly!}}
      
</tab>
 
</tab>
 
<tab name="SME 8">
 
<tab name="SME 8">
  −
===UPS Variables and Commands===
  −
In some cases you may wish to modify variables on the actual UPS such as the Low Charge/LOWBATTERY setting. This requires the use of the '''upsrw''' command and UPS administrative privileges.
  −
  −
You may also want to control the UPS directly from the command line by issuing UPS commands. This requires use of the '''upscmd''' command and UPS administrative privileges.
  −
{{Warning box|In general, the UPS data should be left protected and changes to it or issuing of commands well thought out. If you wish to make data changes or issue commands then the administrative privileges can be enabled as below and should then be disabled.}}
  −
  −
====UPS Administrative Privileges====
   
In order to be able to use '''upsrw''' and '''upscmd''' it is necessary to have a suitable additional user defined in the '''upsd.users''' configuration file.  
 
In order to be able to use '''upsrw''' and '''upscmd''' it is necessary to have a suitable additional user defined in the '''upsd.users''' configuration file.  
   Line 293: Line 252:  
  /usr/sbin/upsd -c reload
 
  /usr/sbin/upsd -c reload
 
}}
 
}}
 +
</tab>
 +
</tabs>
   −
==Setting UPS Variables==
+
==== UPS access ====
In order to set UPS variables it is necessary to have enabled a user with administrative privileges as above first.
+
The access of the ups is controled by database properties. The default propertie is set to localhost and give permission to run '''upsrw''' & '''upscmd''' from localhost only if administrative privileges is set to enabled as above. No slave ups could be connected in this mode. Three choices is available to set access.
 +
 
 +
 
 +
* localhost: the ups access is only from the local machine ( UPS master ).
 +
 
 +
* private: the ups access is from your local machine and local network as per define in server-manager panel.
 +
 
 +
* public: the ups access is similar to localhost.
 +
 
 +
 
 +
To set access properties in the database ( example: localhost )
 +
 
 +
config setprop nut access localhost 
 +
/sbin/e-smith/expand-template /etc/ups/upsd.conf
 +
  /usr/sbin/upsd -c reload
 +
 
 +
In localhost or public mode ( no remote access ), access to your ups is ( UPS name is '''UPS''' )
 +
UPS@localhost
 +
 
 +
In private mode,  access to your ups is ( UPS name is '''UPS''' )
 +
UPS@localhost or UPS@192.168.1.1 ( ups master IP )
 +
slave ups get access with UPS@192.168.1.1 ( ups master IP )
 +
 
 +
 
 +
====Setting UPS Variables====
 +
In order to set UPS variables it is necessary to have enabled the administrative privileges as above first and you get the possibility to run command from slave ups if access is set to private as above.
    
In the examples below, it is assumed your UPS name is '''UPS''', that it is local, that the administrative user is '''admin''' and password '''admin'''. You can verify your UPS name via:
 
In the examples below, it is assumed your UPS name is '''UPS''', that it is local, that the administrative user is '''admin''' and password '''admin'''. You can verify your UPS name via:
Line 308: Line 294:  
You can now modify the variables you wish using a command similar to the following (Note the order of the arguments is important, and you may need quotes around the value being set, "20"):
 
You can now modify the variables you wish using a command similar to the following (Note the order of the arguments is important, and you may need quotes around the value being set, "20"):
 
  upsrw -s battery.charge.low=20 -u admin -p admin UPS
 
  upsrw -s battery.charge.low=20 -u admin -p admin UPS
 +
 +
For remote host (slave UPS ), we need to add the IP from master UPS to run command.
 +
upsrw -s battery.charge.low=20 -u admin -p admin UPS@192.168.2.1
    
Where the value after '''-s''' should be one of the parameters identified by the '''upsrw ups''' command. You can of course verify your changes using     
 
Where the value after '''-s''' should be one of the parameters identified by the '''upsrw ups''' command. You can of course verify your changes using     
Line 314: Line 303:  
  upsc UPS
 
  upsc UPS
   −
After you are done, clean up by disabling the '''upsd''' administrative user '''admin''':
+
After you are done, clean up by disabling the '''upsc''' administrative privileges:
 
{{Warning box|Make sure you understand the meaning or the UPS variables and their available setting options. Verify that your changes meet your intended behaviour!}}
 
{{Warning box|Make sure you understand the meaning or the UPS variables and their available setting options. Verify that your changes meet your intended behaviour!}}
   Line 320: Line 309:     
- Manual page: man upsrw
 
- Manual page: man upsrw
 +
 +
=====Changing battery date=====
 +
An example to update you battery date upon changing it. (use your own password)<syntaxhighlight lang="bash">
 +
upsrw -s  battery.mfr.date=2020/08/31 -u admin -p admin UPS
 +
</syntaxhighlight>
    
====Issuing UPS Commands====
 
====Issuing UPS Commands====
In order to issue UPS commands it is necessary to have enabled a user with administrative privileges as above first.
+
In order to issue UPS commands it is necessary to have enabled the administrative privileges as above first and you get the possibility to run command from slave ups if access is set to private as above.
    
In the examples below, it is assumed your UPS name is '''UPS''', that it is local, that the administrative user is '''admin''' and password '''admin'''. You can verify your UPS name via:
 
In the examples below, it is assumed your UPS name is '''UPS''', that it is local, that the administrative user is '''admin''' and password '''admin'''. You can verify your UPS name via:
Line 330: Line 324:  
  upscmd -l UPS
 
  upscmd -l UPS
   −
You can now issue a command to the UPS with similar to the following:
+
You can now issue a command to the localhost UPS with similar to the following:
 
  upscmd -u admin -p admin UPS test.battery.start
 
  upscmd -u admin -p admin UPS test.battery.start
 +
 +
For remote host (slave UPS ), we need to add the IP from master UPS to run command.
 +
upscmd -u admin -p admin UPS@192.168.2.1 test.battery.start
    
Where the command '''test.battery.start''' is a valid command for your UPS as previously determined by '''upscmd -l UPS'''. Depending upon the command issued you may get broadcast messages and emails relating to and confirming what the UPS is doing.
 
Where the command '''test.battery.start''' is a valid command for your UPS as previously determined by '''upscmd -l UPS'''. Depending upon the command issued you may get broadcast messages and emails relating to and confirming what the UPS is doing.
   −
After you are done, clean up by disabling the '''upsd''' administrative user '''admin''':
+
After you are done, clean up by disabling the '''upsc''' administrative privileges.
 
{{Warning box|Before issuing any commands verify what they do for your particular UPS via the relevant documentation and ensure that the command meets your intended behavioural requirement!
 
{{Warning box|Before issuing any commands verify what they do for your particular UPS via the relevant documentation and ensure that the command meets your intended behavioural requirement!
    
Issuing commands could shutdown your server unexpectedly!}}
 
Issuing commands could shutdown your server unexpectedly!}}
   −
</tab>
+
=Scheduling Events=
 
  −
</tabs>an example to update you battery date upon changing it. (use your own password)<syntaxhighlight lang="bash">
  −
upsrw -s  battery.mfr.date=2020/08/31 -u admin -p admin UPS
  −
</syntaxhighlight>
  −
 
  −
===Scheduling Events===
   
====Shutdown Time Delay Example====
 
====Shutdown Time Delay Example====
   Line 441: Line 432:  
  cd /etc/e-smith/templates-custom/etc/sudoers
 
  cd /etc/e-smith/templates-custom/etc/sudoers
   −
To preserve the content of the orginal /etc/sudoers file copy that into the custom template directory:
+
To preserve the content of the original /etc/sudoers file copy that into the custom template directory:
 
  cp /etc/sudoers 10sudoers  
 
  cp /etc/sudoers 10sudoers  
   Line 471: Line 462:  
  /usr/bin/sudo -u nut /usr/bin/sudo /sbin/e-smith/signal-event halt
 
  /usr/bin/sudo -u nut /usr/bin/sudo /sbin/e-smith/signal-event halt
   −
===Configure Nut-cgi Monitor Scripts===
+
=Configure Nut-cgi Monitor Scripts=
    
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).
   −
====Download and install====
+
===Download and install===
 
<tabs container><tab name="For SME 10">
 
<tabs container><tab name="For SME 10">
 
You have to enable the epel repository:
 
You have to enable the epel repository:
3,054

edits

Navigation menu