<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p class="elementToProof">Now I have this in /etc/nut/upsmon.conf (my QNAP NAS wants admin and 123456 or not working)</p>
<p class="elementToProof"><br>
</p>
<pre class="elementToProof"><code class="x_hljs x_language-sql">RUN_AS_USER root
MONITOR qnapups<span class="x_hljs-variable">@localhost</span> <span class="x_hljs-number">1</span> admin <span class="x_hljs-number">123456</span> master
MONITOR qnapups<span class="x_hljs-variable">@192</span><span class="x_hljs-number">.168</span><span class="x_hljs-number">.222</span><span class="x_hljs-number">.252</span> <span class="x_hljs-number">3493</span> admin <span class="x_hljs-number">123456</span> slave
MINSUPPLIES <span class="x_hljs-number">1</span>
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ <span class="x_hljs-number">5</span>
POLLFREQALERT <span class="x_hljs-number">5</span>
HOSTSYNC <span class="x_hljs-number">15</span>
DEADTIME <span class="x_hljs-number">15</span>
POWERDOWNFLAG <span class="x_hljs-operator">/</span>etc<span class="x_hljs-operator">/</span>killpower

NOTIFYFLAG ONLINE SYSLOG<span class="x_hljs-operator">+</span><span class="x_hljs-keyword">EXEC</span>
NOTIFYFLAG ONBATT SYSLOG<span class="x_hljs-operator">+</span><span class="x_hljs-keyword">EXEC</span>
NOTIFYFLAG LOWBATT SYSLOG<span class="x_hljs-operator">+</span><span class="x_hljs-keyword">EXEC</span>
NOTIFYFLAG REPLBATT SYSLOG<span class="x_hljs-operator">+</span><span class="x_hljs-keyword">EXEC</span>
NOTIFYCMD <span class="x_hljs-operator">/</span>usr<span class="x_hljs-operator">/</span>sbin<span class="x_hljs-operator">/</span>upssched

RBWARNTIME <span class="x_hljs-number">43200</span>
NOCOMMWARNTIME <span class="x_hljs-number">300</span>
FINALDELAY <span class="x_hljs-number">5<br></span></code></pre>
<pre class="elementToProof"><code class="x_hljs x_language-sql">
</code></pre>
<p class="x_elementToProof elementToProof">And in /etc/nut/upssched.conf (changed from 2 min to 4 min)</p>
<p class="x_elementToProof elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</p>
<p class="x_elementToProof elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</p>
<pre class="elementToProof"><code class="x_hljs x_language-sql elementToProof">CMDSCRIPT <span class="x_hljs-operator">/</span>etc<span class="x_hljs-operator">/</span>nut<span class="x_hljs-operator">/</span>upssched<span class="x_hljs-operator">-</span>execscript.sh

PIPEFN <span class="x_hljs-operator">/</span>etc<span class="x_hljs-operator">/</span>nut<span class="x_hljs-operator">/</span>upssched.pipe
LOCKFN <span class="x_hljs-operator">/</span>etc<span class="x_hljs-operator">/</span>nut<span class="x_hljs-operator">/</span>upssched.lock

<span class="x_hljs-keyword">AT</span> ONBATT <span class="x_hljs-operator">*</span> <span class="x_hljs-keyword">START</span><span class="x_hljs-operator">-</span>TIMER shutdown_onbatt <span class="x_hljs-number">240</span>
<span class="x_hljs-keyword">AT</span> ONBATT <span class="x_hljs-operator">*</span> <span class="x_hljs-keyword">EXECUTE</span> info_onbatt

<span class="x_hljs-keyword">AT</span> ONLINE <span class="x_hljs-operator">*</span> CANCEL<span class="x_hljs-operator">-</span>TIMER shutdown_onbatt
<span class="x_hljs-keyword">AT</span> ONLINE <span class="x_hljs-operator">*</span> <span class="x_hljs-keyword">EXECUTE</span> ups<span class="x_hljs-operator">-</span>back<span class="x_hljs-operator">-</span><span class="x_hljs-keyword">on</span><span class="x_hljs-operator">-</span>power

