Friday, August 22, 2008

PF State info via shell script

I use the following script to generate state info on my pf firewalls. The output is placed in a file and transferred to a directory beneath the DocumentRoot of a secured internal web server.


#!/bin/sh
echo \ > /tmp/pfstate.txt
date 1>> /tmp/pfstate.txt
echo --------------------------------------------------------- >> /tmp/pfstate.txt
pfctl -s state | grep ESTABLISHED | sort 1>> /tmp/pfstate.txt
echo --------------------------------------------------------- >> /tmp/pfstate.txt
pfctl -s info 1>> /tmp/pfstate.txt
echo \
>> /tmp/pfstate.txt
scp /tmp/pfstate.txt opsbsd@x.x.x.x:/portal.sv/monitoring/opsbsd001/pfstate.html

No comments: