X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=bindings%2Fperl%2FCollectd%2FUnixsock.pm;h=f21ebfe9f285dc83060ba114c94f70996f4a3980;hb=903ebad4e6fe24e6b04097f18048b63ebb3bcb29;hp=8749c1abff28e3fd1ee2880535a765b5911d5dae;hpb=3469385f04ffcfa2f4ef06d34ed4b24acb378b34;p=collectd.git diff --git a/bindings/perl/Collectd/Unixsock.pm b/bindings/perl/Collectd/Unixsock.pm index 8749c1ab..f21ebfe9 100644 --- a/bindings/perl/Collectd/Unixsock.pm +++ b/bindings/perl/Collectd/Unixsock.pm @@ -400,6 +400,63 @@ sub putnotif return; } # putnotif +=item I<$obj>-EB (B =E I<$timeout>, B =E [...]); + +Flush cached data. + +Valid options are: + +=over 4 + +=item B + +If this option is specified, only data older than I<$timeout> seconds is +flushed. + +=item B + +If this option is specified, only the selected plugins will be flushed. + +=back + +=cut + +sub flush +{ + my $obj = shift; + my %args = @_; + + my $fh = $obj->{'sock'} or confess; + + my $status = 0; + my $msg = "FLUSH"; + + if ($args{'timeout'}) + { + $msg .= " timeout=" . $args{'timeout'}; + } + + if ($args{'plugins'}) + { + foreach my $plugin (@{$args{'plugins'}}) + { + $msg .= " plugin=" . $plugin; + } + } + + $msg .= "\n"; + + send ($fh, $msg, 0) or confess ("send: $!"); + $msg = undef; + recv ($fh, $msg, 1024, 0) or confess ("recv: $!"); + + ($status, $msg) = split (' ', $msg, 2); + return (1) if ($status == 0); + + $obj->{'error'} = $msg; + return; +} + =item I<$obj>-Edestroy (); Closes the socket before the object is destroyed. This function is also