<span class="x_hljs-keyword">AT</span> LOWBATT <span class="x_hljs-operator">*</span> <span class="x_hljs-keyword">EXECUTE</span> shutdown_lowbatt

<span class="x_hljs-keyword">AT</span> REPLBATT <span class="x_hljs-operator">*</span> <span class="x_hljs-keyword">EXECUTE</span> replace_batt
<br>
</code></pre>
<p class="elementToProof">And in /etc/nut/upssched-execscript.sh</p>
<p class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</p>
<p class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</p>
<pre class="elementToProof"><code class="x_hljs x_language-bash"><span class="x_hljs-meta">#! /bin/sh</span>
<span class="x_hljs-keyword">case</span> <span class="x_hljs-variable">$1</span> <span class="x_hljs-keyword">in</span>
    shutdown_onbatt)
        logger -t upsmon[upssched] <span class="x_hljs-string">"shutdown_onbatt): Triggering shutdown after 4 minutes on battery"</span>
        /sbin/shutdown -h +0
        ;;

    shutdown_lowbatt)
        logger -t upsmon[upssched] <span class="x_hljs-string">"shutdown_lowbatt): Triggering shutdown when battery.charge.low is under 50%"</span>
        /sbin/shutdown -h +0
        ;;

    info_onbatt)
        logger -t upsmon[upssched] <span class="x_hljs-string">"info_onbatt): Now on battery"</span>
        ;;

    ups-back-on-power)
        logger -t upsmon[upssched] <span class="x_hljs-string">"ups-back-on-power): UPS back on power"</span>
        ;;

    replace_batt)
        message=<span class="x_hljs-string">"Quick self-test indicates battery requires replacement"</span>
        logger -t upsmon[upssched] <span class="x_hljs-string">"replace_batt): <span class="x_hljs-variable">$message</span>"</span>
        ;;

    *)
        logger -t upsmon[upssched] <span class="x_hljs-string">"*) = Unrecognized command: <span class="x_hljs-variable">$1</span>"</span>
        ;;
<span class="x_hljs-keyword">esac<br></span></code></pre>
<pre class="elementToProof"><code class="x_hljs x_language-bash"><span class="x_hljs-keyword"></span></code><code class="x_hljs x_language-bash elementToProof">
</code></pre>
<p class="elementToProof">And in /etc/nut/ups.conf</p>
<p class="elementToProof"><br>
</p>
<pre class="elementToProof"><code class="x_hljs x_language-cpp">[qnapups]
    driver = usbhid-ups
    port = <span class="x_hljs-keyword">auto</span>
    desc = <span class="x_hljs-string">"UPS"</span>
    ignorelb
    <span class="x_hljs-keyword">override</span>.battery.charge.low=<span class="x_hljs-number">50</span>
