Eagle eye on CPU usage

How to monitor CPU usage and server load.

In shared hosting or cloud hosting monitoring CPU usage and high load is essential part.

What is server load and when it shall considered as overloaded ?

Server could get overload because of excessive usage of CPU / Disk and RAM. We will learn how to monitor and know there is high CPU usage on server. Generally server load upto 1 for a single CPU server indicates very stable server. Server load upto 5 means it is bit overload but still nothing to worry but above 5 there is something wrong and user need to watch server load closely.

Commands to check server load.

1: w


3: top -d2

If user have server with multiple CPUs then normal server load range would vary for him accordingly. Like for server with 4 CPUs very stable server load is 4 and upto 16 server bit overloaded and above 16 user need to take care of CPU usage. Another important factor should be considered while monitoring server load is CPU %idle.


Administrator shall check CPU %idle if it is more than 30% then it can sit and allow to run processes/applications on server without worrying about server load. If it is less than 30% then services/application running on server will become less responsive and that time he need find and fix processes causing high CPU usage.

How to check %idle CPU ?

use command sar -u 1 1 this will show you present status of idle CPU in following example it is 85% which means server is stable and all applications running on server and responding quickly.

To check historical CPU idle% use command sar -u . Below is script which you can add in cronjob to monitor idle CPU usage. This script will monitor average “idle CPU” for 3 mins. If it get less than 30% then it will send an email to you. I recommend to set cron job every after 10 mins.


sar -u 10 3 | grep Average | awk '{print $NF}' > idlecpu
idlecpu=`cat idlecpu | cut -d. -f1`
echo $idlecpu
if test $idlecpu -lt $critical
echo "CPU usage is high"
echo "Idle CPU is $idlecpu, this is critical. Timestamp `date` " | mail -s "Idle CPU % is less than 30" admin@midnight-cafe.com
if test $idlecpu -gt $critical
echo "CPU usage is okay"
echo "CPU usage is high"
echo "Idle CPU is $idlecpu, this is critical. Timestamp `date` " | mail -s "Idle CPU % is less than 30" admin@midnight-cafe.com
rm -f /home/idlecpu


Transfer Website from Weebly to WordPress

How to transfer a website from weebly to wordpress ?

Weebly is web designer software which make easy to design web site using weebly. But many advance web developer use wordpress CMS which provide more access to internal code. This is main reason people need to migrate site from weebly to wordpress.

But weebly doesn’t provide feature to export web site. There is a 3rd party tool named as WPBeginner weebly to wordpress site. We will learn in detail how to migrate using this tool.

Install WordPress

Setup new hosting account with your domain name (which is being used by weebly application). In order to install wordpress on the domain you don’t need to point dns of the domain to new hosting account. Instead just edit host file of your local PC and on last line add IP and domain in following format

IP-address-here yoursitename.com

This will point yoursitename.com to new IP (IP of new hosting account). Now install wordpress , and configure it like setting up theme, install required plugins for backup, security etc..and modify primary menu according to your original site requirement.

Migrate Content

Now we are ready to migrate data from weebly site to new wordpress site.

1: Visit url WeeblytoWP.com.

