Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 145 lines (111 sloc) 4.761 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
== link:index.html[Index] -> link:cookbook.html[Cookbook]

Cookbook: Setting up Nagios
---------------------------

Nagios is a host, service and network monitoring program. It is very
extended and can be up and running in 15 minutes just by following the
link:http://nagios.sourceforge.net/docs/3_0/quickstart.html[Quickstart
Guide]. Though it is well documented and is easy to follow, it is
intended for an Apache audience.

After following the quickstart instructions, getting Nagios it to work
with Cherokee is really simple.

[[trivial]]
Trivial set up: Cherokee as proxy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The most elemental set up is one that assumes that a Nagios
installation runs on another box and that Cherokee simply sits as a
reverse proxy between the Nagios-instance and the world.

In such a set up, we would have Nagios running in its own box with
Apache2, as detailed by their quick installation guide. The only
relevant parts of the apache-configuration are the ones defining the
actual paths. In our case:

----
ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3
ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3
Alias /nagios3 /usr/share/nagios3/htdocs
----

The only needed configuration on the box running Cherokee would be
setting up a rule that matched the above listed paths, and proxied the
request to the server running Nagios.

As you can see, this is trivial to do. Assuming the Cherokee server
was 10.0.0.10 and the Nagios box was 10.0.0.11, we would have to
follow these steps:

- First, define an information source with the parameters of
  the Nagios box.
+
[options="header"]
|==============================
|Nick |Type |Host
|Nagios |External |10.0.0.11:80
|==============================

- Then, create the set of rules that match the following list of
  paths:
+
  . /cgi-bin/nagios3
  . /nagios3/cgi-bin
  . /nagios3

This, in turn, can be done easily. For compactness sake, we will just
use one but you could define a separate one if you need more precise
matching. The mechanism is exactly the same:

- Within the `Behavior` tab of your virtual server, choose "Regular
Expression" as type of the new rule, and use the expression
`.*nagios3.*` for it.

- In the `Handler` section, select the `HTTP reverse proxy` and assign
  the information source previously defined.

Now, whenever a request to 10.0.0.10 contains the `nagios3` substring,
it will be proxied to 10.0.0.11.


[[advanced]]
Advanced set up: Cherokee as host
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is and advanced method only namely. In reality, it is exactly as
simple.

In this case, the relevant information from the configuration
file is limited to a couple of snippets:

----
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
AuthUserFile /usr/local/nagios/etc/htpasswd.users
----

and

----
Alias /nagios "/usr/local/nagios/share"
AuthUserFile /usr/local/nagios/etc/htpasswd.users
----

Please note the above paths are the ones used in the
link:http://nagios.sourceforge.net/docs/3_0/quickstart.html[Nagios
Quickstart guide]. The paths are bound to change if you used any
prepackaged release.

We will translate these directly into a pair of directory-type rules.

The first one will match the `/nagios/cgi-bin` directory, and will be
handled by the `CGI` handler. We will map the `/usr/local/nagios/sbin`
as the `Web Directory` for the rule, in the `Rule` tab.

.First rule
image::media/images/cookbook_nagios1.png[cgi-bin]

.First rule
[options="header"]
|====================================================================
|Field | Value
|Handler | CGI
|Document root | /usr/local/nagios/sbin
|====================================================================

The second one will do something similar, only mapping `/nagios` to
`/usr/local/nagios/share`.

.Second rule
image::media/images/cookbook_nagios2.png[nagios]

.Second rule
[options="header"]
|====================================================================
|Field | Value
|Handler | List & Send
|Document root | /usr/local/nagios/share
|====================================================================

Finally, you can set up the authentication mechanism on both rules by
configuring the `Security` tab. Choose the `Htpasswd file` validation
mechanism, write the correct Password File (the one you should have
created during Nagios' installation), and input the mandatory realm
string, `Nagios` for instance. Note that this step is optional, since
you can secure your application with any other validation mechanism
provided by Cherokee.

.Security configuration
image::media/images/cookbook_nagios3.png[htpasswd]

And that was all for today.

.Nagios in action
image::media/images/cookbook_nagios4.png[It's alive!]
Something went wrong with that request. Please try again.