์ƒ์„ธ ์ปจํ…์ธ 

๋ณธ๋ฌธ ์ œ๋ชฉ

[TIL] Python์—์„œ Ping ์ฒดํฌํ•˜๊ธฐ 220928

DEVELOPMENT/Python

by ์—์Šคํ”„๋ฆฌํ„ฐ 2022. 9. 28. 21:48

๋ณธ๋ฌธ

728x90
๐Ÿ’ก Today I Learned ์š”์•ฝ (19ํšŒ์ฐจ)
- Python์—์„œ ping3๋ฅผ ์‚ฌ์šฉํ•ด์„œ ํŠน์ • ์„œ๋ฒ„์— ping์„ ๋‚ ๋ฆด ์ˆ˜ ์žˆ๋‹ค.

 

Python์—์„œ Ping ์ฒดํฌํ•˜๊ธฐ

๋„คํŠธ์›Œํฌ ๋ฌธ์ œ๋กœ NAS๊ฐ€ ์ฃฝ์–ด๋ฒ„๋ฆฌ๋Š” ์ผ์ด ์ƒ๊ฒผ๋Š”๋ฐ, ์–ธ์ œ ์‚ฌ๊ฑด์ด ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ์•Œ ๋ฐฉ๋ฒ•์ด ์—†์–ด์„œ ์™ธ๋ถ€์—์„œ ์ง€์†์ ์œผ๋กœ NAS ์ฃผ์†Œ์— ping์„ ๋„ฃ์–ด์„œ ์ƒํƒœ๋ฅผ ๊ฒ€์ถœํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ฐพ๋‹ค๊ฐ€ ping3 ๋ผ๋Š” ๊ฑธ ์•Œ๊ฒŒ ๋จ. ๋ฐฉ๋ฒ•๋„ ์–ด๋ ต์ง€ ์•Š์Œ.

from ping3 import ping
path = "google.com"
response = ping(path)

if response == False:
    print(False)
else:
    print(True)

#ping ๊ด€๋ จ ๋ฆฌ์„œ์น˜ ๋‚ด์—ญ:

๊ด€๋ จ๊ธ€ ๋”๋ณด๊ธฐ

๋Œ“๊ธ€ ์˜์—ญ