[Web-Interface] CGI load workaround solution(s)
Rob Moss
robmossrm at aol.com
Fri Oct 28 10:50:38 CEST 2005
Marc Powell wrote:
>>-----Original Message-----
>>From: nagios-users-admin at lists.sourceforge.net [mailto:nagios-users-
>>admin at lists.sourceforge.net] On Behalf Of Marcel Mitsuto Fucatu Sugano
>>Sent: Thursday, October 27, 2005 4:13 PM
>>To: nagios-users at lists.sourceforge.net
>>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
>>
>>
>cannot
>
>
>>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?
>>
>>
>
>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.
>
>
There is a way to do this without changing the nagios code..
Create the nagios.cmd fifo on each webserver in the expected location
/usr/local/nagios/var/nagios.cmd (or wherever the correct location is)
You will need to set up SSH keys to log in to the nagios server as the
nagios username
You can do a while loop on the nagios.cmd file from each webserver
#!/usr/bin/bash
nagioscmd="/usr/local/nagios/var/nagios.cmd"
ssh="/usr/bin/ssh"
nagiosserver=nagios.domain.com
while :; do
commandtxt=`cat $nagioscmd`
$ssh $nagiosserver "echo $commandtxt > $nagioscmd"
sleep 1
done
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.
There is room for error trapping, such as sending email alerts if the
SSH connection fails..
There is another way that I have thought of, probably a little more
reliable but a lot more work.
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.
- 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.
- 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.
You could go for a UDP connection instead of TCP, but UDP is unreliable
by design.
Cheers
rob.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20051028/daa07a11/attachment.html>
More information about the Users
mailing list