Saturday, July 13, 2013

Install and Configure NRPE in CentOS

 Install NRPE on Linux


NRPE is called as ‘Nagios Remote Plugin Executere’. NRPE allows nagios server
to remotely execute nagios commands or plugins on other Linux/Unix machines. NRPE is also available windows servers.
Following document shows you how to install NRPE, I am installing it on CentOS 6.4

1] Install NRPE required packages.

[root@server ~]# yum install openssl-devel gcc xinetd make

2] NRPE runs under the user "nagios", so let's add that user.

[root@server ~]# useradd nagios

3] Download and install Nagios-plugins.

[root@server downloads]# wget https://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz

[root@server downloads]# tar -xvzf nagios-plugins-2.0.tar.gz

[root@server downloads]# cd nagios-plugins-2.0

[root@server nagios-plugins-2.0]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

[root@server nagios-plugins-2.0]# make install

4] Assign nagios user ownership to nagios commands.

[root@server nagios-plugins-2.0]# chown -R nagios:nagios /usr/local/nagios/libexec


5] Install and configure NRPE nagios client.

[root@server downloads]# wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz?r=&ts=1363788540&use_mirror=hivelocity

[root@server downloads]# tar -xvzf nrpe-2.15.tar.gz

[root@server downloads]# cd nrpe-2.15.tar.gz

[root@server downloads]# ./configure --enable-ssl

[root@server nrpe-2.15]# make all

[root@server nrpe-2.15]# make install-plugin

[root@server nrpe-2.15]# make install-daemon

[root@server nrpe-2.15]# make install-daemon-config

[root@server nrpe-2.15]# make install-xinetd

6] Add following line at the end of file for NRPE in /etc/services

[root@server ~]# vi /etc/services
nrpe            5666/tcp                # NRPE

7] NRPE will run under xinetd daemon. So update xinetd file.

[root@server ~]# vi /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 192.168.1.1 --> [ Your Nagios Server IP ]
}

8] Star/Restart xinetd service.

[root@server ~]# service xinetd start

[root@server ~]# chkconfig xinetd on

Friday, April 19, 2013

Install RED5 server on Linux


Install RED5 server on Linux

Following blog post will describe how to install RED5 server on Centos 5.7 (Final)

Red5 Working :

Red5 server converts the video file to the flash file and we everyone knows that flash files play instantly once someone accesses it. Here when we request or select a particular video, the video script will send the video(stream the video) to red5 server. Red5 will convert the video file to flash and sends the output to the video script to display on the browser. Lot of video scripts are being used now a days like dolphin, videowhisper etc for the site. You can configure the admin panel using the server's IP and port details.

Installation Steps:

1. Download and Install Java:
Red5 is a JAVA server. So install Java using yum.

[root@server ~]# yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel

2. Install SVN:
SVN will required to fetch latest release of RED5 source from SVN repository at Google Code.

[root@server ~]# yum install subversion

3. Download and Install Ant & Ivy:
Ant will need to compile RED5 server code. Ant comes in binary form, so just download and install it in /usr/local directory.
First off let’s change to another directory.

[root@server ~]# cd /usr/src
[root@server src]# wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.2-bin.tar.bz2
[root@server src]# tar jxvf apache-ant-1.8.2-bin.tar.bz2
[root@server src]# mv apache-ant-1.8.2 /usr/local/ant

[root@server src]# svn co https://svn.apache.org/repos/asf/ant/ivy/core/trunk ivy
[root@server src]# cd ivy
[root@server src]# /usr/local/ant/bin/ant jar
[root@server src]# cp build/artifact/jars/ivy.jar /usr/local/ant/lib/

4. Export Variables for Ant and Java:
So now we have JAVA installed, and ANT is in place. We need to make sure there are some environment variables set. These are global variables with paths to different binaries or applications. ANT and JAVA will need those.

[root@server src]# export ANT_HOME=/usr/local/ant
[root@server src]# export JAVA_HOME=/usr/lib/jvm/java
[root@server src]# export PATH=$PATH:/usr/local/ant/bin

5. Actually Installing the RED5 Server:
Source:
Let’s get the RED5 source:

[root@server src]# svn co http://red5.googlecode.com/svn/java/server/tags/1_0/ red5

This will fetch the complete Red5 source and save it in a new folder called, red5 (so in /usr/src/red5)

Now that we have the source, let’s move it to /usr/local/ using

[root@server src]# mv red5 /usr/local/
[root@server src]# cd /usr/local/red5

This is the folder where all the source files reside. From here on, we prepare and build the red5 source.

[root@server red5]# /usr/local/ant/bin/ant prepare
[root@server red5]# /usr/local/ant/bin/ant dist

Wait for few minutes to . After a few minutes you should end up with the last line in your terminal window looking like this:

