Changes

Jump to navigation Jump to search
no edit summary
Line 51: Line 51:  
====Serial Connection====
 
====Serial Connection====
   −
<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.  
+
<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:
Line 114: Line 114:     
====Connecting multiple UPS's====
 
====Connecting multiple UPS's====
To be added http://bugs.contribs.org/show_bug.cgi?id=629
+
En référence à http://bugs.contribs.org/show_bug.cgi?id=629 et https://bugs.koozali.org/show_bug.cgi?id=626#c2,
   −
<tabs container>
+
1- vous devrez exécuter :<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>puis éditer le contenu pour remplacer l'en-tête par UPS2 et Model et Device par Model2 et 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- Puis vous devrez exécuter :<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>puis l'éditer  pour changer UPS en UPS2. Puis vous devrez configurer Device2 et 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 )
+
3- Répéter les étapes 1 et 2 pour chaque ASI possédée, puis finaliser par :<syntaxhighlight lang="bash">
+
signal-event console-save
rm -rf /etc/e-smith/templates-custom/etc/ups/upsd.users
+
</syntaxhighlight>
   −
Now, to get '''upsd''' to recognise the modification of user, we need to expand the template and reload the '''upsd''' configuration
+
===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.
/sbin/e-smith/expand-template /etc/ups/upsd.users
+
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.
/usr/sbin/upsd -c reload
     −
===UPS Variables and Commands===
+
{{Warning box|type=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.}}
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.
+
====Droits d'administrateur ASI====
{{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.}}
+
<tabs container>
 
+
<tab name="SME 10">
====UPS Administrative Privileges====
+
Vous devriez vérifier votre nouveau mot de passe (AdminPass) pour exécuter '''upsrw''' et '''upscmd'''. Bien sûr, vous pouvez changer votre mot de passe pour un mot de passe plus facile à utiliser.
 
  −
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
   −
To set new admin password in database. The new password would be admin ( change it to suit your need )  
+
Pour mettre un nouveau mot de passe admin dans la base de données (le nouveau mot de passe étant « admin » (à modifier selon vos souhaits) :
    
  config setprop nut AdminPass admin  
 
  config setprop nut AdminPass admin  
   −
To enabled administrative privileges and run command to ups.
+
Pour activer les privilèges d'administration et passer une commande à l'ASI :
    
  config setprop nut AdminUser enabled
 
  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
+
Maintenant, pour que '''upsd''' reconnaisse la modification de l'administrateur pour les privilèges d'administration, nous développons le modèle et rechargeons la configuration '''upsd''' :
    
  /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 administrative privileges once you have changed the UPS parameters or issued commands as required, issue the commands
+
{{Note box|type=Note : |pour désactiver les privilèges d'administration une fois que vous avez modifié les paramètres de l'onduleur ou émis les commandes nécessaires, exécutez les commandes :
 
  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
Line 165: Line 164:  
}}
 
}}
   −
==== UPS access ====
+
</tab>
   −
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.
+
<tab name="SME 9">
    +
{{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.}}
   −
* localhost: the ups access is only from the local machine ( UPS master ).
+
rpm -qa e-smith-nutUPS
   −
* private: the ups access is from your local machine and local network as per define in server-manager panel.
+
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.
   −
* public: the ups access is similar to localhost.  
+
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
   −
To set access properties in the database ( example: localhost )
+
Vous devriez vérifier votre nouveau mot de passe (AdminPass) pour exécuter '''upsrw''' et '''upscmd'''. Bien sûr, vous pouvez changer votre mot de passe pour un mot de passe plus facile à utiliser.
   −
  config setprop nut access localhost 
+
  config show nut
/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''' )
+
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) :
UPS@localhost
     −
In private mode, access to your ups is ( UPS name is '''UPS''' )
+
  config setprop nut AdminPass admin
UPS@localhost or UPS@192.168.1.1 ( ups master IP )
     −
Slave ups get access with UPS@192.168.1.1 ( ups master IP ).
+
Pour activer les droits d'administrateur et exécuter des commandes à l'ASI :
===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 AdminUser enabled
  upsc -l
     −
To view a complete list of the UPS variables, both informational and modifiable
+
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'''.
  upsc UPS
