Distribution Detection
The distro script detects the operating system, kernel, architecture, distribution,
version, virtualisation platform, and container type of a monitored host. It has no
additional runtime dependencies and works in any sh-compatible environment,
including ksh and bash.
Supported platforms
The script supports:
- Linux
- FreeBSD, OpenBSD, NetBSD, and DragonFly BSD
- Cygwin and MinGW
- QNX
- AIX
- HP-UX
- Solaris and SunOS
- Hurd
- Minix
- VxWorks
- macOS
Supported Linux distributions include Debian, Ubuntu, Red Hat, CentOS, Fedora,
Amazon Linux, openSUSE, SuSE, Arch Linux, Gentoo, Mageia, Slackware, Armbian,
DietPi, OpenWrt, IPFire, Synology, Unraid, Mandriva, Mandrake, Knoppix,
Linux From Scratch, Photon, Annvix, Arklinux, Aurox, BlackCat, Cobalt,
Conectiva, FreeEOS, HLFS, Immunix, Linux-PPC, MkLinux, Novell Linux Desktop,
PLD, Rubix, SME Server, Tiny Sofa, Trustix, TurboLinux, UltraPenguin,
UnitedLinux, VA-Linux, Yellow Dog, and MailCleaner. Any distribution with an
/etc/os-release file should also be detected automatically.
Recognised BSD distributions include pfSense, OPNsense, HardenedBSD, FreeNAS, and PC-BSD.
The script can detect VMware, Xen (HVM/PV), Microsoft Hyper-V, Parallels, KVM,
QEMU, Oracle VirtualBox, bhyve, Amazon EC2, and browser-based x86 emulators
(browservm). It can also identify Docker, LXC, OpenVZ, and FreeBSD Jail
containers.
Run without installing
Run the latest version directly without saving it to the local system:
| Bash | |
|---|---|
Alternatively, use wget:
| Bash | |
|---|---|
Installation
Download the latest script to the device that will be monitored:
| Bash | |
|---|---|
Alternatively, use wget:
| Bash | |
|---|---|
Verify the installation:
| Bash | |
|---|---|
The default output is pipe-delimited and contains seven fields:
| Text Only | |
|---|---|
For example:
| Text Only | |
|---|---|
Updating an existing installation
An installed copy can update itself to the latest version:
| Bash | |
|---|---|
The update requires mktemp and either curl or wget. It preserves the
installed file's permissions, validates the downloaded script, and replaces the
current file only after a successful download. Run the command as a user with
permission to replace the installed file.
Alternatively, download the latest version over the installed script and verify its version:
| Bash | |
|---|---|
Or with wget:
| Bash | |
|---|---|
Command-line usage
| Text Only | |
|---|---|
Options:
-f <format>- output format:pipe(default),twopipe,json,ini, orexport-o <out>- show only one value:os,kernel,arch,distro,version,virt, orcont-h- show help-u- update the installed script to the latest version-v- show the script version
Examples:
| Bash | |
|---|---|
The ini, export, and json formats also include the script version as
SCRIPTVER or scriptver.
Using the script from another application
Set DISTROEXEC before sourcing the script to prevent it from running
automatically:
| Bash | |
|---|---|
The script provides these variables:
OS- operating system, for exampleLinux,Solaris, orFreeBSDKERNEL- kernel version or nameARCH- architecture, for exampleamd64ori386DISTRO- distribution name, for exampleDebian,OpenIndiana, orpfSenseVERSION- distribution version, or OS version whenDISTROis emptyVIRT- virtualisation technology, when detectedCONT- container technology, when detectedDISTROSCRIPT- script version
Sourcing the script alone does not populate or export these values. Call the
corresponding function first: getos, getkernel, getarch, getdistro,
getversion, getvirt, or getcont.
If a value is unavailable or not applicable, it is left blank. On a generic
FreeBSD or OpenBSD installation, DISTRO is blank and VERSION contains the
kernel name. The script normalises x86_64 to amd64 and ix86 to i386.
Virtualisation and container names generally follow the systemd-detect-virt
naming convention.
Net-SNMP integration
Add the following line to /etc/snmp/snmpd.conf on the device to be monitored:
| Text Only | |
|---|---|
Without a custom OID prefix, Net-SNMP exposes the result through the standard
NET-SNMP-EXTEND-MIB. Observium reads nsExtendOutput1Line."distro", whose
numeric OID is:
| Text Only | |
|---|---|
Existing installations using the legacy UCD-SNMP OID continue to be supported.
If an older Net-SNMP version does not support extend, use this legacy exec
configuration:
| Text Only | |
|---|---|
Restart the SNMP daemon:
| Bash | |
|---|---|
Testing via SNMP
Walk the standard Net-SNMP extend tree from the Observium server:
| Bash | |
|---|---|
The output should include nsExtendOutput1Line."distro" with the same seven
pipe-delimited fields returned when the script is run locally, for example:
| Text Only | |
|---|---|
Testing legacy configurations
Older installations may use extend with the Observium UCD-SNMP OID prefix:
| Text Only | |
|---|---|
Check the exact output OID used by Observium:
| Bash | |
|---|---|
Installations using the legacy exec configuration can be checked separately:
| Bash | |
|---|---|
Both commands should return the pipe-delimited distro value. For example:
| Text Only | |
|---|---|
If the configuration type is unknown, walk the complete legacy subtree and look for either of the OIDs above:
| Bash | |
|---|---|