BUILD SUCCESSFUL

This means that you now have a working RED5 build!

Copy the conf directory from the dist folder to the current directory and test the red5 installation.

[root@server red5]# cp -r dist/conf .
[root@server red5]# ./red5.sh

Make sure your server is actually running, you should be able to see the webroot of Red5 when hitting your server at port 5080 (http://yourserver.com:5080)

Note : That the server is currently only running as long as you keep that terminal window open. Once you close it RED5 stops running. Let’s make sure RED5 can run on its own from now on. Hit CTRL+C to stop the process.

6. Init Script:
Now we will create init script for red5 to start, stop and restart easily.

[root@server ~]# vi /etc/init.d/red5 [Enter the following script into vi.]
#!/bin/sh
# For RedHat and cousins:
# chkconfig: 2345 85 85
# description: Red5 flash streaming server
# processname: red5

PROG=red5
RED5_HOME=/usr/local/red5
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid

# Source function library
. /etc/rc.d/init.d/functions

[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5

RETVAL=0

case "$1" in
start)
echo -n $”Starting $PROG: ”
cd $RED5_HOME
$DAEMON >/dev/null 2>/dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $! > $PIDFILE
touch /var/lock/subsys/$PROG

fi
[ $RETVAL -eq 0 ] && success $”$PROG startup” || failure $”$PROG startup”
echo
;;
stop)
echo -n $”Shutting down $PROG: ”
killproc -p $PIDFILE
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
;;
restart)
$0 stop
$0 start
;;
status)
status $PROG -p $PIDFILE
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|status}”
RETVAL=1
esac

exit $RETVAL

7. Assign execute permission to red5 script.

[root@server ~]# chmod +x /etc/init.d/red5

8. Now start the service

[root@server ~]# service red5 start OR /etc/init.d/red5 start
9. To start RED5 when the server boots.

[root@server ~]# chkconfig --add red5
[root@server ~]# chkconfig red5 on

10. To Install RED5 demos

[root@server ~]# cd /usr/local/red5/webapps/root
[root@server root]# svn checkout http://red5.googlecode.com/svn/java/server/tags/0_9_1/webapps/root/demos/

11. Test

Now test the RED5 installation by opening following URL in browser.

http://yourserverip:5080/

Friday, March 29, 2013

Script to find out Linux Hardware Information


How to get Hardware Information on Linux

Simple script to find out Linux Hardware Information.

exec > /root/hard_info 2>&1
date
echo "Motherboard Model Number"
dmidecode -t baseboard | grep 'Product Name'
echo "===================================="
echo "Processor Information"
dmidecode -t processor | grep 'Socket Designation\|Version:'
echo "===================================="
echo "Memory Type & Size"
dmidecode -t memory | grep 'Type\|Size' | grep -v 'Type Detail\|Error Correction Type'
echo "===================================="
echo "Total Memory"
free -t -m
echo "===================================="
echo "Hard Drive's of Machine"
fdisk -l | grep 'Disk /dev/s'
echo "===================================="
echo "Serial Number of /dev/sda"
hdparm -I /dev/sda | grep 'Model Number:\|Serial Number'
echo "===================================="
echo "Serial Number of /dev/sdb"
hdparm -I /dev/sdb | grep 'Model Number:\|Serial Number'
echo "===================================="

Friday, February 15, 2013

Install Nagios on Linux


Install Nagios on Linux

Introduction:-
Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. Nagios is a popular open source computer system and network monitoring software application. It watches hosts and services, alerting users when things go wrong and again when they get better.

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

Prerequisites:-
Make sure you've
installed the following packages on your Linux installation before continuing.
  • Apache
  • PHP
  • GCC compiler
  • GD development libraries
  • IP = 192.168.1.1
  • HOSTNAME = server.anup.co.in
  • Firewall and Selinux must be disabled.
1] Install gcc compiler, gd development libraries
[root@server ~]# yum install gd gd-devel gcc glibc glibc-common -y

2] Install http package for nagios web-interface
[root@server ~]# yum install httpd php -y

3] Create new user account and assign it password
[root@server ~]# useradd nagios
[root@server ~]# passwd nagios

[ Note = apache user already created ]

4] Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

[root@server ~]# groupadd nagcmd
[root@server ~]# usermod -G nagcmd nagios
[root@server ~]# usermod -G nagcmd apache

5] Download nagios and plugins from following links.

Create a directory for storing the downloads.
[root@server ~]# mkdir /root/downloads
[root@server ~]# cd /root/downloads

Nagios Download Link =
[root@server downloads]# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz/download

Plugins Download Link =
[root@server downloads]# wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download

6] Now compile and install nagios

