July 17, 2010 | Posted by
admin | Category: Plesk Management
Plesk uses a ‘psa’ database to store all the data and values. This data can be easily retrieved at any point of time using the Mysql queries.
How to access the Plesk ‘psa’ database in Linux?
There are 2 ways, one via SSH (Linux command line) and the other from the Plesk control panel.
Method 1)
SSH to your server as root and execute the following command. The /etc/psa/.psa.shadow file contains the Plesk admin password.
# mysql -uadmin -p`cat /etc/psa/.psa.shadow`
You will be connected to the Mysql server. To use psa database, execute
mysql> use psa;
To view all the psa database tables:
mysql> show tables;
Method 2)
Login to the Plesk control panel as user admin
Goto Settings -> Database Hosting Preferences -> click OK ->
Local MySQL server -> Databases tab -> click Webadmin.
Once you click “Webadmin”, phpMyAdmin will open in a new window from where you can access all the databases including the ‘psa’ database. Make sure pop-ups are enabled in your browser.
Comments Off on How to access psa database in Plesk?
July 15, 2010 | Posted by
admin | Category: Plesk Management
What is http compression and which module to use for http compression?
Compressing data before transmitting to the browsers and then uncompressing the data before displaying. The module that is responsible for http compression is called mod_deflate.The main advantage of mod_deflate is that it saves a lot of bandwidth and loads the pages faster.
On a Plesk server, the mod_deflate module is installed by default, however it may be disabled in the Apache configuration file. To enable the mod_deflate module in Plesk edit the Apache configuration file
# vi /etc/httpd/conf/httpd.conf
Search the line that says,
#LoadModule deflate_module modules/mod_deflate.so
and uncomment it i.e. remove the ‘#’ mark
LoadModule deflate_module modules/mod_deflate.so
Now, create a /etc/httpd/conf.d/deflate.conf file. Apache reads all the .conf files from the /etc/httpd/conf.d directory on a Plesk server.
# vi /etc/httpd/conf.d/deflate.conf
and place the following code in it
<Location />
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
</Location>
Save the file and restart Apache.
# service httpd restart
This compression code will compress all the files except the .gif, .jpe, .jpeg and .png files before sending them to the browser. To test the compression, use the tool
http://www.whatsmyip.org/mod_gzip_test/
To enable compression for a specific directory or domain, specify the directory path in the <Location> directive in deflate.conf and restart the Apache server.
Related URLs:
Enable http compression on a Plain Linux server
July 10, 2010 | Posted by
admin | Category: Scripts
Load Average on a server reflects the current state of the server. Higher the load average, poorer is the server performance hence it is a necessity to monitor the load average on the server.
The following shell script monitors the load average on the Linux server and inform the server administrator with the load average and the process that are running if the load average is greater than the defined threshold.
Create a file, say, /root/monit_loadaverage.sh and paste the following script in it:
############### START OF THE SCRIPT ###############
#!/bin/bash
# Define Variables
CUR_TIME=`date +"%A %b %e %r"`
HOSTNAME=`hostname`
# Retrieve the load average of the past 1 minute
Load_AVG=`uptime | cut -d'l' -f2 | awk '{print $3}' | cut -d. -f1`
LOAD_CUR=`uptime | cut -d'l' -f2 | awk '{print $3 " " $4 " " $5}'\
| sed 's/,//'`
# Define Threshold. This value will be compared with the current
# load average. Set the value as per your wish.
LIMIT=5
# Compare the current load average with the Threshold value and
# email the server administrator if the current load average
# is greater.
if [ $Load_AVG -gt $LIMIT ]
then
#Save the current running processes in a file
/bin/ps auxf >> /root/ps_output
# Save the other values in a file
echo "Current Time :: $CUR_TIME" >> /tmp/monitload.txt
echo "Current Load Average :: $LOAD_CUR" >> /tmp/monitload.txt
echo "The list of current processes is attached\
with the email for your reference." >> /tmp/monitload.txt
echo "Please Check... ASAP." >> /tmp/monitload.txt
# Send an email to the administrator of the server
/usr/bin/mutt -s "ALERT!!! High 1 minute load average\
on '$HOSTNAME'" -a /root/ps_output youremail@youremail.com <\
/tmp/monitload.txt
fi
# Remove the temporary log files
/bin/rm -f /tmp/monitload.txt
/bin/rm -f /root/ps_output
############### END OF THE SCRIPT ###############
Make sure you replace the Treshold (LIMIT) value and your email address with your own values in the script.
Now, schedule a cronjob to execute the script on per minute basis. Edit the cronjob file
# crontab -e
and place the following cronjob at the end of the file
* * * * * /bin/sh /root/monit_loadaverage.sh
restart the crond service
# service crond restart
In order to use “mutt” to send emails, you need to install the mutt package on the server. It allows you to send emails with attachments.
# yum install mutt
Note: Please place a comment if you receive any error message while executing this script OR you need some modifications in the script.
July 4, 2010 | Posted by
admin | Category: VPS Management
If a VPS doesn’t come online after the host server is rebooted, it is due to the “ONBOOT” parameter of the VPS is set to NO in the VPS configuration file. This parameter decides whether to start the VPS automatically if the host server is restarted.
If it's set to 'yes', the VPS will start automatically.
If it's set to 'no', we will have to start the VPS manually.
To make the changes, edit the VPS configuration file
vi /etc/sysconfig/vz-scripts/VEID.conf
search for
ONBOOT="no"
and change to
ONBOOT="yes"
This change will auto-start the VPS next time the host node is rebooted.
Comments Off on How to auto-start a VPS on a host server/node reboot?
June 29, 2010 | Posted by
admin | Category: cPanel Management
Sometimes it is necessary to monitor a crond service itself on a cPanel server. cPanel offers ‘chkservd’ (a monitoring daemon) that monitors the services that are included in it and restarts them if they are found offline.
However, cPanel do not provide an option to include the ‘crond’ service under chkservd. The following method can be used to add crond service under chkservd.
Create a crond file under the chkservd.d directory where the files of all the services are placed:
# pico /etc/chkserv.d/crond
Add the following and save the file:
service[crond]=x,x,x,/etc/init.d/crond restart,crond,root
Now you need to edit the chkservd configuration file and enable the crond service for monitoring
# pico /etc/chkserv.d/chkservd.conf
add the following line at the end of the file
crond:1
Now, save the file and restart the chkservd service for the new changes to take affect:
# /scripts/restartsrv chkservd
In order to verify if chkservd auto-restarts the crond service if it is offline, stop the service manually
# service crond stop
and watch the chkservd logs
# tail -f /var/log/chkservd.log
You will notice that the crond service is restarted automatically within 5 minutes.
Comments Off on How to monitor and auto restart cron service using cPanel chkservd?