Pages

Saturday, June 16, 2012

Install Nagios 3 on Ubuntu Server 12.04 with a Script


Nagios is a popular Open Source Computer System and Network Monitoring software application. With this tool, you can monitor your entire IT infrastructure, spot problems before they occur, know immediately when problem arise, and more. Here are two new scripts that you can use for easy Nagios installation on Ubuntu Server 12.04.  

  1. Copy and Paste the script below into a Text Editor  e.g  Kate
  2. Save it in the Home folder as  archive_name.sh
  3. Open Terminal
  4. Type sudo su, then press Enter
  5. Type you password, then press Enter
  6. Type  chmod  +x  archive_name.sh, then press Enter
  7. Type ./archive_name.sh, then press Enter. The installation begins
  8. You should just enter the password for user of Nagios

Nagios Script:
# @Author: Osmani Urquiza
# @Create: 6/15/2012
#! /bin/bash
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install openssh-server
sudo /etc/init.d/networking restart
sudo apt-get install putty
sudo apt-get install build-essential
sudo apt-get install libgd2-xpm-dev
sudo apt-get install apache2
sudo apt-get install php-pear
sudo apt-get install rrdtool
sudo apt-get install librrds-perl
sudo apt-get install php5-gd
sudo apt-get install php5-common php5 libapache2-mod-php5
sudo gedit/etc/apache2/apache2.configure
sudo /etc/init.d/apache2 restart
sudo useradd -m nagios
sudo passwd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data
sudo mkdir downloads
cd downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.4.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
tar -zxvf nagios-3.4.4.tar.gz
tar -zxvf nagios-plugins-1.4.16.tar.gz
cd nagios
./configure --with-command-group=nagcmd
sed -i 's:for file in includes/rss/\*;:for file in includes/rss/\*.\*;:g' ./html/Makefile
sed -i 's:for file in includes/rss/extlib/\*;:for file in includes/rss/extlib/\*.\*;:g' ./html/Makefile
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
make install-exfoliation
make install-classicui
mkdir /usr/local/nagios/etc
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
cd
cd /home/ourquiza/downloads
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make all
make install
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
chown nagios.nagcmd /usr/local/nagios/var/rw
chmod g+rwx /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw
/etc/init.d/nagios restart
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
</script>
view raw Nagios hosted with ❤ by GitHub


If you end up in the terminal you see warning:0 and error:0. Congratulation! you'll be ready to start  your network monitor.
  • Open your browser, in the address bar type "localhost / nagios /", and then press Enter
  • Type Nagios username: nagiosadmin
  • Type Nagios username password: "this is what you defined when you entered some password in the script"

16 comments:

  1. hi
    the posts made by you on nagios works like charm.
    i made most use of these posts. can you make a post on how to monitor linux host using nagios

    ReplyDelete
    Replies
    1. Ok, I'll post "how to monitor Linux host using Nagios" in the next weeks.
      Thank you for you comment.

      Delete
  2. thanks for the reply. will wait for the post. we use ubuntu on our servers.

    ReplyDelete
  3. Hi, thanks a lot for the post.
    Now, i have 1 problem...
    What can I do if
    --2013-04-10 15:18:41-- (try: 6) http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
    Connecting to prdownloads.sourceforge.net (prdownloads.sourceforge.net)|216.34.181.59|:80...

    that's happend, again and again...
    Please, if ypu can help me, I really appreciate it
    Thanks again.

    Regards,
    Fabrizio

    ReplyDelete
    Replies
    1. Hi Fabrizio,
      I configured nagios plugins and nrpe plugin. Also i can monitor publically available services on the test machine.

      What i understood from here is you are trying to download the nagios plugin file. i downloaded the nagios plugin and nrpe through browser and configured them.
      This will work as i did the same.

      Regards,
      nagarjun

      Delete
    2. Thanks Nagarjun, do you have the link for download nagios and plugins?

      Regards.
      Fabrizio A.

      Delete
    3. Hi Fabrizio,
      I made ​​a test of the links that are in the script for Nagios and Nagios Plugins download, they work perfectly. I think you should run this script with administrator privileges.

      Thank you,

      Delete
  4. Thanks to all!
    It's works :D

    The best and Sincerily Regards
    Fabrizio A.

    ReplyDelete
  5. HI ,
    Its not working localhost/nagios / .

    ReplyDelete
    Replies
    1. What error you receive when trying to open the browser localhost/nagios/?

      Delete
  6. HI,
    Not Found
    The requested URL was not found on this server.

    AOLserver/4.5.1 on http://localhost/

    ReplyDelete
  7. I made ​​a test after Nagios installation for "http://localhost/nagios", this links work perfectly in a browser of Ubuntu Server 12.04

    ReplyDelete
  8. No sir same things , once below see i sending terminal error

    sudo 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

    ReplyDelete
    Replies
    1. ok, create the folders manually
      Open terminal as "root user"
      type:
      ~$ sudo mkdir /etc/httpd "Press Enter Key"
      ~$ sudo mkdir /etc/httpd/conf.d "Press Enter Key"
      ~$ sudo mkdir /etc/httpd/conf.d/nagios.conf "Press Enter Key"
      finally
      ~$ sudo make install-webconf "Press Enter Key"

      Delete
  9. dear sir ,
    i have installed nagios using quick guide. installed successfully and also added my windows server in /usr/local/nagios/etc/objects to monitor services. after i finished and open web page of my nagios i get an error


    C:\ Drive Space

    CRITICAL 08-09-2013 12:51:25 1d 19h 32m 5s 3/3 (Return code of 127 is out of bounds - plugin may be missing

    i am using ubuntu 12.04 lts desktop ver.

    ReplyDelete
  10. Go to the below link,

    http://systemadministratorrecipes.blogspot.com/2013/01/nagios-return-code-of-127-is-out-of.html

    After do the steps, restart Nagios and try again.

    ReplyDelete