Tuesday, September 20, 2011

nrpe&nagios plugin installation.txt

Nagios plugins and nrpe installation in remote host.

useradd nagios
passwd nagios

download the source files using the below links

wget https://api.opensuse.org/public/source/home:netmax/nagios-plugins/nagios-plugins-1.4.6.tar.gz?rev=285448d8f1b79ea7d33cc6ee74ba65a1&

wget http://space.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.8/nrpe-2.8.tar.gz


tar -xvzf nagios-plugins-1.4.6.tar.gz\?rev\=285448d8f1b79ea7d33cc6ee74ba65a1
tar -xvzf nrpe-2.8.tar.gz

cd nagios-plugins-1.4.6
./configure
make
make install

chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

cd nrpe-2.8
./configure --enable-ssl
make all
make install-plugin
make install-daemon
make install-daemon-config

add the 5666 port no in /etc/services

Add the nagios host IP in the Allowed Host Directive of the nrpe.cfg file.

allowed_hosts=127.0.0.1,x.x.x.x

make sure that both the remote host and nagios hosts servers firewall blocks eachother ip's.

start nrpe plugin use the command below.

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

netstat -nat | grep 5666 or lsof -i tcp:5666

make sure that 5666 port listening

check whether nrpe is working,

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

if this returns the nrpe version then its working.


rndc issues

While restarting named or any services in the server, if you get the below log in Syslog or in messages

Sep 20 14:44:14 named[13573]: isc_socket_create: fcntl/reserved: Too many open
files
Sep 20 14:44:14 named[13573]: could not listen on UDP socket: not enough free resources

in addition in this time..you will have a issues in rndc also like below.

root@#rndc status
rndc: connect failed: 127.0.0.1#953: connection refused


due to this issues the newly created domains will not work because the IP associated with the new domains will not bind with the DNS.

if you do...

root@#telnet <new-ip> 25
connect failed: 127.0.0.1#953: connection refused
you will get the same error as like rndc.

Solution:

the problem is due to the user limit exceeded.

root@# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 106496
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 106496
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited


The output will be like above.

open files (-n) 1024

increase this limit to 2000

root@#ulimit -n 2000

logout the terminal and login so that you can see the change. Now restart named and do rndc reload, telnet to newip for the port 53, everything will work.

Wednesday, June 22, 2011

URL redirection with masking

Here is how to redirect a domain with masking the URL


For ex: 
We need to redirect the domain "abc.com" to "xyz.com". If  we redirect the domain using htaccess redirection using the code below 



RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^/?$ "http\:\/\/www\.xyz\.com" [L]


When we access the domain "abc.com" it will redirect to "xyz.com" but the address bar shows "xyz.com" only not 'abc.com".


so we need to mask the "xyz.com" domain name using the script below.


You need to add the below code in the "index.html" file of the domain in which you are going to add redirect.


#root@test[~] vi index.html


<html>


<head>

<title>Same Title As Your Homepage</title>
<!--incase they have javascript turned off-->

<script type="text/javascript">
<!--changes title bar to match title on current page in frame-->
function changeTitle()
   {
   if (top.frames['main'].document.title)
      {
      top.document.title=top.frames['main'].document.title;
      }
   }
</script>
</head>


<frameset>
<frame name="main"
src="http://xyz.com"scrolling="auto"
target="main" ONLOAD="changeTitle();">
<!--You need the onload handler to make the javascript work-->

<noframes>

<body>
Place a suitable message here for people with browsers that can't read
frames.
</body>

</noframes>

</frameset>

</html>

In this scenario we are redirecting the domain to "xyz.com" so I have given the 
URL like that.

Now if you access the domain "abc.com" it will display the page of the "xyz.com" but the URL in the address will be "abc.com".






Wednesday, April 6, 2011

How to upgrade kernel in Linux CentOS

Here's is the guide for you all to update kernel in Linux..especially in Centos...

Why the need for upgrading Kernel..might be your existing kernel crashes periodically...or the update you need would not be available in the current Linux version....However if we get a situation to upgrade Linux kernel...do the following...

The most important thing is if you update the kernel..it will automatically update some of the packages like httpd, MySQL. If you want to exclude these changes modify the file,

/etc/yum.conf 
as 
[main]
exclude=courier* apache* mod_ssl* httpd* perl mysql* php* spamassassin* exim*
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=centos-release
tolerant=1
exactarch=1
retries=20
obsoletes=1
gpgcheck=1

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

First you need to check the current version of  Kernel..type the below command in the prompt

uname -a

Most of the admin uses "yum upgrade kernel" to update the Kernel version..

yum upgrade kernel

Nothing to do.

the newer kernel version is not present in the Repo you are curretly using, you need to find out the corresponding  repo for the needed kernel...

here...we are going to upgrade the kernel from,


kernel-2.6.18-32  to kernel-2.6.18-238.5.1.1

but that kernel version was not found in the default repo....
so we need to find a exact one...
for this version I have found one which is given below...

Create a new file called centalt.repo file in /etc/yum.repos.d/ and paste the below 
contents.....

[CentALT]
name=CentALT Packages for Enterprise Linux 5 - $basearch
baseurl=http://centos.alt.ru/repository/centos/5/$basearch/
enabled=1
gpgcheck=0

Then try 

yum update kernel*

It will automatically add a new entry in grub.conf file....so just reboot the server and check..

uname -a

Kernel version is Updated ! ! ! !

Sunday, February 20, 2011

Upgrade Joomla from 1.5.x to 1.5.22

Upgrade Joomla from 1.5.x to 1.5.22:
----------------------------------------------

The most important point before proceeding is to take a backup of the mysql database which used by your Joomla.

