Friday, March 13, 2015

Install and configure nagios core 4 on Ubuntu 12.04 LTS

Install and configure nagios core 4 on Ubuntu 12.04 LTS
In this tutorial we will install and configure nagios core 4 on Ubuntu 12.04 LTS. Nagios Core 4 has recently been released,at the time of writing this post Nagios core 4.0.2 was available.

Nagios is one of the most popular,reliable and robust Monitoring System.You can find number of plugins to monitor the network and server resources.
Best thing is Nagios Core is open source.You can modify the monitoring system as per your requirement.You can also create your own nagios plugins.We suggest you to submit your Nagios related contribution in exchange.nagios.org
Nagios team has added lots of new feature in Nagios Core 4.x Version over last version.To read about new feature in Nagios Core 4.x here is the referral link .
We also suggest you to read about version history(Referral link : Nagios core 4.x Version history)

Install and configure Nagios Core 4 in Ubuntu

We are doing this practical in Ubuntu 12.04 LTS. Given below are the brief description of our specs
Operating System : Ubuntu 12.04 LTS (x86_64)
Package Name : Nagios Core 4.0.2
Apache Version : 2.2.22-1ubuntu1.4
IP Address of Nagios Server : 192.168.56.101
Note: The practical has been performed in Freshly installed Ubuntu 12.04 LTS
Follow the given below steps to install and configure Nagios core 4.x in Ubuntu
Step 1 : Login in Server and become super user. Now install dependencies require for Nagios core 4 version
sudo su -

apt
-get update

apt
-get install wget build-essential apache2 php5 openssl perl make php5-gd wget libgd2-xpm libgd2-xpm-dev libapache2-mod-php5 libperl-dev libssl-dev daemon
Step 2 : Download the Nagios core 4 package
wget http://nchc.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.2/nagios-4.0.2.tar.gz
Step 3 : Now untar the downloaded nagios package
tar -xvzf nagios-4.0.2.tar.gz
Step 4 : Create user nagios and group nagcmd. Add the nagios user in supplementry group nagcmd
useradd nagios
groupadd nagcmd
usermod
-a -G nagcmd nagios
Step 5 : Compile and install nagios
cd nagios-4.0.2/
./configure --with-command-group=nagcmd
make all
make install
make install
-init
make install
-config
make install
-commandmode
make install
-webconf

Step 6 :
 Copy eventhandlers directory into nagios base directory . Change the owner and group to nagios
cp -rvf contrib/eventhandlers/ /usr/local/nagios/libexec/

chown
-R nagios:nagios /usr/local/nagios/libexec/eventhandlers
Step 7 : Set nagiosadmin user password.It is a default user for Nagios dashboard administration .
Give the password for nagiosadmin and we will use it in Nagios Dashboard
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Step 8 : Enable the rewrite apache module.Restart the apache after this.
a2enmod rewrite
/etc/init.d/apache2 restart
Step 9 : Starting the Nagios . We found problem while starting the nagios.Hence we will create service init script for nagios to start/stop the nagios service
Note: As per new nagios, the init script for nagios has problem with functions of Ubuntu/Debian system.
Below given is the error ,which we have found while running the command /etc/init.d/nagios start
root@ubuntu:~# /etc/init.d/nagios start
/etc/init.d/nagios: 20: .: Can’t open /etc/rc.d/init.d/functions
root@ubuntu:~#
Create a new file in /etc/init with name called nagios.conf
For service init script,we have taken reference from ssh.conf and rsyslog.conf file (path is /etc/init/ssh.conf and /etc/init/rsyslog.conf)
vi /etc/init/nagios.conf
## paste the below given content in /etc/init/nagios.conf
# nagios4 init script
### use command 'service nagios start|stop|restart'

description
"nagios 4.x core"

start on filesystems
stop on runlevel
[1246]

respawn

setuid nagios
setgid nagcmd
console log

script
exec /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfgend script
Step 10 : Now start the nagios service
service nagios start
Note 1: To stop the Nagios service
service nagios stop
Note 2: To check the status of Nagios service
service nagios status
Step 11 : There is one more problem i.e with eventhandlers found in Ubuntu.(See in this referral link)To fix this issue ,run below given command
chmod 666 /usr/local/nagios/var/rw/nagios.cmd
Step 12 : After starting nagios service.Open the web browser and type the URL appended with /nagios
example http://192.168.56.101/nagios
(Replace the 192.168.56.101 with your server ip address or domain name)
Nagios core 4 ubuntu
When you click on Services tab in Nagios Dashboard,you may see lots of Red area which means plugin is not installed.. For this we will install Nagios plugins.
Nagios core 4 Services

Install and configure Nagios plugin in Nagios Server

Now we will install nagios plugins in Nagios server for local alert check .
Step 13 : Download the nagios plugins in Nagios Server
cd ~
wget https
://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
Step 14: Untar the compressesed nagios-plugins-1.5.tar.gz file
tar -xvzf nagios-plugins-1.5.tar.gz
Step 15 : Change to extracted nagios-pligins directory and install the plugins
cd nagios-plugins-1.5
./configure --with-nagios-user=nagios --with-nagios-group=nagios

make

make install
Step 16 : Wait for a minimum 90 Seconds.The dashboard will be updated and all checks will be active. You can notice all Red colors change to Green colors
Nagios Core 4
Note : Rather then waiting, you can reschedule the check in nagios.
Click on any Service for eg. “Current Load” . Now see at right hand side. There is a link called “Re-schedule the next check of this service“. Click on it, and after giving reschedule time,click ok. The Nagios Server will check and update the information in new re-schedule time.
Below is the reference screenshot of “Service Commands” section
Nagios Service Commands
Continue reading

Thursday, March 12, 2015

How to Break Root Password in Linux

How to Break Root Password in Linux
You can reset forgotten root password under Linux by booting system into single user mode or emergency mode (also known as rescue mode).

Boot loader is GRUB-

Following is the procedure to reset root password if you are using GRUB as a boot loader:

  1. Select the kernel
  2. Press the e key to edit the entry
  3. Select second line (the line starting with the word kernel)
  4. Press the e key to edit kernel entry so that you can append single user mode
  5. Append the letter S (or word Single) to the end of the (kernel) line
  6. Press ENTER key
  7. Now press the b key to boot the Linux kernel into single user mode
  8. At prompt type passwd command to reset password:
You need to mount at least / and other partitions:
# mount -t proc proc /proc
# mount -o remount,rw /
Change the root password, enter:
# passwd
Finally reboot system:
# sync
# reboot
My boot loader is LILO-
At LILO boot loader type linux single and press [ENTER] key:
Boot: linux single
When you get the # prompt you will need to type passwd root to reset password:
# passwd
Reboot system:
# sync
# reboot
Continue reading

How To Set Schedule automatic startup and shutdown System in Linux



If you want to hibernate, your Linux machine automatically or want to start it automatically at a specified time for my arrival at the office. To start some process?

Use- 'rtcwake Command'

Help-
# man rtcwake
You can use this command to either hibernate it now and wake up your Linux machine at a specific time.

                                                                      Or 
you can use it to wake it up after hibernating it at your will (read time) but want the machine to start at a specific time.

Note- I am doing it on ubuntu..

Using rtcwake-


The rtcwake command requires root permissions, so it must be run with sudo on Ubuntu and other Ubuntu-derived distributions. On Linux distributions that don’t use sudo, you’ll have to log in as root with the su command first.

ashu@server:~$ su -
root@server:~#

Step-1 Install the rtcwake Package..

root@server:~#  apt-get install rtcwake

'rtcwake' package successfully Install...

Step- 2 Check & Set The System Hardware Time..

Step- 3 How To Use..


Now use the basic syntax of the command..

root@server:~# rtcwake -m [type of suspend] -s [number of seconds]

(Note- First Check & Set The System Hardware Time..)

Example-1
 The following command suspends your system to disk (hibernates it) and wakes it up 60 seconds later:

root@server:~# rtcwake -m disk -s 60

