Bug 122170 - [patch] [request] New feature: notify admin via page on startup and shutdown
Summary: [patch] [request] New feature: notify admin via page on startup and shutdown
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-27 23:30 UTC by Leif Pedersen
Modified: 2017-12-31 22:37 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leif Pedersen 2008-03-27 23:30:00 UTC
	I think it would be appropriate for FreeBSD to include a way
of notifying an administrator when a server starts up or shuts down.
Attached is an rc.d script I currently add to all my machines.

Fix: 

Add /etc/rc.d/sendpage.sh containing the file below.  The file is also
available temporarily from http://bilbo.hobbiton.org/sendpage.sh

#!/bin/sh
#
# Copyright (c) 2008  Leif Pedersen
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#

# PROVIDE: sendpage
# REQUIRE: LOGIN
# BEFORE:
# KEYWORD: shutdown

# Sends a page to admins when the machine boots or shuts down.  Example:
# sendpage_enable="YES"
# sendpage_command="qpage -f '' -p root"

sendpage_enable=${sendpage_enable-"NO"}
sendpage_command=${sendpage_command-'read subj; echo $subj | mail -s "$subj" root'}

. /etc/rc.subr

name="sendpage"
rcvar=`set_rcvar`
load_rc_config $name
start_cmd="sendpage_start"
stop_cmd="sendpage_stop"

timestamp=`date "+%Y-%m-%d %H:%M"`

sendpage_start()
{
	echo "Sending startup page."
	echo "`hostname -s` coming up at $timestamp" | eval "$sendpage_command"
}

sendpage_stop()
{
	echo "Sending shutdown page."
	echo "`hostname -s` going down at $timestamp" | eval "$sendpage_command"
}

run_rc_command "$1"
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2008-03-28 04:11:49 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-rc

Fix up the synopsis a little bit, and assign to maintainers.
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:19 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped