2017-01-20 11:17:20 +01:00
|
|
|
---
|
|
|
|
categories: openbsd network firewall
|
|
|
|
title: Howto PFStat
|
|
|
|
---
|
2016-12-29 11:25:39 +01:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
~~~
|
|
|
|
# pkg_add pfstat
|
2017-06-12 13:55:32 +02:00
|
|
|
|
|
|
|
# rcctl enable pfstatd
|
|
|
|
# rcctl start pfstatd
|
|
|
|
pfstatd(ok)
|
2016-12-29 11:25:39 +01:00
|
|
|
~~~
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
2017-01-20 11:17:20 +01:00
|
|
|
Exemple de `pfstat.conf` pour afficher la bande passante utilisée:
|
2016-12-29 11:25:39 +01:00
|
|
|
|
|
|
|
~~~
|
|
|
|
collect 1 = interface "bnx0" pass bytes in ipv4 diff
|
|
|
|
collect 2 = interface "bnx0" pass bytes out ipv4 diff
|
|
|
|
|
|
|
|
image "/var/www/htdocs/pfstats/bnx0.jpg" {
|
|
|
|
from 1 days to now
|
|
|
|
width 980 height 300
|
|
|
|
left
|
|
|
|
graph 1 bps "in" "bits/s" color 0 192 0 filled,
|
|
|
|
graph 2 bps "out" "bits/s" color 0 0 255
|
|
|
|
}
|
|
|
|
|
|
|
|
image "/var/www/htdocs/pfstats/bnx0-week.jpg" {
|
|
|
|
from 1 weeks to now
|
|
|
|
width 980 height 300
|
|
|
|
left
|
|
|
|
graph 1 bps "in" "bits/s" color 0 192 0 filled,
|
|
|
|
graph 2 bps "out" "bits/s" color 0 0 255
|
|
|
|
}
|
|
|
|
|
|
|
|
image "/var/www/htdocs/pfstats/bnx0-month.jpg" {
|
|
|
|
from 1 months to now
|
|
|
|
width 980 height 300
|
|
|
|
left
|
|
|
|
graph 1 bps "in" "bits/s" color 0 192 0 filled,
|
|
|
|
graph 2 bps "out" "bits/s" color 0 0 255
|
|
|
|
}
|
|
|
|
~~~
|
|
|
|
|
|
|
|
On lance ensuite les crons suivants :
|
|
|
|
|
|
|
|
~~~
|
|
|
|
# crontab -l
|
|
|
|
|
|
|
|
* * * * * /usr/local/bin/pfstat -q # Met a jour la base RRD
|
|
|
|
*/5 * * * * /usr/local/bin/pfstat -p # Trace les graphs
|
|
|
|
~~~
|
|
|
|
|
|
|
|
|
|
|
|
Une petite page HTML pour rendre la consultation plus facile :
|
|
|
|
|
2017-01-20 11:17:20 +01:00
|
|
|
~~~{.html}
|
2016-12-29 11:25:39 +01:00
|
|
|
<html>
|
|
|
|
<h1>PFStats</h1>
|
|
|
|
<h2>bnx0</h2>
|
|
|
|
<h3>Today :</h3>
|
|
|
|
<img src="bnx0.jpg"/>
|
|
|
|
<h3>Last week :</h3>
|
|
|
|
<img src="bnx0-week.jpg"/>
|
|
|
|
<h3>Last month :</h3>
|
|
|
|
<img src="bnx0-month.jpg"/>
|
|
|
|
</html>
|
|
|
|
~~~
|
2017-11-20 16:20:58 +01:00
|
|
|
|
|
|
|
## Lien utile
|
|
|
|
|
|
|
|
<https://chown.me/blog/faire-des-graphes-a-partir-des-infos-de-pf.html>
|