2: Insert your Weebly website URL (starting with HTTP:// or HTTPS://), name, and email account before clicking Export my Weebly Website.

3: Save the Export file.

4: In WordPress, after downloading your Weebly export file, select Tools and Import.

5: Select WordPress to install and activate the WordPress Import Plugin.

6: Select Run Importer at the top of the screen.

7: Browse for your RSS file before selecting Upload file and import.

8: Make any preferred changes on the Import Settings and assign an author to the imported posts. You can create an author or use an existing user.

The imported content should now show in their respective sections in WordPress.

Import Content Manually.

Many text and contents will not available in export file which will need to be copy manually. ie. Create page / post on your wordpress site and then copy text from weebly to wordpress pages/post and publish them.

Now time to Import images.

We recommend to use WordPress plugin. such as Save & Import Image from URL to import directly from Weebly. 

The easiest way to get an image URL:

For browser like Google Chrome: Right-click the image and select Open image in a new tab.

Fix Permalinks:

Now setting up Permalinks so that format of url’s of old website should match to new site’s url so that your user will not get 404 error while accessing urls using bookmarks. Also you will not need to submit urls for indexing. It can be set from WordPress > Wp-admin > Setting > Permalinks

rsync to copy difference

Rsync to copy difference of source and destination.

We use rsync command to copy files from source to destination. Rsync command sync modified/update files and newly created files on destination server.

But user need copy modified files and newly created files on source as compared to destination to be copied in separate folder.

I created 3 folders in /home as r1 r2 and r3. Then I touched 5 files named as 1 2 3 4 5 in r1 and r2 and r3 are empty.

Here source=/home/r1 destination=/home/r2 and difference=/home/r3

Output of ls -l for r1 r2 and r3 as given below:

[root@midnight home]# ls -l r1
total 0
-rw-r–r– 1 root root 0 Sep 17 01:30 1
-rw-r–r– 1 root root 0 Sep 17 01:30 2
-rw-r–r– 1 root root 0 Sep 17 01:30 3
-rw-r–r– 1 root root 0 Sep 17 01:30 4
-rw-r–r– 1 root root 0 Sep 17 01:30 5

[root@midnight home]# ls -l r2
total 0

[root@midnight home]# ls -l r3
total 0

Now. I will copy r1 to r2 and paste output.

rsync -va /home/r1/ /home/r2/

[root@midnight home]# rsync -va /home/r1/ /home/r2/
sending incremental file list

sent 306 bytes received 114 bytes 840.00 bytes/sec
total size is 0 speedup is 0.00

List all files from r2.

[root@midnight home]# ls -lt r2
total 0
-rw-r–r– 1 root root 0 Sep 17 01:30 1
-rw-r–r– 1 root root 0 Sep 17 01:30 2
-rw-r–r– 1 root root 0 Sep 17 01:30 3
-rw-r–r– 1 root root 0 Sep 17 01:30 4
-rw-r–r– 1 root root 0 Sep 17 01:30 5


Now let’s modify /home/r1/1 file and create two files as 6 and 7. And we need rsync to copy this modified file named as 1 and newly created file 6 & 7 to /home/r3 folder.

[root@midnight home]# rsync -aHxv –progress –compare-dest=/home/r2/ /home/r1/ /home/r3/
sending incremental file list
5 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=6/8)
0 100% 0.00kB/s 0:00:00 (xfr#2, to-chk=1/8)
0 100% 0.00kB/s 0:00:00 (xfr#3, to-chk=0/8)

sent 285 bytes received 81 bytes 732.00 bytes/sec
total size is 5 speedup is 0.01

Above command copied  modified and newly created files to folder r3

[root@midnight home]# ls -l /home/r3
total 4
-rw-r–r– 1 root root 5 Sep 17 01:36 1
-rw-r–r– 1 root root 0 Sep 17 01:36 6
-rw-r–r– 1 root root 0 Sep 17 01:36 7

Types of Webhosting

Types of webhosting.

There are mainly two types of web hosting 1: Managed hosting 2: Un-Managed hosting.

Managed hosting: Here, web hosting provider provide complete support. Even if client send email and ask them to create email account they will create email account for him.

Creating email account is very simple task client just need to login his cPanel account and Go to Email section and create account with few clicks. In un-manage hosting web hosting provider will reply you and ask to create it yourself 🙂

What are pros and cons of Managed hosting

1: Just email or initiate live chat and ask them to perform any smallest and easiest task.

2: Client can blame for any issue like downtime, site hacked or slow loading speed.

3: Client can get assistance to configure and install 3rd party applications like WordPress ,Joomla or any application which need manual installation.


1: Only one so far I noticed you need to pay almost double price every month even if you are managing site/server yourself.

Un-managed hosting pros.

1: Client get hosting at very low cost.


1: Client need to take care of his hosting.

2: Maintain backups, Install and configure applications.

3: Client need to learn all technical stuffs ie. optimizing server, services, applications he has installed.

Suggestion: If client want to run wordpress site and he is non-technical guy. Then he shall go for managed hosting once he learn how to download backup and upgrade applications and maintain his site then he can shift to un-managed hosting and save money.

Change rdp port number

How to change Remote desktop port ie. RDP port on windows server.

Hacker do have brute force script which try to access windows server using standard RDP port which is 3389. If you check logs on your windows server you will find Unauthorized persons tried to access server using standard RDP port hundreds of times from different country some times their attempt is more than 10000+ times in a day.

To secure server it is recommended to change standard port from 3389 to something else like 32000. You can choose any port which is not in use from range 1-65000.


How to change Remote desktop port. Start > Run > regedit > HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp\ > On right hand side search for PortNumber . Right click on portnumber > Modify > select decimal > It will show you default port 3389 . Change it to something else like 32000 and click okay.


Then go to start > Search  > Control panel > Windows firewall > On left hand side > Click on Advance Setting > Right click on Inbound Rules (Left hand side panel) > New Rule > Port > Check TCP and Specific port >  put 32000 > Next > check “Allow the connection > Next > Next > Name rule like Custom RDP port > Hit Finish.

Now more remote desktop connection application from start > Remote desktop connection > Enter Computer as Server-IP:32000. If your server IP is then put Computer as > Hit connect.



cPanel web hosting


cPanel Webhosting.

cPanel is most user friendly panel in web hosting. Most of the shared hosting provider , reseller, dedicated & cloud server use this panel to manage client’s site or their own site. Most important feature of cPanel is it provide lots of features like. Create email accounts, setting filters, forwarders, FTP accounts , Password protect folders etc…

For hosting provider it is very important to manage and monitor activities going on their server especially on shared server. Main advantage of shared hosting server is you can host lots of sites and oversell resources.

What is overselling. Suppose you have server with 16 CPUs, 300 GB disk, 10 TB (10240 GB) bandwidth and 32 GB RAM. Such server will cost provide around $200 per month. Here hosting provider will provide client basic plan like: 10 GB , and 100 GB bandwidth for $2. He would able to host such 500 Clients on his cPanel server because most of the client ie. 90% will not use even 10 GB bandwidth and 1 GB disk space while hosting a site. Also most of sites will have very low traffic in such case they will not be using even 1% of server’s total resources.

In this way shared hosting server would able to make $1000 per server costing him $200 including cPanel license.

I will write few more post about Web hosting business. Feel free to raise any question either technical or non-technical in comment or contact us form. I would glad to assist free of cost.

Block sites without firewall on windows

Block web sites without firewall on windows.

Here, we will learn on how to block web sites for your personal computer ie. outgoing traffic to a site. Make sites inaccessible via your window server/PC.

Here server either it is linux or windows has a hosts file. It map hostname to IP address. Suppose abc.com has IP and you don’t this site accessible using particular server.

You need to open hosts file using text editor as administrator.

Steps to open hosts file as administrator.

Click on windows > Start > search > notepad > Right click on notepad > Run as administrator.

Then click on file > open > Go to C:\Windows\System32\drivers\etc\hosts

Add following line in it. abc.com

This will route abc.com to for your server/PC. Since no such site hosted on your PC ( referred as your local IP) it will not load.

creating database without cpanel user prefix

Creating mysql user and database without cPanel user prefix.

By default cPanel used to create database and DB user with cPanel username _as prefix. But now cPanel version 68 allows you to disable prefixing so you can create single DBs and DB users.

You can enable disable prefix feature from

WHM > Tweak Setting >  Require a username prefix on names of new databases and database user

Example: If you create database with name wp as cPanel user india. It will create database as india_wp but if you disable this then it will allow you to create database with name wp only.

Access webalizer stats without login to cpanel

How to access webalizer stats without login to cpanel.

First login to cPanel > File manager > public_html > edit .htaccess.

Now create symlink for webalizer in public_html folder using following command.

ln -s ../tmp/webalizer webstats

chown username.username webstats

chmod 755 ../tmp/webalizer

Replace webstats with name you want in order to access your website statistics.
Change the owner to account user and permissions to 755.

You will need ssh access to create symlink.

If you don’t have ssh access . Then create php file in public_html and copy paste following code in it.


$target = ‘/home/cPanelusername/tmp/webalizer’;

$shortcut = ‘webstat’;

symlink($target, $shortcut);


Now, access it using browser. This will create symlink and you will able to access webalizer stats using url  yoursite.com/webstats .

You can remove php you created to generate symlink.