Code Monkey home page Code Monkey logo

Comments (14)

rgc2000 avatar rgc2000 commented on June 12, 2024

Have you restarted the upsmon NutClient service on ESXi after changing your settings? Otherwise, it does not take into account hot modifications.

from nutclient-esxi.

YuriyDY avatar YuriyDY commented on June 12, 2024

Yes, I tried to restart the NUT client service and the esxi host. The same issue

from nutclient-esxi.

rgc2000 avatar rgc2000 commented on June 12, 2024

I have made a test on ESXi 7.0U3n (higher revision makes no difference) with NUT-Client-2.8.1-2.6.1 and the same parameters as you. I also sent OB DISCHRG from Nut Server. It works as expected. In ESXi /var/log/syslog.log I can see the power down decision exactly 10 seconds after the onbatt event :

2024-02-18T14:38:40.367Z upsmon[135154]: UPS test1@upserver on battery
2024-02-18T14:38:50.385Z upsmon[135154]: Signal 10: User requested FSD
2024-02-18T14:38:50.385Z upsmon[135154]: Executing automatic power-fail shutdown
2024-02-18T14:38:50.388Z upsmon[135154]: Auto logout and shutdown proceeding

Can you tell me which version of the NUT-Client you are using ?

from nutclient-esxi.

YuriyDY avatar YuriyDY commented on June 12, 2024

I have upgraded my ESXi to 7.0U3n to be syncronized with you. And also I using latest NUT-Client-2.8.1-2.6.1. I installed it from NutClient-ESXi-2.8.1-2.6.1-offline_bundle.zip.

This is part of my log file:

2024-02-18T19:48:18.574Z NUT[2102046]: NUT client is running
2024-02-18T19:48:18.671Z sfcbd-init[2102067]: args ('status')
2024-02-18T19:48:18.677Z sfcbd-init[2102067]: Getting Exclusive access, please wait...
2024-02-18T19:48:18.737Z sfcbd-init[2102067]: Exclusive access granted.
2024-02-18T19:50:26.482Z upsmon[2102036]: UPS [email protected] on battery
2024-02-18T19:51:46.529Z upsmon[2102036]: UPS [email protected] on line power

May be I can provide you something else?

from nutclient-esxi.

rgc2000 avatar rgc2000 commented on June 12, 2024

Strange. Can you post here the contents of ESXi file /opt/nut/etc/notify.conf ? You can anonymize personal data.
This file is created when you start the NutClient service.

from nutclient-esxi.

YuriyDY avatar YuriyDY commented on June 12, 2024

Agree.
From the /opt/nut/etc/notify.conf everething looking good:

# notification configuration
UPS_LIST="[email protected]"
MINSUPPLIES="1"
ONBATT_DELAY="5" ## I try different values for this timer
SEND_MAIL="0"
SMTP_RELAY="none"
[ "${SMTP_RELAY}" = "none" ] && SMTP_RELAY=""
TO="root@domain"

I tryed to modify /opt/nut/bin/notify.sh with echo markers:

# count how many UPSes are still online
NB_UPS_ONLINE=$(for UPS in ${UPS_LIST}; do /opt/nut/bin/upsc "${UPS}" ups.status; done | grep -c OL)

# Delayed shutdown if running on battery with less than minsupplies online
echo "Start"
if [ "${NOTIFYTYPE}" = "ONBATT" -a "${NB_UPS_ONLINE}" -lt "${MINSUPPLIES}" -a "${ONBATT_DELAY}" -gt 0 ]
echo "Getting UPS nums"
then
  if [ ! -f "${SHUDOWN_PID_FILE}" ]
  then
    (
      # seconds to wait
      sleep "${ONBATT_DELAY}"
      echo "End timer"
      # force shutdown
      rm "${SHUDOWN_PID_FILE}"
      /opt/nut/sbin/upsmon -c fsd
      exit 0
    ) &
    echo $! > "${SHUDOWN_PID_FILE}"
  fi
fi

But I cannot see any echos in a command line or syslog file. Its looking like NOTIFY event cannot call notify.sh. But I cannot see any troubles here:

[root@esxi:~] cat /opt/nut/etc/upsmon.conf
# Network UPS Tools: upsmon configuration

SHUTDOWNCMD "poweroff"
**NOTIFYCMD "/opt/nut/bin/notify.sh"**

POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15

NOTIFYFLAG ONLINE   SYSLOG+EXEC
**NOTIFYFLAG ONBATT   SYSLOG+EXEC**

Can you please tell me paths to additional log files for analysis?

from nutclient-esxi.

rgc2000 avatar rgc2000 commented on June 12, 2024

