aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-10-30 00:42:49 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-10-30 00:42:49 +0000
commita4967ca28ec000ad551f2382f81738de428926c9 (patch)
treeea72aee48fd872e4c0acce5159f11be411d2a402
parentf63cc7e8e007251ffe7842121f4e464234e4ff14 (diff)
downloadpfsense-packages-a4967ca28ec000ad551f2382f81738de428926c9.tar.gz
pfsense-packages-a4967ca28ec000ad551f2382f81738de428926c9.tar.bz2
pfsense-packages-a4967ca28ec000ad551f2382f81738de428926c9.zip
Cleanup sampling code. Don't forget to escape \$ awk variable.
-rw-r--r--packages/snort/snort.inc8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/snort/snort.inc b/packages/snort/snort.inc
index 8b42db29..372ddbe2 100644
--- a/packages/snort/snort.inc
+++ b/packages/snort/snort.inc
@@ -113,10 +113,16 @@ function sync_package_snort() {
if($_POST['blockoffenders'])
$start .= ";/usr/bin/killall snort2c; snort2c -w /var/db/whitelist -a /var/log/snort/alert";
+ $sample_before = "\nBEFORE_MEM=`top | grep Free | grep Wired | awk '{print \$10}'`\n";
+ $sample_after = "\nAFTER_MEM=`top | grep Free | grep Wired | awk '{print \$10}'`\n";
+ $sleep_before_final = "\necho \"Sleeping before final memory sampling...\"\nsleep 17";
+ $total_free_after = "\nTOTAL_USAGE=`top | grep snort | awk '{ print \$6 }'`\n";
+ $echo_usage = "\necho \"Ram free BEFORE starting Snort: \${BEFORE_MEM} -- Ram free AFTER starting Snort: \${AFTER_MEM}\" -- Mode {$snort_performance} -- Snort memory usage: \$TOTAL_USAGE | logger -p daemon.info -i -t SnortStartup\n";
+
/* write out rc.d start/stop file */
write_rcfile(array(
"file" => "snort.sh",
- "start" => "BEFORE_MEM=`top | grep Free | grep Wired | awk '{print \$10}'`\n{$start}\necho \"Sleeping before final memory sampling...\"\nsleep 17\nTOTAL_USAGE=`top | grep snort | awk '{ print \$6 }'`\nAFTER_MEM=`top | grep Free | grep Wired | awk '{print $10}'`\necho \"Ram free BEFORE starting Snort: \${BEFORE_MEM} -- Ram free AFTER starting Snort: \${AFTER_MEM}\" -- Mode {$snort_performance} -- Snort memory usage: \$TOTAL_USAGE | logger -p daemon.info -i -t SnortStartup",
+ "start" => "{$sample_before}{$start}{$sleep_before_final}{$sample_after}{$echo_usage}",
"stop" => "/usr/bin/killall snort; killall snort2c"
)
);