Changes

Jump to navigation Jump to search
8,075 bytes added ,  23:52, 27 February 2015
no edit summary
Line 3: Line 3:     
==Uninterruptable Power Supply==
 
==Uninterruptable Power Supply==
{{Level|Advanced}}
+
<!--{{Level|Advanced}} -->
    
===Introduction===
 
===Introduction===
Line 85: Line 85:  
Confirm server is communicating with master:
 
Confirm server is communicating with master:
 
  upsc UPS@192.168.33.11
 
  upsc UPS@192.168.33.11
  −
= SME8 =
      
====Connecting multiple UPS's====
 
====Connecting multiple UPS's====
 
To be added http://bugs.contribs.org/show_bug.cgi?id=629
 
To be added http://bugs.contribs.org/show_bug.cgi?id=629
 +
 +
= SME8 =
    
===UPS Variables and Commands===
 
===UPS Variables and Commands===
Line 140: Line 140:  
  /usr/sbin/upsd -c reload
 
  /usr/sbin/upsd -c reload
 
}}
 
}}
 +
 +
==Setting UPS Variables==
 +
In order to set UPS variables it is necessary to have enabled a user with administrative privileges as above first.
 +
 +
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 the UPS variables, both informational and modifiable
 +
upsc UPS
 +
 +
To determine the modifiable variables for your UPS, their current settings and their available setting values execute the command:
 +
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"):
 +
upsrw -s battery.charge.low=20 -u admin -p admin UPS
 +
 +
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   
 +
upsrw UPS
 +
or
 +
upsc UPS
 +
 +
After you are done, clean up by disabling the '''upsd''' administrative user '''admin''':
 +
{{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 a user with administrative privileges as above first.
 +
 +
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 UPS with similar to the following:
 +
upscmd -u admin -p admin UPS 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 '''upsd''' administrative user '''admin''':
 +
{{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!}}
    
= SME 9 =
 
= SME 9 =
Line 156: Line 202:  
   
 
   
 
  /sbin/e-smith/expand-template /etc/ups/upsd.users
 
  /sbin/e-smith/expand-template /etc/ups/upsd.users
  /usr/sbin/upsd -c reload
+
  /usr/sbin/upsd -c reload  
 +
 
 +
===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====
   −
Second step you should check your new password to run UPSRW & UPSCMD. Of course, you could change your password for a easier one to use.
+
You should check your new password ( AdminPass ) to run '''upserw''' & '''upscmd'''. Of course, you could change your password for a easier one to use.
    
  config show nut
 
  config show nut
Line 173: Line 227:     
  /sbin/e-smith/expand-template /etc/ups/upsd.users
 
  /sbin/e-smith/expand-template /etc/ups/upsd.users
  /usr/sbin/upsd -c reload
+
  /usr/sbin/upsd -c reload  
   −
{{Note box|To disabled the admin user once you have changed the UPS parameters or issued commands as required, issue the commands
+
{{Note box|To disabled the administrative privileges once you have changed the UPS parameters or issued commands as required, issue the commands
 
  config setprop nut AdminUser disabled
 
  config setprop nut AdminUser disabled
 
  /sbin/e-smith/expand-template /etc/ups/upsd.users
 
  /sbin/e-smith/expand-template /etc/ups/upsd.users
  /usr/sbin/upsd -c reload
+
  /usr/sbin/upsd -c reload  
 
}}
 
}}
   −
The access of the ups is controled by database properties, three possible choice.
+
==== UPS access ====
localhost: the ups access is only from the local machine ( UPS master ).
+
 
private: the ups is accessable from your local network as per define in server-manager panel.
+
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.
public:  
+
 
 +
 
 +
* 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 )
 
To set access properties in the database ( example: localhost )
Line 190: Line 251:  
  config setprop nut access localhost   
 
  config setprop nut access localhost   
 
  /sbin/e-smith/expand-template /etc/ups/upsd.conf
 
  /sbin/e-smith/expand-template /etc/ups/upsd.conf
signal-event console-save
+
  /usr/sbin/upsd -c reload
   −
<headertabs/>
+
In localhost or public mode ( no remote access ), access to your ups is ( UPS name is '''UPS''' )
 +
UPS@localhost
   −
====Setting UPS Variables====
+
In private mode,  access to your ups is ( UPS name is '''UPS''' )
In order to set UPS variables it is necessary to have enabled a user with administrative privileges as above first.
+
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 208: Line 273:  
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 214: Line 282:  
  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 222: Line 290:     
====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 230: Line 298:  
  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!}}
   −
===Scheduling Events===
+
<headertabs/>
 +
 
 +
=Scheduling Events=
 
====Shutdown Time Delay Example====
 
====Shutdown Time Delay Example====
   Line 338: Line 411:  
  signal-event reboot
 
  signal-event reboot
   −
===Aditional Information===
+
=Configure Nut-cgi Monitor Scripts=
 +
 
 +
