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

Commit

Permalink
securityonion-sostat: awk division error when Bro doesn't report stat…
Browse files Browse the repository at this point in the history
  • Loading branch information
dougburks committed Mar 20, 2019
1 parent 6385be3 commit eb7e007
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/sostat
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ if [ -d /nsm/sensor_data ] && [ $NUM_INTERFACES -gt 0 ]; then
cat $TMP | \
sed 's/[a-z]*=//g' | \
awk '{ drop += $4 ; link += $5 } \
END { if ( drop >=1 && link >=1 ) printf("%f\n", ((drop/NR) / (link/NR)) * 100); else print("No packets seen. Please check SPAN port and/or cabling."); }'
END { if ( link >=1 ) printf("%f\n", ((drop/NR) / (link/NR)) * 100); else print("No packets seen."); }'
echo
cat $TMP
echo
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
securityonion-sostat (20120722-0ubuntu0securityonion123) xenial; urgency=medium

* securityonion-sostat: awk division error when Bro doesn't report stats correctly Security-Onion-Solutions/security-onion#817

-- Doug Burks <[email protected]> Wed, 20 Mar 2019 09:03:12 -0400

securityonion-sostat (20120722-0ubuntu0securityonion122) xenial; urgency=medium

* securityonion-sostat: implement better error handling for zero packet count Security-Onion-Solutions/security-onion#1464
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Description: <short summary of the patch>
TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.
.
securityonion-sostat (20120722-0ubuntu0securityonion123) xenial; urgency=medium
.
* securityonion-sostat: awk division error when Bro doesn't report stats correctly Security-Onion-Solutions/security-onion#817
Author: Doug Burks <[email protected]>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- securityonion-sostat-20120722.orig/bin/sostat
+++ securityonion-sostat-20120722/bin/sostat
@@ -232,9 +232,10 @@ if [ -d /nsm/sensor_data ] && [ $NUM_INT
echo "${underline}Bro${normal}:"
echo
echo -n "Average packet loss as percent across all Bro workers: "
- cat $TMP | sed \
- 's/[a-z]*=//g' | awk '{ drop += $4 ; link += $5 } \
- END { printf("%f\n", ((drop/NR) / (link/NR)) * 100) }'
+ cat $TMP | \
+ sed 's/[a-z]*=//g' | \
+ awk '{ drop += $4 ; link += $5 } \
+ END { if ( link >=1 ) printf("%f\n", ((drop/NR) / (link/NR)) * 100); else print("No packets seen."); }'
echo
cat $TMP
echo
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ soup:-check-for-lock-Security-Onion-Solutionssecurity-onion#1428
soup:-node-checking-master-for-updates-fails-if-master-has-1-update-Security-Onion-Solutionssecurity-onion#1434
securityonion-sostat:-change-wiki-links-to-docs-Security-Onion-Solutionssecurity-onion#1454
securityonion-sostat:-implement-better-error-handling-for-zero-packet-count-Security-Onion-Solutionssecurity-onion#1464
securityonion-sostat:-awk-division-error-when-Bro-doesn't-report-stats-correctly-Security-Onion-Solutionssecurity-onion#817

0 comments on commit eb7e007

Please sign in to comment.