[root@server downloads]# tar -xvzf nagios-3.3.1.tar.gz
[root@server downloads]# cd nagios
[root@server nagios]# ./configure --with-command-group=nagcmd
[root@server nagios]# make all

7] Now install bineries, init script
[root@server nagios]# make install
[root@server nagios]# make install-init
[root@server nagios]# make install-config
[root@server nagios]# make install-commandmode

8] Install web config file for nagios web-interface
[root@server nagios]# make install-webconf
[root@server nagios]# cd

9] Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account – you’ll need it later.

[root@server ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios

10] Now compile and install nagios plugins

[root@server ~]# cd /root/downloads
[root@server downloads]# tar -xvzf nagios-plugins-1.4.15.tar.gz
[root@server downloads]# cd nagios-plugins-1.4.15
[root@server nagios-plugins-1.4.15]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@server nagios-plugins-1.4.15]# make
[root@server nagios-plugins-1.4.15]# make install
[root@server ~]# cd

13] Start nagios service ( Add Nagios to the list of system services and have it automatically start when the system boots. )

[root@server ~]# chkconfig --add nagios
[root@server ~]# chkconfig nagios on

14] Verify the sample nagios configuration file

[root@server ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

15] If there are no error start nagios and httpd (for nagios web-interface)service

[root@server ~]# service nagios start
[root@server ~]# service httpd restart

16] If you done this successfully then login to Nagios Web-interface

[ Note = You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier. ]

URL is = http://<nagios server ip/nagios

Example = http://192.168.1.1/nagios

How to install Nagios Arana Theme ?

1] Move old Nagios theme into new folder.

[root@server ~]# mkdir /usr/local/nagios/share/old-theme
[root@server ~]# mv /usr/local/nagios/share/* old-theme

2] Download Arana Theme.

[root@server ~]# cd /usr/local/nagios/share
[root@server share]# wget http://kaz.dl.sourceforge.net/project/arana-nagios/arana_style-1.0for-Nagios3x-ENG.zip

[root@server share]# unzip arana_style-1.0for-Nagios3x-ENG.zip
[root@server share]# cd

3] Restart Nagios.

[root@server ~]# service nagios reload

Sunday, January 06, 2013

RkHunter Installtion



RKHunter [Rootkit Hunter]
====================
RootKit is a feature rich scanning tool that scans for rootkits, backdoors, and local exploits. It scans hidden files, wrong permissions set on binaries, suspicious strings in kernel etc.
As rootkits are installed into system files they cannot be removed easily however, RKHunter will still notify you of any rootkits that may exist in your system so that you can take the necessary steps to reload on server. 

Rootkit Hunter is not a reactive tool: it only enumerates encountered threats.
It is up to you to read the log file and investigate suspicious activity.

To know more about Rkhunter and its features visit http://www.rootkit.nl/.

================================== ==============
Installing Rkhunter (Rootkit Hunter) in RHEL, CentOS and Fedora
================================== ==============
Step 1: Downloading Rkhunter:
[root@server ~]# mkdir /download
[root@server ~]# cd /download
[root@server download]# wget http://nchc.dl.sourceforge.net/project/rkhunter/rkhunter/1.4.0/rkhunter-1.4.0.tar.gz

Step 2: Installing Rkhunter:
Once you have downloaded the latest version, run the following commands as a root user to install it.
[root@server download]# tar -xvzf rkhunter-1.4.0.tar.gz
[root@server download]# cd rkhunter-1.4.0
[root@server rkhunter-1.4.0]# ./installer.sh --install
[root@server rkhunter-1.4.0]# cd 

Step 3: Updating Rkhunter:
Run the RKH updater to fill the database properties by running the following command.
[root@server ~]# /usr/local/bin/rkhunter --update
[root@server ~]# /usr/local/bin/rkhunter --propupd 

Step 4: Setting Cronjob and Email Alerts:
Create one file "rkhunter.sh under /etc/cron.daily/, which then scans your file system every day and sends email notifications to your email id. 

[root@server ~]# vi /etc/cron.daily/rkhunter.sh
#Add the following lines of code to it and replace your “Server Name” and your “Email Id“.
#!/bin/sh
(
/usr/local/bin/rkhunter --versioncheck
/usr/local/bin/rkhunter --update
/usr/local/bin/rkhunter --cronjob --report-warnings-only
) | /bin/mail -s 'rkhunter Daily Run (server.anup.co.in)' mail@anup.co.in 

Set execute permission on the file.
[root@server ~]# chmod +x /etc/cron.daily/rkhunter.sh 

Step 5: Manual Scan and Usage:
To scan the entire file system, run the Rkhunter as a root user.
[root@server ~]# rkhunter --check
The above command generates log file under /var/log/rkhunter.log with the checks results made by Rkhunter. 

For more information and options please run the following command.
[root@server ~]# rkhunter --help

