web interface on a different machine then Nagios daemon.

seb seb at virer.net
Mon Feb 11 15:19:46 CET 2008


Nice idea :)

I have compile cmd.c ok
place it to the good path
script file and permissions set.

when i try to submit passive result it not freeze but now i have this error
:

"An error occurred while attempting to commit your command for processing."
Return from whence you came

:(


On Mon, 11 Feb 2008 08:11:35 -0500, kyle.odonnell at gmail.com wrote:
> woops email cut off..
> 
> 
> Add a kill -9 of the tail/script in the nagios stop case.
> 
> If you're concerned about file size, create a logrotate script for the
> file..
> 
> --Kyle
> 
> On 2/11/08, kyle.odonnell at gmail.com <kyle.odonnell at gmail.com> wrote:
>> I found a way around this, but its not pretty:
>>
>> Modify nagios-src/cgi/cmd.c  to write to a flat file instead of  the
>> command pipe:
>>
>> int write_command_to_file(char *cmd){
>>         FILE *fp;
>>         struct stat statbuf;
>>
>>         /* bail out if the external command file doesn't exist */
>>         if(stat("/path/to/var/spool/cgi.pipe",&statbuf)){
>>
>>                 if(content_type==WML_CONTENT)
>>                         printf("<p>Error: Could not stat() external
>> command file!</p>\n");
>>                 else{
>>                         printf("<P><DIV CLASS='errorMessage'>Error:
>> Could not stat() command file
>> '%s'!</DIV></P>\n","/path/to/var/spool/cgi.pipe");
>>                         printf("<P><DIV CLASS='errorDescription'>");
>>                         printf("The external command file may be
>> missing, Nagios may not be running, and/or Nagios may not be checking
>> external commands.\n");
>>                         printf("</DIV></P>\n");
>>                         }
>>
>>                 return ERROR;
>>                 }
>>
>>         /* open the command for writing (since this is a pipe, it will
>> really be appended) */
>>         fp=fopen("/path/to/var/spool/cgi.pipe","w");
>>         if(fp==NULL){
>>
>>                 if(content_type==WML_CONTENT)
>>                         printf("<p>Error: Could not open command file
>> for update!</p>\n");
>>                 else{
>>                         printf("<P><DIV CLASS='errorMessage'>Error:
>> Could not open command file '%s' for
>> update!</DIV></P>\n","/path/to/var/spool/cgi.pipe");
>>                         printf("<P><DIV CLASS='errorDescription'>");
>>                         printf("The permissions on the external
>> command file and/or directory may be incorrect.  Read the FAQs on how
>> to setup proper permissions.\n");
>>                         printf("</DIV></P>\n");
>>                         }
>>
>>                 return ERROR;
>>                 }
>>
>>
>> Create a script like this:
>>
>> # cat cmdpipe.sh
>> #!/bin/sh
>> /bin/true > /path/to/var/spool/cgi.pipe
>> chown nagios:nagios /path/to/var/spool/cgi.pipe
>> /usr/bin/tail -F /path/to/var/spool/cgi.pipe >
> /path/to/var/spool/nagios.cmd
>> &
>>
>>
>> Add it to your nagios start script:
>>
>>         start)
>>         echo -en "\nStarting network monitor: nagios"
>>         $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
>>         if [ $? -eq 0 ]; then
>>         su - $NagiosUser -c "touch $NagiosVarDir/nagios.log
>> $NagiosRetentionFile"
>>         rm -f $NagiosCommandFile
>>         touch $NagiosRunFile
>>         chown $NagiosUser:$NagiosGroup $NagiosRunFile
>>         $NagiosBin -d $NagiosCfgFile
>> su - nagios -c "/path/to/cmdpipe.sh" > /dev/null 2>&1 &
>>
>>
>> On 2/11/08, seb <seb at virer.net> wrote:
>> > Hi,
>> >
>> > I have installed nagios 3.0rc2 on a machine
>> > and run the nagios daemon process on a other
>> > /var/spool/nagios
>> > and /var/log/nagios are shared over NFS
>> > and it works pretty fine.
>> >
>> > BUT! when I want to add/remove a comment, reschedule or submit passive
>> > results, cmd.cgi freeze !
>> >
>> > The idea is to have only one virtual machine with apache http service
> and
>> > one with nagios process without httpd running.
>> > so if it can works or not please tell me
>> >
>> > I think permission is OK I have set 2777 nagios.apache on every
> directory
>> > but when I "post" someting to "cmd.cgi" It hangs...
>> >
>> > I have try on the command line
>> >
>> > export REQUEST_METHOD="post"
>> > export QUERY_STRING="cmd_typ=4&cmd_mod=2&com_id=21"
>> > export REMOTE_USER="xxxx"
>> >
>> > ./cmd.cgi
>> >
>> > but it also freeze after reply me this :
>> >
>> > Content-type: text/html
>> >
>> > <html>
>> > <head>
>> > <link rel="shortcut icon" href="/nagios/images/favicon.ico"
>> > type="image/ico">
>> > <title>
>> > External Command Interface
>> > </title>
>> > <LINK REL='stylesheet' TYPE='text/css'
>> > HREF='skins/default/nagios/stylesheets/common.css'>
>> > <LINK REL='stylesheet' TYPE='text/css'
> HREF='skins/default/nagios/stylesheets/cmd.css'>
>> > </head>
>> > <body CLASS='cmd'>
>> >
>> > <!-- Produced by Nagios (http://www.nagios.org).  Copyright (c)
> 1999-2007
>> > Ethan Galstad. -->
>> > <table border=0 width=100%>
>> > <tr>
>> > <td align=left valign=top width=33%>
>> > <TABLE CLASS='infoBox' BORDER=1 CELLSPACING=0 CELLPADDING=0>
>> > <TR><TD CLASS='infoBox'>
>> > <DIV CLASS='infoBoxTitle'>External Command Interface</DIV>
>> > Last Updated: Mon Feb 11 13:32:27 CET 2008<BR>
>> > Nagios® 3.0rc2 - <A HREF='http://www.nagios.org' TARGET='_new'
>> > CLASS='homepageURL'>www.nagios.org</A><BR>
>> > Logged in as <i>xxxx</i><BR>
>> > </TD></TR>
>> > </TABLE>
>> > </td>
>> > <td align=center valign=top width=33%>
>> > </td>
>> > <td align=right valign=bottom width=33%>
>> > </td>
>> > </tr>
>> > </table>
>> >
>> > Any idea ?
>> >
>> > Thanks
>> >
>> > Sebastien CAPS
>> >
>> >
>> >
>> >
> -------------------------------------------------------------------------
>> > This SF.net email is sponsored by: Microsoft
>> > Defy all challenges. Microsoft(R) Visual Studio 2008.
>> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> > _______________________________________________
>> > Nagios-users mailing list
>> > Nagios-users at lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/nagios-users
>> > ::: Please include Nagios version, plugin version (-v) and OS when
>> reporting
>> > any issue.
>> > ::: Messages without supporting info will risk being sent to /dev/null
>> >
>>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list