Skip to content

Commit

Permalink
check-host v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
diasnull committed May 28, 2023
1 parent a552a0d commit 92cd9b6
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 32 deletions.
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ Check-Host is a utility for monitoring websites and checking the availability of

## view:
```
__ __ __ __
____/ / ___ ____/ /______/ / ___ ___ / /_
/ __/ _ \/ -_) __/ '_/___/ _ \/ _ \(_-</ __/
\__/_//_/\__/\__/_/\_\ /_//_/\___/___/\__/ v1.1 / https://github.com/diasnull
ــــــــﮩ٨ـﮩﮩ٨ـﮩ٨ـﮩﮩ٨ــــ
iplook: website location search, IP address
__ __ __ __
____/ / ___ ____/ /______/ / ___ ___ / /_
/ __/ _ \/ -_) __/ '_/___/ _ \/ _ \(_-</ __/
\__/_//_/\__/\__/_/\_\ /_//_/\___/___/\__/ v1.2 / https://github.com/diasnull
ــــــــﮩ٨ـﮩﮩ٨ـﮩ٨ـﮩﮩ٨ــــ
iplook: website location search
usage:
| python3 check-host.py --iplook -t <target>
examples:
| python3 check-host.py --iplook -t 1.1.1.1
| python3 check-host.py --iplook -t example.com
only for domain, IP address!
ping: checking the integrity and quality of connections
ping: testing the integrity and quality of connections
usage:
| python3 check-host.py --ping -t <target>
examples:
Expand All @@ -29,7 +29,7 @@ Check-Host is a utility for monitoring websites and checking the availability of
| python3 check-host.py --ping -t https://example.com
| python3 check-host.py --ping -t example.com
http: website availability and performance check
http: testing website availability and performance
usage:
| python3 check-host.py --http -t <target>:<port> <-- automatically port 80
examples:
Expand All @@ -38,14 +38,22 @@ Check-Host is a utility for monitoring websites and checking the availability of
| python3 check-host.py --http -t https://example.com
| python3 check-host.py --http -t example.com:80
tcp: testing TCP connection of any port of an IP address, website
tcp: testing TCP connection
usage:
| python3 check-host.py --tcp -t <target>:<port> <-- automatically port 80
examples:
| python3 check-host.py --tcp -t 1.1.1.1:53
| python3 check-host.py --tcp -t http://example.com
| python3 check-host.py --tcp -t ssmtp://smtp.gmail.com
tcp: testing UDP connection
usage:
| python3 check-host.py --udp -t <target>:<port> <-- automatically port 80
examples:
| python3 check-host.py --udp -t 1.1.1.1:53
| python3 check-host.py --udp -t http://example.com
| python3 check-host.py --udp -t example.com:4444
dns: website domain monitoring
usage:
| python3 check-host.py --dns -t <target>
Expand All @@ -68,7 +76,7 @@ dns: website domain monitoring<br>
pip3 install requests
```
```
pip3 install pandas
pip3 install prettytable
```

## install:
Expand Down
24 changes: 19 additions & 5 deletions check-host.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
from src.scripts.methods.ping import ping_part
from src.scripts.methods.http import http_part
from src.scripts.methods.tcp import tcp_part
from src.scripts.methods.udp import udp_part
from src.scripts.methods.dns import dns_part