Example-2 For example, to have your computer wake up at 9:30am tomorrow but not suspend immediately (assuming your hardware clock is set to local time), run the following command:

root@server:~#  rtcwake -m no -l -t $(date +%s -d "tomorrow 09:30")


Example-3. Keep on working right now, but once I hibernate at my will. Start the machine again at 6:30PM (OR 18:30PM) Today.

root@server:~# rtcwake -m no -l -t $(date +%s -d "today 06:30")

Types of Suspend

The -m switch accepts the following types of suspend:
  • standby – Standby offers little power savings, but restoring to a running system is very quick. This is the default mode if you omit the -m switch.
  • mem – Suspend to RAM. This offers significant power savings – everything is put into a low-power state, except your RAM. The contents of your memory are preserved.
  • disk – Suspend to disk. The contents of your memory are written to disk and your computer is powered off. The computer will turn on and its state will be restored when the timer completes.
  • off – Turn the computer off completely. rtcwake’s man page notes that restoring from “off” isn’t officially supported by the ACPI specification, but this works with many computers anyway.
  • no – Don’t suspend the computer immediately, just set the wakeup time. For example, you could tell your computer to wake up at 6am. After that, can put it to sleep manually at 11pm or 1am – either way, it will wake up at 6am.

Seconds vs. Specific Time

The -s option takes a number of seconds in the future. For example, -s 60 wakes your computer up in 60 seconds, while -s 3600 wakes your computer up in an hour.
The -t option allows you to wake your computer up at a specific time. This switch wants a number of seconds since the Unix epoch (00:00:00 UTC on January 1, 1970). To easily provide the correct number of seconds, combine the date command with the rtcwake command.
The -l switch tells rtcwake that the hardware clock is set to local time, while the -u switch tells rtcwake that the hardware clock (in your computer’s BIOS) is set to UTC time. Linux distributions often set your hardware clock to UTC time and translate that to your local time.

Hibernate- 
Hibernation in computing is powering down a computer while retaining its state.
Upon hibernation, the computer saves the contents of its random access memory (RAM) to a hard disk or other non-volatile storage. Upon resumption, the computer is exactly as it was upon entering hibernation.

Example- If You want to set, System automacialy go to hibernate mode after 1 minuts Now..

root@server:~#
 echo 'pm-hibernate' | at now + 01 minutes


Simple Script-

# vim wake.sh

----------------------------------------------------------
#!/bin/bash
#To have your computer wake up at 1:30pm today and suspend after 2 Minutes.
 rtcwake -m no -l -t $(date +%s -d "today 13:30")
 echo 'pm-hibernate' | at now + 02 minutes;exit
------------------------------
------------------------------

# chmod + x wake.sh
# ./wake.sh

Now Your System Power off after 2 Minutes, and System on Automaticaly at 1:30PM.....



More Info..
http://linux.die.net/man/8/rtcwake
_
Continue reading

How do I install Ubuntu Server step-by-step

How do I install Ubuntu Server step-by-step
First, you will need to download the current version of Ubuntu Server . A 64 bit version is recommended, but you can also download a 32bit version Here. Once downloaded you need to create a bootable CD/DVD or USB flash.
   
Once done, put the disc in your drive, or insert the USB flash, and reboot your machine. Make sure that you set your BIOS to boot either from the CD/DVD or USB flash depending on which installation method you choose.
Once booted, just follow the steps shown in the images below.

On the first screen you can choose you language of install.
enter image description here

Select Install Ubuntu Server.
enter image description here

Select the language used for the installation process.
enter image description here

Select your geographical location.
enter image description here

Configure your keyboard. I choose no to manually choose the keyboard.
enter image description here

I choose the English (US) for country origin.
enter image description here

I choose the English (US) keyboard layout.
enter image description here

At this point the system will detect the hardware to find a CD-ROM drive.
enter image description here

At this step, the installation will detect and load any additional component.
enter image description here

At this step, the installation will detect the network hardware.
enter image description here

Type in the host name you want to configure your server as.
enter image description here

