Plesk Monitoring

April 28, 2009

Parallels Plesk Panel 8.6 is running on FreeBSD.

The following error is shown when try to start Watchdog through {Modules -> Watchdog -> Enable}:

Error: The monit service does not respond. Refer to Parallels technical support for help.

The service cannot be started because of empty monitrc:

~# ls -l /usr/local/etc/psa/modules/watchdog/monitrc
-rwxrw—- 1 root psaadm 0 Nov 24 21:05 monitrc
~#

Which cannot be recreated since there are an error:

~# /usr/local/psa/admin/bin/modules/watchdog/wd –regen-all
/tmp/monitrc.chk:86: Error: the executable does not exist ‘mysql-server’
/tmp/monitrc.chk:87: Error: the executable does not exist ‘mysql-server’
Error occurred while building configuration file. For help, refer to technical
support.
~#

The problem is that full path to ‘mysql-server’ rc-script is not written:

~# tail +86 /tmp/monitrc.chk | head -3
with pidfile “/var/db/mysql/21.montereyinstitute.org.pid”
start = “mysql-server start”
stop = “mysql-server stop”
~#

Resolution
To resolve the problem in Parallels Plesk Panel 8.6 you should add full path to mysql in /usr/local/etc/psa/modules/watchdog/monitrc.tpl.
Save old file to monitrc.tpl.orig in the same directory:
~# cd /usr/local/etc/psa/modules/watchdog
~# cp monitrc.tpl monitrc.tpl.orig

Open file monitrc.tpl with file editor (vim) and find section “# MySQL check process mysql” in it. Change path to mysql starting scripts:

~# vi monitrc.tpl
~# diff monitrc.tpl.orig monitrc.tpl
87,88c87,88
< start = “”
< stop = “”

> start = “/usr/local/etc/rc.d/”
> stop = “/usr/local/etc/rc.d/”
~#

Save the file and recreate monitrc with command wd:

~# /usr/local/psa/admin/bin/modules/watchdog/wd –regen-all
Control file syntax OK
~#
After that service Watchdog should be started through {Modules -> Watchdog -> Enable}.

The problem does not exists for Parallels Plesk Panel 9.
Valid path to scripts mysql_start and mysql_stop is set in monitrc.tpl.


Inode Usage/ Find the user having high Inode usage

April 25, 2009

We can find the inode usage (Number of files) owned by each user/directory, especially useful in VPS. Each VPS will have inode limits (the maximum number of files that can be created in that VPS)

For example If the inode usage is 100 % then we needs to find out which user/directory has owned the maximum number of files.

[root@server]# df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/vzfs             800000  800000       0  100% /
simfs                 800000  800000       0  100% /tmp
simfs                 800000  800000       0  100% /var/tmp

Run the following commands

[root@server ~]# repquota -a | sort -nk6 | head

Block limits                File limits
*** Report for user quotas on device /dev/vzfs
———————————————————————-
Block grace time: 00:00; Inode grace time: 00:00
User            used    soft    hard  grace    used  soft  hard  grace
test1      +-   25816   25600   25600   none     663     0     0
test2     –       4       0       0              1     0     0
mail      –       4       0       0              1     0     0

In my case the user mailnull (the system user used by exim to store queued emails) owned maximum number of files as there were around 30000 emails in the mail queue. From the command output shown below the mailnull user has the inode usage of 89971.

[root@host ~]# repquota -a | sort -nk6 | tail
test10   –  375660 4096000 4096000          23463     0     0
test11     –  482460 1024000 1024000          28043     0     0
test12   –  652580 1024000 1024000          29378     0     0
test13  –  286200 4096000 4096000          33996     0     0
test14  –  591400  819200  819200          39027     0     0
test15    — 1528680       0       0          39027     0     0
test16    — 1941748 8192000 8192000          46401     0     0
test17    –  626240       0       0          58163     0     0
mailnull  — 1236324       0       0          89971     0     0
root      — 3563516       0       0         128345     0     0

[root@host ~]#exim -bpc
29930

After mailnull the next user who has owned maximum number of files is test17 (58163). Now need to find out which directory contains maximum number of files.

[root@host ~]# cd /home/test17
[root@host /home/test17]# for d in *; do echo -n “$d: “; find $d -type f | wc -l; done ( This script will display
the directory/file and count the number of files inside that directory )

access-logs: 0
backup-5.27.2008_12-50-20_test17.tar.gz: 1
etc: 6
file.txt: 1
logs: 0
mail: 3
moodledata: 523
public_ftp: 0
public_html: 43469
tmp: 54
www: 0

Here again public_html directory contains the maximum number of files.

[root@host /home/test17]#cd public_html
[root@host /home/test17/public_html]# for d in *; do echo -n “$d: “; find $d -type f | wc -l; done | sort -nk2 | tail -5

x_bck: 4576
x4: 4630
x5: 4680
x6: 4788
x7: 14823

Finally the directory x7 contains the maximum number of files (inodes).

Similarly by using this method we can find out which user/directory owns the maximum number of files in any linux server.

This command might be helpful to you in finding the folder using a great part of the inodes. It outputs the top 5 file system objects utilizing the most inodes in the current folder:

for i in `ls -1A`; do echo "`find $i | sort -u | wc -l` $i"; done | sort -rn | head -5


Upgrade ClamAV to 0.95

April 1, 2009

I’ve noticed that cPanel’s update system doesn’t bother to upgrade clamAV so here is a quick upgrading guide taken from http://www.configserver.com/cp/upgrade.html

  • Download the latest stable ClamAV distribution from http://www.clamav.net (http://www.clamav.net/download/sources)
  • Expand the distribution and cd into the resultant directory and build ClamAV using: tar -xzf clamav-*

cd clamav*

./configure –disable-zlib-vcheck

make

make install

replace “Example” “#Example” — /usr/local/etc/freshclam.conf

replace “Example” “#Example” — /usr/local/etc/clamd.conf

  • Run freshclam to download the latest definitions: freshclam
  • If you’re using the clamavmodule, check you have the latest version installed: /scripts/perlinstaller Mail::ClamAV