sensu-plugins / sensu-plugins-network-checks

This plugin provides native network instrumentation for monitoring and metrics collection, including: hardware, TCP response, RBLs, whois, port status, and more.
http://sensu-plugins.io
MIT License
30 stars 76 forks source link

metric-netif doesn't work if default locale is ru_RU.UTF-8 #46

Closed pvlltvk closed 7 years ago

pvlltvk commented 8 years ago

metris-netif use sar to generate netif metrics and grep sar output by word "Average":

sar -n DEV 1 1 | grep Average | grep -v IFACE.each_line do |line|`

But it's wrong way, if defalut system locale is't en_US.UTF-8. For example ru_RU.UTF-8, where "Average" translated to "Среднее":

sar -n DEV 1 1

11:03:33 eth0 79,00 36,00 43,28 4,28 0,00 0,00 0,00 0,03 Среднее: eth0 79,00 36,00 43,28 4,28 0,00 0,00 0,00 0,03

It can be easliy fixed by using env LANG:

LANG=en_US.UTF8 && sar -n DEV 1 1 | grep Average | grep -v IFACE.each_line do |line|`

majormoses commented 7 years ago

@pvlltvk could you put together a pr?

majormoses commented 7 years ago

Ideally I would like to make it more durable than just setting the locale (which assumes it's installed). But I'd take this if you can't come up with something else.

majormoses commented 7 years ago

@pvlltvk I put together: https://github.com/sensu-plugins/sensu-plugins-network-checks/pull/55 to address this by allowing you to pass in the right value rather than assuming you have en_US.UTF8 available, can you verify this works?