1.Download the component 'com_jupdateman_151.tgz' from the Site "http://joomlacode.org/gf/project/pasamioprojects/frs/?action=FrsReleaseBrowse&frs_package_id=4728"

2.Install the component. After that use the component by going to Components >> Update Manager.

3.Select the 'Download the Updated File' link to download the latest version of the Joomla.

4.Choose the Patch Package version when prompted.  A full package is not required for upgrading from 1.5.x. to 1.5.22.

Thats all upgrade Completed Successfully ! ! ! ! !


Errors and fixes:
----------------------

1.If you face any error while upgrading Joolma, there might be corrupted table so you need to repair the mysql tables to fx it.

2.After upgrading the Joomla to 1.5.22 if you got blank page then at the spot you need to restore the database which you have dumped already.

Sunday, January 23, 2011

How to migrate joomla from version 1.0 to 1.5

Here is how to Migrate Joomla from version 1.0 to 1.5.x stable

The most important thing before proceeding with the steps below is to take the backup of  the current Joomla you are having and also database it will be safe.

1. You need to install the component called migrator for the current version of  Joomla1.0.x

2. Then go to "Components" option in your Joomla admin page then select "Migrator"

3. Then select the "Create Migration SQL" file option



4. Then download the SQL file using the download option and place it in the Local system or FTP it to your server



 5. Download the Stable release Joomla 1.5 from Joomla from the site below and
http://www.joomla.org/download.html

6. Step 4. Perform the migration
Proceed with the installation until you reach Step 6: Configuration:


 7. Fill the site name, email, admin user name and password . The imp thing to keep on mind is to select the option 'Load Migration Script'.




8. Fill the old table prefix _jos and leave the encoding unchanged unless needed and you are familiar with this option.

By clicking on the [Browse] button you should select the Joomla 1.0.x migration dump you downloaded earlier.

Make sure to check the This script is a Joomla! 1.0 migration script. check box as well.
Proceed by clicking on the [Upload and execute] button.

Once the data is imported you will see the following screen


9.As always remove the installation directory and access the joomla admin.















Monday, January 17, 2011

How does Qmail work

Qmail : How does it work ?

Qmail programs & configuration files
Qmail works using about 15 small programs. It also uses a pretty large number of configuration files. At the beginning, this may appear as quite confusing. Once you are familiarised with these configuration files & programs, qmail administration will be easier.

Qmail programs

Qmail continuously runs 5 daemons. Remaining 10 programs are launched by these 5 daemons as and when required.

Let us see which are the 5 daemons.

1. qmail-send
2. qmail-lspawn
3. qmail-rspawn
4. qmail-clean
5. tcpserver

How Qmail works

1. Email arrival in Qmail

Mail arrives in Qmail in two different ways.

(i) Locally injected emails.

There is a program called sendmail that comes with qmail. It is a program that mimics functionality of legacy sendmail, its arguments are also similar. sendmail accepts the local email and passes it to qmail-inject.

(ii) Remote emails arrived via SMTP

* tcpserver listens incoming connections on the SMTP port.
* upon a new SMTP connection, qmail-smtpd is launched.
* qmail-smtpd receives emails via SMTP.



2. Queuing emails

* qmail-inject & qmail-smpd pass received emails to qmail-queue.
* qmail-queue places emails in the folder /var/qmail/todo
* qmail-queue adds necessary headers to emails
* Then, it notifies qmail-send about newly queued emails.

3. Processing queued emails

* qmail-send takes the message out of /var/qmail/queue/todo folder
* qmail-send checks the recipient address of the email
* If the recipient addres is local, email is passed to qmail-lspwan
* If the recipient address is remote, email is passed to qmail-rspawn

4. Email delivery to local and remote recipients

* qmail-lspawn passes email to qmail-local
* qmail-local delivers email to local email address
* qmail-rspawn passes email to qmail-remote
* qmail-remote connects to remote mail server and delivers email to remote email address

5. Cleaning queue after delivering emails

* Once all messages are delivered, qmail-send notifies qmail-clean
* qmail-clean removes the delivered emails from the queue

Qmail configuration files

Qmail configuration files are located in the folder /var/qmail/control.

1. badmailfrom
All "from addresses" which are blacklisted.

2. bouncefrom
It is the bounce email from address. Usually it is "mailer-daemon".

3. bouncehost
It is host name of server

4. concurrencyincoming
Maximum number of simultaneous incoming SMTP connections allowed.

5. concurrencylocal
Maximum number of simultaneous local deliveries

6. concurrencyremote
Maximum number of simultaneous remote deliveries

7. defaultdomain
Default domain name of server

8. defaulthost
Host name of server

9. databytes
Maximum number of bytes in message (0=no limit)

10. doublebouncehost
It is the bounce email from address. Usually it is "mailer-daemon".

11. doublebounceto
It is the bounce email to address. Usually it is "postmaster".

12. helohost
It is the host name used in SMTP HELO command

13. idhost
It is host name of server. It is used when creating Message-ID.

13. localiphost
It is local IP address

14. locals
List of all local domains.

15. me
It is the hostname of server

16. morercpthosts
Only 50 domains can be added in rcpthosts, remaining domains should be in morercpthosts.

17. queuelifetime
It is the number of seconds an email can remain in queue

18. rcpthosts
Domains of all locally hosted email addresses.

19 smtpgreeting
It is the SMTP greeting message used by mail server.

20. timeoutconnect
Time in seconds, the server has to wait for SMTP connection

21. timeoutremote
Time in seconds, server has to wait for remote server

22. timeoutsmtpd
Time in seconds, server has to wait for SMTP client

23. virtualdomains
List of all virtual domains