- my $sock = new IO::Socket::UNIX ( $self->{main}->{conf}->{collectd_socket});
- # debug some informations if collectd is not running or anything else went
- # wrong
- if ( ! $sock ) {
- dbg("collect: could not connect to " .
- $self->{main}->{conf}->{collectd_socket} . ": $! - collectd plugin
- disabled");
- return 0;
+ my $sock;
+ #try at least $self->{main}->{conf}->{collectd_retries} to get a
+ #connection
+ for (my $i = 0; $i < $self->{main}->{conf}->{collectd_retries} ; ++$i) {
+ last if $sock = new IO::Socket::UNIX
+ ($self->{main}->{conf}->{collectd_socket});
+ #sleep a random value between 0 and 50 microsecs to try for a new
+ #thread
+ usleep(int(rand(50)));