Thursday, September 30, 2010

How to integrate tomcat with apache on cpanel linux server?

Guys,

I didn't configure it but I am making it more available in the internet so that you can easily get the link and steps. Hope it'll help you to do the same. Here are the steps :

=======
1- Configure PATH
- vi or pico -w /etc/profile
- Add those lines after the first comments
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

JAVA_HOME=/usr/local/java/java
CATALINA_HOME=/usr/local/tomcat
PATH=$JAVA_HOME/bin:$PATH:$HOME/bin:/sbin:/usr/sbin
CLASSPATH=$CATALINA_HOME/bin/bootstrap.jar:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/common/lib/servlet.jar:/usr/local/pgsql/share/java/postgresql.jar:../lib/struts.jar:.

- Locate the line where you see export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC and add : JAVA_HOME CATALINA_HOME CLASSPATH


2- Download SDK at http://java.sun.com/j2se/1.4.2/download.html (j2sdk-1_4_2_03-linux-i586.bin)

3- Install java SDK
- mkdir /usr/local/java
- cd /usr/local/java
- chmod u+x j2sdk-version.bin
- ./j2sdk-version.bin
- ln -s j2sdk-version java
JAVA is installed under /usr/local/java/java/

4- Download Jakarta Tomcat at http://apache.mirror.mcgill.ca/jakarta/tomcat-4/v4.1.30/bin/jakarta-tomcat-4.1.30.tar.gz

5- Install Tomcat
- tar -zxvf jakarta-tomcat-4.1.30.tar.gz
- mv jakarta-tomcat-4.1.30 /usr/local/
- cd /usr/local
- ln -s jakarta-tomcat-4.1.30 tomcat
Tomcat is installed under /usr/local/tomcat/

6- Download Jakarta ANT at http://apache.mirror.cygnal.ca/ant/binaries/apache-ant-1.6.1-bin.tar.gz

7- Install Jakarta ANT
- tar -zxvf apache-ant-1.6.1-bin.tar.gz
- mv apache-ant-1.6.1 /usr/local/
- cd /usr/local
- ln -s apache-ant-1.6.1 ant
- ln -s /usr/local/ant/bin/ant /usr/local/bin/ant
- ln -s /usr/local/ant/bin/ant /usr/sbin/

8- Download the Java Connector from CVS and build / install mod_jk
- cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login password: anoncvs (When prompted for a password, just hit ENTER)
- cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic checkout jakarta-tomcat-connectors
- mv jakarta-tomcat-connectors /usr/local/java/
- cd /usr/local/java/jakarta-tomcat-connectors/jk/native/
- ./buildconf.sh
- ./configure --with-apxs=/usr/sbin/apxs
- make
- cp apache-1.3/mod_jk.so /etc/httpd/modules/

9- Configure httpd.conf for mod_jk
- Doing a backup : cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
- Enabling mod_jk : vi or pico -w /etc/httpd/conf/httpd.conf
After this line :
LoadModule perl_module /usr/lib/apache/libperl.so

Add :
LoadModule jk_module /usr/lib/apache/mod_jk.so

After your last AddModule line, add :
AddModule mod_jk.c

Include "/usr/local/jakarta-tomcat-4.1.30/conf/mod_jk.conf"

10- Edit/Create /usr/local/jakarta-tomcat-4.1.30/conf/mod_jk.conf
- vi or pico -w /usr/local/jakarta-tomcat-4.1.30/conf/mod_jk.conf
- Enter those lines :


LoadModule jk_module /usr/lib/apache/mod_jk.so


JkWorkersFile "/usr/local/jakarta-tomcat-4.1.30/conf/jk/workers.properties"
JkLogFile "/usr/local/jakarta-tomcat-4.1.30/logs/mod_jk.log"


JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
JkMount /*.do ajp13
JkMount /manager/* ajp13


JkLogLevel emerg

11- Edit/Create /usr/local/jakarta-tomcat-4.1.30/conf/jk/workers.properties
- mkdir /usr/local/jakarta-tomcat-4.1.30/conf/jk
- vi or pico -w /usr/local/jakarta-tomcat-4.1.30/conf/jk/workers.properties
- Enter those lines :

# Setting Tomcat & Java Home
workers.tomcat_home=/usr/local/tomcat
workers.java_home=/usr/local/java/java
ps=/
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13

12- Edit /usr/local/jakarta-tomcat-4.1.30/conf/server.xml
cd /usr/local/jakarta-tomcat-4.1.30/conf/
rm -f server.xml
vi or pico -w server.xml
Copy - Past text below :










some-site.com








13- Edit /usr/local/jakarta-tomcat-4.1.30/conf/tomcat-users.xml







14- Download and install the tomcatd script
- Download the script at http://www.linuxjava.net/howto/webapp/install_files/tomcatd
- mv tomcatd /usr/sbin
- chmod 700 /usr/sbin/tomcatd
- vi or pico -w /usr/sbin/tomcatd
- Locate any lines that contain the text : su - tomcat -c $TOMCAT_START and replace it by : $TOMCAT_START

15- FINISH !! START TOMCAT AND TEST IT :)
- service httpd restart
- tomcatd start
=======

Ref : http://www.directadmin.com/forum/archive/index.php/t-2227.html

Try :)

Wednesday, September 29, 2010

How install MRTG on linux?

Guys,

The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network links. MRTG generates HTML pages containing PNG images which provide a LIVE visual representation of this traffic.

Here are the steps those I followed :

====
Installing Library zlib :

................
wget http://www.gzip.org/zlib/zlib-1.1.4.tar.gz
tar -xvzf zlib-1.1.4.tar.gz
mv zlib-1.1.4 zlib
cd zlib
./configure
make
cd ..
................

Installing Library libpng :

................
wget http://public.planetmirror.com/pub/sourceforge/l/li/libpng/libpng-1.0.15.tar.gz
tar -xvzf libpng-1.0.15.tar.g
mv libpng-1.0.15 libpng
cd libpng
make -f scripts/makefile.std CC=gcc ZLIBLIB=../zlib ZLIBINC=../zlib
cd ..
................

Installing Library gd :

................
wget http://www.boutell.com/gd/http/gd-1.8.4.tar.gz
tar -xvzf gd-1.8.4.tar.gz
mv gd-1.8.4 gd
cd gd

perl -i~ -p -e s/gd_jpeg.o//g Makefile
make INCLUDEDIRS="-I. -I../zlib -I../libpng" \
LIBDIRS="-L../zlib -L. -L../libpng" \
LIBS="-lgd -lpng -lz -lm" \
CFLAGS="-O -DHAVE_LIBPNG"
cd ..
................

Installing MRTG:

.................
cd /usr/local/src
wget http://oss.oetiker.ch/mrtg/pub/mrtg-2.15.0.tar.gz
gunzip -c mrtg-2.15.0.tar.gz | tar xvf -
cd mrtg-2.15.0
./configure --prefix=/usr/local/mrtg-2 \
--with-gd=/usr/local/src/gd \
--with-z=/usr/local/src/zlib \
--with-png=/usr/local/src/libpng
make
make install
.................

Configuration :-

..................
cd /usr/local/src/mrtg-2.15.0/bin

cfgmaker --global 'WorkDir: /home/yourusername/public_html/mrtg' \
--global 'Options[_]: bits,growright' \
--output /usr/local/mrtg-2/mrtg.cfg \
public@localserver
..................

setup cron :

*/5 * * * * root "env LANG=C /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/mrtg.cfg" --logging /var/log/mrtg.log

View the MRTG :

htpp://domain/mrtg

That's it. try :)

Monday, September 27, 2010

make: *** [install-webconf] Error 1

Guys,

I got this error message during configuring the nagios : Here is the exact error message.

=======
root@server [/usr/local/src/nagios-3.2.1]# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf
/etc/httpd/conf.d/nagios.conf
/usr/bin/install: cannot create regular file `/etc/httpd/conf.d/nagios.conf':
No such file or directory
make: *** [install-webconf] Error 1
=======

Sol: As per the error message it's clear that nagios is trying to create the nagios.conf file inside the /etc/httpd.conf file. So, to resolve this problem, please make a sysmlink with the current conf.d directory of httpd daemon. Here are the steps those I followed.

1. Grep httpd daemon :

root@server [/usr/local/nagios/etc]# ps aux | grep httpd
root 6900 0.0 0.0 4204 624 pts/1 S+ 00:12 0:00 grep httpd
root 25825 0.0 0.3 17400 7520 ? Ss Sep27 0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody 25826 0.0 0.2 16768 5152 ? S Sep27 0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody 25828 0.0 0.5 239148 10804 ? Sl Sep27 0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody 25830 0.0 0.5 239012 10732 ? Sl Sep27 0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody 25832 0.0 0.5 239284 10920 ? Sl Sep27 0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody 25852 0.0 0.5 239148 10768 ? Sl Sep27 0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody 25874 0.0 0.5 239148 10772 ? Sl Sep27 0:00 /usr/local/apache/bin/httpd -k start -DSSL
root@server [/usr/local/nagios/etc]#

2. Find Document root of apache or httpd :
root@server [/usr/local/nagios/etc]# /usr/local/apache/bin/httpd -V |grep HTTPD_ROOT
-D HTTPD_ROOT="/usr/local/apache"

3. Make a symlink like :
root@server [/usr/local/nagios/etc]# ln -s /etc/httpd/conf.d /usr/local/apache/conf.d

That's it. Try to re-execute above failed command. It'll work :)

How to install nagios on cpanel or linux server?

Guys,

Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes.

Nagios is an open source application that monitors for computer network problems so that they can be fixed more quickly. Nagios was designed for use with the Linux operating system, but it will also work under Unix and most Unix-based systems.

Nagios runs periodic checks on user-specified resources and services. Resources that can be monitored include memory usage, disk usage, microprocessor load, the number of currently running processes, and log files. Services that can be monitored include Simple Mail Transfer Protocol (SMTP), Post Office Protocol 3 (POP3), Hypertext Transfer Protocol (HTTP), and other common network protocols. The program can monitor environmental variables such as temperature, humidity, or barometric pressure in conjunction with the appropriate measuring hardware. A user-friendly Web-based graphical user interface is provided. An authorization system allows the administrator to restrict access as necessary.

I have referred following steps to install and configure the nagios.

Before proceeding to mention the steps let me tell some points. Here I have installed nagios on monitoring server. So, this server will monitor other remote servers. Here are the required tools for them.

[A] For monitoring server(Who will monitor others) : a)nagios b) nagios-plugin c) nrpe daemon
[B] For monitored remote server(who will be monitored) : a) nagios-plugin c) nrpe daemon
[C] Configuring monitoring server to monitor remote hosts.


Let IP of monitoring server is 64.34.203.8. and 76.74.238.165 is the IP of remote server.

Now please make it sure that following packages has installed on the server.

-------
php-mysql php-gd php-ldap php-xml gd gd-devel gcc glibc glibc-common libstdc++-devel gcc-c++perl-DBI perl-DBD-MySQL perl-Config-IniFiles rrdtool perl-rrdtool

Note : For cpanel server all the modules might have installed. You can also enable them using /scripts/easyapache or yum install mod_name
-------
============================================================================

I am mentioning step by step here :

[A] Installing and configuring the monitoring tools on monitoring server(Who will monitor others) : a)nagios b) nagios-plugin c) nrpe daemon :-

a)nagios :-

------------------
1. Login into the server via ssh and gain root access.
2. useradd nagios
3. passwd nagios
4. groupadd nagcmd
5. /usr/sbin/usermod -a -G nagcmd nagios
6. /usr/sbin/usermod -a -G nagcmd nobody

Note : here nobody is the apache user on my server(cpanel linux server). You can get the user by executing the following command :

root@server [/usr/local/src]# grep '^User' /usr/local/apache/conf/httpd.conf
User nobody
UserDir public_html
root@server [/usr/local/src]#

7. cd /usr/local/src/
8. wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz
9. tar -xvzf nagios-3.2.1.tar.gz
10. cd nagios-3.2.1
11. ./configure --with-command-group=nagcmd
12. make all
13. make install
14. make install-init
15. make install-config
16. make install-commandmode
17. make install-webconf

Note: During executing "make install-webconf" you'll face following error message.

``````````````````````````````````````````````````````````
root@server [/usr/local/src/nagios-3.2.1]# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf
/etc/httpd/conf.d/nagios.conf
/usr/bin/install: cannot create regular file `/etc/httpd/conf.d/nagios.conf':
No such file or directory
make: *** [install-webconf] Error 1

I hope you got the clue from this error message. So, please make a directory and link with cpanel apache conf.d like :

root@server [/usr/local/src/nagios-3.2.1]# mkdir -p /etc/httpd/conf.d
root@server [/usr/local/src/nagios-3.2.1]# ln -s /etc/httpd/conf.d /usr/local/apache/conf.d

Then execute the above webconf once again. It'll create nagios.conf file in that conf.d directory. That's it. This is for integrating the nagios with webserver.
``````````````````````````````````````````````````````````

18. htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin //provide password here.

That's it for nagios. For my case here are the content in conf.d

````````
root@server [/etc/httpd/conf.d]# ll
total 12
drwxr-xr-x 2 root root 4096 Sep 26 23:22 ./
drwxr-xr-x 18 root root 4096 Sep 26 23:17 ../
lrwxrwxrwx 1 root root 6 Sep 26 23:20 conf.d -> conf.d
-rw-r--r-- 1 root root 1010 Sep 26 23:22 nagios.conf
root@server [/etc/httpd/conf.d]#
````````

===================================

b) nagios-plugin installation :-

1. cd /usr/local/src/
2. wget wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-
plugins-1.4.11.tar.gz
3. tar -xvzf nagios-plugins-1.4.11.tar.gz
4. cd nagios-plugins-1.4.11
5. ./configure --with-nagios-user=nagios --with-nagio-group=nagios
6. make
7. make install
8. chkconfig --add nagios
9. chkconfig nagios on
10. chown nagios.nagios /usr/local/nagios
11. chown -R nagios.nagios /usr/local/nagios/libexec
12. /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

````````````````
10th command will check the configuration whether it's correct or not. If it's correct it'll show following :
..............
Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight
check

If there is no error it means your nagios configuration is correct and you can
start nagios service.
.............

