12/20/2012

Nagiosgraph installation

1. Download nagiosgraph.
http://nagiosgraph.sourceforge.
#tar xvfz nagiosgraph-1.4.4.tar.gz
#cd nagiosgraph-1.4.4
#./install.pl
continue with interactive setup.<br />
== configuration summary ==
  ng_layout            standalone
   ng_prefix            /usr/local/nagiosgraph
   ng_etc_dir           /usr/local/nagiosgraph/etc
   ng_bin_dir           /usr/local/nagiosgraph/bin
   ng_cgi_dir           /usr/local/nagiosgraph/cgi
   ng_doc_dir           /usr/local/nagiosgraph/doc
   ng_examples_dir      /usr/local/nagiosgraph/examples
   ng_www_dir           /usr/local/nagiosgraph/share
   ng_util_dir          /usr/local/nagiosgraph/util
   ng_var_dir           /usr/local/nagiosgraph/var
   ng_rrd_dir           /usr/local/nagiosgraph/var/rrd
   ng_log_dir           /usr/local/nagiosgraph/var
   ng_log_file          /usr/local/nagiosgraph/var/nagiosgraph.log
   ng_cgilog_file       /usr/local/nagiosgraph/var/nagiosgraph-cgi.log
   ng_url               /nagiosgraph
   ng_cgi_url           /nagiosgraph/cgi-bin
   ng_css_url           /nagiosgraph/nagiosgraph.css
   ng_js_url            /nagiosgraph/nagiosgraph.js
   nagios_cgi_url       /nagios/cgi-bin
   nagios_perfdata_file /tmp/perfdata.log
   nagios_user          nagios
   www_user             apache
   modify_nagios_config n
   nagios_config_file
   nagios_commands_file
   modify_apache_config n
   apache_config_dir
   apache_config_file
=====

Post installation
2. #vi /etc/nagios/nagios.cfg
add the following lines
====
# process nagios performance data using nagiosgraph
process_performance_data=1
service_perfdata_file=/tmp/perfdata.log
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
service_perfdata_file_processing_command=process-service-perfdata-for-nagiosgraph
====
3. #vi /etc/nagios/objects/commands.cfg
add the following lines.
====
# command to process nagios performance data for nagiosgraph
define command {
  command_name process-service-perfdata-for-nagiosgraph
  command_line /usr/local/nagiosgraph/bin/insert.pl
}
====
4. #vi /etc/httpd/conf/httpd.conf
add the following line.
====
include /usr/local/nagiosgraph/etc/nagiosgraph-apache.conf
====
5. service restart
#nagios -v /etc/nagios/nagios.cfg
#service nagios restart
#service httpd restart

6. #vi /usr/share/nagios/html/config.inc.php
====
#$cfg['cgi_base_url']='/nagios/cgi-bin/';
$cfg['cgi_base_url']='/nagios/cgi-bin';
$cfg['ng_cgi_base_url']='/nagiosgraph/cgi-bin';
====

7. #cd /usr/share/nagios/html/
#cp side.php side.php.org
edit side.php like below.

# diff side.php.org side.php
92c92,100
< <li><a href="<?php echo $cfg["cgi_base_url"];?>/trends.cgi" target="<?php echo $link_target;?>">Trends</a></li>
---
> <li><a href="<?php echo $cfg["cgi_base_url"];?>/trends.cgi" target="<?php echo $link_target;?>">Trends</a>
> <ul>
> <li><a href="<?php echo $cfg["ng_cgi_base_url"];?>/show.cgi" target="<?php echo $link_target;?>">Graphs</a></li>
> <li><a href="<?php echo $cfg["ng_cgi_base_url"];?>/showhost.cgi" target="<?php echo $link_target;?>">Graphs by Host</a></li>
> <li><a href="<?php echo $cfg["ng_cgi_base_url"];?>/showservice.cgi" target="<?php echo $link_target;?>">Graphs by Service</a></li>
> <li><a href="<?php echo $cfg["ng_cgi_base_url"];?>/showgroup.cgi" target="<?php echo $link_target;?>">Graphs by Group</a></li>
> </ul>
> </li>

7. Refresh your nagios web page in your web browser.
nagios graph menu will be appeared.

12/06/2012

Nagios Installation

Nagios Installation

A. Nagios Server
yum install nagios nagios-plugins nagios-nrpe
yum install nagios-plugins-dig nagios-plugins-disk nagios-plugins-disk_smb nagios-plugins-dns nagios-plugins-http nagios-plugins-icmp nagios-plugins-linux_raid nagios-plugins-load nagios-plugins-log nagios-plugins-mailq nagios-plugins-mrtg nagios-plugins-nagios nagios-plugins-nwstat nagios-plugins-perl nagios-plugins-smtp nagios-plugins-snmp nagios-plugins-ssh nagios-plugins-swap nagios-plugins-tcp nagios-plugins-time nagios-plugins-users

NRPE

Servers to be monitored
yum install nagios-nrpe nagios-plugins

To be continued...

11/16/2012

Installing mod_rpaf to Amazon EC2 behind ELB

1. download mod_rpaf-0.6.tar.gz
2. tar xvfz mod_rpaf-0.6.tar.gz
3. cd mod_rpaf-0.6

According to the following link, I created the patch file like below.
http://tech.superhappykittymeow.com/?p=281

4. vi diff.diff


--- mod_rpaf-2.0.c 2008-01-01 03:05:40.000000000 +0000
+++ mod_rpaf-2.0.c~ 2011-08-25 20:04:39.000000000 +0000
@@ -136,13 +136,25 @@
 }

 static int is_in_array(const char *remote_ip, apr_array_header_t *proxy_ips) {
-    int i;
+   /* int i;
     char **list = (char**)proxy_ips->elts;
     for (i = 0; i < proxy_ips->nelts; i++) {
         if (strcmp(remote_ip, list[i]) == 0)
             return 1;
     }
     return 0;
+    */
+    return 1;
+}
+
+static char* last_not_in_array(apr_array_header_t *forwarded_for,
+          apr_array_header_t *proxy_ips) {
+    int i;
+    for (i = (forwarded_for->nelts)-1; i > 0; i--) {
+ if (!is_in_array(((char **)forwarded_for->elts)[i], proxy_ips))
+     break;
+    }
+    return ((char **)forwarded_for->elts)[i];
 }

 static apr_status_t rpaf_cleanup(void *data) {
@@ -161,7 +173,7 @@
     if (!cfg->enable)
         return DECLINED;

-    if (is_in_array(r->connection->remote_ip, cfg->proxy_ips) == 1) {
+    /* if (is_in_array(r->connection->remote_ip, cfg->proxy_ips) == 1) { */
         /* check if cfg->headername is set and if it is use
            that instead of X-Forwarded-For by default */
         if (cfg->headername && (fwdvalue = apr_table_get(r->headers_in, cfg->headername))) {
@@ -183,7 +195,8 @@
             rcr->old_ip = apr_pstrdup(r->connection->pool, r->connection->remote_ip);
             rcr->r = r;
             apr_pool_cleanup_register(r->pool, (void *)rcr, rpaf_cleanup, apr_pool_cleanup_null);
-            r->connection->remote_ip = apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]);
+            /* r->connection->remote_ip = apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]); */
+            r->connection->remote_ip = apr_pstrdup(r->connection->pool, last_not_in_array(arr, cfg->proxy_ips));
             r->connection->remote_addr->sa.sin.sin_addr.s_addr = apr_inet_addr(r->connection->remote_ip);
             if (cfg->sethostname) {
                 const char *hostvalue;
@@ -201,7 +214,7 @@
             }

         }
-    }
+    /* } */
     return DECLINED;
 }
=======

5. patch < diff.diff
6.  vi Makefile
edit the fourth line like below and save it.
=======
# Makefile for mod_rpaf.c (gmake)
# $Id: Makefile 16 2007-12-13 03:40:22Z thomas $
APXS=$(shell which apxs)
#APXS2=$(shell which apxs2)
APXS2=/usr/sbin/apxs
=======

7. make rpaf-2.0
8. make install-2.0
9. /usr/sbin/apachectl configtest
10. service httpd restart
11. Check the apache log. :)

10/31/2012

AWS EC2 setup useful commands



#yum install patch
#yum install make
#yum install gcc

For dig command,
#yum install bind-utils

For locate command,
#yum install mlocate

#yum install httpd httpd-devel
#yum install mod_rpaf
#yum install geoip





10/30/2012

How to enable epel repository

For CentOS 6, 64bit

1. Download the rpm of epel.
# wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-x.noarch.rpm
check the latest epel version.

2. Install the package.
# rpm -ivh epel-release-6-7.noarch.rpm

3. Edit epel conf file to enable epel repository.

# vi /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://dl.fedoraproject.org/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=1
priority=2

4. check if epel repository is working.
# yum install geoip

3/14/2012

Cacti got graphs, But no values.


Cacti about NaN's in their graphs
http://docs.cacti.net/manual:087:4_help.2_debugging#not_nan_but_0_zero_values

Cacti Repodata

For CentOS/RHEL 6.x, 64bit

http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/

3/09/2012

phpMyAdmin Error: Cannot load mcrypt extension

For CentOS 6.2 64bit
The solution is below.


# rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
# yum update
# yum install php-mcrypt
# /usr/sbin/apachectl restart

3/08/2012

sed in vi.

:%s/old_string/new_string/g