Skip to content
This repository has been archived by the owner on Apr 19, 2021. It is now read-only.

Commit

Permalink
improve check for sensortab with no active sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
dougburks committed Dec 28, 2017
1 parent 3c90f6c commit 2241941
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/sostat
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ do
done

# Determine sensor interfaces for packet loss stats
INTERFACES=`grep -v "#" /etc/nsm/sensortab | awk '{print $4}'`
INTERFACES=""
NUM_INTERFACES=0
SENSORTAB="/etc/nsm/sensortab"
if [ -s $SENSORTAB ]; then
INTERFACES=$(grep -v "#" $SENSORTAB | awk '{print $4}')
NUM_INTERFACES=$(grep -v "#" $SENSORTAB | wc -l)
fi

# Text formatting
if [ -t 1 ];then
Expand Down Expand Up @@ -143,7 +149,7 @@ top -b -n1 |head -6
# Use "ps" to get a process listing and sort it by cpu usage
ps -eo pcpu,pmem,args --sort -pcpu

if [ -d /nsm/sensor_data ] && [ -s /etc/nsm/sensortab ]; then
if [ -d /nsm/sensor_data ] && [ $NUM_INTERFACES -gt 0 ]; then
echo
FREQUENCY=`grep -A1 packets_received /var/ossec/etc/ossec.conf | tail -1 | cut -d\> -f2 | cut -d\< -f1`
header "Packets received during last monitoring interval ($FREQUENCY seconds)"
Expand Down

0 comments on commit 2241941

Please sign in to comment.