monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Capture program/script output and display on service page?


From: Jan-Henrik Haukeland
Subject: Re: Capture program/script output and display on service page?
Date: Tue, 26 Nov 2013 17:00:13 +0100

On 25 Nov 2013, at 22:32, Rob Cotrone <address@hidden> wrote:

> Is it possible to capture a program(plugin) script output and display it on 
> the service page?

Yes, but this require some minor modifications to the code

> While looking at the source I've seen that if a failure occurs, stdout, then 
> stderr, are captured into the event structure.
> I modified the cervlet.c to display it if it exists.  It's working a bit.
> *
> The one thing that is missing is the actual program/plugin output display.
> I'm used to popping up NAGIOS, getting a birds eye view of all service plugin 
> output data, not just a success or failure, but a few lines of data from the 
> plugin(program) output.
> 
> When showing users monit, some users balked, because they could not see the 
> output of their test scripts via the browser interface.

In Monit, most of the standard checks are built-in and do not rely on plugins. 
The program check you refer to do not use a plugin output “protocol” to 
determine if the check succeeded or not like I believe Nagios does. Instead we 
simply test the exit code of the program. In case of an error, i.e. the program 
exited with an unexpected status, the output from the program will be included 
in an alert, otherwise no output is displayed.

The web-ui does display the last known exit status of a program. I’m not sure I 
see the benefit of displaying the _output_ from the program in the web-ui if 
everything is okay? In case of errors I can see this might be useful, even 
though you do get the output in an alert. What do others think?

In any case, if you want to always display the last output of a program in the 
web-ui I suggest you copy the approach used to display the latest exit status 
of the program. Expand 'struct myprogram' in monit.h with a buffer to hold the 
program output. I suggest a static buffer of some reasonable size so you don’t 
have to allocate/free every time. Then in validate.c:check_program read the 
output from the command and copy into the myprogram buffer at the same place in 
the code where the exitStatus is copied. To display the output from the program 
in the Web-UI, again use the same approach we use to display program exitStatus 
in cervlet.c:print_service_params_program. That should be it.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]