전체 글
-
[Python] dataframe of pandas returns mysql / Maria DB resultPython/Python For Analytics 2019. 8. 8. 10:20
mysql / maria DB 쿼리의 결과를 pandas의 dataframe으로 만들기 import pymysql import pandas as pd db = pymysql.connect( host=' ', port= , user=' ', password=' ', db=' ', charset='utf8' ) SQL = "select * from table" df = pd.read_sql(SQL,db) print(df)
-
윈도우 2012 NTP 서버 구축 (1) - 외부 인터넷 시간 동기화 설정Python/Python for Windows 2019. 8. 7. 10:20
NTP서버를 만들기 위해서는 NTP서버가 외부 인터넷 타임서버와 주기적으로 동기화 되어야 한다. 기본적으로 인터넷 시간과 동기화 주기는 일주일(weekly)이다 일반적으로 일 1회는 동기화가 되야 NTP서버 노릇을 할 수 있다. 주기 변경은 레지스트리에 할 수 있는데, 경로는 아래와 같다. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient SpecialPollInterval 값을 보면, 기본적으로 604800초(일주일)로 되어있다. 이제 일 단위인 86400으로 변경하겠다. Windows Time 서비스를 재시작 하고, 다시 설정을 보면 일 단위로 변경됨을 알 수 있다. 방화벽 오픈이 필요하면 아웃바운드..
-
윈도우 2012 NTP 서버 구축 (3) - 모니터링결과 메일 받기Python/Python for Windows 2019. 8. 7. 10:18
외부 타임서버과 NTP서버 와의 시간체크를 SMTP를 이용하여 메일로 송부하여 모니터링할 수 있다. 또한 결과를 웹이나 DB으로 송출하여 다양한 방법으로 모니터링이 가능하다. import ntplib from datetime import datetime import os from time import ctime import smtplib from email.mime.text import MIMEText timeServer = 'time.bora.net' c = ntplib.NTPClient() response = c.request(timeServer, version=3) boraTime = ctime(response.tx_time) localserverTime = datetime.now().ctime()..
-
윈도우 2012 NTP 서버 구축 (2) - 서버 시간 모니터링Python/Python for Windows 2019. 8. 7. 10:17
NTP서버가 외부 타임서봐와 동기화가 잘 되는지 모니터링이 필요하다. 파이썬(Python)을 이용하여 간단하게 모니터링 프로그램을 만들겠다. 외부 타임서버는 'time.bora.net' 로 지정해보았다. import ntplib from datetime import datetime import os from time import ctime timeServer = 'time.bora.net' c = ntplib.NTPClient() response = c.request(timeServer, version=3) boraTime = ctime(response.tx_time) localserverTime = datetime.now().ctime() print(timeServer, ':', boraTime) pr..
-
[ OSS - WinSCP ] Linux SFTP 접속Open Source 2019. 8. 6. 13:20
리눅스에서 hostkey 얻는 방법. (SFTP로 접속할 계정으로 SSH 로그인) $ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key 2048 ....... WinSCP 스크립트 파일 : scriptfile.txt open sftp://user:password@host -hostkey="ssh-rsa 2048 ......." close exit 배치파일 (bat) 작성 @echo off winscp.com /ini=nul /script=scriptfile.txt
-
[Python] Send Slack Massages and upload filePython/Python Programming 2019. 8. 2. 20:42
Token : https://api.slack.com/custom-integrations/legacy-tokens Legacy tokens Learn how to build bot users, send notifications, and interact with workspaces using our APIs. api.slack.com Slack에 채널을 만들고, 토큰을 복사 pip install slacker 설치 import slacker token = 'token key' slack = slacker.Slacker(token) # send message slack.chat.post_message('#channel', 'messages') # file upload slack.files.upload(fil..