ossobv / gocollect

Data collector using go, periodically posts json to a REST api
GNU General Public License v3.0
6 stars 1 forks source link

Prefer os-release over lsb_release -a. #7

Closed wdoekes closed 8 years ago

wdoekes commented 8 years ago

It's the new way.

wdoekes commented 8 years ago
PRETTY_NAME="Debian GNU/Linux 7.0 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7.0"
VERSION="7.0 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"
wdoekes commented 8 years ago
VERSION="14.04.4 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.4 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
wdoekes commented 8 years ago
VERSION="16.04 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
UBUNTU_CODENAME=xenial
wdoekes commented 8 years ago
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
wdoekes commented 8 years ago
$ grep -i trust /etc/os-release 
VERSION="14.04.4 LTS, Trusty Tahr"
# grep wheez /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 7.0 (wheezy)"
VERSION="7.0 (wheezy)"
$ grep jess /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
VERSION="8 (jessie)"
$ grep -i xenia /etc/os-release 
VERSION="16.04 LTS (Xenial Xerus)"
UBUNTU_CODENAME=xenial

=>

sed -e '/^VERSION=/!d;s/^[^=]*="[^(,]*[(,] *\([A-Za-z]*\).*/\1/' /etc/os-release |
    tr '[:upper:]' '[:lower:]'
wdoekes commented 8 years ago

https://github.com/systemd/systemd/commit/646b997c118e261c5ececc434dd40d0dbdbac4d8

=> future should have VERSION_CODENAME