Skip to main content

Host OS

Host OS Collector​

To collect information about the operating system installed on the machine, you can use the hostOS collector.

Parameters​

None.

Example Collector Definition​

apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
name: hostOS
spec:
hostCollectors:
- hostOS: {}

Included Resources​

The results of the hostOS collector are stored in the host-collectors/system directory of the support bundle.

hostos_info.json​

Example of the resulting JSON file:

{
"name": "localhost",
"kernelVersion": "5.13.0-1024-gcp",
"platformFamily": "debian",
"platformVersion": "20.04",
"platform": "ubuntu"
}

Host OS Analyzer​

The hostOS analyzer supports multiple outcomes by validating the name and version of the detected operating system. For example:

  • ubuntu = 20.04: The detected OS is Ubuntu 20.04.
  • centos >= 7 && < 8: The detected OS is CentOS 7, which might be anything from 7.0 to 7.9, and so requires a range. Multiple comparisons can be joined by && or ||.
  • rhel >= 8 && < 9: The detected platform family is RHEL with a 8.x version. rhel includes RedHat Enterprise Linux, CentOS, Oracle Linux, Alma Linux, Rocky Linux, and more. The mapping of platform family to platform can be viewed here.
  • kernelVersion > 5.12.0: Check if kernelVersion value in the JSON output, regardless of OS, is greater than 5.12.0
  • ubuntu-16.04-kernel >= 4.14: Detect whether Ubuntu 16.04 has a kernel version greater or equal to 4.14. This string follows <platform>-<platformVersion>-kernel = <kernelVersion> format.

Example Analyzer Definition​

apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
name: hostOS
spec:
hostCollectors:
- hostOS: {}
hostAnalyzers:
- hostOS:
outcomes:
- pass:
when: "centos >= 7 && < 8"
message: "CentOS 7 is supported"
- pass:
when: "centos >= 8 && < 9"
message: "CentOS 8 is supported"
- fail:
when: "ubuntu = 16.04"
message: "Ubuntu 16.04 is not supported"
- pass:
when: "ubuntu = 18.04"
message: "Ubuntu 18.04 is supported"
- pass:
when: "ubuntu = 20.04"
message: "Ubuntu 20.04 is supported"
- pass:
when: "kernelVersion > 5.12.0"
message: "kernel version is supported"

RunHostCollectorsInPod enabled​

If the spec has runHostCollectorsInPod: true, the hostcollectors will be run in a privileged pod. The collector and analyzer will collect and analyze the results from multiple nodes in the cluster. It will be categorized by each node. Example: If a cluster has 2 nodes running this support bundle spec, the output will be categorized by each node.

apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
name: sb
spec:
runHostCollectorsInPod: true # default is false
hostCollectors:
- hostOS: {}
hostAnalyzers:
- hostOS:
outcomes:
- pass:
when: "ubuntu >= 22.04"
message: "Ubuntu 22.04 is supported"
- fail:
when: "ubuntu <= 16.04"
message: "Ubuntu 16.04 is not supported"

The result:

[
{
"name": "host.os.info.node.multinode.demo.m02",
"labels": {
"desiredPosition": "1",
"iconKey": "",
"iconUri": ""
},
"insight": {
"name": "host.os.info.node.multinode.demo.m02",
"labels": {
"iconKey": "",
"iconUri": ""
},
"primary": "Host OS Info - Node multinode-demo-m02",
"detail": "Ubuntu 22.04 is supported",
"severity": "debug"
},
"severity": "debug",
"analyzerSpec": ""
},
{
"name": "host.os.info.node.multinode.demo.m02.node.multinode.demo",
"labels": {
"desiredPosition": "1",
"iconKey": "",
"iconUri": ""
},
"insight": {
"name": "host.os.info.node.multinode.demo.m02.node.multinode.demo",
"labels": {
"iconKey": "",
"iconUri": ""
},
"primary": "Host OS Info - Node multinode-demo-m02 - Node multinode-demo",
"detail": "Ubuntu 22.04 is supported",
"severity": "debug"
},
"severity": "debug",
"analyzerSpec": ""
}
]