DevTech101

DevTech101

Month: September 2016

Python remote backup script

#!/bin/python import os import sys import time import datetime import subprocess import smtplib from email.mime.text import MIMEText def mysqlBackup(): mysql_host = ‘localhost’ mysql_user = ‘root’ mysql_user_passwd = ‘password’ backup_path = ‘/mystuff/mysql_backup/’ dblist = [‘wordpress’] datetime = time.strftime(‘%m%d%Y-%H%M%S’) for db in dblist: backupdate = backup_path + db + “_” + datetime logger(“creating backup folder – ” …

Python remote backup script Read More »

Oracle Solaris 11.4 / 12 Apache And PHP 5.6

Oracle Solaris 11.4 / 12 Apache And PHP 5.6 Install php pkg install web/php-common web/php-56 web/php-56/extension/php-xdebug Install apache pkg install web/server/apache-24 web/server/apache-24/module/apache-ssl web/server/apache-24/module/apache-wsgi-27 Configure apache cd /etc/apache2/2.4 cp samples-conf.d/php5.6.conf conf.d/. Enable extensions /etc/php/5.6/conf.d/extensions.ini create phpinfo file (to test) /var/apache2/2.4/htdocs/phpinfo.php Create Apache virtual server /etc/apache2/2.4/conf.d/wordpress.conf DocumentRoot /wiki/wp ServerName wpserver.tld ServerAdmin admin@wpserver.tld ErrorLog /var/apache2/2.4/logs/wpserver-error_log TransferLog /var/apache2/2.4/logs/wpserver-access_log Options …

Oracle Solaris 11.4 / 12 Apache And PHP 5.6 Read More »

Example Of Capturing IOStat With Python

The below Example captures IOStat output with Python in Solaris #!/bin/python import subprocess import csv io_c = subprocess.Popen([‘iostat’, ‘-xnsMr’, ‘1’, ‘2’], stdout=subprocess.PIPE, shell=False, stderr=subprocess.PIPE) stdout = io_c.communicate()[0] lc = len(stdout.split(‘n’)) it_lc = lc / 2 + 2 reader = csv.reader(stdout.split(‘n’)[it_lc:], delimiter=’,’) for row in reader: if any(row): #print row print row[0],row[1],row[2],row[3],row[7],row[8],row[9],row[10] Output should look similar …

Example Of Capturing IOStat With Python Read More »