How have you ben able to modify the /opt/nut/bin/notify.sh file ? It is a read-only and protected file. Even root cannot modify it. You need to make changes in source files and recompile the package.

If you want to output a message to the syslog don't use echo but use command :
logger -t NUT "message"
the "**" are not part of the file upsmon.conf, right ? I suppose it is a markdown attempt to emphasize the text already in code format.

You can try a larger delay (120 or more) and check that you have a non empty file /var/run/ups_shutdown.pid after receiving the ONBATT event.

then execute this command to check that the shutdown process is running and executing a sleep command.
ps -cv | grep $(cat /var/run/ups_shutdown.pid)

To get the process tree use this command and find the process with the PID stored in /var/run/ups_shutdown.pid, you should see the sleep with the delay
ps -cJ

Also what is the result of this command while UPS is on battery ?
/opt/nut/bin/upsc [email protected] ups.status

Last thing, give me the output of
ls -l /opt/nut/bin

from nutclient-esxi.

YuriyDY avatar YuriyDY commented on June 12, 2024

Yes right. I tryed to make changes to the source files, then do "make". And than I installed modified addon.

Now I've rolled it back. I will modify notify.sh with "logger" command if you want, but I found some unexpected behavior.
Yes, you are right. The "**" is the markdown attemt. Excuse me.

I changed the battery delay timer to 120 seconds
image

And then I started the test:
image

The output for

ls /var/run/ups_shutdown.pid
ps -cv | grep $(cat /var/run/ups_shutdown.pid)
ps -cJ | grep sleep

image

After end of the sleep timer:
image
image

UPS status and bin folder looking good:
image

So, NUT CLient does't created ups_shutdown.pid. Is there a problem with my NUT Client installation?

from nutclient-esxi.

rgc2000 avatar rgc2000 commented on June 12, 2024

One test is missing : the result of this command while UPS is on battery :
/opt/nut/bin/upsc [email protected] ups.status

The other results are correct. The ups_shutdown.pid only exists while the process is waiting for the end of the ONBATT_DELAY. And just after deleting the file it should start the poweroff sequence. Therefore it uses a manual NUT event to force shutdown and it seems that this has no effect.

Could you try to send this event on command line ? This should immediately start a shutdown so your ESXi will poweroff :
/opt/nut/sbin/upsmon -c fsd

If your ESXi ignores this command we'll have to search in the ESXi configuration. Can you confirm that your ESXi is not part of a VMware cluster with HA enabled ?

from nutclient-esxi.

YuriyDY avatar YuriyDY commented on June 12, 2024

You can find ups.status request and answer in a last screenshot. Everething is fine here:
image

This is reaction to the upsmon command:
image

Does it look like the solution to the problem is close?

Yes, my server was deploed in a standalone install without HA and vSphere:
image

from nutclient-esxi.

rgc2000 avatar rgc2000 commented on June 12, 2024

This is very strange, the location of the pid file for upsmon is not /run/upsmon.pid but /var/run/upsmon.pid
There is something wrong with your binary. The compilation process is not ok and the default has not been set as expected.

I can see that the configure script will use the default for the system where you are compiling. So the linux where you made the compilation is using /run instead of /var/run for privileged pid files.

Let's force it to the desired value. Can you edit the Makefile and change the line 42 to add the option --with-pidpath=/var/run to explicitly set the path to the pid file :
cd nut-$(NUT_VERSION); touch .git; ./configure --prefix=/opt/nut --with-pidpath=/var/run --without-cgi --without-snmp --without-wrap --without-serial --with-user=daemon --with-group=daemon --with-openssl --with-openssl-includes="-I$(CURDIR)/libressl-bin/inc lude" --with-openssl-libs="-L$(CURDIR)/libressl-bin/lib -lssl -lcrypto" LDFLAGS="-lrt -lpthread"

Then recompile the package and update/reinstall the package.

from nutclient-esxi.

YuriyDY avatar YuriyDY commented on June 12, 2024

Thank you so much! Now its working
image

I used Centos 7 minimal to build the package.
image

Can I provide something else for you about my Centos installation?

from nutclient-esxi.

rgc2000 avatar rgc2000 commented on June 12, 2024

I am still using an old CentOS 6 to compile the package. I have tested that the compilation works under CentOS 7 and Linux Rocky 8 but I have not tested that the binaries were working as expected.

I am going to add this change to the Makefile in git repository but as this is only a build issue I will not release a new version of the package. The provided binaries are OK.

Thank you for your feedback. This will make the code more portable on other Linux distributions for users who want to edit and compile the sources.

from nutclient-esxi.

rgc2000 avatar rgc2000 commented on June 12, 2024

Build with /var/run path for upsmon pid file fixed in commit ce40ce6

from nutclient-esxi.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.