The nut-cgi rpm contains scripts that can be run via the webserver to monitor the UPS(s).
 +
 
 +
===Dowload and install===
 +
 
 +
You have to enable the '''[[epel]]''' repositories.
 +
yum install --enablerepo=epel nut-cgi
 +
 
 +
Edit file /etc/ups/hosts.conf and add.
 +
 
 +
MONITOR UPS@localhost "local UPS"
 +
 
 +
The nut-cgi rpm contains three cgi scripts. The rpm does not install them correctly for SME however so the following modifications are needed.
 +
 
 +
mkdir -p /opt/nut-cgi-bin
 +
chown root:www /opt/nut-cgi-bin
 +
mv /var/www/nut-cgi-bin/upsstats.cgi /opt/nut-cgi-bin
 +
mv /var/www/nut-cgi-bin/upsset.cgi /opt/nut-cgi-bin
 +
mv /var/www/nut-cgi-bin/upsimage.cgi /opt/nut-cgi-bin
 +
chown root:www /opt/nut-cgi-bin/*
 +
chmod 750 /opt/nut-cgi-bin/*
 +
mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
 +
cd /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
 +
 
 +
Now edit and create a new file 92nutupscmon with the following content
 +
 
 +
{
 +
    $OUT = "";
 +
    my $allow = 'all';
 +
    my $pass = '0';
 +
    my $satisfy = 'all';
 +
    my $name = $nut{'Name'} || 'NUT UPS Daemon Monitoring';
 +
 +
    for ('exit-if-none')
 +
    {
 +
      if ($nut{'PublicAccess'})
 +
      {
 +
          if ($nut{'PublicAccess'} eq 'none')
 +
          {
 +
            next;
 +
          }
 +
          elsif ($nut{'PublicAccess'} eq 'local')
 +
          {
 +
            $allow  = $localAccess;
 +
            $pass    = 0;
 +
            $satisfy = 'all';
 +
          }
 +
          elsif ($nut{'PublicAccess'} eq 'local-pw')
 +
          {
 +
            $allow  = $localAccess;
 +
            $pass    = 1;
 +
            $satisfy = 'all';
 +
          }
 +
          elsif ($nut{'PublicAccess'} eq 'global')
 +
          {
 +
            $allow  = 'all';
 +
            $pass    = 0;
 +
            $satisfy = 'all';
 +
          }
 +
          elsif ($nut{'PublicAccess'} eq 'global-pw')
 +
          {
 +
            $allow  = 'all';
 +
            $pass    = 1;
 +
            $satisfy = 'all';
 +
          }
 +
          elsif ($nut{'PublicAccess'} eq 'global-pw-remote')
 +
          {
 +
            $allow  = $localAccess;
 +
            $pass    = 1;
 +
            $satisfy = 'any';
 +
          }
 +
      }
 +
 +
      $OUT .= "#------------------------------------------------------------\n";
 +
      $OUT .= "# nut multimon - $name\n";
 +
      $OUT .= "#------------------------------------------------------------\n";
 +
 +
      {
 +
        if ((exists $nut{'URL'}) && ($nut{'URL'} ne <nowiki>''</nowiki>)) {
 +
          $OUT .= "Alias  /$nut{'URL'}  /opt/nut-cgi-bin\n";
 +
        } 
 +
      }
 +
 +
      $OUT .= "Alias  /nut  /opt/nut-cgi-bin\n";
 +
 +
      $OUT .= "\n";
 +
      $OUT .= "<Directory /opt/nut-cgi-bin>\n";
 +
      $OUT .= "    DirectoryIndex upsstats.cgi\n";
 +
      $OUT .= "    Options +ExecCGI\n";
 +
      $OUT .= "    order deny,allow\n";
 +
      $OUT .= "    deny from all\n";
 +
      $OUT .= "    allow from $allow\n";
 +
      if ($pass)
 +
      {
 +
          $OUT .= "    AuthName $name\n";
 +
          $OUT .= "    AuthType Basic\n";
 +
          $OUT .= "    AuthExternal pwauth\n";
 +
          $OUT .= "    require valid-user\n";
 +
          $OUT .= "    Satisfy $satisfy\n";
 +
      }
 +
      $OUT .= "</Directory>\n";
 +
    }
 +
}
 +
 
 +
Configure databases and expand the template
 +
 
 +
config setprop nut PublicAccess local
 +
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf
 +
 
 +
{{Note box|The above sets access to the scripts to ''local'' ip addresses only. See the [[Web_Application_RPM#New_DB_settings]] for further info and settings}}
 +
 
 +
Restart the web server
 +
 
 +
sv t httpd-e-smith
 +
 
 +
===Usage of Nut-cgi Scripts===
 +
 
 +
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.
 +
 
 +
=Aditional 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.
 
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.
Line 373: Line 568:     
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>[[Category:Administration]]</noinclude>
+
Ne pas oublier de rajouter les categories
66

edits

Navigation menu