Linux: Remove WHM Disk Warning

cpanel_logo

 

There are many times I am seeing the error below when accessing to the WHM.

Sorry for the inconvenience!
The filesystem mounted at / on this server is running out of disk space. cPanel operations have been temporarily suspended to prevent something bad from happening. Please ask your system admin to remove any files not in use on that partition.

And even after I have cleared the disk space from the server, WHM doesn’t allow me to access to WHM interface.

To get this issue fixed, you may remove the following files and retry again,

/root/.cpanel/datastore/_bin_df_-P_-k_-l

Linux/MySQL: Find all database using innodb engine

mysql

 

If you are the Linux administrator that using full backup of your account, you will find out that the MySQL database full backup couldn’t help to restore your database.

Hence, you might want to schedule a full mysqldump backup for those databases that using the innodb engine.

To show all of your databases that using innodb engine, you may use the following command,

# mysql -N mysql -e "SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE engine = 'innodb';" | awk '{print $1}' | sort | uniq

SED Cheatsheet

bash

 

Some useful cheatsheet for sed:-

sed ‘2d’ file.txt Remove second line from file.txt
sed ‘/mickgenie/d’ file.txt Remove the line containing the word/string mickgenie from file.txt
sed ‘$d’ file.txt Remove last line from file.txt
sed ‘/^$/d’ file.txt Remove empty line from file.txt
sed ‘1,5d’ file.txt Remove line between 1 and 5 from file.txt

exim: Check current PHP Script Spam process

exim-logo

 

This post is very useful for those System Administrator or System Engineer who wish to monitor over hundred of servers which could get the spamming PHP script immediately from your server.

The following example was written based on cPanel exim4 and you may stored them in a .sh file.

Continue reading exim: Check current PHP Script Spam process

Linux epoch time conversion

tuxclock

In Linux or database, many time is display in epoch format, and human might not understand what is the exact time for it. However, you may easily convert them through Linux command.

To convert from digital to epoch format,

# date +%s

To convert from epoch to digital format,

# date [email protected]

Howto: Clear Swap Cache

Recently I’ve wrote a script to calculate the swap usage and triggered the alert when Swap usage hit the certain level.

And I found out the actual memory usage is not using as it is where swap still caching the usage. To clear the swap cache and make the memory usage only, you may turn of swap by selecting the swap drive.

First of all, you need to identify the swap disk. Check the blkid for more information.

blkid

Look at the entry of swap. Assume swap is in sda5.

Turn the swap cache off,

swapoff /dev/sda5

Once it is done, turn on again,

swapon /dev/sda5

Linux: Sysstat (sar)

The sar utility which is use monitor the history system performance data on your system.

To use the sar command, simply enter sar from the system,

# sar

To check the memory statistic,

# sar -r

To check the disk statistic,

# sar -d

To check network statistic,

# sar -n

To check processor statistic,

# sar -P ALL

To check certain date statistic let say 8th of the month

# sar -f /var/log/sa/sar09

Linux: Command to check Perl Modules

instmodsh, a shell to examine installed modules. Used to easily list all the installed module from your server/PC.

[email protected] [~]# instmodsh
Available commands are:
   l            - List all installed modules
   m <module>   - Select a module
   q            - Quit the program
cmd?

By hitting ‘l’, it will show you the list of installed module,

cmd? l
Installed modules are:
   Acme::Spork
   Apache::Admin::Config
   AppConfig
   Archive::Tar
   Archive::Tar::Streamed
   Archive::Zip
   Attribute::Handlers
   Authen::Libwrap
   Authen::SASL
   BSD::Resource
   Bundle::Interchange
   Business::OnlinePayment
   Business::OnlinePayment::AuthorizeNet
   Business::UPS
...
...

 

Howto: Install PDFlib-Lite and PDFlib on Centos server

To install PDFlib on Centos server, you may follow the guide below,

1. Download the PDFlib-Lite package,

cd /usr/local/src 
wget http://www.pdflib.com/binaries/PDFlib/705/PDFlib-Lite-7.0.5.tar

2. Extract and go to PDFlib-Lite folder,

tar -zxvf PDFlib-Lite-7-* 
cd PDFlib-Lite-7.0*

3. Configure PDFlib-Lite,

./configure --prefix=/usr/local

4. Create installation file and install it,

make
make install

5. Once PDFlib-Lite installed, download PDFlib with PECL,

pecl download pdflib

6. Extract and enter the folder,

tar xvzf pdflib-*.tgz 
cd pdflib-*

7. Create configuration file,

phpize

8. Configure, create configuration file and install PDFlib,

./configure
make
make install

9. A pdf.so will be created in your PHP extension folder, check it from PHP info,

php -i | grep extension_dir

10. If it is not exists, add the following line to the php.ini,

extension="pdf.so"