Wednesday, 12 September 2012

How to run shell commands in python

How to run shell commands in python

Inorder to run your shell commands in python script, you may need to import an module named os. Below is the simple example on how it actually works

import os
os.system('ls -l /boot/')
total 22784
-rw-r--r-- 1 root root 791023 Apr 11 05:56 abi-3.2.0-23-generic
-rw-r--r-- 1 root root 140279 Apr 11 05:56 config-3.2.0-23-generic
drwxr-xr-x 3 root root 12288 Aug 14 18:51 grub
-rw-r--r-- 1 root root 14163334 Aug 14 18:51 initrd.img-3.2.0-23-generic
-rw-r--r-- 1 root root 176764 Nov 27 2011 memtest86+.bin
-rw-r--r-- 1 root root 178944 Nov 27 2011 memtest86+_multiboot.bin
-rw------- 1 root root 2884358 Apr 11 05:56 System.map-3.2.0-23-generic
-rw-r--r-- 1 root root 4965840 Apr 25 21:41 vmlinuz-3.2.0-23-generic

Wednesday, 27 June 2012

MySQL performance tuning with MySQLTuner script


MySQL database
     As we all know, MySQL is a powerful opensource database and it is one of the world’s most used Relational Database Management System. In this article, I am going to share you how to increase the performance, stability and efficiency for MySQL server along with any applications that are using it.

MySQL Tuner Script
MySQLTuner is a Perl script that analyzes your MySQL performance and, based on the statistics it gathers, gives recommendations which variables you should adjust in order to increase performance. That way, we can tune your my.cnf file to tease out the last bit of performance from our MySQL server and make it work more efficiently.

SFTP Chroot Jailing - Restricting users to their individual home directories

Secure FTP Chroot jailing 
In this article, I am going to explain you how to enable chroot jailing on sftp which means that sftp users can view and edit only within their home directories only. By default sftp users have shell access to access other users home directories and they also have access under / directories. Let us see how to restrict sftp users within their home directories.



Step 1: Creating chroot directory to secure /home



#mkdir /chroot/home

How to add new order admin email notification on Magento





Magento is a feature-rich eCommerce platform built on open-source technology that provides online merchants with unprecedented flexibility and control over the look, content and functionality of their eCommerce storeIn this article explains I am going to explain, how to add a NEW ORDER ADMIN EMAIL NOTIFICATION extension on Magento. Basically, there were two emails that has to be send when a new order is placed by the customer. One going to the customer and one going to the admins. This feature could be especially valuable for those of us that use a fulfillment company. They could get the ‘admin’ version of the new order email that could include all sorts of details and necessary information about the customer that you don’t necessarily want in the new order email that goes to the customer. Thus the magento version 1.7 and below, does not support for receiving admin notification emails when a new order is placed by the customer. But it is necessary to add the extension for receiving admin mail notification.

Postfix mail queue and its operations


Postfix mail queue
In this article, I am going to explain you how flush a postfix mail queue and its operation in details. Suppose if you are handling a MTA(Mail Transfer Agent) then you must have to know about these. Basically postfix consists of four different types of  queues such as


* active queue - it is limited size queue which contains mails to be sent out.
* deferred queue - mails that cannot be delivered will stored in the deferred queue.
* incoming queue - mails from network will first enter in to incoming queue and after some cleanup it will give it to active queue for mail delivery.
* maildrop queue - it consists of locally posted mails.

Saturday, 2 June 2012

How to install UCARP

Common Address Redundancy Protocol(CARP)

UCARP allows multiple servers to share common virtual IP addresses in order to provide automatic failover. UCARP is a portable implementation of the CARP protocol.

Set up UCARP Installation on two hosts

Install ucarp on both nodes(nodeA and nodeB) and set one nodeA as master.

apt-get install ucarp

Configure ISCSI initiator and target


Client side iscsi initiator setup:

root@manager-desktop:~# apt-get install open-iscsi

Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libdevel-symdump-perl libipc-run-perl debootstrap libauthen-sasl-perl diffstat libio-stringy-perl patchutils libaio1 seabios
  python-cheetah libio-pty-perl openvpn-blacklist libterm-size-perl kpartx libpkcs11-helper1 vgabios devscripts libtest-pod-perl
  dctrl-tools dput libpod-coverage-perl libapt-pkg-perl lintian libparse-debcontrol-perl wdiff qemu-common