Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(host_sysctl): add host sysctl collector #1676

Merged
merged 9 commits into from
Nov 7, 2024

Conversation

JGAntunes
Copy link
Member

@JGAntunes JGAntunes commented Nov 6, 2024

Description, Motivation and Context

Fixes - #1674

Checklist

Does this PR introduce a breaking change?

  • Yes
  • No

@JGAntunes JGAntunes self-assigned this Nov 6, 2024
@CLAassistant
Copy link

CLAassistant commented Nov 6, 2024

CLA assistant check
All committers have signed the CLA.

@JGAntunes JGAntunes requested a review from banjoh November 6, 2024 17:08
pkg/collect/host_sysctl.go Show resolved Hide resolved
pkg/collect/host_sysctl.go Show resolved Hide resolved
pkg/collect/host_sysctl_test.go Show resolved Hide resolved
@JGAntunes JGAntunes requested a review from banjoh November 7, 2024 11:29
@JGAntunes
Copy link
Member Author

@banjoh I've re-implemented the collector using - https://github.com/lorenzosaino/go-sysctl - let me know what you think. I've regenerated the schemas and tested out the collector but for wtv reason it isn't picking up on it 🤔 :

sudo bin/support-bundle -v 5 examples/collect/host/sysctl.yaml
I1107 11:30:15.363160   21229 loader.go:261] Loaded 1 troubleshoot specs successfully

I1107 11:30:15.363755   21229 supportbundle.go:80] Support bundle created in temporary directory: /tmp/supportbundle1604379718

============ Collectors summary =============
Succeeded (S), eXcluded (X), Failed (F)
=============================================
No collectors executed

============ Redactors summary =============
No redactors executed

============= Analyzers summary =============
Succeeded (S), eXcluded (X), Failed (F)
=============================================
No analyzers executed

Duration: 0ms
Error: failed to run collect and analyze process: failed to generate support bundle

I'm gonna follow up and try to get to the bottom of it after lunch but meanwhile if you have any leads let me know


func (c *CollectHostSysctl) Collect(progressChan chan<- interface{}) (map[string][]byte, error) {
client, err := sysctl.NewClient(sysctlVirtualFiles)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an error here

E1107 12:10:03.235230   56942 host_sysctl.go:39] Failed to initialize sysctl client: could not create client: directory /proc/sys/ does not exist

I think we should revert back to calling sysctl instead of relying on a library, otherwise we need to handle those rare environments, e.g darwin that don't have /proc/sys.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah true, darwin won't have procfs, however the props will be completely different too and even the output will differ between sysctl -a in darwin vs linux. But agree it's probably the best approach out of both options. Gonna go back to that and have a common output from the collector

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, let me know what you think @banjoh

@JGAntunes
Copy link
Member Author

Running this locally:

sudo bin/support-bundle -v 5 examples/collect/host/sysctl.yaml
Password:
Sorry, try again.
Password:
I1107 17:36:46.636143   22606 loader.go:261] Loaded 1 troubleshoot specs successfully

I1107 17:36:46.638142   22606 supportbundle.go:80] Support bundle created in temporary directory: /tmp/supportbundle3644184749
I1107 17:36:46.638421   22606 host_sysctl.go:37] Running sysctl collector
I1107 17:36:46.660001   22606 result.go:138] Added "host-collectors/system/sysctl.json" (61 KB) to bundle output
I1107 17:36:46.660079   22606 host_sysctl.go:58] Finished writing JSON output
I1107 17:36:46.660284   22606 redact.go:76] Redacting host-collectors/system/sysctl.json
I1107 17:36:46.676436   22606 result.go:138] Added "version.yaml" (0 KB) to bundle output
I1107 17:36:46.676641   22606 result.go:138] Added "analysis.json" (0 KB) to bundle output
I1107 17:36:46.676875   22606 result.go:138] Added "execution-data/summary.txt" (0 KB) to bundle output
I1107 17:36:46.678857   22606 result.go:364] Added "support-bundle-2024-11-07T17_36_46/host-collectors/system/sysctl.json" file to bundle archive
I1107 17:36:46.679426   22606 result.go:364] Added "support-bundle-2024-11-07T17_36_46/version.yaml" file to bundle archive
I1107 17:36:46.679456   22606 result.go:364] Added "support-bundle-2024-11-07T17_36_46/analysis.json" file to bundle archive
I1107 17:36:46.679501   22606 result.go:364] Added "support-bundle-2024-11-07T17_36_46/execution-data/summary.txt" file to bundle archive

A support bundle was generated and saved at support-bundle-2024-11-07T17_36_46.tar.gz. Please send this file to your software vendor for support.

============ Collectors summary =============
Succeeded (S), eXcluded (X), Failed (F)
=============================================
sysctl (S) : 21ms

============ Redactors summary =============
No redactors executed

============= Analyzers summary =============
Succeeded (S), eXcluded (X), Failed (F)
=============================================
No analyzers executed

Duration: 38ms

The file

cat support-bundle-2024-11-07T17_36_46/host-collectors/system/sysctl.json | jq . | less

{
  "debug.batman": "3",
  "debug.bpf_bufsize": "4096",
  "debug.bpf_bufsize_cap": "33554432",
  "debug.bpf_debug": "0",
  "debug.bpf_hdr_comp_enable": "1",
  "debug.bpf_maxbufsize": "524288",
  "debug.bpf_maxdevices": "256",
  "debug.bpf_trunc_overflow": "0",
  "debug.bpf_wantpktap": "0",
  "debug.didevice_bounce_count": "0",
  "debug.didevice_cache_fully_satisfied": "0",
  (...)
   "hw.cacheconfig": "16 1 4 0 0 0 0 0 0 0",
  "hw.cachelinesize": "128",
  "hw.cachesize": "3077505024 65536 4194304 0 0 0 0 0 0 0",
  (...)
   "kern.bootobjectspath": "/A81AC697-1175-480B-BCFF-526D0CD80FAB/boot/B654B73FA61DA0731F2F0CCC0E3C9ECA7260AF38CEF42BEAB2F12DCD58F01F37F14F51EDCDDBB4393F0FDFDA2BCDBA5B",
  "kern.bootreason": "gcb_off_wakeup gcb_wakeup rtc_alarm_wakeup auto_wakeup",
  "kern.bootsessionuuid": "844BD71A-07AB-42D3-8BF7-68309DF07CD3",
  "kern.bootsignature": "",
  "kern.boottime": "{ sec = 1729157179, usec = 466869 } Thu Oct 17 10:26:19 2024",
  (...)
}

@JGAntunes JGAntunes requested a review from banjoh November 7, 2024 17:41
Copy link
Member

@banjoh banjoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JGAntunes JGAntunes merged commit 77c9968 into main Nov 7, 2024
27 checks passed
@JGAntunes JGAntunes deleted the feat/host_sysctl_collector branch November 7, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type::feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants