Search Results for: python

daily system check and send mail

真的太懶了…XDD,基本上當系統多到一定程度的時候,就因該進化到異常管理與通知…. 人在怎麼勤快,一定會有懶散的時候… 這時候就是想想辦法讓電腦幫我們檢查個個系統的狀態與回報的時候, 前提:你已經裝好Nagios….:P 因Nagios…沒有report的功能…所以我就用python做了一個把網頁轉寄出去的功能…以應付老闆XDD #!/usr/bin/env python #-*- coding: utf-8 -*- ”’ ===== Check Spam Report Script ===== Log: 2009/12/20 10:42 ver 0.1 Create Script “The mail system daily check” 2009/12/20 15:40 ver 0.5 add css in the daily report … Continue reading

Posted in 技術 | Tagged , , | Leave a comment

Check Spam Report

今天寫了一個script來協助daily check… 沒用到太高級的方法,只是把事情搞定而已…. python,真是一個好物啊…:D #!/usr/bin/env python #-*- coding: utf-8 -*- ”’ ===== Check Spam Report Script ===== Log: 2009/12/09 21:58 ver 1.0 Create Script 2009/12/10 13:30 ver 1.1 add localtime 2009/12/11 ver 1.5 add if spam reboot count is equal … Continue reading

Posted in 技術 | Tagged , , | Leave a comment

Python compile

#!/usr/bin/python import py_compile import sys file=raw_input(“Please enter your file name”) py_compile.compile(file) sys.exit()

Posted in 技術 | Tagged , , | Leave a comment

Backup_SVN.py

#!/usr/bin/env python #-*- coding: utf-8 -*- ”’ ============================================ LOG Date:2009/09/24 Add Threading Process Date:2009/11/10 Add Check PATH, if you forget enter ‘/’ ============================================ ”’ import threading import Queue import os import sys import time __author__ = “AllenWang” __copyright__ = “Copyright … Continue reading

Posted in 技術 | Tagged , , | Leave a comment

rsync.py

#!/usr/bin/env python #-*- coding: utf-8 -*- from subprocess import call import sys import time import commands source = “xxx@10.181.59.137:~/sysbackup/” target = “~/sysbackup/relay/” rsync = “/usr/local/bin/rsync” arguments = “-avuzb –delete -e” ssh = “‘ssh -i /home/xxx/.ssh/id_dsa’” cmd = “%s %s %s … Continue reading

Posted in 技術 | Tagged , , | Leave a comment

automount.py

只是為了偷懶,所以隨手寫了一個script… #!/usr/bin/env python #-*- coding: utf-8 -*- import os import commands def usbdisk(): S_usb = commands.getoutput(‘df |grep /mnt/bkusb’) if ‘/mnt/bkusb’ in S_usb: print ‘usb disk relly to use’ return True else: if os.path.exists(‘/dev/da0s1′): S_Musb = commands.getoutput(‘sudo mount_ntfs /dev/da0s1 /mnt/bkusb/’) print … Continue reading

Posted in 技術 | Tagged , , | Leave a comment

admintools.py

#!/usr/bin/env python #-*- coding: utf-8 -*- #System Admin tools library #ver 0.1 by AllenWang 2009/06/29 import socket import sys import time import commands class ConnectedTest(): def CoTest(self, address, port): s = socket.socket() try: s.connect((address,port)) print “Connected to %s on port … Continue reading

Posted in 技術 | Tagged , , | Leave a comment

Connected_Test.py for OOP

#!/usr/bin/env python #-*- coding: utf-8 -*- import socket import sys class Connected_Test(): def CoTest(self, address, port): s = socket.socket() try: s.connect((address,port)) print “Connected to %s on port %s Successful” % (address, port) return True except socket.error: print “Connect Error” return … Continue reading

Posted in 技術 | Tagged , , | Leave a comment

Vim setting with python

.vimrc set shiftwidth=4 set tabstop=4 set expandtab 說明: shiftwidth: 使用 [>>] , [< <] , cindent 時填入的空白數 tabstop:一個 tab 其長度相當於多少個空白 expandtab:將 tab 轉成空白

Posted in 技術 | Tagged , | Leave a comment

Mail to Mysql

#!/usr/bin/env python #-*- coding: utf-8 -*- import MySQLdb import mailbox dbhost=”127.0.0.1″ database=”xxxx” sqluser=”xxxx” sqlpassword=”xxxx” db = MySQLdb.connect(host=dbhost, user=sqluser, passwd=sqlpassword, db=database , charset=”utf8″) cursor = db.cursor() param = [] sql = “insert into `maildate`.`mail` (`id`, `to`, `from`, `subject`, `received`, `date`, `message`) … Continue reading

Posted in 技術 | Tagged , , | Leave a comment