#!/usr/bin/python
# Python Version : 2.7.5
from os import system
from datetime import datetime
checkList = ('127.0.0.1','192.168.x.99','192.168.x.98')
logTime = str(datetime.today())[:19]
for host in checkList:
cmdstring = 'ping -c1 '+host+' 1>/dev/null' # Linux Ping Check Command
var = system(cmdstring)
if var == 0: # value = 0, OK
print host, 'ping ok : ', logTime
else:
print host, 'ping fail : ', logTime
------------------------------------------------------------
127.0.0.1 ping ok : 2019-04-09 13:39:34
192.168.1.99 ping ok : 2019-04-09 13:39:34
192.168.1.98 ping fail : 2019-04-09 13:39:34
'Python > Python for Linux' 카테고리의 다른 글
[Python] pandas를 이용한 tomcat accesslog 분석 및 활용 (0) | 2019.09.05 |
---|---|
[Python] Linux에서 간단한 Web 모니터링 하기 (0) | 2019.04.15 |
[Python] Linux Sendmail을 이용한 메일 보내기 (0) | 2019.04.13 |
[ CentOS ] Python pip install (0) | 2019.04.13 |
[Python] CentOS 7 Python3 Install and Symbolc link (0) | 2019.03.28 |
[Python] Linux 디렉토리와 파일 리포팅 (0) | 2019.03.27 |
[Python] Linux에서 python 실행파일 만들기 (0) | 2019.03.27 |
[Python] paramiko와 timedelta를 조합하여 리눅스 로그 핸들링 (0) | 2018.05.24 |