Skip to content

AyoobAli/TCPing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCPing v0.2.2 (Beta)

TCPing is a tool that allows you to use a TCP connection to ping a service. It can be used as a replacement of ICMP Ping in case the network doesn't allow ICMP, or as a service live check.

This is a beta release, so please open an issue if you notice an issue.

The tools is written in Python3 and it needs Python v3 to be installed.

TCPing


Install (Linux)

Simply clone the repository to the location you want:

(Example: you want to place it in ~/apps/

mkdir -p ~/apps/
cd ~/apps/
git clone https://github.com/ayoobali/TCPing
cd TCPing
chmod ug+x tcping.py
python3 tcping.py -h

To run the application from any directory, just create a symlink of tcping in your bin directory.

ln -s ~/apps/TCPing/tcping.py ~/bin/tcping

OR One line installation:

mkdir -p ~/apps/ && mkdir -p ~/bin/ && cd ~/apps/ && git clone https://github.com/ayoobali/TCPing && cd TCPing && chmod gu+x tcping.py && ln -s ~/apps/TCPing/tcping.py ~/bin/tcping

Update

To update TCPing to the latest version, navigate to the directory where TCPing is located and run the command git pull

If you installed TCPing using the above command, you can simply update it using the following command:

cd ~/apps/TCPing/
git pull

Uninstall (Linux)

To remove TCPing from your system just delete the downloaded files.

If you installed it using the above command, you can simply uninstall it using the following command:

rm ~/bin/tcping
rm -rf ~/apps/TCPing

Usage

To ping a service:

tcping -i <hostname> -p <port>

To save the response time of a server once every hour for 24 hours:

tcping -i example.com -p 443 -n 24 -s 3600000 -q --online-cmd "echo '{#DATE#},{#RESPONSE#}' >> data.csv" &

This will run the command in the background and it will create a file called data.txt with the timestamp and response time for the next 24 hours

To show the output of --online-cmd and --offline-cmd commands use -vv

For more options type tcping -h


ToDo:

  • Connect to a database to store all data and save last status.
  • Get target Hosts:Ports from file to ping multiple services.
  • Send HTTP request when target status changes (Online/Offline).
  • Run shell command when target status changes from online to offline and vice versa.
  • Run shell command if target is Offline.
  • Run shell command if target is Online.

License

This tool is released under MIT License.


Change Log:

[2021-05-28] v0.2.2 (Beta):

  • [Fix] Fixed the update option to exit after checking the new version.

[2019-03-05] v0.2.1 (Beta):

  • [Fix] Fixed a minor issue with the update option.

[2019-03-05] v0.2.0 (Beta):

  • [Add] Added option --to-offline-cmd that allows execution of shell command onetime when the status changes from Online to Offline.

  • [Add] Added option --to-online-cmd that allows execution of shell command onetime when the status changes from Offline to Online.

  • [Add] Added option --update to check if there is a new version of TCPing.

  • [Fix] Minor fixes.

    Note: in the options --to-offline-cmd and --to-online-cmd you can use the following variables to be automatically replaced. {#NO#}, {#DATE#}, {#IP#}, {#PORT#}, {#STATUS#} and {#RESPONSE#} Example: tcping -i example.com -p 443 -n 0 -s 10000 -q --to-offline-cmd 'curl "http://alertsystem.tld/?ip={#IP#}&port={#PORT#}&status={#STATUS#}"'

[2019-01-31] v0.1.3 (Beta):

  • [Add] Added option --online-cmd that allows execution of shell commands for each online status.

  • [Add] Added option --offline-cmd that allows execution of shell commands for each offline status.

  • [Mod] Modified the option -n and --number to allow the value 0 for infinite ping requests.

  • [Mod] Modified the sleep function to sleep after each request instead of before each request.

    Note: in the options --online-cmd and --offline-cmd you can use the following variables to be automatically replaced. {#NO#}, {#DATE#}, {#IP#}, {#PORT#}, {#STATUS#} and {#RESPONSE#} Example: tcping -i example.com -p 443 -n 0 -s 10000 -q --offline-cmd 'notify-send "TCPing" "IP: {#IP#} is {#STATUS#}\nOn Port: {#PORT#}\nAt: {#DATE#}"'

[2019-01-27] v0.1.2 (Beta):

  • [Fix] Fixed an issue that --sleep, --timeout and --number were throwing an error.

[2019-01-27] v0.1.1 (Beta):

  • [Fix] Fixed an error that sys and os were used but not imported.
  • [Fix] Fixed wrong License Label in source code file.

[2019-01-26] v0.1 (Beta):

  • First Beta Release.

About

A tool that allows you to use a TCP connection to ping a service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages