Changes

Jump to navigation Jump to search
no edit summary
Line 114: Line 114:     
====Connecting multiple UPS's====
 
====Connecting multiple UPS's====
To be added http://bugs.contribs.org/show_bug.cgi?id=629
+
En référence à http://bugs.contribs.org/show_bug.cgi?id=629 et https://bugs.koozali.org/show_bug.cgi?id=626#c2,
    +
1- vous devrez exécuter :<syntaxhighlight lang="bash">
 +
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.
 +
 +
 +
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.
 +
 +
 +
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
 +
</syntaxhighlight>
 +
 +
===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 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">
 +
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 show nut
 +
 +
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
 +
 +
Pour activer les privilèges d'administration et passer une commande à l'ASI :
 +
 +
config setprop nut AdminUser enabled
 +
 +
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
 +
/usr/sbin/upsd -c reload
 +
 +
{{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
 +
/sbin/e-smith/expand-template /etc/ups/upsd.users
 +
/usr/sbin/upsd -c reload
 +
}}
 +
 +
</tab>
 +
 
<tab name="SME 9">
 
<tab name="SME 9">
   Line 134: Line 183:  
  /usr/sbin/upsd -c reload
 
  /usr/sbin/upsd -c reload
   −
===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 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====
   
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 162: 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 218: 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 245: 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 461: 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 475: 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
   −
=Configure Nut-cgi Monitor Scripts=
+
=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>
 +
</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===
   −
The nut-cgi rpm contains scripts that can be run via the webserver to monitor the UPS(s).
+
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