Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving sensor "apt" #35

Closed
ghost opened this issue Aug 24, 2015 · 7 comments
Closed

Improving sensor "apt" #35

ghost opened this issue Aug 24, 2015 · 7 comments

Comments

@ghost
Copy link

ghost commented Aug 24, 2015

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
Copy link
Author

ghost commented Aug 24, 2015

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 konstantinpae self-assigned this Aug 31, 2015
@konstantinpae
Copy link
Contributor

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
Copy link
Author

ghost commented Sep 1, 2015

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
Copy link
Contributor

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 pushed a commit that referenced this issue Sep 15, 2015
@konstantinpae
Copy link
Contributor

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
Copy link
Author

ghost commented Sep 16, 2015

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant