Jeff Busby
  • Home
  • About Jeff
KEEP IN TOUCH

Katango Makes Sense Out of Social Graph

Jul12
2011
Leave a Comment Written by Jeff

Interesting interview by Robert Scoble talking to Yoav Shoham, founder and chairman of Katango a new start up out of Stanford University that positions itself as a social organizer.  In a nutshell, you login to Facebook Connect via the Katango mobile app and within a few seconds it organizes your friends into clusters or circles.  Right now there’s only support for Facebook but as Yoav states near the end of the interview, you can expect to see support for more social platforms in the coming future.   It’s this last comment that I find very exciting and what makes this application apeal to me.

 

Posted in facebook, internet, social graph, start ups - Tagged facebook, katango, mobile, scoble, social graph

A Better Solr Startup Script (initd)

Mar24
2011
3 Comments Written by Jeff

We started using Solr a few months ago as an upgrade from Zend Lucene which we were using prior to that.  The reason for the switch is the content of a later post, what I wanted to share here is some of the glue we used to integrate Solr into our architecture.

One of the things I notice when I first started working with Solr was it’s lack of a good startup script that worked well as an initd service.  There are a few examples out there that do the job, and admittedly worked for me for a while.  The problem I ran into was trying to integrate Solr updates and indexing jobs into our continuous integration environments.  Quite simply, all the solutions offered in the blogsphere caused our ant build scripts to hang.  This is what initially got me digging into the solution we were currently using.

I’m not going to get into the how and where of the script itself, if you want to have a look you can clone a copy from my github repository:

$ git clone https://github.com/jbusby/solr-initd.git

In order to get it up and running on your Fedora/RHEL/CentOS machin copy solr.initd to /etc/initd/solr

$ cp solr.initd /etc/initd/solr

Copy solr.start to /path/to/solr/install/solr.start

$ cp solr.start /path/to/solr/install/solr.start

Copy solr.conf to /etc/solr.conf

$ cp solr.conf /etc/solr.conf

Edit solr.conf to suite your needs.

$ vim /etc/solr.conf

Make sure solr isn’t currently running and if it is shut it down using your current method then.

Start it up using service:

$ service solr start

That’s it!  Let me know if you found it useful, or if you have any suggestions for improvement.

————————————————

References:

Apache Solr: http://lucene.apache.org/solr/
Creating Custom Init Scripts: http://www.novell.com/coolsolutions/feature/15380.html
A Solr Init script in the wild: http://rc98.net/solrinit
And another: http://daveelkins.com/2009/01/13/setting-solr-as-a-daemon-and-monitoring-with-god/

Posted in fedora, linux, web development - Tagged fedora, linux, search, solr

Monitoring a Remote Machine with Nagios and Fedora

Feb24
2011
1 Comment Written by Jeff

In the first part to this article I showed how I setup Nagios on a host and configured it to monitor itself.  Not  particularly useful in and of itself,  but it was a good starting point.  In this next article I’ll show you how I’m using the Nagios host to monitor any number of remote machines.

When I originally wrote these notes I was setting up this system on mostly Fedora 11 and 12 machines.  Since then I’ve done the same setup on both Fedoara 13 and 14 machines and a couple of Windows 2003 servers with very little modifications, I’ll try to point out any differences as we go.

The first step is to install NRPE (Nagios Remote Plug-Ins Executor) on the remote machine you want to monitor, along with the neccessary plugins.   I chose to install nagios-plugins-all just because I use most of them on at least one server or another, so it simplified the setup proccess accross all our servers.  You may want to have a look at what plugins are available and choose only the ones you’ll need, the last time I checked there was quite a few.

You can view the available list using YUM like so:

remote#: sudo yum list nagios\*

Once you’ve decided what ones you’ll need go ahead and install them, here’s what I did:

remote#: sudo yum install nrpe nagios-plugins nagios-plugins-nrpe nagios-plugins-all

The next step is to setup the nrpe daemon to run under xinetd. I should mention here that you don’t have to use xinetd to run nagios, it can be run unter inietd or as a stand-alone daemon if my memory serves me correct, this is the way I decided to run it however.  I believe with Fedora 11 and 12 xinetd isn’t installed by default so you may need to do so:

remote#:  sudo yum install xinetd

Now you can create/edit the nrpe config file under xinetd:

