Grep Exim Email Transaction with Bash

While email transport having problem, the first we look for is the email log file, to check incoming and outgoing email transaction, to see was the email sent to the recipient or whether did the sender’s email it delivered to our email server.

I like exim log file provide the transport when an email is coming in or out from the server. I have written a simple script to grep sender/recipient email address and analysis the email transaction. Read the rest of this entry »

PECL Manual Install on Linux Centos

Just bought a VPS server hosting to play around from Media Temple. The Dedicated Virtual (DV) package come with Linux Centos, and all this while I’ve been a FreeBSD user, think it shouldn’t be hard to use Linux :D Sorry I’m a n00b on Linux.

yum is fun, I did yum install memcache and yum install php-pecl-memcache. memcache daemon service started successfully but php-pecl-memcache ain’t working.

memcache.ini is included in /etc/php.d/ and from phpinfo(), I can clearly seen memcache.ini is included as well. But, when I search for memcache module info, the module seem not loaded with into php.

memcache-ini

I remove php-pecl-memcache and tried to install with pecl install memcache, not good, pecl install were not working and the error message;


shell> pecl install memcache
downloading memcache-2.2.5.tgz ...
Starting to download memcache-2.2.5.tgz (35,981 bytes)
..........done: 35,981 bytes
11 source files, building
running: phpize
Configuring for:
PHP Api Version:         xxxxx
Zend Module Api No:      xxxxx
Zend Extension Api No:   xxxxx
 1. Enable memcache session handler support? : yes

1-1, 'all', 'abort', or Enter to continue:
building in /var/tmp/pear-build-root/memcache-2.2.5
running: /var/cache/php-pear/memcache-2.2.5/configure --enable-memcache-session=yes
checking for egrep... grep -E
checking for a sed that does not truncate output... //bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
ERROR: `/var/cache/php-pear/memcache-2.2.5/configure --enable-memcache-session=yes' failed

Search for the error message, and it seem like it’s something to do with mount point permission for /var or /var/tmp partition.

Not wanting to do much on un-mount and re-mount the drive, I tried to install php-pecl-memcache manually.

Manual Compile PECL Extension with phpize

I will take memcahe as PECL extension for example, first I need to download the package file from PECL website, untar it and start compiling


shell> wget http://pecl.php.net/get/memcache-2.2.5.tgz
shell> tar zxfv memcache-2.2.5.tgz
shell> cd memcache-2.2.5 && phpize && ./configure && make && make install

After the installation, create memcahe.ini in /etc/php.d/


; Enable memcache extension module
extension=memcache.so

; Options for the memcache module

; Whether to transparently failover to other servers on errors
memcache.allow_failover=1
; Defines how many servers to try when setting and getting data.
memcache.max_failover_attempts=20
; Data will be transferred in chunks of this size
memcache.chunk_size=8192
; The default TCP port number to use when connecting to the memcached server
memcache.default_port=11211
; Hash function {crc32, fnv}
memcache.hash_function=crc32
; Hash strategy {standard, consistent}
memcache.hash_strategy=standard

Restart apache webserver with /etc/init.d/httpd restart and write a phpinfo() file, now I can see memcache module is loaded

memcache-info

Anyone have the same error like I do and you have other workaround, please do let me know. Or change the permission on /etc/mtab :)

Need to get familiar with Linux Centos…

Kill Multiple Processes or PID on FreeBSD

Sometime I have problem killing all apache processes or PID on a high load web server even though the service has been stopped. One of the quick way to kill all the services is using ps command.


shell> ps ax | grep http
  795  ??  S      0:01.03 /usr/local/sbin/httpd -DSSL
 4280  ??  S      0:00.59 /usr/local/sbin/httpd -DSSL
 4796  ??  S      0:00.47 /usr/local/sbin/httpd -DSSL
 6219  ??  S      0:01.36 /usr/local/sbin/httpd -DSSL
10459  ??  S      0:01.34 /usr/local/sbin/httpd -DSSL
16048  ??  S      0:00.64 /usr/local/sbin/httpd -DSSL
16050  ??  S      0:00.43 /usr/local/sbin/httpd -DSSL
16562  ??  S      0:00.39 /usr/local/sbin/httpd -DSSL
19888  ??  S      0:00.47 /usr/local/sbin/httpd -DSSL
22362  ??  S      0:00.10 /usr/local/sbin/httpd -DSSL
92166  ??  Ss     0:49.08 /usr/local/sbin/httpd -DSSL
24972  p8  S+     0:00.00 grep http

Try to grep httpd processes which currently running on your server


shell> ps ax | grep http | awk '{print $1}'
795
4280
4796
6219
10459
16048
16050
16562
19888
22362
92166
24995

use awk command to grab the process IDs


shell> ps ax | grep http | awk '{print $1}' | xargs kill

using xrgs command to kill all the process ID we have gather earlier.

This is a handful command instead of killing the process ID one by one.
A clean kill.

Quick Screen Lock on Apple Mac OSX

mac-osx-leopard-available Locking your screen is critical when you are using your laptop in public or in the office, if you don’t lock your screen, within a second the data in your laptop might be owned by somebody who walk pass by your desk.

Does Apple Mac OSX support screen lock by keyboard shortcut key? I would say no, but you can do it with simple hacks.

Quick Screen Lock with Expose

One of my favorite screen lock method is through Expose. Before showing you how to lock the screen with Expose, you have to work on something at System Preferences.

Read the rest of this entry »

Star Wars ASCII Animation Through Telnet

Telnet to mail server port? telnet to web server port? telnet to domain name server port?

Why not telnet to watch Star Wars ASCII animation? Found this interesting stuff, An ASCII animation based on Star Wars created by Erik Thorne. Fire up your terminal and telnet the address as shown below. Before doing that, get a cup of coffee first ;)

Read the rest of this entry »