Changes

From SME Server
Jump to navigationJump to search
no edit summary
Line 475: Line 475:  
  /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 cripts du monieteur Nut-cgi=
   −
The nut-cgi rpm contains scripts that can be run via the webserver to monitor the UPS(s).
+
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>
3,054

edits

Navigation menu