Tuesday, April 30, 2013

Add a nagios service monitor

Step 1: Write a script to monitor service using any scripting languages. In this article, I use perl to monitor port 8888
=================================
root@restmq:/usr/local/nagios/etc/objects# less ~/nagios/checkrestmq.pl

#!/usr/bin/perl -w

my $restmq_result = `netstat -na | grep 8888` ;

#print "$restmq_result" ;
# OK  WARNING  UNKNOWN CRITICAL

if ($restmq_result)
{
   print "OK\n"
}
else
{
   print "CRITICAL\n"
}

Step 2 : Add this perl into nagios command.cfg
Default location:
/usr/local/nagios/etc/objects/commands.cfg

define command{
       command_name    check_restmq
       command_line    /home/chang/nagios/checkrestmq.pl
}

Step 3: Add this command into service localhost.cfg
 #check_restmq
define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        service_description             RestMQ
        check_command                   check_restmq
        notifications_enabled           0
        }



Step 4: restart nagios
  /etc/init.d/nagios stop
  /etc/init.d/nagios start

install nagios 3.5 in ubuntu 12

  • Prerequirement
  105  apt-get install apache2 libapache2-mod-php5 build-essential
  106  apt-get install libgd2-xpm-dev
  107  /usr/sbin/useradd -m -s /bin/bash nagios
  108  passwd nagios
  109  /usr/sbin/groupadd nagcmd
  110  /usr/sbin/usermod -a -G nagcmd nagios
  111  /usr/sbin/usermod -a -G nagcmd www-data
  • Download Nagios
  114  mkdir download
  115  cd download/
  116  wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5.0.tar.gz
  117  wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz

  • Install Nagios
  118  tar xvf nagios-3.5.0.tar.gz
  119  cd nagios/
  120  ./configure --with-command-group=nagcmd

=================================================================
General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagcmd
            Embedded Perl:  no
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
                Lock file:  ${prefix}/var/nagios.lock
   Check result directory:  ${prefix}/var/spool/checkresults
           Init directory:  /etc/init.d
  Apache conf.d directory:  /etc/apache2/conf.d
             Mail program:  /bin/mail
                  Host OS:  linux-gnu

 Web Interface Options:
 ------------------------
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):

  • Install latest ssl library
check which version is avaiable
apt-cache search libssl | grep SSL
libssl-dev - SSL development libraries, header files and documentation
libssl-doc - SSL development documentation documentation
libssl1.0.0 - SSL shared libraries
libssl-ocaml - OCaml bindings for OpenSSL (runtime)
libssl-ocaml-dev - OCaml bindings for OpenSSL
libssl0.9.8 - SSL shared libraries
libsslcommon2 - enterprise messaging system - common SSL libraries
libsslcommon2-dev - enterprise messaging system - common SSL development file

 Install SSL library
 apt-get install libssl1.0.0 libssl-dev
  • Install Nagios plugin
  133  tar xvf nagios-plugins-1.4.16.tar.gz
  134  cd nagios-plugins-1.4.16/
  135  ./configure --with-nagios-user=nagios --with-nagios-group=nagios
  146  make
  147  make install


  • Start Nagios
Configure Nagios to automatically start when the system boots.
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Verify the sample Nagios configuration files.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, start Nagios.
/etc/init.d/nagios start

Monday, April 15, 2013

mongodb for ubuntu


 2003  mkdir /data
 2004  mkdir /data/db/
 2005  mongod --journal
 2006  nohup mongod --journal &

Thursday, April 11, 2013

install RESTMQ in Ubuntu 12 64

1, Update system

  apt-get update
  apt-get upgrade
  apt-get install make cpp gcc
  apt-get install tcl
  apt-get install git

2, install redis
    cd /opt/
   wget http://redis.googlecode.com/files/redis-2.6.12.tar.gz
  
    tar zxvf redis-2.6.12.tar.gz
      
   rm redis-2.6.12.tar.gz
   cd redis-2.6.12/
   make

   make test
  
3, Install twiested
 apt-get install python python-twisted python-twisted-web python-openssl  python-setuptools intltool

 twistd
 
4, install RESTMQ
  cd /opt/
   git clone https://github.com/gleicon/restmq.git
   cd restmq/

   python setup.py install

   cd start_scripts/
 
   ./restmq_server --listen=192.168.88.50
  
5, Open browser, check restmq is running:
http://192.168.88.50:8888/p/test

ubuntu install twisted, redis, restmq

Step 1 : install twisted
root@restmq:~# apt-get install python python-twisted python-twisted-web python-openssl python-simplejson python-setuptools intltool python-xdg python-chardet geoip-database python-libtorrent python-notify python-pygame python-glade2 librsvg2-common xdg-utils python-mako

Step 2: install redis.

root@restmq:~# apt-get install make cpp gcc


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

Installing Redis: jemalloc/jemalloc.h: No such file or directory


make distclean


root@restmq:/opt/redis-2.6.12/src# ./redis-server ../redis.conf
root@restmq:/opt/redis-2.6.12/src# pwd
/opt/redis-2.6.12/src
root@restmq:/opt/redis-2.6.12/src# ps -ef | grep redis
root     28454     1  0 22:27 ?        00:00:00 ./redis-server ../redis.conf
root     28458 18551  0 22:27 pts/1    00:00:00 grep --color=auto redis
root@restmq:/opt/redis-2.6.12/src# telnet localhost 6379
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.


Step 3: install restMQ:

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

root@restmq:/opt/restmq/start_scripts# ./restmq_server --listen=192.168.1.44

Friday, April 5, 2013

install restmq

prerequirements:

 yum install python-devel openssl-devel

Install:
 git clone  git://github.com/gleicon/restmq.git

 cd restmq/
 python setup.py install