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

FreeBSD Support #126

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
2db0640
Add HostInfo support for FreeBSD
dbolcsfoldi Feb 5, 2019
d6b209f
Use os.SameFile to compare cwds
dbolcsfoldi Feb 10, 2019
08f7b57
Add basic support for ProcessInfo on FreeBSD.
dbolcsfoldi Feb 10, 2019
f8ea094
Add support for OpenHandleEnumerator and OpenHandleCounter.
dbolcsfoldi Feb 11, 2019
7d8b0f6
Add support for Environment
dbolcsfoldi Feb 11, 2019
4388e47
Review fixes.
dbolcsfoldi Feb 12, 2019
926d715
Clean up build process.
dbolcsfoldi Feb 12, 2019
37cd519
Updated support for FreeBSD
redanthrax Aug 5, 2022
042a304
Removed unsupported /proc directives
redanthrax Aug 5, 2022
e0d9718
Merge remote-tracking branch 'upstream/main' into FreeBSD
redanthrax Aug 16, 2022
32a9266
Merge remote-tracking branch 'elastic/main' into FreeBSD
andrewkroh Mar 14, 2024
cf4130f
gofumpt the code
andrewkroh Mar 14, 2024
68c3cbe
Add changelog file
andrewkroh Mar 14, 2024
3cba121
go.mod - tidy up
andrewkroh Mar 14, 2024
47ee9c3
implement type.Host by adding FQDN() and FQDNWithContext()
andrewkroh Mar 14, 2024
1b786ed
Fix changelog PR number
andrewkroh Mar 14, 2024
984d22f
add license headers with 'make update'
andrewkroh Mar 14, 2024
98a3c4f
TestOperatingSystem/freebsd14 - make test pass
andrewkroh Mar 14, 2024
26ffe87
Merge remote-tracking branch 'upstream/main' into FreeBSD
redanthrax Apr 9, 2024
608fba5
moved files
redanthrax Apr 9, 2024
056b9f1
Use stdlib errors
andrewkroh Apr 10, 2024
e7fcbe6
align go:build tags
andrewkroh Apr 10, 2024
1ba0ba6
Rename files to include _cgo
andrewkroh Apr 10, 2024
6870e0a
go mod tidy
andrewkroh Apr 10, 2024
00cb2d3
use t.Log instead of fmt.Print
andrewkroh Apr 10, 2024
174d0bb
Fix system_test.go for macos without CGO
andrewkroh Apr 10, 2024
2002a73
update README with freebsd
andrewkroh Apr 10, 2024
a15881d
add go:generate for ztypes_freebsd.go
andrewkroh Apr 10, 2024
bfbc2e6
os_freebsd.go - make test less strict
andrewkroh Apr 10, 2024
ff57aec
remove getOSInfo(baseDir)
andrewkroh Apr 10, 2024
496d742
use unix.SysctlTimeval to get boot time
andrewkroh Apr 10, 2024
8f57214
use unix.SysctlUint{32,64}
andrewkroh Apr 10, 2024
9753408
use block comment for C code
andrewkroh Apr 10, 2024
ff2ef7b
boottime - add assertion on returned time
andrewkroh Apr 10, 2024
26dfaba
remove dead code
andrewkroh Apr 10, 2024
3952336
refactor kvmGetSwapInfo to address shadowing
andrewkroh Apr 10, 2024
21e4945
hw.physmem is a uint64
andrewkroh Apr 10, 2024
56e911a
Merge branch 'main' into FreeBSD
redanthrax Apr 11, 2024
772144c
change memory data sources
andrewkroh Apr 11, 2024
ceb2852
vm.stats.vm.v_page_size is uint32
andrewkroh Apr 11, 2024
c4a0b0d
use uint32 for all sysctl vm.stats.vm.*
andrewkroh Apr 11, 2024
eedf803
initialize types.HostMemoryInfo.Metrics map
andrewkroh Apr 11, 2024
0398d56
improve code locality - combine sysctl sources
andrewkroh Apr 11, 2024
5b21c93
dead code - remove vmstat.go + related
andrewkroh Apr 11, 2024
5da5e60
system_test.go - exercise process NetworkCounters()
andrewkroh Apr 11, 2024
1eac8f6
return error from host CPUTime()
andrewkroh Apr 11, 2024
46fd95b
replace ioutil.ReadFile with os.ReadFile
andrewkroh Apr 11, 2024
69bf19c
fix handling of kern.cp_time
andrewkroh Apr 11, 2024
8f0f7aa
initialize process.fs to fix NetworkCounters
andrewkroh Apr 11, 2024
0f176f3
remove NetworkCounters implementation
andrewkroh Apr 11, 2024
0701447
comment for HostMemroyInfo implementation
andrewkroh Apr 11, 2024
6f81957
add process.open_handle_count to test output
andrewkroh Apr 11, 2024
60b935f
multiple ki_rssize by page size
andrewkroh Apr 11, 2024
9ffae07
timevalToDuration - use time constants
andrewkroh Apr 11, 2024
d3ab680
ki_size does not need multiplied by page size
andrewkroh Apr 11, 2024
96ff4d1
Merge branch 'main' into FreeBSD
andrewkroh May 16, 2024
799d779
apply OpenHandles path from jurajlutter
andrewkroh May 16, 2024
5c5317e
filter empty paths from OpenHandles
andrewkroh May 16, 2024
534a478
TestBootTime() compare with system uptime binary output
sarog Jun 19, 2024
f9fda75
Moved sysctl value casts into helper methods
sarog Jun 19, 2024
d3d45df
Use mib const in sysctlRaw()
sarog Jun 19, 2024
bbb75c4
memInfo(): be less optimistic
sarog Jun 19, 2024
be7058a
Simplified reader.Err()
sarog Jun 20, 2024
1e82bbf
TestArchitecture(): compare with known machine architecture (MACHINE_…
sarog Jun 20, 2024
b119ea8
TestMachineID(): validate host UUID
sarog Jun 20, 2024
1449217
TestKernelVersion(): compare with currently running kernel version
sarog Jun 20, 2024
1106c15
TestArchitecture(): revised architectures to compare against
sarog Jun 20, 2024
57174b1
Merge pull request #1 from sarog/FreeBSD
redanthrax Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/126.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
freebsd: Implement a new provider for FreeBSD that requires CGO.
```
1 change: 1 addition & 0 deletions .ci/scripts/check-cross-compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export CGO_ENABLED=0
GOOS=aix GOARCH=ppc64 go build ./...
GOOS=darwin GOARCH=amd64 go build ./...
GOOS=darwin GOARCH=arm64 go build ./...
GOOS=freebsd GOARCH=amd64 go build ./...
GOOS=linux GOARCH=386 go build ./...
GOOS=linux GOARCH=amd64 go build ./...
GOOS=linux GOARCH=arm go build ./...
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.phony: update
.PHONY: update
update: fmt lic imports

.PHONY: lic
Expand Down
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ if handleCounter, ok := process.(types.OpenHandleCounter); ok {
These tables show what methods are implemented as well as the extra interfaces
that are implemented.

| `Host` Features | Darwin | Linux | Windows | AIX |
|------------------|--------|-------|---------|-----|
| `Info()` | x | x | x | x |
| `Memory()` | x | x | x | x |
| `CPUTimer` | x | x | x | x |
| `LoadAverage` | x | x | | |
| `VMStat` | | x | | |
| `NetworkCounters`| | x | | |

| `Process` Features | Darwin | Linux | Windows | AIX |
|------------------------|--------|-------|---------|-----|
| `Info()` | x | x | x | x |
| `Memory()` | x | x | x | x |
| `User()` | x | x | x | x |
| `Parent()` | x | x | x | x |
| `CPUTimer` | x | x | x | x |
| `Environment` | x | x | | x |
| `OpenHandleEnumerator` | | x | | |
| `OpenHandleCounter` | | x | | |
| `Seccomp` | | x | | |
| `Capabilities` | | x | | |
| `NetworkCounters` | | x | | |
| `Host` Features | Darwin | Linux | Windows | AIX | FreeBSD |
|-------------------|--------|-------|---------|-----|---------|
| `Info()` | x | x | x | x | x |
| `Memory()` | x | x | x | x | x |
| `CPUTimer` | x | x | x | x | x |
| `LoadAverage` | x | x | | | |
| `VMStat` | | x | | | |
| `NetworkCounters` | | x | | | |

| `Process` Features | Darwin | Linux | Windows | AIX | FreeBSD |
|------------------------|--------|-------|---------|-----|---------|
| `Info()` | x | x | x | x | x |
| `Memory()` | x | x | x | x | x |
| `User()` | x | x | x | x | x |
| `Parent()` | x | x | x | x | x |
| `CPUTimer` | x | x | x | x | x |
| `Environment` | x | x | | x | x |
| `OpenHandleEnumerator` | | x | | | x |
| `OpenHandleCounter` | | x | | | x |
| `Seccomp` | | x | | | |
| `Capabilities` | | x | | | |
| `NetworkCounters` | | x | | | |

### GOOS / GOARCH Pairs

Expand All @@ -62,6 +62,7 @@ This table lists the OS and architectures for which a "provider" is implemented.
| aix/ppc64 | x | |
| darwin/amd64 | optional * | x |
| darwin/arm64 | optional * | x |
| freebsd/amd64 | x | x |
| linux/386 | | |
| linux/amd64 | | x |
| linux/arm | | |
Expand Down
23 changes: 23 additions & 0 deletions internal/cgo/disabled.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

//go:build !cgo

package cgo

// Enabled is true if cgo was enabled at compile-time.
const Enabled = false
23 changes: 23 additions & 0 deletions internal/cgo/enabled.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

//go:build cgo

package cgo

// Enabled is true if cgo was enabled at compile-time.
const Enabled = true
33 changes: 33 additions & 0 deletions providers/freebsd/defs_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

//go:build ignore
// +build ignore

package freebsd

/*
#include <sys/types.h>
#include <sys/vmmeter.h>
#include <sys/time.h>
#include <kvm.h>
*/
import "C"

type kvmSwap C.struct_kvm_swap

type clockInfo C.struct_clockinfo
22 changes: 22 additions & 0 deletions providers/freebsd/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

// Package freebsd implements the HostProvider and ProcessProvider interfaces
// for providing information about FreeBSD.
package freebsd

//go:generate sh -c "go tool cgo -godefs defs_freebsd.go > ztypes_freebsd.go"
Loading
Loading