Type in the user's name.
enter image description here

Type in a password for the username.
enter image description here

Choose whether to encrypt your home directory or not. I recommend selecting No I recommend selecting No because it makes it easier to do recovery if needed in case a corruption of data happens.
enter image description here

Configure clock, and time zone.
enter image description here

At this point, the installation is detecting disks, and other hardware.
enter image description here

At this stage is were you partition your disk(s). Select Guided as it is the default method.
enter image description here

Select the partition of your choice, is this installation its the SCSI1.
enter image description here

Select Yes to start writing the changes to disks, and configure LVM.
enter image description here

Answer Yes to actually write the changes to disk.
enter image description here

The installation is copying data at this stage.
enter image description here

At this stage the installation is configuring Apt Sources.List.
enter image description here

This is were you can configure a Proxy. I select Continue since I'm not using a proxy.
enter image description here

The installation is selecting the software being installed.
enter image description here

This is where you configure how to install updates. I choose the automatic method.
enter image description here

You can choose one these option at the time of install or later. if you select continue, you can manually choose what you want to install later.
enter image description here

Cleaning up is being done.
enter image description here

Starting the installation of Grub
enter image description here

Select Yes to install grub to the Master Boot Record
enter image description here

Finishing the installation. Select continue and remove the disk or USB.
enter image description here
You're done. Reboot your machine, and type in your username you created earlier, and your password to login. That is it, you are now logged in to your new Ubuntu server!
Continue reading

Ubuntu History

Ubuntu History

The Ubuntu story

ubuntu

Ubuntu is an ancient African word meaning 'humanity to others'. It also means 'I am what I am because of who we all are'. The Ubuntu operating system brings the spirit of Ubuntu to the world of computers.

Where did it all begin?

Linux was already established as an enterprise server platform in 2004, but free software was not a part of everyday life for most computer users. That's why Mark Shuttleworth gathered a small team of developers from one of the most established Linux projects – Debian – and set out to create an easy-to-use Linux desktop: Ubuntu.
The vision for Ubuntu is part social and part economic: free software, available to everybody on the same terms, and funded through a portfolio of services provided by Canonical.

Ubuntu releases

The Ubuntu team broke new ground in committing to a programme of scheduled releases on a predictable six-month basis. It was decided that every fourth release, issued on a two-year basis, would receive long-term support (LTS). LTS releases are typically used for large-scale deployments.
Ubuntu is different from the commercial Linux offerings that preceded it because it doesn't divide its efforts between a high-quality commercial version and a free 'community' version. The commercial and community teams collaborate to produce a single, high-quality release, which receives ongoing maintenance for a defined period. Both the release and ongoing updates are freely available to all users.

Governance

The first official Ubuntu release -- Version 4.10, codenamed the 'Warty Warthog' — was launched in October 2004, and sparked dramatic global interest as thousands of free software enthusiasts and experts joined the Ubuntu community.
The governance of Ubuntu is somewhat independent of Canonical, with volunteer leaders from around the world taking responsibility for many critical elements of the project. It remains a key tenet of the Ubuntu Project that Ubuntu is a shared work between Canonical, other companies, and the thousands of volunteers who bring their expertise to bear on making it a world-class platform for anyone to use.

Ubuntu today

Ubuntu today has eight flavours and dozens of localised and specialised derivatives. There are also special editions for servers, OpenStack clouds, and mobile devices. All editions share common infrastructure and software, making Ubuntu a unique single platform that scales from consumer electronics to the desktop and up into the cloud for enterprise computing.
The Ubuntu OS and the innovative Ubuntu for Android convergence solution make it an exciting time for Ubuntu on mobile devices. In the cloud, Ubuntu is the reference operating system for the OpenStack project, it’s a hugely popular guest OS on Amazon's EC2 and Rackspace's Cloud, and it’s pre-installed on computers from Dell, HP, Asus, Lenovo and other global vendors. And thanks to that shared infrastructure, developers can work on the desktop, and smoothly deliver code to cloud servers running the stripped-down Ubuntu Server Edition.
Continue reading