+
/sbin/e-smith/expand-template /etc/ups/upsd.users
 +
  /usr/sbin/upsd -c reload
   −
To determine the modifiable variables for your UPS, their current settings and their available setting values execute the command:
+
{{Note box|type=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 :
upsrw UPS
+
  config setprop nut AdminUser disabled
 
+
  /sbin/e-smith/expand-template /etc/ups/upsd.users
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"):
+
  /usr/sbin/upsd -c reload
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 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 294: Line 250:  
  /usr/sbin/upsd -c reload
 
  /usr/sbin/upsd -c reload
 
}}
 
}}
 +
</tab>
 +
 +
</tabs>
 +
==== Accès à l'ASI ====
   −
==Setting UPS Variables==
+
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 :
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:
+
* « 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)
 +
 
 +
Une ASI esclave peut accéder avec UPS@192.168.1.1 (IP de l'ASI maître).
 +
 
 +
====Réglages des variables de l'ASI====
 +
Afin de définir les variables de l'ASI, il est nécessaire d'avoir d'abord activé les privilèges administratifs comme ci-dessus et vous avez la possibilité d'exécuter une commande à partir de l'onduleur esclave si l'accès est défini sur « private » comme ci-dessus.
 +
 
 +
Dans les exemples ci-dessous, on suppose que le nom de votre ASI est '''UPS''', qu'elle est locale, que l'utilisateur administrateur est '''admin''' et que le mot de passe est '''admin'''. Vous pouvez vérifier votre nom d'ASI par :
 
  upsc -l
 
  upsc -l
   −
To view a complete list of the UPS variables, both informational and modifiable
+
Pour voir une liste complète des variables de l'ASI, à la fois informationnelles et modifiables :
 
  upsc UPS
 
  upsc UPS
   −
To determine the modifiable variables for your UPS, their current settings and their available setting values execute the command:
+
Pour déterminer les variables modifiables de votre ASI, leurs valeurs actuelles et leurs valeurs de réglage possibles, exécutez la commande :
 
  upsrw UPS
 
  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"):
+
Vous pouvez maintenant modifier les variables souhaitées à l'aide d'une commande similaire à la suivante (notez que l'ordre des arguments est important et vous aurez peut-être besoin de guillemets autour de la valeur définie, "20") :
 
  upsrw -s battery.charge.low=20 -u admin -p admin UPS
 
  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    
+
Pour un hôte distant (ASI esclave), nous aurons besoin d'ajouter l'IP de l'ASI maître pour lancer la commande :
 +
upsrw -s battery.charge.low=20 -u admin -p admin UPS@192.168.2.1
 +
 
 +
Où la valeur après '''-s''' doit être l'un des paramètres identifiés par la commande '''upsrw ups'''. Vous pouvez, naturellement, vérifier vos modifications en utilisant  :    
 
  upsrw UPS
 
  upsrw UPS
or
+
ou
 
  upsc UPS
 
  upsc UPS
   −
After you are done, clean up by disabling the '''upsd''' administrative user '''admin''':
+
À la fin, effectuer un nettoyage en désactivant les privilèges d'administrateur de  '''upsc'''.
{{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|type=Attention : |Assurez-vous de bien comprendre la signification des variables UPS et leurs options de configuration disponibles. Vérifiez que vos modifications correspondent au comportement souhaité !}}
   −
More information on upsrw can be found at:
+
Plus d'information sur upsrw peut être obtenue sur la page du manuel :
 +
man upsrw
   −
- Manual page: man upsrw
+
=====Date du changement de la batterie=====
 +
Un exemple de mise à jour de la date du changement de la batterie (utilisez votre propre mot de passe) :<syntaxhighlight lang="bash">
 +
upsrw -s  battery.mfr.date=2024/01/18 -u admin -p admin UPS
 +
</syntaxhighlight>
   −
====Issuing UPS Commands====
+
====Émission de commandes à l'ASI====
In order to issue UPS commands it is necessary to have enabled a user with administrative privileges as above first.
+
Pour émettre des commandes à l'ASI, il est nécessaire d'avoir d'abord activé les privilèges administratifs comme ci-dessus et vous avez la possibilité d'exécuter une commande à partir de l'onduleur esclave si l'accès est défini sur « private » comme ci-dessus.
   −
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:
+
Dans les exemples ci-dessous, on suppose que le nom de votre ASI est '''UPS''', qu'elle est locale, que l'utilisateur administrateur est '''admin''' et que le mot de passe est '''admin'''. Vous pouvez vérifier votre nom d'ASI par :
 
  upsc -l
 
  upsc -l
   −
To view a complete list of available commands for your UPS:
+
Pour voir la liste complète des commandes pour votre ASI :
 
  upscmd -l UPS
 
  upscmd -l UPS
   −
You can now issue a command to the UPS with similar to the following:
+
vous pouvez maintenant émettre une commande à l'ASI « localhost » avec une commande similaire à celle-ci :
 
  upscmd -u admin -p admin UPS test.battery.start
 
  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.
+
Pour un hôte distant (ASI esclave), nous aurons besoin d'ajouter l'IP de l'ASI maître pour lancer la commande :
 +
upscmd -u admin -p admin UPS@192.168.2.1 test.battery.start
 +
 
 +
Où la commande '''test.battery.start''' est une commande valide pour votre ASI comme déterminée préalablement par '''upscmd -l UPS'''. En fonction de la commande émise, vous pouvez recevoir des messages diffusés et des courriels concernant et confirmant ce que fait l'ASI.
 +
 
 +
À la fin, effectuer un nettoyage en désactivant les privilèges d'administrateur de  '''upsc'''.
 +
{{Warning box|type=Attention : |Assurez-vous de bien comprendre la signification des variables UPS et leurs options de configuration disponibles. Vérifiez que vos modifications correspondent au comportement souhaité !
 +
L'émission de commandes pourrait arrêter votre serveur de manière inattendue.}}
   −
After you are done, clean up by disabling the '''upsd''' administrative user '''admin''':
+
Plus d'information sur upscmd peut être obtenue sur la page du manuel :
{{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!
+
man upscmd
   −
Issuing commands could shutdown your server unexpectedly!}}
+
=Planification d'évènements=
 +
====Exemple de délai d'arrêt====
 +
Par défaut, NUT émettra une commande d'arrêt dès qu'il recevra un événement de batterie faible de l'onduleur. Il peut y avoir des instances et des configurations d'installation qui nécessitent un arrêt plus tôt, ou d'autres événements avec des résultats chronométrés ou planifiés. Voir les pages '''man''', etc. pour plus d'informations et des exemples de situations.
    +
Essentiellement, le programme '''upsmon''' surveille l'onduleur concerné et pour chaque événement '''NOTIFYFLAG''' dans '''upsmon.conf''' prend l'action immédiate telle que définie. Afin de retarder ou de planifier des actions, les événements doivent être transmis à '''upssched''' qui peut définir des minuteries et planifier des événements.
 +
 +
Les modifications suivantes apportées à la configuration normale de NUT sur le serveur Koozali SME arrêteront le serveur après un délai spécifié, après avoir reçu le signal « sur batterie » (l'exemple donné est de 2 minutes). Cela suppose que vous disposez déjà d'une configuration NUT et d'une ASI activées et fonctionnelles.
 +
 +
Pour créer un arrêt temporisé avant la réception du signal '''BATTLOW''', il est nécessaire de configurer '''upssched''' et d'avoir un script pour gérer les événements UPS ('''upsmon''' ne peut pas faire cela).
 +
 +
 +
En premier, nous avons besoin de créer un nouveau répertoire pour un modèle personnalisé :
 +
mkdir -p /etc/e-smith/templates-custom/etc/ups/upsmon.conf
 +
cd /etc/e-smith/templates-custom/etc/ups/upsmon.conf
 +
 +
Créez et éditez un nouveau fichier appelé 'NOTIFYCMD' avec le contenu suivant :
 +
NOTIFYCMD /usr/sbin/upssched
 +
 +
Propagez le modèle :
 +
/sbin/e-smith/expand-template /etc/ups/upsmon.conf
 +
 +
Créez maintenant un autre répertoire pour un modèle personnalisé :
 +
mkdir -p /etc/e-smith/templates-custom/etc/ups/upssched.conf
 +
cd /etc/e-smith/templates-custom/etc/ups/upssched.conf
 +
 +
Créez et éditez un nouveau fichier appelé '01CONFIG' avec le contenu suivant :
 +
CMDSCRIPT /sbin/e-smith/nutUPS.cmd
 +
PIPEFN /tmp/upspipe
 +
LOCKFN /tmp/upslock
 +
AT COMMBAD * EXECUTE commbad
 +
AT COMMOK * EXECUTE commok
 +
AT NOCOMM * EXECUTE nocomm
 +
AT ONBATT * EXECUTE powerout
 +
AT ONBATT * START-TIMER shutdownnow 120   
 +
AT LOWBATT * EXECUTE shutdowncritical
 +
AT ONLINE * CANCEL-TIMER shutdownnow
 +
AT ONLINE * EXECUTE powerup
 +
 +
Dans ce qui précéède, définissez dans la ligne :
 +
AT ONBATT * START-TIMER shutdownnow 120
 +
le délai en secondes, après le signal ONBATT, après lequel vous voulez arrêter.
 +
 +
Propagez le modèle :
 +
/sbin/e-smith/expand-template /etc/ups/upssched.conf
 +
 +
 +
Créez et éditez un nouveau script à :
 +
/sbin/e-smith/nutUPS.cmd
 +
 +
Ajoutez le contenu suivant :
 +
 +
#! /bin/sh
 +
        case $1 in
 +
                commbad)
 +
                        /bin/echo "UPS communications failure on `date`." | /bin/mail -s"UPS communications LOST" admin
 +
                        /usr/bin/wall "UPS communications failure."
 +
                        ;;
 +
                commok)
 +
                        /bin/echo "UPS communications restored on `date`." | /bin/mail -s"UPS communications restored" admin
 +
                        /usr/bin/wall "UPS communications restored."
 +
                        ;;
 +
                nocomm)
 +
                        /bin/echo "UPS communications cannot be established on `date`." | /bin/mail -s"UPS uncontactable" admin
 +
                        /usr/bin/wall "UPS communications cannot be established."
 +
                        ;;
 +
                powerout)
 +
                        /bin/echo "Power failure on `date`." | /bin/mail -s"UPS on battery" admin
 +
                        /usr/bin/wall "UPS on battery. Shutdown in 60 seconds...."
 +
                        ;;
 +
                shutdownnow)
 +
                        /bin/echo "UPS has been on battery for 60 seconds. Starting orderly shutdown on `date`." | /bin/mail -s"UPS on battery for 60 seconds" admin
 +
                        /usr/bin/wall "UPS has been on battery for 60 seconds. Shutting down NOW!!!!"
 +
                        /usr/bin/sudo /sbin/e-smith/signal-event halt
 +
                        ;;
 +
                shutdowncritical)
 +
                        /bin/echo "UPS battery level CRITICAL. Starting EMERGENCY shutdown on `date`." | /bin/mail -s"UPS battery CRITICAL" admin
 +
                        /usr/bin/wall "UPS battery level CRITICAL. Shutting down NOW!!!!"
 +
                        /usr/bin/sudo /sbin/e-smith/signal-event halt
 +
                        ;;
 +
                powerup)
 +
                        /bin/echo "Power restored on `date`." | /bin/mail -s"UPS on line" admin
 +
                        /usr/bin/wall "UPS on line. Shutdown aborted."
 +
                        ;;
 +
                *)
 +
                        /bin/echo "Unrecognized command: $1"
 +
                        ;;
 +
        esac
 +
 +
Maintenant, rendez-le exécutable par l'utilisateur '''nut''' :
 +
chmod 754 /sbin/e-smith/nutUPS.cmd
 +
chown root:nut /sbin/e-smith/nutUPS.cmd
 +
 +
Nut nécessite d'utiliser sudo pour que ce processus fonctionne, donc sudo doit être configuré pour activer l'utilisateur nut. Par défaut, le fichier /etc/sudoers ne fait pas partie du système de modèles du serveur Koozali SME. Pour contourner ce problème, créez un répertoire de modèles personnalisé :
 +
mkdir -p /etc/e-smith/templates-custom/etc/sudoers
 +
cd /etc/e-smith/templates-custom/etc/sudoers
 +
 +
Pour préserver le contenu du fichier original /etc/sudoers, copiez celui-ci dans le répertoire de modèles personnalisé :
 +
cp /etc/sudoers 10sudoers
 +
 +
Créer et éditer un nouveau fichier dénommé '30nut' avec le contenu suivant :
 +
nut  ALL=NOPASSWD: ALL
 +
 +
Puis exécutez :
 +
/sbin/e-smith/expand-template /etc/sudoers
 +
 +
Finalement, pour terminer le processus :
 +
signal-event post-upgrade
 +
signal-event reboot
 +
 +
Lors des tests sur SMEServer v9.1 (vers mars 2016), le script <tt>nutUPS.cmd</tt> ci-dessus avec des entrées dans le modèle <tt>01CONFIG</tt> plantait à cause du manque de droits sur <tt>shutdownnow</tt> dans :
 +
/usr/bin/sudo /sbin/e-smith/signal-event halt
 +
 +
La modification de <tt>/etc/sudoers</tt> n'a pas réglé le problème.
 +
 +
Voici l'erreur dans le journal <tt>/var/log/messages</tt> :
 +
<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>
 +
 +
Pourtant, l'utilisateur '''nut''' dispose des autorisations d'arrêt nécessaires :
 +
/usr/bin/sudo -u nut /usr/bin/sudo /sbin/e-smith/signal-event halt
 +
 +
=Configurer les scripts du moniteur Nut-cgi=
 +
 +
Le paquet nut-cgi contient des scripts qui peuvent être exécutés via le serveur Web pour surveiller la(es) ASI.
 +
 +
===Téléchargement et installation===
 +
<tabs container><tab name="For SME 10">
 +
You have to enable the epel repository:
 +
yum install smeserver-extrarepositories-epel -y
 +
 +
then install nut-cgi:
 +
yum install --enablerepo=epel nut-cgi
 +
 +
then configure it the SME way:
 +
Edit file /etc/ups/hosts.conf and add.
 +
mkdir -p /etc/e-smith/templates-custom/etc/ups/hosts.conf
 +
echo 'MONITOR UPS@localhost "local UPS"' >/etc/e-smith/templates-custom/etc/ups/hosts.conf/10localhost
 +
expand-template /etc/ups/hosts.conf
 +
 +
Httpd template
 +
 +
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';
 +
    my $PublicAccess = $nut{'PublicAccess'} || "local";
 +
 +
    for ('exit-if-none')
 +
    {
 +
      if ($PublicAccess eq 'none')
 +
          {
 +
            next;
 +
          }
 +
      elsif ($PublicAccess eq 'local')
 +
          {
 +
            $allow  = "ip $localAccess";
 +
            $pass    = 0;
 +
            $satisfy = 'All';
 +
          }
 +
      elsif ($PublicAccess eq 'local-pw')
 +
          {
 +
            $allow  = "ip $localAccess";
 +
            $pass    = 1;
 +
            $satisfy = 'All';
 +
          }
 +
      elsif ($PublicAccess eq 'global')
 +
          {
 +
            $allow  = 'all granted';
 +
            $pass    = 0;
 +
            $satisfy = 'All';
 +
          }
 +
      elsif ($PublicAccess eq 'global-pw')
 +
          {
 +
            $allow  = 'all granted';
 +
            $pass    = 1;
 +
            $satisfy = 'All';
 +
          }
 +
      elsif ($PublicAccess eq 'global-pw-remote')
 +
          {
 +
            $allow  = "ip $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'}  /var/www/nut-cgi-bin\n";
 +
        } 
 +
      }
 +
 +
      $OUT .= "Alias  /nut  /var/www/nut-cgi-bin\n";
 +
 +
      $OUT .= "\n";
 +
      $OUT .= "<Directory /var/www/nut-cgi-bin>\n";
 +
      $OUT .= "    DirectoryIndex upsstats.cgi\n";
 +
      $OUT .= "    Options +ExecCGI\n";
 +
      $OUT .= "    <Require$satisfy>\n" if ($pass);
 +
      $OUT .= "    Require $allow\n";
 +
      if ($pass)
 +
      {
 +
          $OUT .= "    AuthName $name\n";
 +
          $OUT .= "    AuthType Basic\n";
 +
          $OUT .= "    AuthExternal pwauth\n";
 +
          $OUT .= "    require valid-user\n";
 +
          $OUT .= "    </Require$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
 +
 +
systemctl restart httpd-e-smith
 +
 +
</tab><tab name="For SME 9  and before">
 +
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 granted';
 +
    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
 
</tab>
 
</tab>
 +
</tabs>
 +
 +
===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 <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.
 +
 +
=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. 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.
 +
 +
SME Server sets the '''NOTIFYCMD''' to '''/sbin/e-smith/nutUPS.notify''', and this executable file simply sends an email to the SME admin user with a notification of the event.
 +
 +
Apart from the various events that the UPS and '''upsmon''' may notify via the '''NOTIFYFLAGS''' a ''Low Battery'' event will automatically and immediately cause '''upsmon''' to issue the '''SHUTDOWNCMD''' as defined in '''upsmon.conf''' (signal-event halt) and set a flag '''POWERDOWNFLAG''' so it knows on future restart that it is a UPS recovery.
 +
 +
For information on configuration parameters:
 +
man ups.conf
 +
man upsd.conf
 +
man upsd.users
 +
man upsmon.conf
 +
man upssched.conf
 +
 +
For general information:
 +
man upsd
 +
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
   −
</tabs>an example to update you battery date upon changing it. (use your own password)<syntaxhighlight lang="bash">
+
config setprop nut pollInterval 4
upsrw -s  battery.mfr.date=2020/08/31 -u admin -p admin UPS
  −
</syntaxhighlight>
      +
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
   −
===Variables et commandes ASI===
+
Add the bits between the # comments
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 box|type=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.}}
+
    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};
   −
====Droits d'administrateur ASI====
+
    # Add this
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.
+
    my $poll = $nut{pollInterval} || '2';
 +
    if ($poll ne '2') {
 +
      $OUT .= "pollinterval = $poll\n";
 +
    }
 +
    # ends here
   −
config show nut
+
    $OUT .= "[UPS]\n";
 +
    $OUT .= "\tdriver = $model\n";
   −
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) :
+
expand-template /etc/ups/ups.conf
 +
cat /etc/ups/ups.conf
   −
config setprop nut AdminPass admin
+
You should see something like this:
   −
Pour activer les droits d'administrateur et exécuter des commandes à l'ASI :
+
# Copyright (C) 1999-2006 Mitel Networks Corporation
 +
#------------------------------------------------------------
 +
pollinterval = 4
 +
[UPS]
   −
config setprop nut AdminUser enabled
+
Restart nut
   −
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'''.
+
  service nut restart
  /sbin/e-smith/expand-template /etc/ups/upsd.users
  −
/usr/sbin/upsd -c reload
     −
{{Note box|type=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 :
+
Now check to see the correct timeout:
config setprop nut AdminUser disabled
  −
/sbin/e-smith/expand-template /etc/ups/upsd.users
  −
/usr/sbin/upsd -c reload
  −
}}
     −
==== Accès à l'ASI ====
+
upsc UPS | grep driver.parameter.pollinterval
   −
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 :
+
driver.parameter.pollinterval: 4
   −
* « localhost » : l'accès à l'ASI se fait uniquement depuis la machine locale ( ASI maître) ;
+
To reset either delete the key, or set it to the default of 2
   −
* « 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 ;
+
==Further reading==
   −
* « public » : l'accès à l'ASI est similaire à « localhost ».  
+
The NUT website is here: [http://www.networkupstools.org/ NUT]
    +
From the above references you can glean which configuration setting does what function, etc.
   −
Pour régler les propriétés d'accès dans la base de données (exemple : localhost) :
+
If you want to modify the operation of NUT from the standard configuration, then you should generally modify the NUT config files by creating custom templates, expanding the templates and restarting service. This will ensure modifications survive a future reboot or reconfiguration.
   −
config setprop nut access localhost 
+
An example of doing this can be found in the forum [http://forums.contribs.org/index.php?topic=40668.0] and in the section above for UPS Administrative Privileges
/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''') :
+
See also [[KnownProblems#Restarting_NUT| Known Problem - Restarting Nut]]
UPS@localhost
+
----
   −
En mode « private »,  l'accès à votre ASI est (le nom de l'ASI est '''UPS''') :
+
===Documentation===
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).
+
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/fr]]
 +
</noinclude>
 +
<noinclude>
 +
[[Category:Administration]]
 +
</noinclude>
 +
__FORCETOC__
3,054

edits

Navigation menu