Port the live LibreNMS monitoring patterns from the legacy
KNELServerBuild repo into oam/librenms-agent/, joining the existing
OAM tooling (oxidized, unpoller, smokeping, netdisco):
- agent/ — upstream check_mk agent + snmp-extend scripts (dmi, dpkg,
mysql, ntp-client, ntp-server, os-updates, postfix, raspberry, smart,
ss, ups-nut), copied verbatim (md5-verified), never to be edited here
- setup.sh — deploy module ported from ProjectCode/Modules/OAM/
oam-librenms.sh; only the legacy framework bootstrap was replaced
with plain bash (path constants + print_info -> echo)
- snmp-sudo.conf — Debian snmpd sudo rule the extends require
(Debian-snmp NOPASSWD /bin/cat); carried as a file only, sudoers
install is a policy decision per AGENTS.md
Lint gates: extend the existing upstream-skip mechanism for the
verbatim agent scripts (tests/shellcheck.sh + check-rules.sh prune,
same precedent as archive/provisioning/Agents/librenms), and fix the
stale skip path there (provisioning/ moved to archive/provisioning in
6244c1c; the bash extends have been failing the whole-repo shellcheck
gate since).
💘 Generated with Crush
Assisted-by: Crush:glm-5.2
115 lines
3.2 KiB
Bash
115 lines
3.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Detects which OS and if it is Linux then it will detect which Linux Distribution.
|
|
|
|
OS=`uname -s`
|
|
REV=`uname -r`
|
|
MACH=`uname -m`
|
|
|
|
if [ "${OS}" = "SunOS" ] ; then
|
|
OS=Solaris
|
|
ARCH=`uname -p`
|
|
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
|
|
|
elif [ "${OS}" = "AIX" ] ; then
|
|
OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
|
|
|
elif [ "${OS}" = "Linux" ] ; then
|
|
KERNEL=`uname -r`
|
|
|
|
if [ -f /etc/fedora-release ]; then
|
|
DIST=$(cat /etc/fedora-release | awk '{print $1}')
|
|
REV=`cat /etc/fedora-release | sed s/.*release\ // | sed s/\ .*//`
|
|
|
|
elif [ -f /etc/redhat-release ] ; then
|
|
DIST=$(cat /etc/redhat-release | awk '{print $1}')
|
|
if [ "${DIST}" = "CentOS" ]; then
|
|
DIST="CentOS"
|
|
elif [ "${DIST}" = "Mandriva" ]; then
|
|
DIST="Mandriva"
|
|
PSEUDONAME=`cat /etc/mandriva-release | sed s/.*\(// | sed s/\)//`
|
|
REV=`cat /etc/mandriva-release | sed s/.*release\ // | sed s/\ .*//`
|
|
elif [ -f /etc/oracle-release ]; then
|
|
DIST="Oracle"
|
|
else
|
|
DIST="RedHat"
|
|
fi
|
|
|
|
PSEUDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
|
|
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
|
|
|
|
elif [ -f /etc/mandrake-release ] ; then
|
|
DIST='Mandrake'
|
|
PSEUDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
|
|
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
|
|
|
|
elif [ -f /etc/devuan_version ] ; then
|
|
DIST="Devuan `cat /etc/devuan_version`"
|
|
REV=""
|
|
|
|
elif [ -f /etc/debian_version ] ; then
|
|
DIST="Debian `cat /etc/debian_version`"
|
|
REV=""
|
|
ID=`lsb_release -i | awk -F ':' '{print $2}' | sed 's/ //g'`
|
|
if [ "${ID}" = "Raspbian" ] ; then
|
|
DIST="Raspbian `cat /etc/debian_version`"
|
|
fi
|
|
|
|
elif [ -f /etc/gentoo-release ] ; then
|
|
DIST="Gentoo"
|
|
REV=$(tr -d '[[:alpha:]]' </etc/gentoo-release | tr -d " ")
|
|
|
|
elif [ -f /etc/arch-release ] ; then
|
|
DIST="Arch Linux"
|
|
REV="" # Omit version since Arch Linux uses rolling releases
|
|
IGNORE_LSB=1 # /etc/lsb-release would overwrite $REV with "rolling"
|
|
|
|
elif [ -f /etc/os-release ] ; then
|
|
DIST=$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '"')
|
|
REV=$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '"')
|
|
|
|
elif [ -f /etc/openwrt_version ] ; then
|
|
DIST="OpenWrt"
|
|
REV=$(cat /etc/openwrt_version)
|
|
|
|
elif [ -f /etc/pld-release ] ; then
|
|
DIST=$(cat /etc/pld-release)
|
|
REV=""
|
|
|
|
elif [ -f /etc/SuSE-release ] ; then
|
|
DIST=$(echo SLES $(grep VERSION /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
|
|
REV=$(echo SP$(grep PATCHLEVEL /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
|
|
fi
|
|
|
|
if [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then
|
|
LSB_DIST=$(lsb_release -si)
|
|
LSB_REV=$(lsb_release -sr)
|
|
if [ "$LSB_DIST" != "" ] ; then
|
|
DIST=$LSB_DIST
|
|
fi
|
|
if [ "$LSB_REV" != "" ] ; then
|
|
REV=$LSB_REV
|
|
fi
|
|
fi
|
|
|
|
if [ "`uname -a | awk '{print $(NF)}'`" = "DD-WRT" ] ; then
|
|
DIST="dd-wrt"
|
|
fi
|
|
|
|
if [ -n "${REV}" ]
|
|
then
|
|
OSSTR="${DIST} ${REV}"
|
|
else
|
|
OSSTR="${DIST}"
|
|
fi
|
|
|
|
elif [ "${OS}" = "Darwin" ] ; then
|
|
if [ -f /usr/bin/sw_vers ] ; then
|
|
OSSTR=`/usr/bin/sw_vers|grep -v Build|sed 's/^.*:.//'| tr "\n" ' '`
|
|
fi
|
|
|
|
elif [ "${OS}" = "FreeBSD" ] ; then
|
|
OSSTR=`/usr/bin/uname -mior`
|
|
fi
|
|
|
|
echo ${OSSTR}
|