def parser_help_trigger(parser):
help_text = """ iplook: website location search, IP address
help_text = """
iplook: website location search
usage:
| python3 check-host.py --iplook -t <target>
examples:
| python3 check-host.py --iplook -t 1.1.1.1
| python3 check-host.py --iplook -t example.com
only for domain, IP address!
ping: checking the integrity and quality of connections
ping: testing the integrity and quality of connections
usage:
| python3 check-host.py --ping -t <target>
examples:
Expand All @@ -27,7 +29,7 @@ def parser_help_trigger(parser):
| python3 check-host.py --ping -t https://example.com
| python3 check-host.py --ping -t example.com
http: website availability and performance check
http: testing website availability and performance
usage:
| python3 check-host.py --http -t <target>:<port> <-- automatically port 80
examples:
Expand All @@ -36,14 +38,22 @@ def parser_help_trigger(parser):
| python3 check-host.py --http -t https://example.com
| python3 check-host.py --http -t example.com:80
tcp: testing TCP connection of any port of an IP address, website
tcp: testing TCP connection
usage:
| python3 check-host.py --tcp -t <target>:<port> <-- automatically port 80
examples:
| python3 check-host.py --tcp -t 1.1.1.1:53
| python3 check-host.py --tcp -t http://example.com
| python3 check-host.py --tcp -t ssmtp://smtp.gmail.com
tcp: testing UDP connection
usage:
| python3 check-host.py --udp -t <target>:<port> <-- automatically port 80
examples:
| python3 check-host.py --udp -t 1.1.1.1:53
| python3 check-host.py --udp -t http://example.com
| python3 check-host.py --udp -t example.com:4444
dns: website domain monitoring
usage:
| python3 check-host.py --dns -t <target>
Expand All @@ -65,7 +75,7 @@ def logo_part():
__ __ __ __
____/ / ___ ____/ /______/ / ___ ___ / /_
/ __/ _ \/ -_) __/ '_/___/ _ \/ _ \(_-</ __/
\__/_//_/\__/\__/_/\_\ /_//_/\___/___/\__/ v1.1 / https://github.com/diasnull
\__/_//_/\__/\__/_/\_\ /_//_/\___/___/\__/ v1.2 / https://github.com/diasnull
ــــــــﮩ٨ـﮩﮩ٨ـﮩ٨ـﮩﮩ٨ــــ
"""
return logo_text
Expand All @@ -85,6 +95,9 @@ def methods_part():
elif args.tcp:
tcp_part(args)
break
elif args.udp:
udp_part(args)
break
elif args.dns:
dns_part(args)
break
Expand All @@ -101,6 +114,7 @@ def arg_parser_part():
parser.add_argument("--ping", dest="ping", action="store_true")
parser.add_argument("--http", dest="http", action="store_true")
parser.add_argument("--tcp", dest="tcp", action="store_true")
parser.add_argument("--udp", dest="udp", action="store_true")
parser.add_argument("--dns", dest="dns", action="store_true")
return parser.parse_args()

Expand Down
3 changes: 3 additions & 0 deletions src/scripts/api_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

def id_key_part(target, method):
id_key_req = json.loads(requests.get(f"https://check-host.net/check-{method}?host={target}", headers={"Accept": "application/json"}).text)
# trigger // reached API limit
if "request_id" not in id_key_req:
return 0
return id_key_req


Expand Down
7 changes: 5 additions & 2 deletions src/scripts/methods/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def dns_data_parser(result_data, data_frame_temp, id_key):


def dns_data_part(data_frame, id_key, index_count):
# trigger // api_data --> id_key_part()
if id_key == 0:
return datetime.datetime.now().strftime("%H:%M:%S") + " { error } inf: reached API limit, wait a minute."
result_data = result_data_part(id_key)
for nod_location in result_data:
if result_data[nod_location] == None:
Expand All @@ -47,6 +50,6 @@ def dns_part(args):
# index_count = index // index_frame
index_count = 0
id_key = id_key_part(target, "dns")
print("{ info } dns started at:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print("{ info } DNS started at:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print(dns_data_part(data_frame, id_key, index_count))
print("{ info } dns ended in:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print("{ info } DNS ended in:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
7 changes: 5 additions & 2 deletions src/scripts/methods/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def http_data_parser(result_data, data_frame_temp, id_key):


def http_data_part(data_frame, id_key, index_count):
# trigger // api_data --> id_key_part()
if id_key == 0:
return datetime.datetime.now().strftime("%H:%M:%S") + " { error } inf: reached API limit, wait a minute."
result_data = result_data_part(id_key)
for nod_location in result_data:
if result_data[nod_location] == None:
Expand All @@ -47,6 +50,6 @@ def http_part(args):
# index_count = index // index_frame
index_count = 0
id_key = id_key_part(target, "http")
print("{ info } http started at:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print("{ info } HTTP started at:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print(http_data_part(data_frame, id_key, index_count))
print("{ info } http ended in:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print("{ info } HTTP ended in:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
3 changes: 1 addition & 2 deletions src/scripts/methods/iplook.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def iplook_data(target, data_frame):
# remove index // set index to ""
data_frame.index = [""] * len(data_frame)
return data_frame
elif iplook_req["status"] == "fail":
return datetime.datetime.now().strftime("%H:%M:%S") + " { error } inf: invalid target"
return datetime.datetime.now().strftime("%H:%M:%S") + " { error } inf: invalid target."


def iplook_part(args):
Expand Down
19 changes: 11 additions & 8 deletions src/scripts/methods/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def ping_data_parser(result_data, data_frame_temp, id_key):
if data_in_result_data != None:
# result data // data_in_result_data
time_1, time_2, time_3, time_4 = round(data_in_result_data[0][1] * 1000, 2), \
round(data_in_result_data[1][1] * 1000, 2), \
round(data_in_result_data[2][1] * 1000, 2), \
round(data_in_result_data[3][1] * 1000, 2)
round(data_in_result_data[1][1] * 1000, 2), \
round(data_in_result_data[2][1] * 1000, 2), \
round(data_in_result_data[3][1] * 1000, 2)
code_1, code_2, code_3, code_4 = data_in_result_data[0][0], \
data_in_result_data[1][0], \
data_in_result_data[2][0], \
data_in_result_data[3][0]
data_in_result_data[1][0], \
data_in_result_data[2][0], \
data_in_result_data[3][0]
ip_address = data_in_result_data[0][2]
data_frame_temp.loc[count] = [f"{country}, {city}", f"{time_1}/{time_2}/{time_3}/{time_4} ms.", f"{code_1}/{code_2}/{code_3}/{code_4}", ip_address]
# remove index // set index to ""
Expand All @@ -33,6 +33,9 @@ def ping_data_parser(result_data, data_frame_temp, id_key):


def ping_data_part(data_frame, id_key, index_count):
# trigger // api_data --> id_key_part()
if id_key == 0:
return datetime.datetime.now().strftime("%H:%M:%S") + " { error } inf: reached API limit, wait a minute."
result_data = result_data_part(id_key)
for nod_location in result_data:
if result_data[nod_location] == None:
Expand All @@ -52,6 +55,6 @@ def ping_part(args):
# index_count = index // index_frame
index_count = 0
id_key = id_key_part(target, "ping")
print("{ info } ping started at:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print("{ info } PING started at:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print(ping_data_part(data_frame, id_key, index_count))
print("{ info } ping ended in:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print("{ info } PING ended in:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
7 changes: 5 additions & 2 deletions src/scripts/methods/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def tcp_data_parser(result_data, data_frame_temp, id_key):


def tcp_data_part(data_frame, id_key, index_count):
# trigger // api_data --> id_key_part()
if id_key == 0:
return datetime.datetime.now().strftime("%H:%M:%S") + " { error } inf: reached API limit, wait a minute."
result_data = result_data_part(id_key)
for nod_location in result_data:
if result_data[nod_location] == None:
Expand All @@ -49,6 +52,6 @@ def tcp_part(args):
# index_count = index // index_frame
index_count = 0
id_key = id_key_part(target, "tcp")
print("{ info } tcp started at:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print("{ info } TCP started at:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print(tcp_data_part(data_frame, id_key, index_count))
print("{ info } tcp ended in:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print("{ info } TCP ended in:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
56 changes: 56 additions & 0 deletions src/scripts/methods/udp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import pandas
import datetime

from src.scripts.api_data import *
from src.scripts.loading_process import *


def udp_data_parser(result_data, data_frame_temp, id_key):
for count, nod_location in enumerate(result_data, start=0):
# id key data // api_data --> id_key_part()
country = id_key["nodes"][nod_location][1]
city = id_key["nodes"][nod_location][2]
if result_data[nod_location] != None:
# result data // api_data --> result_data_part()
data_in_result_data = result_data[nod_location][0]
if data_in_result_data == None:
data_frame_temp.loc[count] = [f"{country}, {city}", "no data", "no data"]
if data_in_result_data != None:
if "address" not in data_in_result_data:
data_frame_temp.loc[count] = [f"{country}, {city}", data_in_result_data["error"], "None"]
if "address" in data_in_result_data:
# result data // data_in_result_data
reason = "open or filtered"
ip_address = data_in_result_data["address"]
data_frame_temp.loc[count] = [f"{country}, {city}", reason, ip_address]
# remove index // set index to ""
data_frame_temp.index = [""] * len(data_frame_temp)
return data_frame_temp


def udp_data_part(data_frame, id_key, index_count):
# trigger // api_data --> id_key_part()
if id_key == 0:
return datetime.datetime.now().strftime("%H:%M:%S") + " { error } inf: reached API limit, wait a minute."
result_data = result_data_part(id_key)
for nod_location in result_data:
if result_data[nod_location] == None:
# next frame // index_frame
index_count += 1
print(loading_process_part(index_count), end="\r", flush=True)
return udp_data_part(data_frame, id_key, index_count)
# return final data frame // data_frame
return udp_data_parser(result_data, data_frame, id_key)


def udp_part(args):
data_frame = pandas.DataFrame(columns=["location", "reason", "IP address"])
# data frame display width limit // 150
pandas.set_option("display.width", 150)
target = args.target
# index_count = index // index_frame
index_count = 0
id_key = id_key_part(target, "udp")
print("{ info } UDP started at:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
print(udp_data_part(data_frame, id_key, index_count))
print("{ info } UDP ended in:", datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))

0 comments on commit 92cd9b6

Please sign in to comment.