<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Marc Powell wrote:<br>
<blockquote  cite="midA7B0A9F02975A74A845FE85D0B95B8FA0192E135@misex01.ena.com"  type="cite">
  <blockquote type="cite">
    <pre wrap="">-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:nagios-users-admin@lists.sourceforge.net">nagios-users-admin@lists.sourceforge.net</a> [<a class="moz-txt-link-freetext" href="mailto:nagios-users">mailto:nagios-users</a>-
<a class="moz-txt-link-abbreviated" href="mailto:admin@lists.sourceforge.net">admin@lists.sourceforge.net</a>] On Behalf Of Marcel Mitsuto Fucatu Sugano
Sent: Thursday, October 27, 2005 4:13 PM
To: <a class="moz-txt-link-abbreviated" href="mailto:nagios-users@lists.sourceforge.net">nagios-users@lists.sourceforge.net</a>
Subject: [Nagios-users] [Web-Interface] CGI load workaround

Hi,

Placed '<path_to_nagios>/var' available through a NFS partition, and
would like to spread webservers to reduce the load on CGIs at the
central nagios server. But the servers running the web-interface
    </pre>
  </blockquote>
  <pre wrap=""><!---->cannot
  </pre>
  <blockquote type="cite">
    <pre wrap="">place commands to be executed by cmd.cgi, all permissions are set
correctly, and we still can't figure out what we missed along the way.

Does anyone know any documentation, or links to, or any thought about
this situation?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Nagios uses a named pipe to receive external commands. Named pipes are
not supported over NFS so at best you'll end up with at read-only view
on the other hosts. We've done this in a similar fashion.

Purely speculating, it may be possible to specify a path to the command
file that is unique to each machine then write a small daemon that
creates the pipe on each machine, reads the external commands and ships
them off to the master server for insertion there. Sort of like NSCA but
for external commands. I am not aware of any work that has been done
like that though. That seems like it might be an interesting project to
enhance the scalability of Nagios.

The alternative of course is to change the way that Nagios receives
external commands to be NFS friendly. I believe there may be compelling
reasons to stick with a named pipe however.
  </pre>
</blockquote>
There is a way to do this without changing the nagios code..<br>
<br>
Create the nagios.cmd fifo on each webserver in the expected location
/usr/local/nagios/var/nagios.cmd (or wherever the correct location is)<br>
<br>
You will need to set up SSH keys to log in to the nagios server as the
nagios username<br>
<br>
You can do a while loop on the nagios.cmd file from each webserver<br>
<br>
#!/usr/bin/bash<br>
nagioscmd="/usr/local/nagios/var/nagios.cmd"<br>
ssh="/usr/bin/ssh"<br>
nagiosserver=nagios.domain.com<br>
<br>
while :; do<br>
    commandtxt=`cat $nagioscmd`<br>
    $ssh $nagiosserver "echo $commandtxt > $nagioscmd"<br>
    sleep 1<br>
done<br>
<br>
<br>
This is write-only, which I think is okay.. I don't think the
nagios.cmd needs to write anything back to the client cgi.<br>
<br>
There is room for error trapping, such as sending email alerts if the
SSH connection fails..<br>
<br>
There is another way that I have thought of, probably a little more
reliable but a lot more work.<br>
<br>
Create a Perl script, client/server app which constantly reads the
nagios.cmd file on each webserver, and a server counterpart which
listens on a TCP port and writes in to the nagios.cmd fifo on the
server.<br>
- On the client application, when there is data to write by a
webserver, open a TCP connection to the nagios server and write the
output.<br>
- On the server application, every time there is a new connection check
it against a list of valid IP addresses and perhaps some other auth
(secret key or something). Then write into the nagios.cmd fifo.<br>
<br>
You could go for a UDP connection instead of TCP, but UDP is unreliable
by design.<br>
<br>
Cheers<br>
rob.<br>
<br>
</body>
</html>