logstash-plugins / logstash-input-ganglia

Apache License 2.0
1 stars 6 forks source link

UDP Listener uses one thread CPU on 100% #22

Open aleksprusov opened 6 years ago

aleksprusov commented 6 years ago

Hi!

Why are you using recvfrom_nonblock? In my case, it causes infinity loop which uses 100% CPU of one thread. Locally I resolved it by changing @udp.recvfrom_nonblock(9000) to @udp.recvfrom(9000)

https://github.com/logstash-plugins/logstash-input-ganglia/blob/4d494c9fb6836b5d92010932d8fe13a9cbf35c04/lib/logstash/inputs/ganglia.rb#L61

colinsurprenant commented 6 years ago

thanks for the headsup @aleksprusov - I am not sure simply using recvfrom is the best fix. I think it may potentially cause hanging problems at shutdown for example.

In any case, I think the best here would be to unify the UDP read strategy with the udp input plugin or better yet, use the udp input and move the parse_packet logic into a codec?