From 2b263794aef3dc4c65204d0633a267474535d1e6 Mon Sep 17 00:00:00 2001 From: robl Date: Wed, 10 May 2023 10:43:28 +0100 Subject: [PATCH] 1.16a Bugfixes: - Bugfix: Do not try to copy the report via slack on arp alert, only email. - Bugfix: RRD Graph PNGs not updated. --- Changelog | 4 ++++ bin/ixp-watch | 31 +++++++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Changelog b/Changelog index 0ccf5d2..04d5f77 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +* 1.16a 2023-05-09 - robl + - Bugfix: Do not try to copy the report via slack on arp alert, only email. + - Bugfix: RRD Graph PNGs not updated. + * 1.16 2022-12-14 - robl - Move things to functions to avoid repeated code in many places. - Error handling / alerting is now more consistent diff --git a/bin/ixp-watch b/bin/ixp-watch index 75a0dbf..e2d9db0 100755 --- a/bin/ixp-watch +++ b/bin/ixp-watch @@ -1,5 +1,5 @@ #!/bin/bash -# ixp-watch version: 1.16 +# ixp-watch version: 1.16a # This file is part of IXP Watch # # IXP Watch is free software: you can redistribute it and/or modify it @@ -97,6 +97,7 @@ function do_alert() local level=$1 local text=$2 local inc_file=$3 + local email_file=$4 # Log from text or file: local syslog_msg="[$NETWORK] $text" @@ -104,9 +105,15 @@ function do_alert() local email_msg="[$NETWORK] $text" if [ -n "$inc_file" ] && [ -f "$inc_file" ] ; then - local syslog_msg="-f $inc_file" - local pager_msg=$(head -1 $inc_file) - local email_msg=$(cat $inc_file) + syslog_msg="-f $inc_file" + pager_msg=" $(head -1 $inc_file)" + email_msg="$(cat $inc_file)" + fi + + if [ -n "$email_file" ] && [ -f "$email_file" ] ; then + # add copy of report/something else to the email output only: + email_msg="$email_msg\n$(cat $email_file)" + fi ### PAGER ALERTS ############################################################ @@ -119,7 +126,7 @@ function do_alert() ### EMAIL ALERTS ############################################################ if [ -n "$ALARM_EMAIL" ] ; then - echo "$email_msg" | $MAILPROG -s "[$NETWORK] $level: $text" $ALARM_EMAIL + echo -e "$email_msg" | $MAILPROG -s "[$NETWORK] $level: $text" $ALARM_EMAIL if [ $? != 0 ] ; then echo "WARN: $MAILPROG failed for ALARM_EMAIL $ALARM_EMAIL" >&2 ; fi fi @@ -157,7 +164,7 @@ function do_alert() fi fi - + rm -f $inc_file # die on fatal alerts: @@ -165,6 +172,7 @@ function do_alert() } + function log_error { local level=$1 @@ -716,10 +724,10 @@ function do_graph() local val=$2 local title=$3 - if [ ! -f "$RRD_DIR/$rrd.rrd" ] ; then $RRDTOOL create $RRD_DIR/$rrd.rrd --step=$SAMPLE_TIME DS:${rrd}:GAUGE:1800:U:U RRA:AVERAGE:0.5:1:96 ; fi + if [ ! -f "$RRD_DIR/${rrd}.rrd" ] ; then $RRDTOOL create $RRD_DIR/${rrd}.rrd --step=$SAMPLE_TIME DS:${rrd}:GAUGE:1800:U:U RRA:AVERAGE:0.5:1:96 ; fi - $RRDTOOL update $RRD_DIR/$rrd.rrd $E_DATE:${val} - $RRDTOOL graph $GRAPH_DIR/$rrd.png --vertical-label "$title" DEF:${rrd}=${RRD_DIR}/{$rrd}.rrd:${rrd}:AVERAGE AREA:$rrd#99CCFF > /dev/null + $RRDTOOL update $RRD_DIR/${rrd}.rrd $E_DATE:${val} + $RRDTOOL graph $GRAPH_DIR/${rrd}.png --vertical-label "$title" DEF:${rrd}=${RRD_DIR}/${rrd}.rrd:${rrd}:AVERAGE AREA:"${rrd}#99CCFF" } @@ -760,9 +768,8 @@ if [ $NUM_ARPS_MIN -ge $ARP_WARNLEVEL ] ; then echo "ARPS Per min is $NUM_ARPS_MIN" > $LOG_ROOT/alarms_arp.tmp if [ ! -f $LOG_ROOT/arpstorm.warn ] ; then - cat $LOGDIR/$FILEDATE.TXT >> $LOG_ROOT/alarms_arp.tmp - - do_alert CRITICAL "High number of ARPS in progress - Please investigate" $LOG_ROOT/alarms_arp.tmp + + do_alert CRITICAL "High number of ARPS in progress - Please investigate" $LOG_ROOT/alarms_arp.tmp $LOGDIR/$FILEDATE.TXT touch $LOG_ROOT/arpstorm.warn fi