Currently when you write an exec notify handler, you get a stdin
stream that looks a bit like an RFC822 or Debian thing:

    Plugin: foo
    PluginInstance: bar
    <field>: <field value>
    ...

    <message body>

This means the handler needs to parse these out each time, e.g.

        #!/bin/bash
        data=$(cat)
        Plugin=$(field Plugin)
        #PluginInstance=$(field PluginInstance)
        #Type=$(field Type)
        #TypeInstance=$(field TypeInstance)
        Host=$(field Host)
        #Severity=$(field Severity)
        #Time=$(field Time)
        Message=$(sed '1,/^$/d' <<<"$data")

        if [[ "$Plugin" != foo -a $Host =~ \.example\.net$ ]]; then
           mail [email protected] <<< "$Message"
        fi

Collectd presumably already has the constituent components, so I think
it would be easier to simply pass the key/value pairs via the
environment, and reserve stdin for the message body.  If the body is
guaranteed to be short, that might also be feasible to pass as
environment.  Thus, the above toy example would reduce to

        #!/bin/bash
        if [[ "$Plugin" != foo -a $Host =~ \.example\.net$ ]]; then
           mail [email protected]  # consumes message from stdin
        fi

_______________________________________________
collectd mailing list
[email protected]
http://mailman.verplant.org/listinfo/collectd

Reply via email to