x70b1 / telegraf-apt

A Telegraf plugin to check Debian for package updates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add other debian derivatives support

electrofloat opened this issue · comments

Hi!

Checking the repo it seems that this is only for debian, but it also seems that it shouldn't be that hard to be able to support for example ubuntu too.

Can you add support for at least ubuntu?

commented

The required changes should be small. But I dont use Ubuntu.
If you find out whats missing or wrong, we could work on this.

I haven't used your plugin yet (I'm searching one that can be used on ubuntu to check apt), but looking through https://github.com/x70b1/telegraf-apt/blob/master/telegraf-apt.sh, the following surely needs changing:

  • on ubuntu release version/codename comes from lsb_release (-r for release, -c for codename)
  • I'm not exactly sure what the release_ltsinfo and from that release_support should contain
  • instead of /usr/sbin/needsrestart, most probably only the existence of /run/reboot-required needs checking, also /run/reboot-required.dpkgs should contain packages that needs reboot

I think the other commands should work as is on ubuntu too.

commented

Codename ist doable.

release_support and release_ltsinfo check the debian wiki if the running system is on a current version.
We need a way for ubuntu here to find this out.

needrestart is a tool that should also be availiable on ubuntu to check which services use old libs but also checks if a newer kernel is availiable. That should work without issues.

I see.
Ubuntu does not have the same versioning like debian. lsb_release can also tell if the current version installed is an LTS or not, but there are new releases every half a year and not all of them LTS versions.
do-release-upgrade -c can tell if there is a new LTS version or not. For example here is the output of it on Ubuntu Jammy (22.04):

Checking for a new Ubuntu release
There is no development version of an LTS available.
To upgrade to the latest non-LTS development release 
set Prompt=normal in /etc/update-manager/release-upgrades.

Looking into the above script, it can also output a lot of different infos, like:

Your Ubuntu release is not supported anymore.
For upgrade information, please visit:\n
(url)s\n") % { 'url' : url }
In /etc/update-manager/release-upgrades Prompt
is set to never so upgrading is not possible.
New release '%s' available.
Run 'do-release-upgrade' to upgrade to it.

so you could parse the output of this python script, or just simply check for the exit code of it. Exit codes are:

RELEASE_AVAILABLE=0
NO_RELEASE_AVAILABLE=1
commented

Thanks for this hint.

The problem is that it reports an 20.04.6 LTS as upgradable to 22.04.2 LTS which is true. But 20.04 is still not outdated.

One other thing is in my mind that is still open. In the script at L22 is a curl that asks the Debian wiki to find out if the current running version is still supported or not. I could also hard code the time values when a specific release is up to date or not. The idea was that a system is able to find out his own status even if the script is outdated. If I insert some timestamps, the script needs to be up to date to return correct values.

This info is used for debian_support (would be ubuntu_support on Ubuntu) and updates_severity.

Solution A: We could remove this logic and insert some timestamps for specific releases.

Solution B: We find a way to solve this for ubuntu too. But as there are a lot more releases and the wiki release page is not that easy to parse.

I think inserting timestamps is not the best idea, since as you said that means the script needs to be updated every time to be correct.

Maybe there are other ways for ubuntu then. Needs a bit more research.