dcsimg
Results 1 to 21 of 21

Thread: [RESOLVED] Detect power outage

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    27

    Resolved [RESOLVED] Detect power outage

    Good day.

    We have this server and the server is with UPS capable for 15 minutes upon power loss.

    Since nobody is allowed to touch the server to shutdown properly, especially on weekends where I am off duty, I am think if I can create an application that can detect power loss and start properly server shutdown.

    Any suggestion?

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,919

    Re: Detect power outage

    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  3. #3
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    632

    Re: Detect power outage

    Does the UPS have the ability to indicate somehow that it has lost power?
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2019 (16.3.5)

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,596

    Re: Detect power outage

    Quote Originally Posted by Zvoni View Post
    I don't think a server is running on it's own battery like a laptop does.
    To the server the UPS is "just" the power supply.
    Thus indeed you need to get a signal from the UPS itself.

  5. #5
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,919

    Re: Detect power outage

    Quote Originally Posted by Arnoutdv View Post
    I don't think a server is running on it's own battery like a laptop does.
    To the server the UPS is "just" the power supply.
    Thus indeed you need to get a signal from the UPS itself.
    You're right. I missed that.
    Usually a UPS is connected to the server via Ethernet or USB, and the UPS itself should send a "Shutdown"-Signal to the server in case of an outage,
    or the server should check the status of the UPS (endless loop), and in case "Power outage - I'm shutting down"
    At least that's the way it is with our server/UPS
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    27

    Re: Detect power outage

    Im not sure if our UPS has that feature but I will check. But if in case it has none, what else can be done?

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,455

    Re: Detect power outage

    Quote Originally Posted by techbee View Post
    Im not sure if our UPS has that feature but I will check. But if in case it has none, what else can be done?
    Either wait for the to power drain completely and the servers enters an instant power off state, or power is restored in time and there's no issue.

    It's either that, or you somehow become aware that there's a power outage and you physically go to the location and power down the servers yourself.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,919

    Re: Detect power outage

    Quote Originally Posted by techbee View Post
    Im not sure if our UPS has that feature but I will check. But if in case it has none, what else can be done?
    If it's recently bought i would be surprised if it doesn't have that feature.
    Could you tell as the brand/model of the UPS?
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  9. #9
    Lively Member
    Join Date
    Mar 2019
    Posts
    83

    Re: Detect power outage

    1) Find an old box and plug it into mains (not ups)
    2) Set up a simple monitoring system to monitor it. You can download one probably. You dont need many features just up/down
    3) When it goes down get an alert sent to you

    It will either be power or some other issue but usually its power.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    27

    Re: Detect power outage

    Quote Originally Posted by Zvoni View Post
    If it's recently bought i would be surprised if it doesn't have that feature.
    Could you tell as the brand/model of the UPS?
    Its an old model. Forgot the name. Its around 2006 model.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    27

    Re: Detect power outage

    Quote Originally Posted by vbwins View Post
    1) Find an old box and plug it into mains (not ups)
    2) Set up a simple monitoring system to monitor it. You can download one probably. You dont need many features just up/down
    3) When it goes down get an alert sent to you

    It will either be power or some other issue but usually its power.
    What do you mean old box? Old pc, old lsptop, old ups?

  12. #12
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,929

    Re: Detect power outage

    Quote Originally Posted by techbee View Post
    Its an old model. Forgot the name. Its around 2006 model.
    Every UOS I have saw over the last 15 years or so have had some kind of interface on them serial, usb or ethernet often they have more than one interface available.

  13. #13
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,549

    Re: Detect power outage

    As far as I can tell no 3rd party software is required. Windows can still recognize a UPS, even old ones that use a COM: port for signaling.

  14. #14
    Hyperactive Member
    Join Date
    Feb 2019
    Posts
    400

    Re: Detect power outage

    ....
    Last edited by qvb6; Oct 10th, 2019 at 11:39 AM.

  15. #15
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,701

    Re: Detect power outage

    I've got two APC UPS units, one runs my NAS box and the modem and routers where they come into the house. The other runs a desktop my wife uses for work. The one for my NAS box is a few years old. I just looked at it and it's got an RJ45 plug that says USB on it, and I remember that it's for UPS on/off detection. I'd have to rummage through my cable box to find the actual cable, but it was a funny looking thing with the RJ45 on one end and a standard USB plug on the other. And, some software came with the UPS unit to install on computers using it.

    Truth be told, I've never messed with that, as I live in the country, and we frequently get little glitches, but seldom anything longer than a couple of minutes. If it's ever longer, I just start manually shutting things down. Mostly, I worry about my NAS box, but it's running a customized version of Linux (Synology). I think there's a software app for it to work with the UPS unit, but I've never spent the time to see if I could get it running.

    Personally, I'd think using that UPS detector would be the only way to do it. Supposedly, these UPS units work pretty hard to give you a sinusoidal longitudinal A/C wave pattern, even when working from the batteries. And, if your power company is anything like mine, they may also be sending you all kinds of weird stuff in the waveform. Most UPS units are also suppose to smooth that stuff out. So, I'd be surprised if there's a way to do it by trying to examine the power input, and that's all you've got without some other signal coming in.

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    27

    Re: Detect power outage

    I have apc smart ups 2200 with rj45 label usb at the back panel. Problem is i dont have the software since i only assumed the job and no turnover of software with this one.

  17. #17
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,442

    Re: Detect power outage

    Quote Originally Posted by techbee View Post
    What do you mean old box? Old pc, old lsptop, old ups?
    I'm pretty sure he meant an old computer hanging around that isn't used for anything and you can connected to the same wall power the ups is on.
    If your server is on a network, and the old computer is on the network, the server could check periodically to see if the old box is there, i.e. ping it, or have an application that generates a heartbeat or responds to a message over the network.

    If the box stops responding, assume the power has gone off.

    {and if you have two old boxes, even better. If only one stops responding, then you can assume the power didn't go off, but if both stop responding at around the same time, it is more likely that it did}.

    And, if the old box will restart after power comes back, you could even wait 5 or 10 minutes, before shutting down, in case they come back on line indicated the outage was for a short period, and the server shouldn't need to shutdown.
    Last edited by passel; Oct 10th, 2019 at 08:58 PM.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  18. #18
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,379

    Re: [RESOLVED] Detect power outage

    Connectivity-wise - the Drivers for the APC RJ45->USB-connection are already contained in Windows.
    https://www.youtube.com/watch?v=DCgsmwbBRKM

    Their own "GUI-App" on top of these drivers is labelled "PowerChute".
    (several versions and variants of it - Personal Edition is free downloadable I think).

    Olaf

  19. #19
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,919

    Re: Detect power outage

    Quote Originally Posted by passel View Post
    I'm pretty sure he meant an old computer hanging around that isn't used for anything and you can connected to the same wall power the ups is on.
    If your server is on a network, and the old computer is on the network, the server could check periodically to see if the old box is there, i.e. ping it, or have an application that generates a heartbeat or responds to a message over the network.

    If the box stops responding, assume the power has gone off.

    {and if you have two old boxes, even better. If only one stops responding, then you can assume the power didn't go off, but if both stop responding at around the same time, it is more likely that it did}.

    And, if the old box will restart after power comes back, you could even wait 5 or 10 minutes, before shutting down, in case they come back on line indicated the outage was for a short period, and the server shouldn't need to shutdown.
    To build up on that: An (old) Laptop, connected to the LAN and server.
    Code a small app with the API-call in my Post#2
    Since it's a laptop which is plugged directly into a power outlet, a power outage would switch that laptop to Battery/DC-supply, which the API can recognize.
    then maybe use this API --> https://docs.microsoft.com/en-us/win...temshutdownexw

    and you're done with a workaround, that shouldn't be necessary
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  20. #20
    Lively Member
    Join Date
    Mar 2019
    Posts
    83

    Re: Detect power outage

    Old PC or Laptop

  21. #21
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    1,919

    Re: Detect power outage

    Quote Originally Posted by vbwins View Post
    Old PC or Laptop
    Laptop! I wouldn't know of a (Desktop)-PC to run on batteries.
    You need to recognize the switch from AC to DC
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width