[collectd] Notifications not working

Sebastian Harl sh at tokkee.org
Tue Nov 6 07:41:09 CET 2012


Hi,

On Mon, Nov 05, 2012 at 01:31:24PM +0100, Stian Øvrevåge wrote:
> Hi list, trying to configure notifications but I find the
> documentation quite confusing.

Which parts of the documentation are not clear to you?

> My current non-working test config looks like this:
> 
> From collectd.conf:
> 
> LoadPlugin exec
> <Plugin exec>
>   NotificationExec "user" "echo 'notification' >> /home/user/notiftest"
> </Plugin>

The 'exec' command is not run inside a shell but it's executed using
execvp(3). Thus, your command does not work. Rather, collectd tries to
execute some command called "echo 'notification' >>
/home/user/notiftest".

(Side-note: In order to specify a command plus arguments, you need to
provide multiple arguments to the "NotificationExec" option:
  NotificationExec "user" "cmd" "foo" "bar")

> LoadPlugin snmp
> <Plugin snmp>
> 
>   <Data "cisco_cpu">
>     Type "cisco_cpu"
>     Table true
>     Values "CISCO-PROCESS-MIB::cpmCPUTotal5secRev"
> "CISCO-PROCESS-MIB::cpmCPUTotal1minRev"
> "CISCO-PROCESS-MIB::cpmCPUTotal5minRev"
>   </Data>
> 
>   <Host "test-switch">
>     Address "10.0.0.1"
>     Version 2
>     Community "public"
>     Collect "cisco_cpu"
>     Interval 60
>   </Host>
> 
> </Plugin>
> 
>  <Threshold>
>   <Host "test-switch">
>     <Plugin "snmp">
>       <Type "cisco_cpu">
>         Instance "1"	// Tried with and without this
>          WarningMin    0.00
>          WarningMax 8.00
>          FailureMin    0.00
>          FailureMax 12.00
>          DataSource "cpu5sec" // Tried with and without this
>       </Type>
>     </Plugin>
>   </Host>
>  </Threshold>

This looks fine to me and should match the example data below.

> The data is collected fine from the switch:
> 
> rrdtool lastupdate cisco_cpu-1.rrd
>  cpu5sec cpu1min cpu5min
> 1352118105: 22.000000 10.000000 9.000000
> 
> But nothing is written to the notiftest-file so I'm assuming the
> command is not executed.
> 
> I'm running collectd in foreground but it gives no errors there, nor
> in the syslog.

The problem is that collectd (the exec plugin) connects stdout and
stderr of the child process to a pipe but does not read from that. Thus,
you're not seeing any messages that execvp() failed.

I think we should let the exec plugin read everything from stderr and
log that as error messages.

HTH,
Sebastian

-- 
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://mailman.verplant.org/pipermail/collectd/attachments/20121106/4ac78ed0/attachment.pgp>


More information about the collectd mailing list