`````````````````

13. /etc/init.d/nagios start
14. ps aux | grep nagios //check whether nagios is running or not.

that's it for nagios plugin :)

===================================

c) nrpe daemon installation : --

1. cd /usr/local/src/
2. wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
3. tar -xvzf nrpe-2.12.tar.gz
4. cd nrpe-2.12

......
Make sure openssl-devel has installed on the server. Check like

root@server [/usr/local/src/nrpe-2.12]# rpm -qa | grep openssl-devel
openssl-devel-0.9.8e-12.el5_4.6
root@server [/usr/local/src/nrpe-2.12]#

Else execute : yum install openssl*
......

5. ./configure
6. make all
7. make install-plugin
8. make install-daemon
9. make install-daemon-config
10. make install-xinetd

.......
Note : Make sure that xinetd has installed on the server. Else install it like yum install xinetd
.......

11. vi /etc/xinetd.d/nrpe and disable “only_from” directive. So, the content of the file will look like :

.......
root@server [~]# cat /etc/xinetd.d/nrpe
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
# only_from = 127.0.0.1
}
root@server [~]#
.......

12. echo "nrpe 5666/tcp # NRPE" >> /etc/services
13. Make it sure that you have opened the above port at the firewall.
14. chkconfig xinetd on
15. service xinetd restart

op will be like :

.....
root@server [/usr/local/src/nrpe-2.12]# chkconfig --list | grep xinetd
xinetd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
xinetd based services:
root@server [/usr/local/src/nrpe-2.12]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
root@server [/usr/local/src/nrpe-2.12]#
.....

That's it.

Test the NRPE daemon locally :

16. netstat -at | grep nrpe

Here is the o/p :
........
tcp 0 0 *:nrpe *:* LISTEN

root@server [/usr/local/src/nrpe-2.12]# netstat -plan | grep 5666
tcp 0 0 0.0.0.0:5666 0.0.0.0:*
LISTEN 31130/xinetd
root@server [/usr/local/src/nrpe-2.12]#
........

17. /usr/local/nagios/libexec/check_nrpe -H localhost

Here is the o/p :

........
root@server [/usr/local/src/nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.12
root@server [/usr/local/src/nrpe-2.12]#
........

===================================
==========================================================================================

[B] Installing and configuring the monitoring tools on monitored server (who will be monitored) : a) nagios-plugin c) nrpe daemon :----

Login into the remote server via ssh and gain root access.

a) : nagios-plugin installation :

1. cd /usr/local/src/
2. /usr/sbin/useradd nagios
3. passwd nagios
4. wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
5. tar -xvzf nagios-plugins-1.4.15.tar.gz
6. cd nagios-plugins-1.4.15
7. ./configure
8. make
9. make install
11. chown nagios.nagios /usr/local/nagios
12. chown -R nagios.nagios /usr/local/nagios/libexec
13. Make sure that xinetd has installed on the server. Else install using : yum install xinetd

That's it :)
===================================

b) nrpe daemon installation :-


1. cd /usr/local/src/
2. wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
3. tar -xvzf nrpe-2.12.tar.gz
4. cd nrpe-2.12

......
Make sure openssl-devel has installed on the server. Check like

root@server [/usr/local/src/nrpe-2.12]# rpm -qa | grep openssl-devel
openssl-devel-0.9.8e-12.el5_4.6
root@server [/usr/local/src/nrpe-2.12]#

Else execute : yum install openssl*
......

5. ./configure
6. make all
7. make install-plugin
8. make install-daemon
9. make install-daemon-config
10. make install-xinetd

.......
Note : Make sure that xinetd has installed on the server. Else install it like yum install xinetd
.......

11. vi /etc/xinetd.d/nrpe and change the IP at the “only_from” directive. It'll be monitoring server's(who will monirot) IP. For my case it was 64.34.203.8. So, the content of the file will look like :

.......
root@server [/etc/xinetd.d]# hostname
server.loveme.com
root@server [/etc/xinetd.d]# cat /etc/xinetd.d/nrpe
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 64.34.203.8
}
root@server [/etc/xinetd.d]#
.......

12. echo "nrpe 5666/tcp # NRPE" >> /etc/services
13. Make it sure that you have opened the above port at the firewall.
14. chkconfig xinetd on
15. service xinetd restart

op will be like :

.....
root@server [/usr/local/src/nrpe-2.12]# chkconfig --list | grep xinetd
xinetd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
xinetd based services:
root@server [/usr/local/src/nrpe-2.12]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
root@server [/usr/local/src/nrpe-2.12]#
.....


Test the NRPE daemon locally :

16. netstat -at | grep nrpe

Here is the o/p :
........
tcp 0 0 *:nrpe *:* LISTEN

root@server [/usr/local/src/nrpe-2.12]# netstat -plan | grep 5666
tcp 0 0 0.0.0.0:5666 0.0.0.0:*
LISTEN 31130/xinetd
root@server [/usr/local/src/nrpe-2.12]#
........

17. /usr/local/nagios/libexec/check_nrpe -H localhost

Here is the o/p :

........
root@server [/usr/local/src/nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.12
root@server [/usr/local/src/nrpe-2.12]#
........

That's it.

================================================================================


[C] Configuring monitoring server to monitor remote hosts :-

Login into the monitoring server(who will monitor) via ssh and gain root access.

1. Create a command definition: /usr/local/nagios/etc/commands.cfg

and add following entries in that file :
---
root@server [/usr/local/nagios/etc/objects]# cat /usr/local/nagios/etc/commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

root@server [/usr/local/nagios/etc/objects]
---

2. chown nagios. /usr/local/nagios/etc/commands.cfg
3. create the file /usr/local/nagios/etc/objects/linux-box-remote.cfg and add
following entries in that file.

........
root@server [/usr/local/nagios/etc/objects]# cat /usr/local/nagios/etc/objects/linux-box-remote.cfg
define host{
name linux-box-remote ; Name of this
template
use generic-host ; Inherit default values
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS - ITS A
TEMPLATE
}

define host{
use linux-box-remote ; Inherit default values from a
template
host_name server.ubeea2.com ; The name we're giving to this
server
alias ubeea2 ; A longer name for the server
address 76.74.238.165 ; IP address of the server
}

define service{
use generic-service
host_name server.ubeea2.com
service_description CPU Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name server.ubeea2.com
service_description Current Users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name server.ubeea2.com
service_description /dev/hda1 Free Space
check_command check_nrpe!check_hda1
}
define service{
use generic-service
host_name server.ubeea2.com
service_description Total Processes
check_command check_nrpe!check_total_procs
}
define service{
use generic-service
host_name server.ubeea2.com
service_description Zombie Processes
check_command check_nrpe!check_zombie_procs
}
root@server [/usr/local/nagios/etc/objects]#
..........

Note : Change the IP and hostname. Then call this file in the nagios.cfg file. Just add
like

4. cfg_file=/usr/local/nagios/etc/objects/linux-box-remote.cfg

Example :
........
root@server [/usr/local/nagios/etc]# grep linux-box-remote.cfg /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/linux-box-remote.cfg
........

5. chown nagios. /usr/local/nagios/etc/objects/linux-box-remote.cfg
6. check config like :
....
root@server [/usr/local/nagios/etc/objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Make sure warning and error are zero.
....

7. service nagios restart
8. You can add multple remote host in the linux-box-remote.cfg file. Just add another entry like second defined "host" to last one(only you have to change the hostname and services those you want to monitor).

That's it. Try :)

===================================================================================

Thursday, September 16, 2010

How to + extract + untar + unzip .tar.gz file on linux ?

Guys,

I refer following commands :

Examples :
=========
gzip -d guiderj_content.sql.gz
tar -xvzf guiderj_content.sql.gz
tar -jxvf eaccelerator-0.9.5.3.tar.bz2
=========

try :)

How to repair mysql database or tables of the database?

Guys,

I usually use following command to repair all the tables of the databases of a user.

=========
[root@server /var/lib/mysql]#for i in `ll |grep bigchakr|awk '{print $9}' |cut -d/ -f1`; do for j in `mysql -e "use $i; show tables;"|grep -v -`; do mysql -e "use $i; repair table $j;"; done done;
=========

User : bigchakr, please replace this user. It'll repair all the tables of all the DB of that user.

You can use myisamchk command to repair the DB. Here is the comamnd :

========
[root@server /var/lib/mysql]# myisamchk -r /var/lib/mysql/bigchakr_content/*.MYI
========

Note : bigchakr_content is the name of the DB. You can use following command.

========
[root@server /var/lib/mysql]# for i in `ll |grep bigchakr|awk '{print $9}'`; do myisamchk -r $i/*.MYI ; done
========

I don't prefer myisamchk since sometime it doesn't give good results.

Try. :)

Saturday, September 11, 2010

FileList::init() failed: ls_dir_wrapper() failed: Unable to logon user + Logon failure: unknown user name or bad password

Guys,

I have referred the following steps to sort out the error :

steps to recreate the error : Login into plesk cp >> domain's cp >> browse file manager. Here is the error :

------
---------------------- Debug Info -------------------------------
0: FileManagerUIPointer.php:709
FileManagerUIPointer->accessItem(string 'GET', NULL null)
1: client.domain.hosting.file-manager.php:86
plesk__client__domain__hosting__file_manager->accessItem(string 'GET', NULL null)
2: UIPointer.php:601
UIPointer->access(string 'GET')
3: plesk.php:43
------

Solutions :

1. RDP >> Mycomputer >>right click >> properties >>manage >>user & group >>click on users>> find the user(domain name) >>right click and click on properties >> uncheck 'password disable option'.

2. Go to run>>cmd>> and execute following query to retrieve the password of the user's admin area of the domain. For my case I executed the following query :

Example :
------
C:\>"%plesk_bin%"\dbclient --direct-sql --sql="select su.login, a.password from
accounts a, sys_users su where a.id=su.account_id and su.login='dhelalqamar.com
'"
login password
dhelalqamar.com domain_passwd
------

Note : Replace only login name here

3. Execute following command to be recognized the password by the system :

net user login_name password

Example :

====
C:\>
net user dhelalqamar.com qwertyu

The command executed successfully
====

Now try to browse the file manager. Error will be vanished :)

That's it. try :)

Thursday, September 9, 2010

How to install htop on linux machine?

Guys,

I used one bash script to automatically install the htop binary. The binary will show details of the running processes when you execute it on the konsole. Here is the script.

======
#!/bin/bash
cd /usr/local/src/
wget http://citylan.dl.sourceforge.net/project/htop/htop/0.8.3/htop-0.8.3.tar.gz
tar xzvf htop-0.8.3.tar.gz
cd htop-0.8.3
./configure
make
make install
======

That's it. Try :)

Sunday, September 5, 2010

Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\HTMLPDF.mdf" failed with the operating system error 3

Guys,

I got this error when I was restoring one database on mssql 2005(win 2003). I have tried to override the DB but still got the error message. I have changed the path and then successfully restored it since error is giving the clue :)

Error :
======
System.Data.SqlClient.SqlError: Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\HTMLPDF.mdf" failed with the operating system error 3(The system cannot find the path specified.). (Microsoft.SqlServer.Express.Smo)
======

Exact path for my system(Try to find out the paths of those files/You can make new files[May be inside the plesk directory]) :

=====
C:\Program Files (x86)\Parallels\Plesk\Databases\MSSQL\MSSQL.1\MSSQL\Data\dbname.mdf
C:\Program Files (x86)\Parallels\Plesk\Databases\MSSQL\MSSQL.1\MSSQL\Data\dbname.LDF
=====

Note : You'll get it at the "option" of the windows tool. You can refer the following URL.

======
http://www.linglom.com/2008/01/12/how-to-backup-and-restore-database-on-microsoft-sql-server-2005/
======

Note : You can create/backup/restore the DB at the mssql 2005 management area.

Try :)

Saturday, September 4, 2010

How to build kernel module + How to develop kernel module + How to create kernel module?

Guys,

I developed a small program called hello.c and called some kernel functions in it. Here are the steps those I followed :

========
1. yum install kernel-headers-$(uname -r)
2. vi hello.c and add the following codes :
-----
#include "linux/module.h"
#include "linux/kernel.h"
int init_module(void)
{
printk(KERN_INFO "init_module() called\n");
return 0;
}

void cleanup_module(void)
{
printk(KERN_INFO "cleanup_module() called\n");
}
-----

3. vi Makefile and add the following lines :

-----
obj-m += hello.o

all:
make -C /lib/modules/2.6.18-194.8.1.el5/build/ M=$(PWD) modules

clean:
make -C /lib/modules/2.6.18-194.8.1.el5/build/ M=$(PWD) clean
-----
Note : Replace the version here. -C option is used to use the Makefile which has inside the "build" directory.

4. make //To create object files like .o and .ko. PT: ./configure is not needed since basic function of ./configure is to check the existence of header files and to create the Makefile and setup rules in those files. Here we have manually created the file and put the rules.

5. List of created object files after executing "make" command :

-----
root@server [~/test]# ls
./ hello.c .hello.ko.cmd hello.mod.o hello.o Makefile Module.symvers
../ hello.ko hello.mod.c .hello.mod.o.cmd .hello.o.cmd Module.markers .tmp_versions/
root@server [~/test]#

Example(O/P) :-
root@server [~/test]#make
make -C /lib/modules/2.6.18-194.8.1.el5/build/ M=/root/test modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-194.8.1.el5-i686'
CC [M] /root/test/hello.o
Building modules, stage 2.
MODPOST
CC /root/test/hello.mod.o
LD [M] /root/test/hello.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.18-194.8.1.el5-i686'
-----

6. root@server [~/test]# modinfo hello.ko //To get the details of the module
filename: hello.ko
srcversion: 4F856ABA1F3290D5F81D961
depends:
vermagic: 2.6.18-194.8.1.el5 SMP mod_unload 686 REGPARM 4KSTACKS gcc-4.1
root@server [~/test]#

7. Load module : insmod hello.ko
example :
root@server [~/test]# insmod hello.ko

8. Check whether it has loaded or not : lsmod | grep hello
example :
root@server [~/test]# lsmod | grep hello
hello 5504 0
root@server [~/test]#

9. Remove the module : rmmod hello
Ex :
root@server [~/test]# rmmod hello

10. Check the log :

root@server [~/test]# tail -2 /var/log/messages
Sep 4 19:28:20 server kernel: init_module() called
Sep 4 19:28:28 server kernel: cleanup_module() called
root@server [~/test]#
========

That's it. Try :)

Friday, September 3, 2010

How to upgrade kernel on linux?

Guys,

I referred the following steps :

============================
1. cd /usr/local/src
2. wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2 //replace the version that you want to install or check it at http://www.kernel.org/
3. tar -xjvf linux-2.6.35.4.tar.bz2 -C /usr/src
4. cd /usr/src/linux-2.6.35.4
5. make menuconfig //if gcc is not there just install it like : yum install gcc

Note : You can enable various option here. But make it sure that you have enabled kernel config option. Go to General option >> Kernel .config support(enter space) and exit. (save the changes). make oldconfig > Use when upgrading kernel, only asks if new options.

6. make
7. make modules
8. make modules_install

Note(Do the following) : # ln -s /usr/src/linux-2.6.35.4 /usr/src/linux
# ln -s /usr/src/linux-2.6.35.4 /usr/src/linux-2.6

9. make install

Note : It will install three files inside the /boot directory :

* System.map-2.6.35.4
* config-2.6.35.4
* vmlinuz-2.6.35.4 and vmlinuz will point here.

example(For my case):

----------
root@server [/usr/src/linux-2.6.35.4]# make install
sh /usr/src/linux-2.6.35.4/arch/x86/boot/install.sh 2.6.35.4
arch/x86/boot/bzImage \
System.map "/boot"
root@server [/usr/src/linux-2.6.35.4]#
root@server [/boot]# ll |grep 2.6.35.4
-rw------- 1 root root 2586318 Sep 3 18:00 initrd-2.6.35.4.img
lrwxrwxrwx 1 root root 25 Sep 3 18:00 System.map ->
/boot/System.map-2.6.35.4
-rw-r--r-- 1 root root 1360605 Sep 3 18:00 System.map-2.6.35.4
lrwxrwxrwx 1 root root 22 Sep 3 18:00 vmlinuz -> /boot/vmlinuz-2.6.35.4
-rw-r--r-- 1 root root 2653408 Sep 3 18:00 vmlinuz-2.6.35.4
root@server [/boot]

Make sure System.map and vmlinuz are pointing to latest kernel else point them like :

ln -s /boot/System.map-2.6.28 /boot/System.map
ln -s /boot/vmlinuz-2.6.35.4 /boot/vmlinuz
-----------

10. cd /boot
11. mkinitrd initrd.img-2.6.35.4 2.6.35.4 //You may not be needed this step. For me it has automatically created. This is creation of RAM driver.

Example for my case :

------------
root@server [/boot]# mkinitrd initrd-2.6.35.4.img 2.6.35.4
initrd-2.6.35.4.img already exists.
root@server [/boot]#
------------

12. vi /boot/grub/menu.lst or /etc/grub.conf : //For me the entries has automatically put in this file like :

------------
root@server [/usr/src/linux-2.6.35.4]# cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda3
# initrd /initrd-version.img
#boot=/dev/hda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.35.4)
root (hd0,0)
kernel /vmlinuz-2.6.35.4 ro root=/dev/hda3
initrd /initrd-2.6.35.4.img
title CentOS (2.6.18-194.8.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.8.1.el5 ro root=/dev/hda3
initrd /initrd-2.6.18-194.8.1.el5.img
title CentOS (2.6.18-128.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-128.el5 ro root=/dev/hda3
initrd /initrd-2.6.18-128.el5.img
root@server [/usr/src/linux-2.6.35.4]#
------------

13. reboot //enter this command at the konsole.
14. Check the server whether it comes online and check uname -r //If it does not come please contact DC to load the server from old kernel and sort the problem.
==============================

That's it. Try :)

Thursday, September 2, 2010

How to manually recompile php on cpanel server?

Guys,

I referred following steps :

========
1. cd /home/cpeasyapache/src/php-5.2.9/
2. ./configure --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-magic-quotes --enable-mbstring --enable-pdo=shared --enable-sockets --enable-zip --with-kerberos --prefix=/usr/local --with-apxs2=/usr/local/apache/bin/apxs --with-curl=/opt/curlssl/ --with-curlwrappers --with-freetype-dir=/usr --with-gd --with-gettext --with-imap=/opt/php_with_imap_client/ --with-imap-ssl=/usr --with-jpeg-dir=/usr --with-libdir=lib64 --with-libexpat-dir=/usr --with-libxml-dir=/opt/xml2/ --with-mcrypt=/opt/libmcrypt/ --with-mime-magic --with-mysql=/usr --with-mysql-sock=/var/lib/mysql/mysql.sock --with-openssl=/usr --with-openssl-dir=/usr --with-pcre-regex=/opt/pcre --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-pic --with-png-dir=/usr --with-sqlite=shared --with-ttf --with-xmlrpc --with-xpm-dir=/usr --with-zlib --with-zlib-dir=/usr

Note : You can get these options from info.php or php -i|grep configure (here you have to remove '' syntax)

3. make
4. make install
5. /etc/init.d/httpd restart

Note : You can do like : CUSTOM_PHP_FLAGS="--with-xsl" /scripts/easyapache //I didn't try it since one of my friend got error here.
=========

That's it. Try :)

configure: error: This c-client library is built with Kerberos support

Guys,

I got the error message during executing easyapache. I have manually recompiled the php on cpanel server. Here is the script that I have used to do the same :

Note : I enabled kerberos and added the line like : --with-kerberos to fix the issue.

=======
-bash-3.2# cat /root/manual_php_recompile.sh
#!/bin/bash
#By Kamal Maiti

cd /home/cpeasyapache/src/php-5.2.9/

./configure --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-magic-quotes --enable-mbstring --enable-pdo=shared --enable-sockets --enable-zip --with-kerberos --prefix=/usr/local --with-apxs2=/usr/local/apache/bin/apxs --with-curl=/opt/curlssl/ --with-curlwrappers --with-freetype-dir=/usr --with-gd --with-gettext --with-imap=/opt/php_with_imap_client/ --with-imap-ssl=/usr --with-jpeg-dir=/usr --with-libdir=lib64 --with-libexpat-dir=/usr --with-libxml-dir=/opt/xml2/ --with-mcrypt=/opt/libmcrypt/ --with-mime-magic --with-mysql=/usr --with-mysql-sock=/var/lib/mysql/mysql.sock --with-openssl=/usr --with-openssl-dir=/usr --with-pcre-regex=/opt/pcre --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-pic --with-png-dir=/usr --with-sqlite=shared --with-ttf --with-xmlrpc --with-xpm-dir=/usr --with-zlib --with-zlib-dir=/usr

make
make install

#eaccelerator reinstall
mv /usr/local/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so /usr/local/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so.bk2sept

cd /usr/local/src/
wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
tar -jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3
phpize
./configure

make
make install

/etc/init.d/httpd restart

-bash-3.2#
=======

You need to create the .sh file and make it executable. Then run it on screen.

That's it :)

Wednesday, September 1, 2010

How to install suhosin on linux ?

Guys,

Suhosin is an advanced protection system for PHP installations. It was designed to protect servers and users from known and unknown flaws in PHP applications and the PHP core. Suhosin comes in two independent parts, that can be used separately or in combination. The first part is a small patch against the PHP core, that implements a few low-level protections against bufferoverflows or format string vulnerabilities and the second part is a powerful PHP extension that implements all the other protections.

I have referred following steps to install it on the linux server :

=========
wget http://download.suhosin.org/suhosin-0.9.32.1.tar.gz
tar -xvzf suhosin-0.9.32.1.tar.gz
cd suhosin-0.9.32.
phpize
./configure
make
make install
echo "extension=suhosin.so" >> /usr/local/lib/php.ini
=========

Note : You can get latest version of suhosin from that above URL.

Advance setting in the php.ini file(Just add those in php.ini file and restart webserver) :

=========
;************************************************************************
; suhosin Parameters
; For a full list of parameters and their documentation go to:
; (http://www.hardened-php.net/suhosin/configuration.html)
;************************************************************************
[suhosin]
; Logging Configuration
suhosin.log.syslog.facility = 9
suhosin.log.use-x-forwarded-for = Off

; Executor Options
suhosin.executor.max_depth = 0
suhosin.executor.include.max_traversal = 4
suhosin.executor.disable_emodifier = Off
suhosin.executor.allow_symlink = Off
;Example: include.whitelist allows includes from foreign sites,. (comma separated)
;suhosin.executor.include.whitelist = http://externalsite1.tld/, externalsite2.tld/

; Misc Options
suhosin.simulation = Off
;
suhosin.apc_bug_workaround = Off
suhosin.sql.bailout_on_error = Off
suhosin.multiheader = Off
suhosin.mail.protect = 1
suhosin.memory_limit = 20

; Transparent Encryption Options
suhosin.session.encrypt = On
suhosin.session.cryptua = On
suhosin.session.cryptdocroot = On
suhosin.session.cryptraddr = 0
suhosin.cookie.encrypt = On
suhosin.cookie.cryptua = On
suhosin.cookie.cryptraddr = 0

; Filtering Options
suhosin.filter.action = 406
suhosin.cookie.max_array_depth = 100
suhosin.cookie.max_array_index_length = 64
suhosin.cookie.max_name_length = 64
suhosin.cookie.max_totalname_length = 256
suhosin.cookie.max_value_length = 10000
suhosin.cookie.max_vars = 100
suhosin.cookie.disallow_nul = On
suhosin.get.max_array_depth = 50
suhosin.get.max_array_index_length = 64
suhosin.get.max_name_length = 64
suhosin.get.max_totalname_length = 256
suhosin.get.max_value_length = 512
suhosin.get.max_vars = 100
suhosin.get.disallow_nul = On
suhosin.post.max_array_depth = 100
suhosin.post.max_array_index_length = 64
suhosin.post.max_totalname_length = 256
suhosin.post.max_value_length = 65000
suhosin.post.max_vars = 200
suhosin.post.disallow_nul = On
suhosin.request.max_array_depth = 100
suhosin.request.max_array_index_length = 64
suhosin.request.max_totalname_length = 256
suhosin.request.max_value_length = 65000
suhosin.request.max_vars = 200
suhosin.request.max_varname_length = 64
suhosin.request.disallow_nul = On
suhosin.upload.max_uploads = 25
suhosin.upload.disallow_elf = On
suhosin.upload.disallow_binary = Off
suhosin.upload.remove_binary = Off
suhosin.session.max_id_length = 128
;************************************************************************
; End suhosin Parameters
;************************************************************************
=========

That's it try :)