Monday, April 18, 2011

Zend Optimizer

Zend Optimizer

  • To install Zend Optimizer, it's best is to download from http://www.zend.com/en/products/guard/downloads . Be aware you will need to register an account to be able to download it. After a few browsing and searching, get this ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz OR ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
  • Extract it :
tar -zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
  • Then copy it to php modules folder:
cp ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/lib/php/modules/ 
(if that is 32bit machine)
  • Create a file /etc/php.d/zend.ini, put this in:
zend_extension=/usr/lib/php/modules/ZendOptimizer.so
  • Restart apache
/etc/init.d/httpd restart
  • Now it should work. Try doing a
php -i |grep -i zend
to get the following result. This mean Zend is running
/etc/php.d/zend.ini,
Zend Extension => 220060519
Zend Memory Manager => enabled
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
report_zend_debug => Off => Off
zend.ze1_compatibility_mode => Off => Off
Zend Optimizer
Zend Loader => enabled
  • To test a encoded file, download ZendGuard from http://www.zend.com/en/products/guard/downloads , the latest is ZendGuard 5.5 which support php5.3, but it still could be used to encode php5.2. Just remember while encoded, choose php 5.2, since the ZendOptimzer we just installed only support until php5.2 (as at 2011-01-18)
  • Create a simple php script by putting
<?php echo 'this is encoded file' ?>
and encode it. It should be a binary if success encoded. Upload that file into the webserver and test whether you can get the exact output.

Monday, April 11, 2011

transfer log from remote machine

vi /etc/sysconfig/syslog

change SYSLOGD_OPTION="-m 0"
to
SYSLOGD_OPTION="-m 0 -r"

then restart the syslog services

vi /etc/syslog.conf

instead of write the folder location
change it to @172.30.10.10

Wednesday, April 6, 2011

Smokeping setup

Go to this Url for guide on how to install smokeping to Centos 5.5
The pages was for centos 5.5 i386
If you are installing it to centos 5.5 x86_64
just change the
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
to
rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

http://www.how2centos.com/installing-smokeping-on-centos-5-5/

This is the official pages for the smokeping
http://oss.oetiker.ch/smokeping/

and here is the official simple guide
http://oss.oetiker.ch/smokeping/doc/index.en.html

Unix useful command

Check memory
free -m

Check all running application pid and stat
ps -aux

Check running services
chkconfig --list
chkconfig <services> --level <1-5> <on/off>

Tuesday, April 5, 2011

shell script for replace, add, and delete

#! /bin/sh

echo "what you want to do"
echo "1:user change department"
echo "2:user change PC"
echo "3:add PC"
echo "4.delete PC"
read ANSWER

if [ $ANSWER = "1" ]; then
        echo "Enter User name"
        read USER1
        echo "Enter PC number"
        read PC1
        echo "Enter previous department name"
        read OLD1
        echo "Enter new department name"
        read NEW1

        sed -i '/'"$PC1"'/d' $OLD1
        echo "172.30.10."$PC1"  #"$USER1 >> $NEW1
        echo "Success"



elif [ $ANSWER = "2" ]; then
        echo "Enter previous PC number"
        read PC2
        echo "Enter new PC number"
        read NEW2
        echo "Enter department name"
        read DEPARTMENT2

        sed 's/'"$PC2"'/'"$NEW2"'/' $DEPARTMENT2 > $DEPARTMENT2".temp"
        cat $DEPARTMENT2".temp" > $DEPARTMENT2
        rm -rf $DEPARTMENT2".temp"

elif [ $ANSWER = "3" ]; then
        echo "Enter user name"
        read USER
        echo "Enter PC number"
        read PC3
        echo "Enter department name"
        read DEPARTMENT3

        echo "172.30.10."$PC3"  #"$USER >> $DEPARTMENT3

elif [ $ANSWER = "4" ]; then
        echo "Enter PC number"
        read PC4
        echo "Enter department name"
        read DEPARTMENT4

        sed -i '/'"$PC4"'/d' $DEPARTMENT4


else
        echo "you had enter an invalid number"

fi

Monday, April 4, 2011

scan music file

This will teach how to scan all music file under a folder and send out the result to your email as attachment

First you will need to install (for Centos5)
- sharutils
- mailt

For Centos6, just install
- sharutils


Below is the script:


#! /bin/sh

find /users -iname "*.mp3" > /var/log/music.txt
find /users -iname "*.wma" >> /var/log/music.txt
find /users -iname "*.mp4" >> /var/log/music.txt

find /export -iname "*.mp3" >> /var/log/music.txt
find /export -iname "*.wma" >> /var/log/music.txt
find /export -iname "*.mp4" >> /var/log/music.txt

uuencode /var/log/music.txt /var/log/music.txt | mail -s "[My-Domain] music file" sat.support@my.offgamers.com


the send out email attachment usage is

uuencode "file location" "file location" | mail -s "subject" "email address"