remote#: sudo vim /etc/xinetd.d/nrpe

Add the following to the file:

# 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/sbin/nrpe
server_args     = -c /etc/nagios/nrpe.cfg --inetd
log_on_failure  += USERID
disable         = no
only_from       = 127.0.0.1  xxx.xxx.xxx.xxx  <-- This last ip should be the ip of the nagios host machine
}

Note: make sure you add the ip address of you host nagios machine next to ‘only_from = 127.0.0.1′.

The next step is to add nrpe somewhere in the services config:

remote#:  sudo vim /etc/services
nrpe            5666/tcp                # NRPE <-- Insert this line somewhere in the file

Now restart xinetd:

remote#:  sudo service xinetd restart
Stopping xinetd:                      [  OK  ]
Starting xinetd:                       [  OK  ]

Now check that everything has been configured correctly by using the following command:

remote#:  sudo netstat -at | grep nrpe

Which should display something like this:

tcp        0      0 *:nrpe           *:*            LISTEN

If it displays nothing then the service isn’t setup, go back and make sure you didn’t miss any steps, otherwise continue on.

If you have a firewall setup make sure you open port 5666. If you’re using iptables you can do something like this:

remote#: sudo iptables -A INPUT -p tcp --dport 5666 -j ACCEPT

If you want to make sure that the ip is added successfully you can list your current iptables setup:

remote#: sudo iptables -L

If all’s well you should see the nrpe service listed like so:

ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:nrpe

At this point you might want to have a look at the nrpe config file for nagios located at /etc/nagios/nrpe.cfg. You shouldn’t need to change any of the defaults for the purpose of this post as we’re only going to monitor ping, ssh and http for this machine. However if you want to monitor some of the internal processes and statistics like swap size and disk space you’ll have to configure what Nagios refers to as ‘command definitions’. I may make another post with regards to this later but in the mean time if you want to add this functionality have a look at the bottom of the file under “COMMAND DEFINITIONS”.

In this next step you’ll need to open a terminal on your nagios host machine and add the new remote machine to the nagios configs.

Start by creating the config file for the new remote machine we just configured.

nagios-host#: sudo vim /etc/nagios/objects/remote-server-name.cfg

Insert the following definitions in the the config:

# HOST DEFINITION
# Define a host for the remote machine
define host{
    use                     linux-server            ; Name of host template to use
                                                    ; This host definition will inherit all variables that are defined
                                                    ; in (or inherited by) the linux-server host template definition.
    host_name               remote-server-name      ; A unique name that is refered to when defining services to monitor
    alias                   Web Server              ; A User friendly name of the server, used in the nagios admin web interface
    address                 xx.xx.xx.xx             ; The ip of the remote server
}

# SERVICE DEFINITIONS
# Define a service to "ping" the remote machine
define service{
    use                             generic-service         ; Name of service template to use
    host_name                       remote-server-name
    service_description             PING
    check_command                   check_ping!100.0,20%!500.0,60%
}

# Define a service to check SSH on the remote machine.
define service{
    use                             generic-service         ; Name of service template to use
    host_name                       remote-server-name
    service_description             SSH
    check_command                   check_ssh
}

# Define a service to check HTTP on the local machine.
define service{
    use                             generic-service         ; Name of service template to use
    host_name                       remote-server-name
    service_description             HTTP
    check_command                   check_http
}

We’ve done two things in this config file, 1 we’ve defined the remote server for nagios inside the define host definition, and 2 we’ve define 3 services that we’re going to monitor on the remote server, ping, ssh and http. As I mentioned above there are a lot more services and statistics that you can monitor, but these should be a good starting point.

Now we need to add a reference to this new config file in Nagios’ main config.

nagios-host#: sudo vim /etc/nagios/nagios.cfg
cfg_file=/etc/nagios/objects/remote-server.cfg # <-- add this line somewhere

Now you can run a sanity check on the nagios host config:

nagios-host#: sudo /usr/sbin/nagios -v /etc/nagios/nagios.cfg

If all’s well then you should get some output with this at the end:

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

If everything is fine you can start the nrpe daemon on the remote machine:

remote#: sudo service nrpe start
Starting nrpe:                                             [  OK  ]

Then restart nagios on the nagios host machine so it can see the new configurations

nagios-host#: sudo service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.

Gotchas:

If you get a response like:

CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.

Make sure that you have dont_blame_nrpe=1 in your /etc/nagios/nrpe.cfg file on the remote server.

If you get a response like:

NRPE: Command 'check_users' not defined

Make sure you have the corresponding command in your /etc/nagios/nrpe.cfg file on the machine running nrpe (the remote machine). For the error above the entry to fix it would look something like this:

command[check_users]=/usr/lib64/nagios/plugins/check_users -w $ARG1$ -c $ARG2$

If you’ve made it through and there’s no errors then you should be able to open up your Nagios admin page and see the new remote server in your list of hosts. Happy monitoring!

————————————————————

References:

Nagios Quick Start
Nagios Core Documentation

Posted in fedora, linux, nagios

Monitoring a Local Machine with Nagios and (Fedora)

Jan29
2011
3 Comments Written by Jeff

There are plenty of resources that speak to the what and why of real-time server monitoring and there’s no shortage of lists of software that will help you achieve such a goal, so I’m not going to try and pretend I can add anything to that conversation, but what I will do is share with you my installation notes on how to setup such a service.

The company I work for currently uses a couple dozen servers that run our various environments, the majority of them are Fedora with a couple of Windows servers sprinkled in the mix and even one Mac server…which is a first for me. In this, the first of two posts, I’ll show you how we installed Nagios on a single server and set it up to monitor itself. In an second post I’ll show you how we use this Nagios host to monitor all of our remote linux severs.

Caveat lector:

- The host server is running Fedora 13, but we successfully ran this installing on Fedora 11, 12, 13 and 14 servers.

- We installed all software via YUM

On the Nagios host you should make sure you have all the neccessary utilities installed:

nagios-host#: yum install httpd php
nagios-host#: yum install gcc glibc glibc-common
nagios-host#: yum install gd gd-devel

The Nagios quick start says to add the nagios user as well as nagcmd group and to add apache to the nagcmd group, however the YUM installation takes care of this for you (note: nagcmd appears to be deprecated).

nagios-host#: yum install nagios nagios-plugins  nagios-plugins-all

If you want to confirm that the nagios user and group was setup you can check:

nagios-host#: id nagios
uid=496(nagios) gid=492(nagios) groups=492(nagios)
 
nagios-host#: id -Gn apache
apache nagios

Open /etc/nagios/objects/contacts.cfg and add your email address to the nagiosadmin contact.

nagios-host#: vim /etc/nagios/objects/contacts.cfg

— open /etc/nagios/objects/contacts.cfg —

 email    nagios@localhost      ; &lt;&lt;***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

— close /etc/nagios/objects/contacts.cfg —

Configure the web interface

Edit the nagios.conf file that was installed via yum

nagios-host#: vim /etc/httpd/conf.d/nagios.conf

Add the ip’s you want to allow access to, then save:

— open /etc/httpd/conf.d/nagios.conf —

ScriptAlias /nagios/cgi-bin/ /usr/lib64/nagios/cgi-bin/
 
   Options ExecCGI
   order deny,allow
   deny from all
   allow from 127.0.0.1
   allow from another.ip.address.here
   AuthType Basic
   AuthUserFile /etc/nagios/passwd
   AuthName "nagios"
   require valid-user
 
Alias /nagios/ /usr/share/nagios/html/
 
   Options None
   order deny,allow
   deny from all
   allow from 127.0.0.1
   AuthType Basic
   AuthUserFile /etc/nagios/passwd
   AuthName "nagios"
   require valid-user

— close /etc/httpd/conf.d/nagios.conf —

Now you can reload apache:

nagios-host#: sudo service httpd graceful

Nagios creates it’s own htpasswd file with the nagiosadmin user added to it, I wasn’t able to find out what the password is initially set to, so I just reset myself:

nagios-host#: sudo htpasswd passwd nagiosadmin
New password: ########
Re-type new password: ########
Updating password for user nagiosadmin

Make sure nagios is added to the list of services that turn on at startup:

nagios-host#: chkconfig nagios on
nagios-host#: chkconfig
nagios          0:off   1:off   2:on    3:on    4:on    5:on    6:off

Do the nagios.cfg sanity check:

nagios-host#: sudo /usr/sbin/nagios -v /etc/nagios/nagios.cfg

Hopefully you’ll see a print out with something like this at the end

Total Warnings: 0
Total Errors:   0
 
