/usr/share/cluster-glue/ha_log.sh is in cluster-glue 1.0.8-2ubuntu6.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | #!/bin/sh
#
#
# ha_log.sh for stonith external plugins
# (equivalent to ocf_log in ocf-shellfuncs in resource-agents)
#
# Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée
# All Rights Reserved.
#
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Build version: @GLUE_BUILD_VERSION@
PROG=`basename $0`
: ${HA_DATEFMT=+"%b %d %T"}
: ${HA_LOGD=yes}
: ${HA_LOGTAG=""}
: ${HA_LOGFACILITY=daemon}
: ${HA_LOGFILE=""}
: ${HA_DEBUGLOG=""}
: ${HA_debug="0"}
hadate() {
date "+$HA_DATEFMT"
}
level_pres() {
case "$1" in
crit) echo "CRIT";;
err|error) echo "ERROR";;
warn|warning) echo "WARN";;
notice) echo "notice";;
info) echo "info";;
debug) echo "debug";;
*)
ha_log err "$PROG: unrecognized loglevel: $1"
exit 1
;;
esac
}
ha_log() {
loglevel=$1
shift
prn_level=`level_pres $loglevel`
msg="$prn_level: $@"
# add parent pid to the logtag
if [ "$HA_LOGTAG" ]; then
HA_LOGTAG="$HA_LOGTAG[$PPID]"
fi
# if we're connected to a tty, then output to stderr
if tty >/dev/null; then
if [ "x$HA_debug" = "x0" -a "x$loglevel" = xdebug ] ; then
return 0
fi
if [ "$HA_LOGTAG" ]; then
echo "$HA_LOGTAG: $msg"
else
echo "$msg"
fi >&2
return 0
fi
[ "x$HA_LOGD" = "xyes" ] &&
cat<<EOF | ha_logger -t "$HA_LOGTAG" && return 0
$msg
EOF
if [ -n "$HA_LOGFACILITY" -a "$HA_LOGFACILITY" != none ]; then
logger -t "$HA_LOGTAG" -p $HA_LOGFACILITY.$loglevel "$msg"
fi
dest=${HA_LOGFILE:-$HA_DEBUGLOG}
if [ -n "$dest" ]; then
msg="$prn_level: `hadate` $@"
echo "$HA_LOGTAG: $msg" >> $dest
fi
}
if [ $# -lt 2 ]; then
ha_log err "$PROG: not enough arguments [$#]"
exit 1
fi
loglevel="$1"
shift 1
msg="$*"
ha_log "$loglevel" "$msg"
|