GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python_report/python_report.py at master · boxcontrol/python_report Expand file tree/ Copy pathpython_report.pyMore file actions 48 lines (37 loc) · 1.46 KB / Copy pathpython_report.pyFile metadata and controls48 lines (37 loc) · 1.46 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 #!/usr/local/bin/python import commands import smtplib, os, sys from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.MIMEText import MIMEText from email.Utils import COMMASPACE, formatdate from email import Encoders logfile = open('/pyth/to/message.txt', 'w') logfile.truncate() #logfile.close() comm_list = ['uptime', 'vnstat -d', 'free -m', 'df -h', "cat /var/log/auth.log | grep 'sshd.*Invalid'", "cat /var/log/auth.log | grep 'sshd.*opened'"] for i in comm_list: stat, out = commands.getstatusoutput(i) if not stat: logfile.write(out) logfile.close() #send email def send_mail(send_from, send_to, subject, text, files=[], server="localhost"): assert type(send_to)==list assert type(files)==list msg = MIMEMultipart() msg['From'] = send_from msg['To'] = COMMASPACE.join(send_to) msg['Date'] = formatdate(localtime=True) msg['Subject'] = subject msg.attach( MIMEText(text) ) for f in files: part = MIMEBase('application', "octet-stream") part.set_payload( open(f,"rb").read() ) Encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f)) msg.attach(part) smtp = smtplib.SMTP(server) smtp.sendmail(send_from, send_to, msg.as_string()) smtp.close() send_mail('[email protected]', ['[email protected]'], 'Daily Server Report', 'Your Daily Server Report:', ['/path/to/message.txt']) |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |