Line 138: |
Line 138: |
| {{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.}} | | {{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.}} |
| | | |
| + | ====Droits d'administrateur ASI==== |
| <tabs container> | | <tabs container> |
| <tab name="SME 10"> | | <tab name="SME 10"> |
Line 182: |
Line 183: |
| /usr/sbin/upsd -c reload | | /usr/sbin/upsd -c reload |
| | | |
− |
| |
− | ====Droits d'administrateur ASI====
| |
| 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. | | 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. |
| | | |
Line 205: |
Line 204: |
| /usr/sbin/upsd -c reload | | /usr/sbin/upsd -c reload |
| }} | | }} |
| + | |
| + | </tab> |
| + | <tab name="SME 8"> |
| + | |
| + | 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[http://forums.contribs.org/index.php?topic=40668.0]. |
| + | |
| + | 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} || <nowiki>''</nowiki>) ne <nowiki>''</nowiki>); |
| + | |
| + | $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 |
| + | |
| + | {{Note box|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 |
| + | }} |
| + | </tab> |
| + | |
| + | </tabs> |
| ==== Accès à l'ASI ==== | | ==== Accès à l'ASI ==== |
| | | |
Line 261: |
Line 309: |
| man upsrw | | man upsrw |
| | | |
− | Un exemple de mise à jour de la date de changement de la batterie (utilisez votre propre mot de passe) :<syntaxhighlight lang="bash"> | + | =====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 | | upsrw -s battery.mfr.date=2024/01/18 -u admin -p admin UPS |
| </syntaxhighlight> | | </syntaxhighlight> |
Line 288: |
Line 337: |
| Plus d'information sur upscmd peut être obtenue sur la page du manuel : | | Plus d'information sur upscmd peut être obtenue sur la page du manuel : |
| man upscmd | | man upscmd |
− |
| |
− | </tab>
| |
− | <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 create a suitable user we will use SME Servers templating system and configuration database. This is based on an original forum thread[http://forums.contribs.org/index.php?topic=40668.0].
| |
− |
| |
− | 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} || <nowiki>''</nowiki>) ne <nowiki>''</nowiki>);
| |
− |
| |
− | $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
| |
− |
| |
− | {{Note box|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 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!}}
| |
− |
| |
− | </tab>
| |
− |
| |
− | </tabs>
| |
| | | |
| =Planification d'évènements= | | =Planification d'évènements= |
Line 504: |
Line 450: |
| /usr/bin/sudo /sbin/e-smith/signal-event halt | | /usr/bin/sudo /sbin/e-smith/signal-event halt |
| | | |
− | La modification de <tt>/etc/sudoers</tt> ne l'a pas réglé. | + | 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> : | | Voici l'erreur dans le journal <tt>/var/log/messages</tt> : |
Line 518: |
Line 464: |
| /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 |
| | | |
− | =Configurer les cripts du monieteur Nut-cgi= | + | =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. | | Le paquet nut-cgi contient des scripts qui peuvent être exécutés via le serveur Web pour surveiller la(es) ASI. |
Line 741: |
Line 687: |
| </tab> | | </tab> |
| </tabs> | | </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 |
| + | |
| + | config setprop nut pollInterval 4 |
| + | |
| + | Modify the template |
| + | |
| + | mkdir -p /etc/e-smith/templates-custom/etc/ups/ups.conf |
| + | cp /etc/e-smith/templates/etc/ups/ups.conf/UPS /etc/e-smith/templates-custom/etc/ups/ups.conf/UPS |
| + | nano /etc/e-smith/templates-custom/etc/ups/ups.conf/UPS |
| + | |
| + | Add the bits between the # comments |
| + | |
| + | { |
| + | my $model = $nut{Model} || "usbhid-ups"; |
| + | my $device = $nut{Device} || "/var/lib/ups/hiddev0"; |
| + | my $type = $nut{Type}; |
| + | my $mfr = $nut{mfr}; |
| + | my $mdl = $nut{mdl}; |
| + | |
| + | # Add this |
| + | my $poll = $nut{pollInterval} || '2'; |
| + | if ($poll ne '2') { |
| + | $OUT .= "pollinterval = $poll\n"; |
| + | } |
| + | # ends here |
| + | |
| + | $OUT .= "[UPS]\n"; |
| + | $OUT .= "\tdriver = $model\n"; |
| + | |
| + | expand-template /etc/ups/ups.conf |
| + | cat /etc/ups/ups.conf |
| + | |
| + | You should see something like this: |
| + | |
| + | # Copyright (C) 1999-2006 Mitel Networks Corporation |
| + | #------------------------------------------------------------ |
| + | pollinterval = 4 |
| + | [UPS] |
| + | |
| + | Restart nut |
| + | |
| + | service nut restart |
| + | |
| + | Now check to see the correct timeout: |
| + | |
| + | upsc UPS | grep driver.parameter.pollinterval |
| + | |
| + | driver.parameter.pollinterval: 4 |
| + | |
| + | To reset either delete the key, or set it to the default of 2 |
| + | |
| + | ==Further reading== |
| + | |
| + | The NUT website is here: [http://www.networkupstools.org/ NUT] |
| + | |
| + | From the above references you can glean which configuration setting does what function, etc. |
| + | |
| + | 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. |
| + | |
| + | 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 |
| + | |
| + | See also [[KnownProblems#Restarting_NUT| Known Problem - Restarting Nut]] |
| + | ---- |
| + | |
| + | ===Documentation=== |
| + | |
| + | 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__ |