Run an ssh command on a certain battery percentage

Hello,


I need to shutdown a Qnap NAS when the UPS battery attached (via usb) to a mac server is low. Is it possible to automate this thing? I suppose the mac should send a command via ssh but I have no idea of how to do this automatically when the battery is at a certain percentage.


Thank you

Posted on Mar 27, 2020 3:47 PM

Reply
11 replies

Mar 28, 2020 3:22 PM in response to etresoft

The NAS is more important in this case.

Now I'm gonna try to enable the NUT function on the mac, I found a tutorial on Youtube to installa software called "Fink". This method should take advantage of the NAS capability to notify the power failure to other hosts and makes the mac capable of listening to this.


https://www.youtube.com/watch?v=8rWlouT18pw&list=WL&index=29&t=0s

Mar 30, 2020 11:28 PM in response to FRANCE5CO

> The NAS is more important in this case.


Fink aside, I think the Mac is more important.


If the Mac knows the UPS is low (which is easy because it has built-in UPS monitoring), then the Mac can unmount the NAS volume and shut down gracefully. Assuming there are no other users on the NAS, you should be good to go (yes, big assumption, I know). Even if the NAS subsequently loses power, if there are no active users/files, you should be OK.


Contrast that with the NAS shutting down because the UPS is low - the Mac doesn't know this and may have open files - it could be actively saving files when the shutdown is triggered, and now you risk data loss.


So if you can't get them hooked together, focus on the Mac first.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Run an ssh command on a certain battery percentage

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.