Change delimiter for ZED email scripts

When the ZED_EMAIL_INTERVAL_SECS="3600" option is set in zed.rc
configuration file then notification emails should be rate limited.

Rate limiting is accomplished by maintaining a colon delimited state
file which includes the device name.  Unfortunately there are valid
device names which include a colon and therefore prevent the rate
limiting for working properly.  For this reason the delimiter has
been changed to a semi-colon.

Signed-off-by: louwrentius <louwrentius@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Dunlap <cdunlap@llnl.gov>
Closes #2645
This commit is contained in:
louwrentius 2014-08-30 00:14:20 +02:00 committed by Brian Behlendorf
parent 76c3a61642
commit bcd9624d0f
2 changed files with 9 additions and 9 deletions

View File

@ -12,7 +12,7 @@
# 4: unsupported event class
# 5: internal error
# State File Format:
# POOL:TIME_OF_LAST_EMAIL
# POOL;TIME_OF_LAST_EMAIL
#
test -f "${ZED_SCRIPT_DIR}/zed.rc" && . "${ZED_SCRIPT_DIR}/zed.rc"
@ -47,7 +47,7 @@ flock -x 8
# Query state for last time email was sent for this pool.
TIME_NOW=`date +%s`
TIME_LAST=`egrep "^${ZEVENT_POOL}:" "${STATEFILE}" 2>/dev/null | cut -d: -f2`
TIME_LAST=`egrep "^${ZEVENT_POOL};" "${STATEFILE}" 2>/dev/null | cut -d ";" -f2`
if test -n "${TIME_LAST}"; then
TIME_DELTA=`expr "${TIME_NOW}" - "${TIME_LAST}"`
if test "${TIME_DELTA}" -lt "${ZED_EMAIL_INTERVAL_SECS:=3600}"; then
@ -67,8 +67,8 @@ EOF
MAIL_STATUS=$?
# Update state.
egrep -v "^${ZEVENT_POOL}:" "${STATEFILE}" 2>/dev/null > "${STATEFILE}.$$"
echo "${ZEVENT_POOL}:${TIME_NOW}" >> "${STATEFILE}.$$"
egrep -v "^${ZEVENT_POOL};" "${STATEFILE}" 2>/dev/null > "${STATEFILE}.$$"
echo "${ZEVENT_POOL};${TIME_NOW}" >> "${STATEFILE}.$$"
mv -f "${STATEFILE}.$$" "${STATEFILE}"
if test "${MAIL_STATUS}" -ne 0; then

View File

@ -12,7 +12,7 @@
# 4: unsupported event class
# 5: internal error
# State File Format:
# POOL:VDEV_PATH:TIME_OF_LAST_EMAIL
# POOL;VDEV_PATH;TIME_OF_LAST_EMAIL
#
test -f "${ZED_SCRIPT_DIR}/zed.rc" && . "${ZED_SCRIPT_DIR}/zed.rc"
@ -49,8 +49,8 @@ flock -x 8
# Query state for last time email was sent for this pool/vdev.
TIME_NOW=`date +%s`
TIME_LAST=`egrep "^${ZEVENT_POOL}:${ZEVENT_VDEV_PATH}:" "${STATEFILE}" \
2>/dev/null | cut -d: -f3`
TIME_LAST=`egrep "^${ZEVENT_POOL};${ZEVENT_VDEV_PATH};" "${STATEFILE}" \
2>/dev/null | cut -d ";" -f3`
if test -n "${TIME_LAST}"; then
TIME_DELTA=`expr "${TIME_NOW}" - "${TIME_LAST}"`
if test "${TIME_DELTA}" -lt "${ZED_EMAIL_INTERVAL_SECS:=3600}"; then
@ -71,9 +71,9 @@ EOF
MAIL_STATUS=$?
# Update state.
egrep -v "^${ZEVENT_POOL}:${ZEVENT_VDEV_PATH}:" "${STATEFILE}" \
egrep -v "^${ZEVENT_POOL};${ZEVENT_VDEV_PATH};" "${STATEFILE}" \
2>/dev/null > "${STATEFILE}.$$"
echo "${ZEVENT_POOL}:${ZEVENT_VDEV_PATH}:${TIME_NOW}" >> "${STATEFILE}.$$"
echo "${ZEVENT_POOL};${ZEVENT_VDEV_PATH};${TIME_NOW}" >> "${STATEFILE}.$$"
mv -f "${STATEFILE}.$$" "${STATEFILE}"
if test "${MAIL_STATUS}" -ne 0; then