Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fping interval setting #3817

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/admin/settings/index.php
Expand Up @@ -599,6 +599,17 @@
</td>
</tr>

<!-- FPing interval -->
<tr>
<td class="title"><?php print _('FPing interval'); ?></td>
<td>
<input type="text" class="form-control input-sm" name="scanFPingInterval" value="<?php print $settings['scanFPingInterval']; ?>">
</td>
<td class="info2">
<?php print _('FPing interval for IP addresses in miliseconds - (Default: 10)'); ?>
</td>
</tr>

<!-- Ping status intervals -->
<tr>
<td class="title"><?php print _('Ping status intervals'); ?></td>
Expand Down
1 change: 1 addition & 0 deletions app/admin/settings/settings-save.php
Expand Up @@ -104,6 +104,7 @@
"pingStatus" =>@$_POST['pingStatus'],
"scanPingPath" =>@$_POST['scanPingPath'],
"scanFPingPath" =>@$_POST['scanFPingPath'],
"scanFPingInterval" =>@$_POST['scanFPpingInterval'],
"scanMaxThreads" =>@$_POST['scanMaxThreads']
);
// Update linked_field indexes
Expand Down
1 change: 1 addition & 0 deletions db/SCHEMA.sql
Expand Up @@ -202,6 +202,7 @@ CREATE TABLE `settings` (
`api` BINARY NOT NULL DEFAULT '0',
`scanPingPath` VARCHAR(64) NULL DEFAULT '/bin/ping',
`scanFPingPath` VARCHAR(64) NULL DEFAULT '/bin/fping',
`scanFpingInterval` INT(12) NULL DEFAULT '10',
`scanPingType` ENUM('none','ping','pear','fping') NOT NULL DEFAULT 'ping',
`scanMaxThreads` INT(4) NULL DEFAULT '128',
`prettyLinks` ENUM('Yes','No') NOT NULL DEFAULT 'No',
Expand Down
18 changes: 13 additions & 5 deletions functions/classes/class.Scan.php
Expand Up @@ -92,6 +92,13 @@ class Scan extends Common_functions {
*/
private $fping_path;

/**
* fping interval
*
* @var int
*/
private $fping_interval;

/**
* last fping result
*
Expand Down Expand Up @@ -153,9 +160,10 @@ public function __construct (Database_PDO $database, $settings = null) {
# fetch settings
$settings = is_null($this->settings) ? $this->get_settings() : (object) $this->settings;

$this->ping_type = $settings->scanPingType;
$this->ping_path = $settings->scanPingPath;
$this->fping_path = $settings->scanFPingPath;
$this->ping_type = $settings->scanPingType;
$this->ping_path = $settings->scanPingPath;
$this->fping_path = $settings->scanFPingPath;
$this->fping_interval = $settings->scanFPingInterval;

# set type
$this->reset_scan_method ($this->ping_type);
Expand Down Expand Up @@ -430,7 +438,7 @@ public function ping_address_method_fping ($address) {

# set command
$type = ($this->identify_address ($address)=="IPv6") ? '--ipv6' : '--ipv4';
$cmd = $this->fping_path." $type -c $this->icmp_count -t ".($this->icmp_timeout*1000)." $address";
$cmd = $this->fping_path." $type -c $this->icmp_count -i $this->fping_interval -t ".($this->icmp_timeout*1000)." $address";
# execute command, return $retval
exec($cmd, $output, $retval);

Expand Down Expand Up @@ -480,7 +488,7 @@ public function ping_address_method_fping_subnet ($subnet_cidr, $return_result =
$this->ping_verify_path ($this->fping_path);
$out = array();
# set command
$cmd = $this->fping_path . ' -c ' . $this->icmp_count . ' -t ' . ($this->icmp_timeout * 1000) . ' -Agq ' . $subnet_cidr . ' 2>&1';
$cmd = $this->fping_path . ' -c ' . $this->icmp_count . ' -i ' . $this->fping_interval . ' -t ' . ($this->icmp_timeout * 1000) . ' -Agq ' . $subnet_cidr . ' 2>&1';
# execute command, return $retval
exec($cmd, $output, $retval);

Expand Down
5 changes: 5 additions & 0 deletions functions/upgrade_queries/upgrade_queries_1.5.php
Expand Up @@ -190,3 +190,8 @@
$upgrade_queries["1.5.39"][] = "INSERT INTO `widgets` (`wtitle`, `wdescription`, `wfile`, `wparams`, `whref`, `wsize`, `wadminonly`, `wactive`) VALUES ('MAC lookup', 'Shows MAC address vendor', 'mac-lookup', NULL, 'yes', '6', 'no', 'yes');";
$upgrade_queries["1.5.39"][] = "-- Database version bump";
$upgrade_queries["1.5.39"][] = "UPDATE `settings` set `dbversion` = '39';";

$upgrade_queries["1.5.40"] = [];
$upgrade_queries["1.5.40"][] = "ALTER TABLE `settings` ADD `scanFPingInterval` INT(12) NULL DEFAULT '10';";
$upgrade_queries["1.5.40"][] = "-- Database version bump";
$upgrade_queries["1.5.40"][] = "UPDATE `settings` set `dbversion` = '40';";