[collectd] [PATCH] add PUTNOTIF command

Doug MacEachern Doug.MacEachern at hyperic.com
Sat Jan 17 16:13:47 CET 2009


I was using this to test notifications for jcollectd like so:
echo "PUTNOTIF host=foo severity=warning message=my perl is rusty" |
perl -Mblib=bindings/perl contrib/cussh.pl


> -----Original Message-----
> From: Doug MacEachern [mailto:dougm at hyperic.com]
> Sent: Saturday, January 17, 2009 7:09 AM
> To: collectd at verplant.org
> Cc: Doug MacEachern
> Subject: [PATCH] add PUTNOTIF command
> 
> Signed-off-by: Doug MacEachern <dougm at hyperic.com>
> ---
>  contrib/cussh.pl |   25 +++++++++++++++++++++++++
>  1 files changed, 25 insertions(+), 0 deletions(-)
> 
> diff --git a/contrib/cussh.pl b/contrib/cussh.pl
> index 2ec6308..ee4c893 100755
> --- a/contrib/cussh.pl
> +++ b/contrib/cussh.pl
> @@ -62,6 +62,7 @@ use Collectd::Unixsock();
>  		GETVAL  => \&getval,
>  		FLUSH   => \&flush,
>  		LISTVAL => \&listval,
> +		PUTNOTIF => \&putnotif,
>  	};
> 
>  	if (! $sock) {
> @@ -163,6 +164,7 @@ Available commands:
>    GETVAL
>    FLUSH
>    LISTVAL
> +  PUTNOTIF
> 
>  See the embedded Perldoc documentation for details. To do that, run:
>    perldoc $0
> @@ -290,6 +292,29 @@ sub listval {
>  	return 1;
>  }
> 
> +=item B<PUTNOTIF> [[B<severity>=I<$severity>]
[B<message>=I<$message>]
> [ ...]]
> +
> +=cut
> +
> +sub putnotif {
> +	my $sock = shift || return;
> +	my $line = shift || return;
> +
> +	my (%values) = ();
> +	foreach my $i (split m/ /, $line) {
> +		my($key,$val) = split m/=/, $i, 2;
> +		if ($key && $val) {
> +			$values{$key} = $val;
> +		}
> +		else {
> +			$values{'message'} .= ' '.$key;
> +		}
> +	}
> +	$values{'time'} ||= time();
> +	my(@tmp) = %values;
> +	return $sock->putnotif(%values);
> +}
> +
>  =back
> 
>  These commands follow the exact same syntax as described in
> --
> 1.5.5.1




More information about the collectd mailing list