Archive

Archive for the ‘Unix / Linux’ Category

PHP OPCodes Cached with APC – part 1

October 21st, 2009 Ali Abbas No comments

There are many caching system in use to optimize the execution of PHP script on busy web/database servers. Today we will focus on the OPcode caching method using APC.

Before we start… what is an OPcode?

The OPcode is an executable code generated each time a PHP script is interpreted and compiled. Each time you visit a webpage, the webserver (apache for example) would generate an OPcode of the PHP script serving your request. They are therefore simply C data structure which are interpreted by the PHP Virtual Machine (Zend Engine).

Now you can imagine, generating the OPcode can be a drain on the server and quite useless if the code does not change often. This is where the OPcode caching system comes into play; but before we go on, let’s see some OPcode example using the Vulcan Logic Disassembler.

First, we create a file test.php in which we will execute a unix ls -l command

test.php – <? system(“ls -l”); ?>

wrk01:/var/www# php -d vld.active=1 test.php
Branch analysis from position: 0
Return found
filename:       /var/www/test.php
function name:  (null)
number of ops:  4
compiled vars:  none
line     #  op                           fetch          ext  return  operands
——————————————————————————-
2     0  SEND_VAL                                                 ‘ls+-l’
1  DO_FCALL                                      1          ‘system’
4     2  RETURN                                                   1
3* ZEND_HANDLE_EXCEPTION

Now let’s try a simple ( echo “hello world!” ) Read more…

Categories: LAMP, Unix / Linux

mcelog – monitor hardware issues

October 17th, 2009 Ali Abbas No comments

It is often the case to receive a call in the middle of the night or walk into the office and find out a server which failed due to hardware problems.

What is mcelog?

From the project site description

mcelog decodes machine check events (hardware errors) on x86-64 machines running a 64-bit Linux kernel. It should be run regularly as a cron job on any x86-64 Linux system (if it is not in the default packages on your x86-64 distribution, please complain to your distributor). It can also decode machine check panic messages from console logs.

Now before we go on, it is important to understand what MCE is

MCE stands for Machine Check Exception, which is nothing but an AMD/Intel 64bit feature that allows to detect unrecoverable hardware problem such as “Communication errors between the motherboard and the CPU, CPU cache errors, Memory ECC erros etc..”

A common MCE log error would look like this

CPU 0: Machine Check Exception: 0000000400000000<0>
fault: 0000
CPU: 0
EIP: 0010:[mcheck_fault+225/336]
EFLAGS: 00010246
eax: 00000115 ebx: 72000000 ecx: 00000405 edx: 72000000
esi: 00000004 edi: 00000003 ebp: 00000115 esp: c3187f94
ds: 0018 es: 0018 ss: 0018

A program like syslogd will write the message to the console or to the kernel log; if the machine crashes, then only to the console.

mcelog will therefore “decode” those machine event errors, which are saved in the special kernel buffer /dev/mcelog.

Work with mcelog

mcelog should be run as a cron

/usr/sbin/mcelog –generic –ignorenodev –filter >> /var/log/mcelog

Make sure to check the man page of mcelog for all the options.

I would recommend setting up a script to email you in case of alerts or even why not “pipe your mcelog through a socket

That’s it. Hopefully from now, you can catch system, hardware errors before a kernel panic :-)

Cheers,

Categories: Unix / Linux

qtcreator-collec2-ld-returned-1-exit-status

September 14th, 2009 Ali Abbas No comments

When facing this error…

manually cd into the project QT folder and run “make”… ld would return the library name it isn’t able to locate.

Example:

ali@laptop:~/Documents/Dev/QT-Progs/Test$ make
g++ -Wl,-rpath,/opt/qtsdk-2009.03/qt/lib -o Test main.o testhello.o moc_testhello.o    -L/opt/qtsdk-2009.03/qt/lib -lQtGui -L/opt/qtsdk-2009.03/qt/lib -L/usr/X11R6/lib -pthread -lfreetype -lgobject-2.0 -lSM -lICE -pthread -pthread -lXrender -lfontconfig -lXext -lX11 -lQtCore -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
/usr/bin/ld: cannot find -lfreetype
collect2: ld returned 1 exit status
make: *** [Test] Error 1

Note the “cannot find -lfreetype”.. now note it can be any other library, depending on your current system configuration.

In most cases, install the devel package associated with this library.

Debian/Ubuntu “apt-get install libfreetype6-dev” for example.

Now, re-run the “make” and observe for further errors…

Categories: Unix / Linux

How to install Acrobat Reader on Centos

June 17th, 2009 Ali Abbas 2 comments

1. go to acrobat.com/reader

2. download the bin linux install file

3. chmod +x AdbeRdr9.1.1-1_i486linux_enu.bin

4. ./AdbeRdr9.1.1-1_i486linux_enu.bin

Extracting files, please wait. (This may take a while depending on the configuration of your machine)

This installation requires 144 MB of free disk space.

Enter installation directory for Adobe Reader 9.1.1 [/opt]

(press enter)

The installation will therefore go on

Installing platform independent files … Done
Installing platform dependent files … Done
Setting up libraries … Done
Setting up desktop and menu icons … Done
Setting up the browser plugin … Done

And that’s it

Categories: Redhat/Centos

How to change sudo cache timeout

May 19th, 2009 Ali Abbas No comments

For those who wishes to change the sudo cache timeout for a specific user, let’s userA

sudo visudo or (su – then visudo)

Defaults:userA timestamp_timeout=20

We have now set the sudo timeout “password-less” prompt to 20mn, to make it infinite set it to -1

If for some reasons you have it set it to 20 or -1 and wish to re-enable the password prompt, simple type sudo -K

** remember even after a reboot, the sudo cache would still persist if it is of course in its timeout grace time.

Have a look in /var/run/sudo/userA/ and it will all be clear :)

I hope that was informative :)

Categories: Unix / Linux