Things look okay - No serious problems were detected during the pre-flight check

Now start nagios:

nagios-host#: sudo service nagios start

Before I could view the web interface I had to change the ownership of the nagios html directory:

nagios-host#: sudo chown -R apache.apache /usr/share/nagios/html/

If you have selinux on then you’ll need to do some more configuration, you can consult the quick start for that as selinux and I aren’t on speaking terms at the moment.

Now you can point your browser to http://xxx.xxx.xxx.xxx/nagios/ , where xxx.xxx.xxx.xxx is your ip or hostname, and don’t forget the trailing slash or you’ll get a 404 error.

————————————————————

References:

Nagios Quick Start

http://en.wikipedia.org/wiki/Internet_server_monitoring

http://blog.serverfault.com/post/1264376462/

http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/

Posted in apache, fedora, linux, nagios

Using mod_geoip – A Simple PHP Class

Nov04
2010
Leave a Comment Written by Jeff

I was working on a metrics module recently in order to track download statistics for some mobile applications. One of the requirements was city and country of the user downloading the app. I figured the easiest way to do this was to use the apache module mod_geoip in conjunction with Maxmind’s free GeoLite City database. There’s some good documentation on Maxmind’s website, as well as various blogs, but just for the record here’s how I did it.

Caveat lector:
- These instructions were tested on Fedora 12 and 13 machines.

1. Install mod_geoip via YUM

sudo yum install mod_geoip

2. Install the free city database from MaxMind

cd /usr/share/GeoIP
wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz

3. Add the city database to the apache conf file

vim /etc/httpd/conf.d/mod_geoip.conf

------ mod_geoip.conf ------
LoadModule geoip_module modules/mod_geoip.so

GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
GeoIPDBFile /usr/share/GeoIP/GeoLiteCity.dat # &lt;-- add this line

------ mod_geoip.conf ------

4. Restart apache

sudo service httpd restart

Now you should be able to use the class:

$geo = JB_GeoIp::factory($_SERVER);
$geo->getCity();        // Returns the city name e.g. Toronto
$geo->getCountryName(); // Returns the country name e.g. Canada
$geo->getLongitude();   // Return the longitude e.g. -79.41670

If you get an exception make sure you restarted apache, and make sure you have the GEO environment variables in your _SERVER array

var_dump($_SERVER);

I’ve added this simple class to my Github account, I hope someone finds it useful.

View GeoIp Class

Posted in apache, fedora, linux, php

Fix for “PAM adding faulty module: /lib64/security/pam_fprintd.so” Log Message

Jul14
2010
3 Comments Written by Jeff

For the past few versions of Fedora I’ve encountered the following error message in my log files:

“PAM adding faulty module: /lib64/security/pam_fprintd.so”

After an initial Google session I came across some squabbling on Redhats bug tracker as to what/who is responsible for the bug (or anti-bug), regardless of who wins that argument, the solution was located in the comments. The resulting code is here for your convenience:

(If you don’t have authconfig installed):

yum install authconfig

After it’s installed use the following command:

authconfig --disablefingerprint --update

That worked for me on all my Fedora boxes. Good luck.

Posted in linux - Tagged fedora, linux

Recent Posts

  • Katango Makes Sense Out of Social Graph
  • A Better Solr Startup Script (initd)
  • Monitoring a Remote Machine with Nagios and Fedora
  • Monitoring a Local Machine with Nagios and (Fedora)
  • Using mod_geoip – A Simple PHP Class

Blogroll

  • Bad Astronomy
  • Panvista Blog
  • Skeptic Blog

Search

RSS Jeff Busby

  • Katango Makes Sense Out of Social Graph July 12, 2011 Jeff
  • A Better Solr Startup Script (initd) March 24, 2011 Jeff
  • Monitoring a Remote Machine with Nagios and Fedora February 24, 2011 Jeff
  • Monitoring a Local Machine with Nagios and (Fedora) January 29, 2011 Jeff
  • Using mod_geoip – A Simple PHP Class November 4, 2010 Jeff
  • Fix for “PAM adding faulty module: /lib64/security/pam_fprintd.so” Log Message July 14, 2010 Jeff

StackExchange

profile for Jeff Busby on Stack Exchange, a network of free, community-driven Q&A sites

EvoLve theme by Blogatize  •  Powered by WordPress Jeff Busby