summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6ce771a)
raw | patch | inline | side by side (parent: 6ce771a)
author | Doug MacEachern <dougm@hyperic.com> | |
Tue, 20 Jan 2009 09:27:10 +0000 (10:27 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 20 Jan 2009 09:27:10 +0000 (10:27 +0100) |
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
Signed-off-by: Doug MacEachern <dougm@hyperic.com>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
echo "PUTNOTIF host=foo severity=warning message=my perl is rusty" |
perl -Mblib=bindings/perl contrib/cussh.pl
Signed-off-by: Doug MacEachern <dougm@hyperic.com>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
contrib/cussh.pl | patch | blob | history |
diff --git a/contrib/cussh.pl b/contrib/cussh.pl
index f95d54d2010eac76bd1e0a134d17b23fdd9fe383..9b578e6329da35536d2536d563f4216cc1b7cea9 100755 (executable)
--- a/contrib/cussh.pl
+++ b/contrib/cussh.pl
GETVAL => \&getval,
FLUSH => \&flush,
LISTVAL => \&listval,
+ PUTNOTIF => \&putnotif,
};
if (! $sock) {
GETVAL
FLUSH
LISTVAL
+ PUTNOTIF
See the embedded Perldoc documentation for details. To do that, run:
perldoc $0
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