Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
apcupsd - not emailing me when power down
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2571
Location: Edmonton, AB

PostPosted: Sun Jun 07, 2015 3:40 pm    Post subject: apcupsd - not emailing me when power down Reply with quote

My remote box is connected direclty to apcups and it is running "apcupsd"
However, when I pull the cord out of the wall the "onbattery" script is not
email me anything.

My configuration: apcupsd.conf
Code:
UPSCABLE usb
UPSTYPE usb
DEVICE
POLLTIME 60
LOCKFILE /var/lock
SCRIPTDIR /etc/apcupsd
PWRFAILDIR /etc/apcupsd
NOLOGINDIR /etc
ONBATTERYDELAY 6
BATTERYLEVEL 60
MINUTES 10
TIMEOUT 0
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 0
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0

onbattery - script suppose to be called by "/etc/apcupsd/apccontrol" and execute it.
What am I missing?

I have "mailto" installed and it is working. I sent an email to "root" and I received it.
There is nothing to be configured in "onbattery" script.
_________________
#Thelma
Back to top
View user's profile Send private message
mvaterlaus
Apprentice
Apprentice


Joined: 01 Oct 2010
Posts: 202
Location: Switzerland

PostPosted: Mon Jun 08, 2015 8:22 am    Post subject: Reply with quote

hi,
you have to edit the on battery event script and send yourself a mail when the script is executet. Normally, apcupsd sends a message via wall, so all logged in users are notified that the ups is running on battery. If you do not implement the mailing part, you wont get any mails.

You could also send a mail for every event by replacing the ${WALL} command in the apccontrol script, but if you overwrite the wall command, your logged in users are not notified when the ups status changes and they probably will get an unexpected logout.
_________________
For calming down your eyes or clearing your mind: www.patrickwehli.ch
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2571
Location: Edmonton, AB

PostPosted: Mon Jun 08, 2015 8:01 pm    Post subject: Reply with quote

mvaterlaus wrote:
hi,
you have to edit the on battery event script and send yourself a mail when the script is executet. Normally, apcupsd sends a message via wall, so all logged in users are notified that the ups is running on battery. If you do not implement the mailing part, you wont get any mails.

You could also send a mail for every event by replacing the ${WALL} command in the apccontrol script, but if you overwrite the wall command, your logged in users are not notified when the ups status changes and they probably will get an unexpected logout.


onbattery - script suppose to be called by "/etc/apcupsd/apccontrol" and execute it. What am I missing?

I have "mailto" installed and it is working. I sent an email to "root" and I received it.
There is nothing to be configured in "onbattery" script:
Code:
#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when the UPS
# goes on batteries.
# We send an email message to root to notify him.
#
SYSADMIN=root
APCUPSD_MAIL="/bin/mail"

HOSTNAME=`hostname`
MSG="$HOSTNAME Power Failure !!!"
#
(
  echo "Subject: $MSG"
  echo " "
  echo "$MSG"
  echo " "
  /sbin/apcaccess status
) | $APCUPSD_MAIL -s "$MSG" $SYSADMIN
exit 0

The script is called by apccontrol and SYSADMIN=root


Yes, I have "/bin/mail" on the path.
So I don't know why isn't it working.
_________________
#Thelma
Back to top
View user's profile Send private message
mvaterlaus
Apprentice
Apprentice


Joined: 01 Oct 2010
Posts: 202
Location: Switzerland

PostPosted: Mon Jun 08, 2015 8:33 pm    Post subject: Reply with quote

ok. i didn't know the mail part is already scripted in gentoo. please have a look at the var ONBATTERYDELAY in your apcupsd.conf. It will tell you, how long it takes unitl the event ONBATTERY is raised.

also, have a look at /var/log/apcupsd.event and pull out the cable to see if the event appears in the log.
_________________
For calming down your eyes or clearing your mind: www.patrickwehli.ch
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2571
Location: Edmonton, AB

PostPosted: Mon Jun 08, 2015 11:30 pm    Post subject: Reply with quote

