DevTech101

DevTech101

scripting

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 »

Modifying perl config by hand – just modify Config.pm

The post below will show you how to generate the Config.pm Then if you still need configuration changes (for example proxy) just modify the file by hand. To initially configure perl cpan. Make note of the config file & directory, for example below its /user/.cpan/CPAN/MyConfig.pm perl -MCPAN -e shell [..] snip Would you like to …

Modifying perl config by hand – just modify Config.pm Read More »

perl how to change from string to a number

Below you can asee a subrutine that will cause perl to undrtsnad this as numbers foreach (@full_cpu_data) {         $_ =~ s/K//;         @cpu_data = split(':', $_);         @cpu_data  = map { $_ += 0 } @cpu_data;            push @cpu_plot, { cpu => @cpu_data[3], core => @uptime[6], disk => @disk[4] };         $i++; }  

Show installed perl modules

To list all installed perl modules #!/usr/bin/perl # ## # #!/usr/bin/perl use ExtUtils::Installed; my $instmod = ExtUtils::Installed->new(); foreach my $module ($instmod->modules()) { my $version = $instmod->version($module) || “???”; print “$module — $version\n”; }

Sun Web Server 7 PHP-PDO Oracle – Informix extension installation and configuration

Note: The PHP plug we use on the intranet today taken from here and here, will not work with Informix-PDO Because it was compiled with Thread Safety: Enabled and Informix-PDO compiles with Thread Safety: Disabled causing a mismatch Contents 1 Sun Web Server PHP installation 2 Oracle PHP-PDO installation 3 Informix PHP-PDO installation 4 Cool …

Sun Web Server 7 PHP-PDO Oracle – Informix extension installation and configuration Read More »