Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Jan 2008 11:34:21 -0800
From:      "Derrick Ryalls" <ryallsd@gmail.com>
To:        "Derek Ragona" <derek@computinginnovations.com>
Cc:        Bob Johnson <fbsdlists@gmail.com>, Kurt Buff <kurt.buff@gmail.com>, FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: Nut and RAID on FreeBSD 7.0
Message-ID:  <d5eb95fc0801111134q793e7e8eya16cd71061cd390b@mail.gmail.com>
In-Reply-To: <6.0.0.22.2.20080111090620.0245e338@mail.computinginnovations.com>
References:  <d5eb95fc0801091651h1788afd1m256a824e4722906d@mail.gmail.com> <6.0.0.22.2.20080110025841.023a9bb8@mail.computinginnovations.com> <d5eb95fc0801101140w717095dfhed569274c261e4a6@mail.gmail.com> <6.0.0.22.2.20080110155430.023d29d8@mail.computinginnovations.com> <d5eb95fc0801101443l6b4cd69do6d69d5b90cd91702@mail.gmail.com> <54db43990801101514y317a2889l7ad18fa4ffce56be@mail.gmail.com> <a9f4a3860801101552p1f82abddnce1ba982ea791ba8@mail.gmail.com> <d5eb95fc0801102343m7cf7cb3ckf78c0b0e694d3959@mail.gmail.com> <6.0.0.22.2.20080111090620.0245e338@mail.computinginnovations.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 11, 2008 7:19 AM, Derek Ragona <derek@computinginnovations.com> wrote:
>
>
>  At 01:43 AM 1/11/2008, Derrick Ryalls wrote:
>
> On Jan 10, 2008 3:52 PM, Kurt Buff <kurt.buff@gmail.com> wrote:
>  >
>  > On Jan 10, 2008 3:14 PM, Bob Johnson <fbsdlists@gmail.com> wrote:
>  > > On 1/10/08, Derrick Ryalls <ryallsd@gmail.com> wrote:
>  > >
>  > > >
>  > > > Perhaps I need to re-evaluate my line of thinking.  Light sometime
>  > > > flicker, but power almost never goes out.  When it does it is either
>  > > > back on in less than 1 minute, or out for hours.  If the UPS detects
>  > > > critical correctly and gives me at least a minute before death, then
>  > > > that should be plenty of time for the system to auto-shutdown.  Guess
>  > > > I will have to do some experimentation tonight.
>  > >
>  > > While you experiment, keep in mind the following sequence of events:
>  > >
>  > > -- Power fails
>  > > -- UPS signals low battery
>  > > -- System shuts down
>  > > -- Power returns before UPS shuts itself down
>  > > --> System never reboots, because it never lost power.
>  > >
>  > > Getting around this is the tricky part. I haven't used NUT in about
>  > > seven years, but back then the recommendation was to shut down to
>  > > single user mode and run a script that delayed for some time longer
>  > > than the remaining battery life of the UPS, then rebooted the system.
>  > > There didn't seem to be an easy hook for running a script after
>  > > shutting down to single user mode (maybe there is now).
>  > >
>  > > I haven't looked at NUT recently, but I expect the various flags that
>  > > you are supposed to test are another way around this problem.
>  >
>
>  Trying to test out the scripts, I ran into a road block.  I see that
>  upsmon is working and detecting the events I wanted to detect from
>  these sorts of entries in /var/log/messages:
>
>  Jan 10 23:28:57 frodo upsmon[80983]: UPS powercom@localhost on line power
>
>  Plus a similar message for going to battery power.  However, the
>  notify executable is having issues and is dumping dozens of lines like
>  this in /var/log/messages:
>
>  Jan 10 23:28:09 frodo kernel: pid 81029 (upssched), uid 1005: exited
>  on signal 11
>  Jan 10 23:28:09 frodo kernel: pid 81031 (upssched), uid 1005: exited
>  on signal 11
>  Jan 10 23:28:10 frodo kernel: pid 81032 (upssched), uid 1005: exited
>  on signal 11
>  Jan 10 23:28:10 frodo kernel: pid 81033 (upssched), uid 1005: exited
>  on signal 11
>  Jan 10 23:28:11 frodo kernel: pid 81034 (upssched), uid 1005: exited
>  on signal 11
>  Jan 10 23:28:11 frodo kernel: pid 81035 (upssched), uid 1005: exited
>  on signal 11
>
>  I tried giving the user the user in question (nutmon) a shell of
>  /bin/sh instead of /sbin/nologin but that didn't help.  Any clues on
>  how to fix this?  Executing upssched from the command line it tells me
>  not to execute directly (similar to what the man page states), and
>  manually executing the upsched-cmd shell script does work and the
>  script itself uses full paths for commands.
>
>  What is in your notify command?
>
>  I set my NOTIFYCMD in upsmon.conf to a simple shell script I created to
> send the message via sendmail, here is my script if that helps:
>
>  ============================================
>  #!/usr/local/bin/ksh
>  #set -x
>  SENDMAIL=/usr/sbin/sendmail
>  MAIL=/usr/bin/mail
>  HOSTNAME=/bin/hostname
>
>  MYHOSTNAME=`$HOSTNAME -s`
>
>  echo $* | $MAIL -s "UPS Alert from $MYHOSTNAME"
> upsmon@computinginnovations.com
>
>  ================================================
>
>          -Derek
>

I was previously pointing it at the provided upssched process which is
supposed to handle timers and such and fire off upsshed-cmd which is a
provided shell script that I had modified.  This is the 'documented'
way of doing it and gives the extra benefit of being able to add
timers so if the power goes out for 3 seconds, I won't be notified.
Using your script directly did work for lost/gained power events so I
guess I can go that route.  I won't be able to do timers or anything,
but I will at least be notified when the power goes out.  I'll be
checking the safe power down this weekend.  Thanks.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d5eb95fc0801111134q793e7e8eya16cd71061cd390b>