Uninterruptable Power Supply/fr

From SME Server
Revision as of 22:59, 17 January 2024 by Gieres (talk | contribs)
Jump to navigationJump to search


Is this article helpful to you?
Please consider donating or volunteering
Thank you!

Alimentation sans interruption - ASI

PythonIcon.png Skill level: Advanced
The instructions on this page may require deviations from standard procedures. A good understanding of linux and Koozali SME Server is recommended.


Introduction

L'objectif principal du projet Network UPS Tools (NUT) est de fournir une surveillance fiable du matériel d'ASI et d'assurer des arrêts sûrs des systèmes connectés.

La configuration par défaut de NUT maintiendra vos systèmes connectés opérationnels jusqu'à ce qu'un état critique de la batterie soit atteint (c'est-à-dire que la batterie soit presque vide), puis mettra hors tension votre serveur/équipement de manière contrôlée. Voir http://www.networkupstools.org/ (en anglais).

Si vous disposez d'un onduleur de marque APC, consultez également Uninterruptable_Power_Supply:APC (en anglais) pour une alternative à l'implémentation ordinaire Koozali SME « Nut ».

Si vous disposez d'une ASI Dell, cela pourrait vous aider Uninterruptable_Power_Supply:LatestGeekery (en anglais).

Configuration par défaut (USB)

La configuration par défaut pour 'NUT' dans le serveur Koozali SME est assurée par les propriétés de la base de données de configuration :

Model  = usbhid-ups
status = disabled
type   = service
Important.png Note :
l'absence d'une propriété 'Master' définit la configuration par défaut comme étant une configuration principale. Il s'agit d'un ASI connectée directement au serveur via un câble USB ou série. Voir plus tard pour le réglage en tant qu'esclave.

Par défaut, NUT est désactivé, c'est qu'il n'y a pas d'ASI connectée.


La plupart des ASI connectées en USB fonctionneront avec ces paramètres par défaut. Si vous utilisez une connexion USB, activez seulement NUT comme suit :

Pour Koozali SME 10, systemd est maintenant en service. Nous avons créé un service générique pour votre commodité :

config setprop nut status enabled
signal-event e-smith-nutUPS-update
systemctl restart nut-server.service
systemctl restart nut-monitor.service
systemctl restart nut.service
config setprop nut status enabled
signal-event post-upgrade
signal-event reboot

Si votre ASI USB ne fonctionne pas correctement OU si vous avez un appareil série, alors suivez les « Options de configuration » ci-après comme requises.

Configuration Options

Not all UPS's are supported by USB or the usbhid-ups driver. However NUT supports many UPS's and can be configured under SME Server easily.

Serial Connection

  1. 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.png Warning:
    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.

  2. From the console issue the following commands: config setprop nut Model <model> config setprop nut Device <device> config setprop nut Type <type> config setprop nut status enabled Where:
    <model> and <type> are the driver name and type number found above.
    <device> is the serial port that the UPS is connected to eg. /dev/ttyS0. It also possible to use a more readable symlink. See HowTo on udev - symlinks for details. Note: The case of Model, Device and Type.
  3. Check: config show nut
  4. Apply changes and restart server: signal-event post-upgrade signal-event reboot Alternatively, without NUT running or requiring a server reboot: signal-event console-save service nut start
  5. Confirm server is communicating with UPS: upsc UPS@localhost Whenever a UPS event occurs Emails are sent to the admin account.

Configuring as a master

edit the file /etc/ups/nut.conf, and modify the line

MODE=netserver

Set configuration values:

config setprop nut access private TCPPort 3493 
expand-template /etc/ups/upsd.conf
expand-template /etc/rc.d/init.d/masq
systemctl restart masq
systemctl restart nut-server 

Configuring as a slave

Set configuration values:

config setprop nut SlaveUPS UPS@192.168.33.11
config setprop nut Master no

Where 192.168.33.11 is your UPS master, that is the computer that is in direct communication with the UPS. The hostname of that computer may also work.

Apply changes and restart server:

signal-event post-upgrade
signal-event reboot 

or (for SME10):

signal-event e-smith-nutUPS-update

Confirm server is communicating with master:

upsc UPS@192.168.33.11

Connecting multiple UPS's

To be added http://bugs.contribs.org/show_bug.cgi?id=629


Warning.png Warning:
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

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

/sbin/e-smith/expand-template /etc/ups/upsd.users
/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.png Warning:
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

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

To set new admin password in database. The new password would be admin ( change it to suit your need )

config setprop nut AdminPass admin 

To enabled administrative privileges and run command to ups.

config setprop nut AdminUser enabled

Now, to get upsd to recognise admin modification for administrative privileges we expand the template and reload the upsd configuration

/sbin/e-smith/expand-template /etc/ups/upsd.users
/usr/sbin/upsd -c reload 


Important.png Note:
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
/sbin/e-smith/expand-template /etc/ups/upsd.users
/usr/sbin/upsd -c reload

UPS access

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:

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

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

upsrw UPS

or

upsc UPS

After you are done, clean up by disabling the upsc administrative privileges:

Warning.png Warning:
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.png Warning:
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!


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.png Warning:
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 create a suitable user we will use SME Servers templating system and configuration database. This is based on an original forum thread[1].

First we need to create a suitable custom template directory

mkdir -p /etc/e-smith/templates-custom/etc/ups/upsd.users
cd /etc/e-smith/templates-custom/etc/ups/upsd.users

Create and edit a new file called 'admin' with the following content:

{
    # create admin user for upsd to allow setting of
    # UPS parameters via upsrw

    $OUT .= "";
    return unless (($nut{AdminUser} || 'disabled') eq 'enabled');
    return unless (($nut{AdminPass} || '') ne '');

    $OUT .= "\n";
    $OUT .= "       [admin]\n";
    $OUT .= "               password  = $nut{AdminPass}\n";
    if ( ($nut{Master} || 'yes') ne 'no') {
       $OUT .= "               allowfrom = localhost\n";
    } else {
       $OUT .= "               allowfrom = localhost localnet\n";
    }
    $OUT .= "               actions   = set\n";
    $OUT .= "               instcmds  = all\n";
}

Create two new database properties for nut

config setprop nut AdminUser enabled                (This enables the creation of the user in the template above)
config setprop nut AdminPass admin                  (This sets a password for the admin user. Set to whatever you want)

Now, to get upsd to recognise the new user with the required administrative privileges we expand the template and reload the upsd configuration

/sbin/e-smith/expand-template /etc/ups/upsd.users
/usr/sbin/upsd -c reload


Important.png Note:
To disabled the admin user once you have changed the UPS parameters or issued commands as required, issue the commands
config setprop nut AdminUser disabled
/sbin/e-smith/expand-template /etc/ups/upsd.users
/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.png Warning:
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.png Warning:
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!


an example to update you battery date upon changing it. (use your own password)

upsrw -s  battery.mfr.date=2020/08/31 -u admin -p admin UPS


Variables et commandes ASI

Dans certains cas, vous souhaiterez peut-être modifier les variables de l'onduleur lui-même, telles que le paramètre Low Charge/LOWBATTERY. Cela nécessite l'utilisation de la commande upsrw et les privilèges d'administrateur ASI.

Vous souhaiterez peut-être également contrôler l'onduleur directement à partir de la ligne de commande en émettant des commandes ASI. Cela nécessite l'utilisation de la commande upscmd et les privilèges d'administrateur ASI.

Warning.png Attention :
en général, les données de l'onduleur doivent rester protégées et les modifications ou l'émission de commandes doivent être effectuées avec attention. Si vous souhaitez apporter des modifications aux données ou émettre des commandes, les privilèges d'administrateur peuvent être activés comme ci-dessous et doivent ensuite être désactivés.


Droits d'administrateur ASI

Vous devriez vérifier votre nouveau mot de passe (AdminPass) pour exécuter upserw et upscmd. Bien sûr, vous pouvez changer votre mot de passe pour un mot de passe plus facile à utiliser.

config show nut

Pour mettre un nouveau mot de passe admin dans la base de données. Le nouveau mot de passe serait admin (changer comme vous voulez) :

config setprop nut AdminPass admin 

Pour activer les droits d'administrateur et exécuter des commandes à l'ASI :

config setprop nut AdminUser enabled

Maintenant, pour que upsd reconnaisse la modification de l'administrateur pour les droits d'administrateur, nous développons le modèle et rechargeons la configuration upsd.

/sbin/e-smith/expand-template /etc/ups/upsd.users
/usr/sbin/upsd -c reload


Important.png Note :
pour désactiver les droits d'administrateur après avoir modifié les paramètres de l'ASI ou effectué les commandes nécessaires, exécutez les commandes :
config setprop nut AdminUser disabled
/sbin/e-smith/expand-template /etc/ups/upsd.users
/usr/sbin/upsd -c reload


Accès à l'ASI

L'accès à l'ASI est contrôlé par les propriétés de la base de données. La propriété par défaut sélectionne « localhost » et donne le droit d'exécuter upsrw et upscmd depuis « localhost » si le privilège d'administrateur est activé comme ci-dessus. Aucune ASI esclave ne peut être connectée dans ce mode. Trois choix sont disponibles pour paramétrer l'accès :

  • « localhost » : l'accès à l'ASI se fait uniquement depuis la machine locale ( ASI maître) ;
  • « private » : l'accès à l'ASI se fait depuis votre machine locale et le réseau local comme défini dans le gestionnaire du serveur ;
  • « public » : l'accès à l'ASI est similaire à « localhost ».


Pour régler les propriétés d'accès dans la base de données (exemple : localhost) :

config setprop nut access localhost  
/sbin/e-smith/expand-template /etc/ups/upsd.conf
 /usr/sbin/upsd -c reload 

En mode « localhost » ou « public » (pas d'accès à distance), l'accès à votre ASI est (le nom de l'ASI est UPS) :

UPS@localhost

En mode « private », l'accès à votre ASI est (le nom de l'ASI est UPS) :

UPS@localhost

ou

UPS@192.168.1.1    # (IP de l'ASI maître)

Un ASI esclave peut accéder avec UPS@192.168.1.1 (IP de l'ASI maître).