Skip to content

Commit

Permalink
1.16a Bugfixes:
Browse files Browse the repository at this point in the history
  - Bugfix: Do not try to copy the report via slack on arp alert, only email.
  - Bugfix: RRD Graph PNGs not updated.
  • Loading branch information
listerr committed May 10, 2023
1 parent 8fff796 commit 2b26379
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
31 changes: 19 additions & 12 deletions bin/ixp-watch
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -97,16 +97,23 @@ 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"
local pager_msg="[$NETWORK] $text"
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 ############################################################
Expand All @@ -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

Expand Down Expand Up @@ -157,14 +164,15 @@ function do_alert()
fi

fi

rm -f $inc_file

# die on fatal alerts:
if [ $level = "FATAL" ] ; then die "$level: $text" ; fi

}


function log_error {

local level=$1
Expand Down Expand Up @@ -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"

}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2b26379

Please sign in to comment.