This commit is contained in:
Riccardo Bicelli 2021-07-05 19:31:48 +02:00
parent e3bddbd56b
commit e639c05c5e
3 changed files with 13 additions and 5 deletions

View File

@ -30,6 +30,11 @@ Tested with pfSense 2.4.x, Zabbix 4.0, Zabbix 5.0
- Discovery of IPsec Site-to-Site tunnels
- Monitoring tunnel status (Phase 1 and Phase 2)
**Template pfSense Active: Speedtest**
- Discovery of WAN Interfaces
- Perform speed tests and collect metrics
## Configuration
@ -65,7 +70,7 @@ UserParameter=pfsense.discovery[*],/usr/local/bin/php /root/scripts/pfsense_zbx.
UserParameter=pfsense.value[*],/usr/local/bin/php /root/scripts/pfsense_zbx.php $1 $2 $3
```
_Please note that **AllowRoot=1** option is required in order to execute correctly OpenVPN checks and others._
_Please note that **AllowRoot=1** option is required in order to correctly execute OpenVPN checks and others._
Also increase the **Timeout** value at least to **5**, otherwise some checks will fail.

View File

@ -7,6 +7,10 @@ Written by Riccardo Bicelli <r.bicelli@gmail.com>
This program is licensed under Apache 2.0 License
*/
//Some Useful defines
define('SPEEDTEST_INTERVAL',8); //Speedtest Interval (in hours)
require_once('globals.inc');
require_once('functions.inc');
require_once('config.inc');
@ -169,7 +173,7 @@ function pfz_interface_speedtest_value($ifname, $value){
function pfz_speedtest_exec ($ifname, $ipaddr, $is_cron=false){
$filename = "/tmp/speedtest-$ifname";
$filerun = "/tmp/speedtest-run";
$filecron = "/tmp/speedtest.cron"
$filecron = "/tmp/speedtest.cron";
if (file_exists($filename)) {
$json_output = json_decode(file_get_contents($filename), true);
@ -180,8 +184,8 @@ function pfz_speedtest_exec ($ifname, $ipaddr, $is_cron=false){
if ($is_cron) touch($filecron);
if ( $is_cron==false || file_exists($filecron)) {
if ( (time()-filemtime($filename) > 8 * 3600) || (file_exists($filename)==false) ) {
// file older than 8 Hours
if ( (time()-filemtime($filename) > SPEEDTEST_INTERVAL * 3600) || (file_exists($filename)==false) ) {
// file is older than SPEEDTEST_INTERVAL
if ( (time()-filemtime($filerun) > 180 ) ) @unlink($filerun);
if (file_exists($filename)==false) {
@ -189,7 +193,6 @@ function pfz_speedtest_exec ($ifname, $ipaddr, $is_cron=false){
$st_command = "nohup /usr/local/bin/speedtest --source $ipaddr --json > $filename && rm $filerun &";
exec ($st_command);
}
}
}