mvaterlaus wrote:
ok. i didn't know the mail part is already scripted in gentoo. please have a look at the var ONBATTERYDELAY in your apcupsd.conf. It will tell you, how long it takes unitl the event ONBATTERY is raised.

also, have a look at /var/log/apcupsd.event and pull out the cable to see if the event appears in the log.


I just checked the log "apcupsd.events" is not registering anything from apcupsd.
I unplug/plug the power from the wall and there was no entry in the /var/log/apcupsd.events
Code:
tail /var/log/apcupsd.events
2015-06-06 17:29:57 -0600  Valid lock file for pid=2386, but not ours pid=32492
2015-06-06 17:29:57 -0600  apcupsd FATAL ERROR in device.c at line 71
Unable to create UPS lock file.
  If apcupsd or apctest is already running,
  please stop it and run this program again.
2015-06-06 17:29:57 -0600  Valid lock file for pid=2386, but not ours pid=32492
2015-06-06 17:29:57 -0600  apcupsd error shutdown completed
2015-06-06 17:35:07 -0600  apcupsd exiting, signal 15
2015-06-06 17:35:07 -0600  apcupsd shutdown succeeded
2015-06-06 17:35:46 -0600  apcupsd 3.14.8 (16 January 2010) gentoo startup succeeded


My configuration: apcupsd.conf
Code:
sed -e 's/#.*//' -e '/^$/ d' apcupsd.conf
UPSCABLE usb
UPSTYPE
DEVICE
LOCKFILE /var/lock
SCRIPTDIR /etc/apcupsd
PWRFAILDIR /etc/apcupsd
NOLOGINDIR /etc
ONBATTERYDELAY 6
BATTERYLEVEL 60
MINUTES 10
TIMEOUT 0
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 0
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0


apccontrol - I did not touch it.
The apcupsd is started.
_________________
#Thelma
Back to top
View user's profile Send private message
mvaterlaus
Apprentice
Apprentice


Joined: 01 Oct 2010
Posts: 202
Location: Switzerland

PostPosted: Tue Jun 09, 2015 9:37 am    Post subject: Reply with quote

Does it work to read the status of your ups manually with the apctest tool [1]? For this to work, you have to shutdown the apcupsd daemon.


[1]http://www.apcupsd.org/manual/manual.html#apctest
_________________
For calming down your eyes or clearing your mind: www.patrickwehli.ch
Back to top
View user's profile Send private message
Joseph_sys
Advocate
Advocate


Joined: 08 Jun 2004
Posts: 2571
Location: Edmonton, AB

PostPosted: Tue Jun 09, 2015 10:27 pm    Post subject: Reply with quote

mvaterlaus wrote:
Does it work to read the status of your ups manually with the apctest tool [1]? For this to work, you have to shutdown the apcupsd daemon.


[1]http://www.apcupsd.org/manual/manual.html#apctest


apctest - is working
Code:
apctest


2015-06-09 16:21:45 apctest 3.14.8 (16 January 2010) gentoo
Checking configuration ...
Attached to driver: usb
sharenet.type = DISABLE
cable.type = USB_CABLE

You are using a USB cable type, so I'm entering USB test mode
mode.type = USB_UPS
Setting up the port ...
Hello, this is the apcupsd Cable Test program.
This part of apctest is for testing USB UPSes.

Getting UPS capabilities...SUCCESS

Please select the function you want to perform.

1)  Test kill UPS power
2)  Perform self-test
3)  Read last self-test result
4)  View/Change battery date
5)  View manufacturing date
6)  View/Change alarm behavior
7)  View/Change sensitivity
8)  View/Change low transfer voltage
9)  View/Change high transfer voltage
10) Perform battery calibration
11) Test alarm
12) View/Change self-test interval
 Q) Quit


Though the problem I think it might be my small box. "Intel(R) Atom(TM) CPU 330 @ 1.60GHz"
Though, I don't know how this could be causing a problem.

On a remote location I have two computers connected to this APCUPS, one is this Atom and another one full-tower box that is running apcupsd in a slave mode; and it is working correctly. When power goes down I get and email from my tower-box; but not from small one Atom.
_________________
#Thelma
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum