Latency Check is a little PHP script for Linux that measures latency for one or several IP addresses.
This script can use several methods to measure the latency (fsock, icmp and ping). The results an be displayed on screen or written on a output file. The number of measures and the delay between two measures can also be configured.
You use this script at your own risks, you are solely responsible for sending packets on the network.
First download the last version (1.6) of the script here, uncompress it (for example with unzip latencycheck_v1.6.zip
).
If PHP CLI (Command Line Interpreter) is not installed, install it (for example apt-get install php-cli
on Debian based systems).
Execute the scrit, for example : php latencycheck.php -d 5 -a 192.168.1.1
You should have this kind of result :
>> Latency Check v1.5 - Hisbergue Franck
>> For bug reports, feature requests, comments or FAQ :
https://xulops.net/forge/latencycheck.php
Use --help to get all the options
>> DISCLAIMER : this script is provided 'as is', without warranty of any
kind. You use the software at your own risk, and you are solely
responsible for the consequences of modifications you may apply to
your system.
>> Licensed under the Apache License, Version 2.0. You may not use this file
except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an 'AS IS' BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
Press ctrl+c to end this madness.
2021-09-07 00:51:08 IP: 192.168.1.1 Latency: 2ms
2021-09-07 00:51:13 IP: 192.168.1.1 Latency: 4ms
2021-09-07 00:51:18 IP: 192.168.1.1 Latency: 9ms
2021-09-07 00:51:23 IP: 192.168.1.1 Latency: 2ms
2021-09-07 00:51:28 IP: 192.168.1.1 Latency: 1ms
Other options are listed using the --help option : php latencycheck.php --help
>> Latency Check v1.5 - Hisbergue Franck
>> For bug reports, feature requests, comments or FAQ :
https://xulops.net/forge/latencycheck.php
>> DISCLAIMER : this script is provided 'as is', without warranty of any
kind. You use the software at your own risk, and you are solely
responsible for the consequences of modifications you may apply to
your system.
>> Licensed under the Apache License, Version 2.0. You may not use this file
except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an 'AS IS' BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
>> usage : php latencycheck.php [option]
Options :
-a ip --address=ip IP for latency measure (use -f for several IPs)
-d 30 --delay=30 Number of seconds (default 30) between two
measures. Minimum 1, no decimal.
-f file --file=file File with IP addresses for latency measures.
Each lines of the file must contain the IP
address to measure, and optionally the method,the
port for 'fsock' method (default 7) like that :
IP1 fsock 80
IP2
IP3 icmp
IP4 ping
IP5 fsock 443
-h --help Display this help and exit.
-i --no-internet Don't check for new version of the script.
-m fsock --method=fsock Method used for measuring latency default is
'fsock', can also be 'icmp' (need to be root)
or 'ping' (using ping command)
-n 0 --number=0 Number of measures for each IP before exit. The
deault value is 0, which means infinite mesures.
-o file --out=file Don't print latency on screen, write results on
the specified file. The file name can have one
or all the variables below :
%DATE : date of the measure, %YEAR%MONTH%DAY
%TIME : time of the measure, %HOUR%MIN%SEC
%YEAR : year of the measure
%MONTH : month of the measure
%DAY : day of the measure
%HOUR : hour of the measure
%MIN : minute of the measure
%SEC : second of the measure
%IP : IP of the measure
%METHOD : method of the measure
-p port --port=port Change port (default 7) for fsock latency
measure.
-s --skip-header Don't display header message (implies -i)
-t 30 --timeout=30 Timeout in seconds (default 30)
>> usage examples :
php latencycheck.php -s -d 5 -p 80 -t 10 -a 192.168.1.1
Display the latency for IP 192.168.1.1 every 5 seconds using fsock on
port 80 with timeout of 10 seconds, don't display header message.
php latencycheck.php -d 60 -m icmp -f list_address
Display the measured latency for each of the IPs of the file
'list_address' every minutes, using icmp method.
php latencycheck.php -d 3 -n 10 -f list -o latency_results
Append to the file 'latency_results' the measured latency for each of
the IPs from 'list_address', every 3 seconds, 10 times then exit.
php latencycheck.php -d 1 -f list_address -o dir_%DATE/%IP
Create (if not exist) a directory per day, a file per IP from list,
and write the latencies for each IP every seconds, until ctrl+c.
Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License. You may obtain a copy of the
License at : http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
You can use, copy, modify and redistribute this script for free, in compliance with the License. If you want to thank the developper, or want to support further developpements, you can use this button to donate.