Skip to content

Commit

Permalink
feat(host_sysctl): add doc entry for a host sysctl collector and anal…
Browse files Browse the repository at this point in the history
…yzer (#592)

* feat(host_sysctl): add doc entry for a host sysctl collector and analyzer

* fix: add sidebar menu nav and `all` entry

* fix: json file and references to inequality for strings

* chore: retrigger netlify build

* Update docs/source/host-collect-analyze/sysctl.md

---------

Co-authored-by: Xav Paice <[email protected]>
  • Loading branch information
JGAntunes and xavpaice authored Nov 12, 2024
1 parent 552200c commit d6c6667
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ module.exports = {
"host-collect-analyze/regex",
"host-collect-analyze/run",
"host-collect-analyze/subnetAvailable",
"host-collect-analyze/sysctl",
"host-collect-analyze/systemPackages",
"host-collect-analyze/tcpConnect",
"host-collect-analyze/tcpLoadBalancer",
Expand Down
1 change: 1 addition & 0 deletions docs/source/host-collect-analyze/all.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ description: A list of all available host collectors and analyzers.

- [hostServices](./hostServices): Collects and analyzes information about the available host system services.
- [hostOS](./hostOS): Collects and analyzes information about the operating system installed on the machine.
- [sysctl](./sysctl): Collects and analyzes information about the host kernel parameters at runtime using `sysctl`
- [systemPackages](./systemPackages) Collects and analyzes information about the host system packages for the specified operating system.
- [time](./time): Collects and analyzes information about the system clock.
- [kernelConfigs](./kernelConfigs): Collects and analyzes information about available Kernel Configs on the machine.
Expand Down
84 changes: 84 additions & 0 deletions docs/source/host-collect-analyze/sysctl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: Host Sysctl
description: Collect and analyze kernel parameters.
---

## Host Sysctl Collector

To collect information about the configured kernel parameters you can use the `sysctl` collector. This will read the Kernel's parameters at runtime through the `sysctl` utility, similar to what you would get by running `sysctl -a`.

### Parameters

None.

### Example Collector Definition

```yaml
apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
name: sysctl
spec:
hostCollectors:
- sysctl: {}
```
### Included Resources
The results of the `sysctl` collector are stored in the `host-collectors/system` directory of the support bundle.

#### `sysctl.json`

Example of the resulting JSON file:

```
{
(...)
"net.ipv4.conf.all.arp_accept": "0",
"net.ipv4.conf.all.arp_announce": "0",
"net.ipv4.conf.all.arp_evict_nocarrier": "1",
"net.ipv4.conf.all.arp_filter": "0",
"net.ipv4.conf.all.arp_ignore": "0",
"net.ipv4.conf.all.arp_notify": "0",
"net.ipv4.conf.all.drop_gratuitous_arp": "0",
"net.ipv4.conf.all.proxy_arp": "0",
"net.ipv4.conf.all.proxy_arp_pvlan": "0",
"net.netfilter.nf_log.0": "NONE",
"net.netfilter.nf_log.1": "NONE",
"net.netfilter.nf_log.10": "nf_log_ipv6",
"net.netfilter.nf_log.2": "nf_log_ipv4",
"net.netfilter.nf_log.3": "nf_log_arp",
(...)
}
```

## Host Sysctl Analyzer

The `sysctl` analyzer supports multiple outcomes by validating the values of multiple properties. For example:

- `net.ipv4.conf.all.arp_ignore > 2`: Value for the `net.ipv4.conf.all.arp_ignore` property is greater than 2.
- `net.ipv4.conf.all.arp_filter = 0`: Value for the `net.ipv4.conf.all.arp_filter` equals 0.

**Note:** inequality operators (`>`, `>=`, `<` and `<=`) will only work when the type of the value being analyzed can be converted to `int`.

### Example Analyzer Definition

```yaml
apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
name: sysctl
spec:
hostCollectors:
- sysctl: {}
hostAnalyzers:
- sysctl:
checkName: "ARP parameters"
outcomes:
- fail:
when: "net.ipv4.conf.all.arp_ignore > 0"
message: "ARP ignore is enabled for all interfaces on the host. Disable it by running 'sysctl net.ipv4.conf.all.arp_ignore=0'."
- warn:
when: "net.ipv4.conf.all.arp_filter = 1"
message: "ARP filtering is enabled for all interfaces on the host. Disable it by running 'sysctl net.ipv4.conf.all.arp_filter=0'."
```

0 comments on commit d6c6667

Please sign in to comment.