Monday, October 15, 2012

Serial key for VMware Workstation 9




Serial key for VMware Workstation 9

 
     VMWare workstation is a free virtualization product that installs on any existing server or powerful PC hardware and partitions a physical computer or server into multiple virtual machines by abstracting processor, memory, storage and networking resources, and thus able to further fully utilize the hardware and have the flexibility to run another same or operating system without the need of new computer.

To install VMWare Workstation, users need to have serial number or product key. 

VMware Workstation 8 Serial Key: 

0A494-8U0EM-UZ2A9-0105M-A303M
MA406-25387-7ZNW8-F197P-1AL2D
4A4GP-6PLD0-QZTP9-WK0NK-C3UQD
4A2XP-D03DN-7Z6H9-Z2ANM-0C9PFD
0F0G8-FK29Q-AZ529-2J1NP-AC02F 

VMware Workstation 9 Serial Key: 

0F23V-4D38L-9ZQ38-2K37H-83C50
0F03K-80JEQ-8ZF89-8287H-A2R47
0A22R-400EM-EZ4W8-3K9NK-3AUPL
NA64Z-0V054-UZVC0-2L370-837K4 

Try above serial keys

Friday, September 28, 2012

Configuring A High Availability Cluster (Heartbeat) On CentOS


      In this example we will configure a webserver using apache and we will cluster it. It can be implemented on centos, fedora and other redhat flavors.

Pre-Configuration Requirements

1] Following are the hostnames and ipv4 addresses that will be used:
  • Primary Node : IP - 192.168.1.1 Hostname - server1.linuxhome.in 
  • Secondary Node : IP - 192.168.1.2 Hostname - server2.linuxhome.in 
  • Virtual IP for Apache - 192.168.1.100
Assign virtual IP address using following steps on both node :
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0 :0
BOOTPROTO=none
BROADCAST=192.168.1.255
HWADDR=00:15:17:a3:92:04
IPADDR=192.168.1.100
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet

2] Download and install the heartbeat package. In our case we are using CentOS so we will install heartbeat with yum:

[root@server1 ~]# yum install heartbeat

or download below package
heartbeat-2.08
heartbeat-pils-2.08
heartbeat-stonith-2.08

3] Now we have to configure heartbeat on our two node cluster. We will deal with three files. These are: (authkeys, ha.cf, haresources)

[root@server1 ~]# cp /usr/share/doc/heartbeat-2.1.2/{authkeys,ha.cf,haresources} /etc/ha.d/

4] First we will deal with the authkeys file, we will use authentication method 2 (sha1). For this we will make changes in the authkeys file as below.

[root@server1 ~]# vi /etc/ha.d/authkeys
Add the following lines at the end of file & save:
auth 2
2 sha1 test-ha
5] Also the authkeys file must be read only root:

[root@server1 ~]# chmod 600 /etc/ha.d/authkeys

6] Make changes in second file of hearteat (haresources) :

[root@server1 ~]# vi /etc/ha.d/ haresources
#Add the following line at the end of file & save:
server1.linuxhome.in  192.168.1.100  httpd

7] The final piece of work in our configuration is to edit the ha.cf file which is important :

[root@server1 ~]# vi /etc/ha.d/ha.cf
#Add / Uncommnet below lines in ha.cf file & save.
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
initdead 120
bcast eth0
udpport 694
auto_failback on
node server1.linuxhome.in
node server2.linuxhome.in

8] As we want httpd highly enabled let's start configuring httpd:

[root@server1 ~]# vi /etc/httpd/conf/httpd.conf
#Add following line:
Listen 192.168.1.100:80

9] Copy the /etc/ha.d/ directory from server1 to server2:

[root@server1 ~]# scp -rvp /etc/ha.d/ root@server2.linuxhome.in:/etc/

10] Copy httpd.conf file from server1 to server2:

[root@server1 ~]# scp -rvp /etc/httpd/conf/httpd.conf root@server2.linuxhome.in:/etc/httpd/conf/

11] Create index.html file on both server under /var/www/html directory.

On server1.linuxhome.in
[root@server1 ~]# echo "SERVER1 Apache test server" > /var/www/html/index.html

On server2.linuxhome.in
[root@server2 ~]# echo "SERVER2 Apache test server" > /var/www/html/index.html

12 ] Now start heartbeat on the primary server1 and slave server2:
# /etc/init.d/heartbeat start
13] Open web-browser and type in the URL:
http://192.168.1.100
It will show server1.linuxhome.in apache test server.
13. Now stop the hearbeat daemon on server1.linuxhome.in:
# /etc/init.d/heartbeat stop
In your browser type in the URL http://192.168.1.100 and press enter.
It will show server2.linuxhome.in apache test server.