PRTG / PythonMiniProbe

MiniProbe for PRTG Network Monitor written in Python
BSD 3-Clause "New" or "Revised" License
73 stars 50 forks source link

Improving sensor "apt" #35

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hello,

thank you for providing the PythonMiniProbe! Its really helpfull for us to monitor linux-systems with PRTG. Keep up the great work!

We want to use the "apt"-sensor on systems with the default language "german" but this wont work. The reason is, that the sensor "apt" uses "apt-get -s dist-upgrade | grep 'newly inst'" to determine the line with all information about available updates - in other language "newly installed" is simply translated to the setted language.

Maybe - as easy way for the beginning - you should just use "locale" to check the current setted language and throw an error? Or just search for the line "* upgraded, * newly installed, * to remove and * not upgraded." - whent this line is not in the output the sensor should fail.

At the moment the sensor shows no error - for a security relevant sensor not the best output when not working ;-)

What do you think?

ghost commented 9 years ago

Or even better change the locale for the runtime:

LC_ALL=C apt-get upgrade -s

http://unix.stackexchange.com/questions/87745/what-does-lc-all-c-do

konstantinpae commented 9 years ago

Hi, sorry for the delayed reply, was on vacation. Thank you for the feedback on the sensor, I will implement the proposed changes in the next version. To get the sensor running correctly for now, please open the file apt.py and change the line:

ret = os.popen("apt-get -s dist-upgrade | grep 'newly inst'")

to

if locale == "en_GB.UTF-8" or "'en_US.UTF-8'": ret = os.popen("apt-get -s dist-upgrade | grep 'newly inst'") elif locale == "de_DE.UTF-8": ret = os.popen("apt-get -s dist-upgrade | grep 'neu inst'") else: raise Exception

This fix will go to the development branch soon. I'm planning to do this by checking the locale rather than changing it.

ghost commented 9 years ago

Hi Konstantin,

i hope you had a good time!

Thank you for the implementation of a solution. This solution sure works for us because we are using german and english systems. But i think you should considering using "LC_ALL=C" so it will work for every localised system.

We are planning to add a new sensor for softwareraidchecks (mdadm) to a fork and send you a pull request in the next day. Hope you can have a look on it.

konstantinpae commented 9 years ago

Hey, I'll give your proposal a try although I will have to get this tested first. If this works, you can expect a new development release within the next week. :) Also looking forward to your Pull request.

konstantinpae commented 9 years ago

Proposed change is available in this branch. Could you check if this works for your, if ok I'm going to merge this to development.

ghost commented 9 years ago

Hi Konstantin,

we tested the changes (apt sensor and mdadm) from the dev_apt_sensor-branch and it works like a charm.

Thank you!

konstantinpae commented 9 years ago

Nice, I'm glad it's working now. So I'll close this issue for now.