๋์ธ๋ก ์๋น์ค๋๋ ํํ์ด์ง์ ๋ค์ด ์ฌ๋ถ ๋ฐ ์ ๊ทผ ๋ถ๊ฐ ์ํ๋ฅผ ํ๋ณํด์ฃผ๋ ํ๋ก๊ทธ๋จ์ด๋ค. ์คํ ํ ๋ฉ์ผ ๋ฐ์กํ๋ ๊ธฐ๋ฅ๊น์ง ์๋ค. ๋ฉ์ผ ๋ณธ๋ฌธ์ OX ์ํ์ ๋ฌด๋ง ๋ ๋ผ๊ฐ๋ค. ์๋น์ค ์ค์ผ์ค๋ฌ๋ก ๋ฑ๋กํ์ฌ ํฌ์ค์ฒดํฌ๋ฅผ ํ ์ ์๋ค.
๋์ธ์๋น์ค ๋์์ด๋ฏ๋ก ํ์ฌ ๋ด๋ถ๋ง์์ ์คํํ๋ฉด ๊ฒฐ๊ณผ๊ฐ์ด ๋ฌ๋ผ์ง๋ค. ํ์ฌ๋ด๋ถ๋ง์์ VPN ์ฌ์ดํธ์ ์ ์ํ๋ ค๊ณ ํ๋ค๋๊ฐ ๊ทธ๋ฌ๋ฉด ์ํ๋ X๊ฐ ๋ฐ ์๋ ์๋ค. ์ธ๋ถ์ฌ์ดํธ ์ ๊ทผ์ ํ์ด ๋๋ฉด X๊ฐ ๋ฐ ์๋ ์๋ค.
import sys
from PyQt5.QtWidgets import (QApplication, QWidget, QGridLayout, QLabel, QLineEdit, QTextEdit)
import requests as r
import socket
import smtplib
r.packages.urllib3.disable_warnings(r.packages.urllib3.exceptions.InsecureRequestWarning)
flag = 0
#gmail ์ด๋ฉ์ผ ๋ฐ์ก
def sender(toaddrs,status):
# Specifying the from and to addresses
fromaddr = '๋ฐ์กํ์๋ฉ์ผ'
toaddrs = toaddrs
# Writing the message (this message will appear in the email)
urlList
msg = "[์ธ๋ถ์๋น์ค] ์ ๊ฒ๊ฒฐ๊ณผ".join(status)
# Gmail Login
username = 'Google ID' # without @gmail.com only write Google Id.
password = 'Google PW'
# Sending the mail
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username, password)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
statBar = ["๋ฒํธ", "์๋น์ค", "URL", "์ํ(๐ด/โ)"]
#์ ๊ฒ ์๋น์ค ๋ชฉ๋ก 2์ฐจ์ ๋ฆฌ์คํธ ๋ฐฐ์ด
urlList = [['NAVER','https://www.naver.com'],
['daum','https://www.daum.net']]
#์ ๊ฒ ์ํ ๊ฒฐ๊ณผ
statusTEXT = []
status = ['๐ด','โ','โ']
#์ฐฝ ๊ทธ๋ฆฌ๊ธฐ
class MyApp(QWidget):
def __init__(self):
super().__init__()
self.initUI()
self.show()
def initUI(self):
count = 1
#Main Display
grid = QGridLayout()
self.setLayout(grid)
self.setWindowTitle('Status Checker')
self.setGeometry(300, 300, 300, 200)
myIP = socket.gethostbyname(socket.gethostname())
grid.addWidget(QLabel("my IP: "), 0, 0)
grid.addWidget(QLabel(myIP), 0, 1)
grid.addWidget(QLabel("if(์ฌ๋ด๋ง): ์ผ๋ถ ํ์ด์ง ์ํ โ"), 0, 2)
grid.addWidget(QLabel(statBar[0]), 1, 0)
grid.addWidget(QLabel(statBar[1]), 1, 1)
grid.addWidget(QLabel(statBar[2]), 1, 2)
grid.addWidget(QLabel(statBar[3]), 1, 3)
for i in range(0,18) :
grid.addWidget(QLabel(str(count)), i+2, 0)
grid.addWidget(QLabel(urlList[i][0]), i+2, 1)
grid.addWidget(QLabel(urlList[i][1]), i+2, 2)
count+=1
self.show()
# Status Display
for i in range(0, 18):
try:
result = r.get(urlList[i][1], timeout=1, verify=False)
if result.ok:
grid.addWidget(QLabel(status[0]), i+2, 3)
else:
grid.addWidget(QLabel(status[1]), i+2, 3)
# ์ฐ๊ฒฐ ์๊ฐ์ด๊ณผ ์์ธ์ฒ๋ฆฌ
except r.exceptions.Timeout:
grid.addWidget(QLabel(status[1]), i+2, 3)
flag = 1
pass
# SSL ์ธ์ฆ์ ์๋ฌ ๋ฐ์ ๋ฐฉ์ง
except r.exceptions.SSLError:
grid.addWidget(QLabel(status[1]), i+2, 3)
pass
# ์ฐ๊ฒฐ ์คํจ(์๋ต ์์) ์์ธ์ฒ๋ฆฌ
except r.exceptions.ConnectionError:
grid.addWidget(QLabel(status[1]), i+2, 3)
pass
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyApp()
# gmail ๋ฐ์ก๊ธฐ๋ฅ ์ฃผ์์ ๋ง์๋์ statusTEXT๋ก ๋ฉ์ผ ๋ณธ๋ฌธ์ ๋ณด๋ผ ๋ด์ฉ ์์ฑ ํ์
# sender("๋ณด๋ผ์ฌ๋์ฃผ์",statusTEXT)
sys.exit(app.exec_())
'๐ค์ ๋ณด๋ณด์ > ๐๋ธ๋ฃจํ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์ ๋ณด] ์น ๋ฐฉํ๋ฒฝ ip ์ฐจ๋จ ์ ์ฃผ์ ์ฌํญ (0) | 2023.02.15 |
---|---|
[์ ๋ณด] ๋์งํธ ํฌ๋ ์์ด๋ (0) | 2023.02.15 |
XDR EDR ์ฐจ์ด(CrowdStrike์ ํ์ฌ ๋น๊ต ๋ฉํธ) (0) | 2023.01.12 |
[ํ์ด์ฌ] ์น์๋น์ค IP ์ ๊ทผ ๋ ธ์ถ ํ์ธ ์์ค์ฝ๋(๋ณด์์ ์ฑ ) (0) | 2021.04.20 |
[ํ์ด์ฌ3.x] nslookup ์๋ํ ํด (0) | 2020.05.21 |