</code></pre>
<p class="elementToProof"><br>
</p>
<p class="elementToProof"><br>
</p>
<p class="elementToProof">So I have these files</p>
<pre><code class="x_hljs x_language-yaml">[<span class="x_hljs-string">root@ipfire2</span> <span class="x_hljs-string">nut</span>]<span class="x_hljs-comment"># pwd</span>
<span class="x_hljs-string">/etc/nut</span>
[<span class="x_hljs-string">root@ipfire2</span> <span class="x_hljs-string">nut</span>]<span class="x_hljs-comment"># ls -la</span>
<span class="x_hljs-string">total</span> <span class="x_hljs-number">104</span>
<span class="x_hljs-string">drwxr-xr-x</span>  <span class="x_hljs-number">2</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">4096 </span><span class="x_hljs-string">Jan</span> <span class="x_hljs-number">10</span> <span class="x_hljs-number">09</span><span class="x_hljs-string">:23</span> <span class="x_hljs-string">.</span>
<span class="x_hljs-string">drwxr-xr-x</span> <span class="x_hljs-number">50</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">4096 </span><span class="x_hljs-string">Jan</span> <span class="x_hljs-number">10</span> <span class="x_hljs-number">10</span><span class="x_hljs-string">:33</span> <span class="x_hljs-string">..</span>
<span class="x_hljs-string">-rw-r--r--</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">1542 </span><span class="x_hljs-string">Jan</span> <span class="x_hljs-number">10</span> <span class="x_hljs-number">09</span><span class="x_hljs-string">:05</span> <span class="x_hljs-string">nut.conf</span>
<span class="x_hljs-string">-rw-r--r--</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">1538 </span><span class="x_hljs-string">Dec</span> <span class="x_hljs-number">18</span>  <span class="x_hljs-number">2020 </span><span class="x_hljs-string">nut.conf.sample</span>
<span class="x_hljs-string">-rw-r--r--</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">4734 </span><span class="x_hljs-string">Jan</span> <span class="x_hljs-number">10</span> <span class="x_hljs-number">09</span><span class="x_hljs-string">:10</span> <span class="x_hljs-string">ups.conf</span>
<span class="x_hljs-string">-rw-r--r--</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">4618 </span><span class="x_hljs-string">Dec</span> <span class="x_hljs-number">18</span>  <span class="x_hljs-number">2020 </span><span class="x_hljs-string">ups.conf.sample</span>
<span class="x_hljs-string">-rw-r-----</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">4606 </span><span class="x_hljs-string">Dec</span> <span class="x_hljs-number">22</span> <span class="x_hljs-number">08</span><span class="x_hljs-string">:44</span> <span class="x_hljs-string">upsd.conf</span>
<span class="x_hljs-string">-rw-r--r--</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">4578 </span><span class="x_hljs-string">Dec</span> <span class="x_hljs-number">18</span>  <span class="x_hljs-number">2020 </span><span class="x_hljs-string">upsd.conf.sample</span>
<span class="x_hljs-string">-rw-r-----</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">2292 </span><span class="x_hljs-string">Dec</span> <span class="x_hljs-number">22</span> <span class="x_hljs-number">07</span><span class="x_hljs-string">:11</span> <span class="x_hljs-string">upsd.users</span>
<span class="x_hljs-string">-rw-r--r--</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">2131 </span><span class="x_hljs-string">Dec</span> <span class="x_hljs-number">18</span>  <span class="x_hljs-number">2020 </span><span class="x_hljs-string">upsd.users.sample</span>
<span class="x_hljs-string">-rw-r--r--</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span> <span class="x_hljs-number">15569</span> <span class="x_hljs-string">Jan</span> <span class="x_hljs-number">10</span> <span class="x_hljs-number">10</span><span class="x_hljs-string">:20</span> <span class="x_hljs-string">upsmon.conf</span>
<span class="x_hljs-string">-rw-r--r--</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span> <span class="x_hljs-number">15313</span> <span class="x_hljs-string">Dec</span> <span class="x_hljs-number">18</span>  <span class="x_hljs-number">2020 </span><span class="x_hljs-string">upsmon.conf.sample</span>
<span class="x_hljs-string">-rw-r--r--</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">4173 </span><span class="x_hljs-string">Jan</span> <span class="x_hljs-number">10</span> <span class="x_hljs-number">10</span><span class="x_hljs-string">:22</span> <span class="x_hljs-string">upssched.conf</span>
<span class="x_hljs-string">-rw-r--r--</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>  <span class="x_hljs-number">3895 </span><span class="x_hljs-string">Dec</span> <span class="x_hljs-number">18</span>  <span class="x_hljs-number">2020 </span><span class="x_hljs-string">upssched.conf.sample</span>
<span class="x_hljs-string">-rwxr-xr-x</span>  <span class="x_hljs-number">1</span> <span class="x_hljs-string">root</span> <span class="x_hljs-string">root</span>   <span class="x_hljs-number">810</span> <span class="x_hljs-string">Jan</span> <span class="x_hljs-number">10</span> <span class="x_hljs-number">10</span><span class="x_hljs-string">:29</span> <span class="x_hljs-string">upssched-execscript.sh</span>
</code></pre>
<p class="elementToProof">Do all that seem right to you?</p>
<br>
</body>
</html>