Skip to content

Commit

Permalink
merged freebsd for main
Browse files Browse the repository at this point in the history
  • Loading branch information
redanthrax committed Jun 30, 2022
2 parents 4581d2f + 66f78b6 commit 932f15f
Show file tree
Hide file tree
Showing 54 changed files with 1,434 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pipeline {
agent { label 'ubuntu-18 && immutable' }
environment {
REPO = "go-sysinfo"
BASE_DIR = "src/github.com/elastic/${env.REPO}"
BASE_DIR = "src/github.com/redanthrax/${env.REPO}"
JOB_GIT_CREDENTIALS = "f6c7695a-671e-4f4f-a331-acdce44ff9ba"
PIPELINE_LOG_LEVEL = 'INFO'
}
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/check_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"strings"
)

const localPkgs = "github.com/elastic/go-sysinfo"
const localPkgs = "github.com/redanthrax/go-sysinfo"

var defaultPaths = []string{"."}

Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/test.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go install github.com/elastic/go-licenser@latest
go install github.com/redanthrax/go-licenser@latest

go mod verify
go-licenser -d
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euxo pipefail

go install github.com/elastic/go-licenser@latest
go install github.com/redanthrax/go-licenser@latest

go mod verify
go-licenser -d
Expand Down
92 changes: 46 additions & 46 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,126 +21,126 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added the Oracle Linux ("ol") platform to the "redhat" OS family. [#54](https://github.com/elastic/go-sysinfo/issues/54) [#115](https://github.com/elastic/go-sysinfo/pull/115)
- Added the Linux Mint ("linuxmint") platform to the "debian" OS family. [#52](https://github.com/elastic/go-sysinfo/issues/52)
- Added the Oracle Linux ("ol") platform to the "redhat" OS family. [#54](https://github.com/redanthrax/go-sysinfo/issues/54) [#115](https://github.com/redanthrax/go-sysinfo/pull/115)
- Added the Linux Mint ("linuxmint") platform to the "debian" OS family. [#52](https://github.com/redanthrax/go-sysinfo/issues/52)

### Changed

- Updated module to require Go 1.17. [#111](https://github.com/elastic/go-sysinfo/pull/111)
- The boot time value for Windows is now rounded to the nearest second to provide a more stable value. [#53](https://github.com/elastic/go-sysinfo/issues/53) [#114](https://github.com/elastic/go-sysinfo/pull/114)
- Updated module to require Go 1.17. [#111](https://github.com/redanthrax/go-sysinfo/pull/111)
- The boot time value for Windows is now rounded to the nearest second to provide a more stable value. [#53](https://github.com/redanthrax/go-sysinfo/issues/53) [#114](https://github.com/redanthrax/go-sysinfo/pull/114)

### Fixed

- Fix handling of environment variables without values on macOS. [#94](https://github.com/elastic/go-sysinfo/pull/94)
- Fix build tags on AIX provider such that CGO is required. [#106](https://github.com/elastic/go-sysinfo/issues/106)
- Fix handling of environment variables without values on macOS. [#94](https://github.com/redanthrax/go-sysinfo/pull/94)
- Fix build tags on AIX provider such that CGO is required. [#106](https://github.com/redanthrax/go-sysinfo/issues/106)

## [1.7.1] - 2021-10-11

### Fixed

- Fixed getting OS info when an unsupported file or directory is found matching /etc/\*-release [#102](https://github.com/elastic/go-sysinfo/pull/102)
- Fixed getting OS info when an unsupported file or directory is found matching /etc/\*-release [#102](https://github.com/redanthrax/go-sysinfo/pull/102)

## [1.7.0] - 2021-02-22

### Added

- Add per-process network stats [#96](https://github.com/elastic/go-sysinfo/pull/96)
- Add per-process network stats [#96](https://github.com/redanthrax/go-sysinfo/pull/96)

## [1.6.0] - 2021-02-09

### Added

- Add darwin/arm64 support (Apple M1). [#91](https://github.com/elastic/go-sysinfo/pull/91)
- Add darwin/arm64 support (Apple M1). [#91](https://github.com/redanthrax/go-sysinfo/pull/91)

## [1.5.0] - 2021-01-14

### Added

- Added os.type field to host info. [#87](https://github.com/elastic/go-sysinfo/pull/87)
- Added os.type field to host info. [#87](https://github.com/redanthrax/go-sysinfo/pull/87)

## [1.4.0] - 2020-07-21

### Added

- Add AIX support [#77](https://github.com/elastic/go-sysinfo/pull/77)
- Added detection of containerized cgroup in Kubernetes [#80](https://github.com/elastic/go-sysinfo/pull/80)
- Add AIX support [#77](https://github.com/redanthrax/go-sysinfo/pull/77)
- Added detection of containerized cgroup in Kubernetes [#80](https://github.com/redanthrax/go-sysinfo/pull/80)

## [1.3.0] - 2020-01-13

### Changed

- Convert NetworkCountersInfo maps to uint64 [#75](https://github.com/elastic/go-sysinfo/pull/75)
- Convert NetworkCountersInfo maps to uint64 [#75](https://github.com/redanthrax/go-sysinfo/pull/75)

## [1.2.1] - 2020-01-03

### Fixed

- Create a `sidToString` function to deal with API changes in various versions of golang.org/x/sys/windows. [#74](https://github.com/elastic/go-sysinfo/pull/74)
- Create a `sidToString` function to deal with API changes in various versions of golang.org/x/sys/windows. [#74](https://github.com/redanthrax/go-sysinfo/pull/74)

## [1.2.0] - 2019-12-09

### Added

- Added detection of systemd cgroups to the `IsContainerized` check. [#71](https://github.com/elastic/go-sysinfo/pull/71)
- Added networking counters for Linux hosts. [#72](https://github.com/elastic/go-sysinfo/pull/72)
- Added detection of systemd cgroups to the `IsContainerized` check. [#71](https://github.com/redanthrax/go-sysinfo/pull/71)
- Added networking counters for Linux hosts. [#72](https://github.com/redanthrax/go-sysinfo/pull/72)

## [1.1.1] - 2019-10-29

### Fixed

- Fixed an issue determining the Linux distribution for Fedora 30. [#69](https://github.com/elastic/go-sysinfo/pull/69)
- Fixed an issue determining the Linux distribution for Fedora 30. [#69](https://github.com/redanthrax/go-sysinfo/pull/69)

## [1.1.0] - 2019-08-22

### Added

- Add `VMStat` interface for Linux. [#59](https://github.com/elastic/go-sysinfo/pull/59)
- Add `VMStat` interface for Linux. [#59](https://github.com/redanthrax/go-sysinfo/pull/59)

## [1.0.2] - 2019-07-09

### Fixed

- Fixed a leak when calling the CommandLineToArgv function. [#51](https://github.com/elastic/go-sysinfo/pull/51)
- Fixed a crash when calling the CommandLineToArgv function. [#58](https://github.com/elastic/go-sysinfo/pull/58)
- Fixed a leak when calling the CommandLineToArgv function. [#51](https://github.com/redanthrax/go-sysinfo/pull/51)
- Fixed a crash when calling the CommandLineToArgv function. [#58](https://github.com/redanthrax/go-sysinfo/pull/58)

## [1.0.1] - 2019-05-08

### Fixed

- Add support for new prometheus/procfs API. [#49](https://github.com/elastic/go-sysinfo/pull/49)
- Add support for new prometheus/procfs API. [#49](https://github.com/redanthrax/go-sysinfo/pull/49)

## [1.0.0] - 2019-05-03

### Added

- Add Windows provider implementation. [#22](https://github.com/elastic/go-sysinfo/pull/22)
- Add Windows process provider. [#26](https://github.com/elastic/go-sysinfo/pull/26)
- Add `OpenHandleEnumerator` and `OpenHandleCount` and implement these for Windows. [#27](https://github.com/elastic/go-sysinfo/pull/27)
- Add user info to Process. [#34](https://github.com/elastic/go-sysinfo/pull/34)
- Implement `Processes` for Darwin. [#35](https://github.com/elastic/go-sysinfo/pull/35)
- Add `Parent()` to `Process`. [#46](https://github.com/elastic/go-sysinfo/pull/46)
- Add Windows provider implementation. [#22](https://github.com/redanthrax/go-sysinfo/pull/22)
- Add Windows process provider. [#26](https://github.com/redanthrax/go-sysinfo/pull/26)
- Add `OpenHandleEnumerator` and `OpenHandleCount` and implement these for Windows. [#27](https://github.com/redanthrax/go-sysinfo/pull/27)
- Add user info to Process. [#34](https://github.com/redanthrax/go-sysinfo/pull/34)
- Implement `Processes` for Darwin. [#35](https://github.com/redanthrax/go-sysinfo/pull/35)
- Add `Parent()` to `Process`. [#46](https://github.com/redanthrax/go-sysinfo/pull/46)

### Fixed

- Fix Windows registry handle leak. [#33](https://github.com/elastic/go-sysinfo/pull/33)
- Fix Linux host ID by search for older locations for the machine-id file. [#44](https://github.com/elastic/go-sysinfo/pull/44)
- Fix Windows registry handle leak. [#33](https://github.com/redanthrax/go-sysinfo/pull/33)
- Fix Linux host ID by search for older locations for the machine-id file. [#44](https://github.com/redanthrax/go-sysinfo/pull/44)

### Changed

- Changed the host containerized check to reduce false positives. [#42](https://github.com/elastic/go-sysinfo/pull/42) [#43](https://github.com/elastic/go-sysinfo/pull/43)

[Unreleased]: https://github.com/elastic/go-sysinfo/compare/v1.8.0...HEAD
[1.8.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.8.0
[1.7.1]: https://github.com/elastic/go-sysinfo/releases/tag/v1.7.1
[1.7.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.7.0
[1.6.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.6.0
[1.5.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.5.0
[1.4.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.4.0
[1.3.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.3.0
[1.2.1]: https://github.com/elastic/go-sysinfo/releases/tag/v1.2.1
[1.2.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.2.0
[1.1.1]: https://github.com/elastic/go-sysinfo/releases/tag/v1.1.0
[1.1.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.1.0
[1.0.2]: https://github.com/elastic/go-sysinfo/releases/tag/v1.0.2
[1.0.1]: https://github.com/elastic/go-sysinfo/releases/tag/v1.0.1
[1.0.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.0.0
- Changed the host containerized check to reduce false positives. [#42](https://github.com/redanthrax/go-sysinfo/pull/42) [#43](https://github.com/redanthrax/go-sysinfo/pull/43)

[Unreleased]: https://github.com/redanthrax/go-sysinfo/compare/v1.8.0...HEAD
[1.8.0]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.8.0
[1.7.1]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.7.1
[1.7.0]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.7.0
[1.6.0]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.6.0
[1.5.0]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.5.0
[1.4.0]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.4.0
[1.3.0]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.3.0
[1.2.1]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.2.1
[1.2.0]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.2.0
[1.1.1]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.1.0
[1.1.0]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.1.0
[1.0.2]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.0.2
[1.0.1]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.0.1
[1.0.0]: https://github.com/redanthrax/go-sysinfo/releases/tag/v1.0.0
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ fmt: $(GOPATH)/bin/gofumpt

.PHONY: imports
imports: $(GOPATH)/bin/goimports
goimports -l -local github.com/elastic/go-sysinfo ./
goimports -l -local github.com/redanthrax/go-sysinfo ./

$(GOPATH)/bin/go-licenser:
@echo "go-licenser missing, installing"
go install github.com/elastic/go-licenser@latest
go install github.com/redanthrax/go-licenser@latest

$(GOPATH)/bin/gofumpt:
@echo "gofumpt missing, installing"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://beats-ci.elastic.co/job/Library/job/go-sysinfo-mbp/job/main/badge/icon)](https://beats-ci.elastic.co/job/Library/job/go-sysinfo-mbp/job/main/)
[![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs]

[godocs]: http://godoc.org/github.com/elastic/go-sysinfo
[godocs]: http://godoc.org/github.com/redanthrax/go-sysinfo

go-sysinfo is a library for collecting system information. This includes
information about the host machine and processes running on the host.
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/redanthrax/go-sysinfo
go 1.18

require (
github.com/elastic/go-sysinfo v1.8.0
github.com/elastic/go-windows v1.0.1
github.com/redanthrax/go-sysinfo v1.8.0
github.com/redanthrax/go-windows v1.0.1
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901
github.com/pkg/errors v0.9.1
github.com/prometheus/procfs v0.7.3
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/elastic/go-sysinfo v1.8.0 h1:hwmVlZLfTVTP+L0hSS2BD/G8GNPmcl4JEMoOktSw/wc=
github.com/elastic/go-sysinfo v1.8.0/go.mod h1:JfllUnzoQV/JRYymbH3dO1yggI3mV2oTKSXsDHM+uIM=
github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0=
github.com/elastic/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss=
github.com/redanthrax/go-sysinfo v1.8.0 h1:hwmVlZLfTVTP+L0hSS2BD/G8GNPmcl4JEMoOktSw/wc=
github.com/redanthrax/go-sysinfo v1.8.0/go.mod h1:JfllUnzoQV/JRYymbH3dO1yggI3mV2oTKSXsDHM+uIM=
github.com/redanthrax/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0=
github.com/redanthrax/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss=
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
Expand Down
2 changes: 1 addition & 1 deletion internal/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package registry
import (
"github.com/pkg/errors"

"github.com/elastic/go-sysinfo/types"
"github.com/redanthrax/go-sysinfo/types"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions providers/aix/host_aix_ppc64.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import (
"github.com/joeshaw/multierror"
"github.com/pkg/errors"

"github.com/elastic/go-sysinfo/internal/registry"
"github.com/elastic/go-sysinfo/providers/shared"
"github.com/elastic/go-sysinfo/types"
"github.com/redanthrax/go-sysinfo/internal/registry"
"github.com/redanthrax/go-sysinfo/providers/shared"
"github.com/redanthrax/go-sysinfo/types"
)

//go:generate sh -c "go tool cgo -godefs defs_aix.go | sed 's/*byte/uint64/g' > ztypes_aix_ppc64.go"
Expand Down
2 changes: 1 addition & 1 deletion providers/aix/os_aix_ppc64.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

"github.com/pkg/errors"

"github.com/elastic/go-sysinfo/types"
"github.com/redanthrax/go-sysinfo/types"
)

// OperatingSystem returns information of the host operating system
Expand Down
2 changes: 1 addition & 1 deletion providers/aix/process_aix_ppc64.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (

"github.com/pkg/errors"

"github.com/elastic/go-sysinfo/types"
"github.com/redanthrax/go-sysinfo/types"
)

// Processes returns a list of all actives processes.
Expand Down
6 changes: 3 additions & 3 deletions providers/darwin/host_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"github.com/joeshaw/multierror"
"github.com/pkg/errors"

"github.com/elastic/go-sysinfo/internal/registry"
"github.com/elastic/go-sysinfo/providers/shared"
"github.com/elastic/go-sysinfo/types"
"github.com/redanthrax/go-sysinfo/internal/registry"
"github.com/redanthrax/go-sysinfo/providers/shared"
"github.com/redanthrax/go-sysinfo/types"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion providers/darwin/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/pkg/errors"
"howett.net/plist"

"github.com/elastic/go-sysinfo/types"
"github.com/redanthrax/go-sysinfo/types"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion providers/darwin/process_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

"github.com/pkg/errors"

"github.com/elastic/go-sysinfo/types"
"github.com/redanthrax/go-sysinfo/types"
)

//go:generate sh -c "go tool cgo -godefs defs_darwin.go > ztypes_darwin.go"
Expand Down
2 changes: 1 addition & 1 deletion providers/darwin/process_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/go-sysinfo/internal/registry"
"github.com/redanthrax/go-sysinfo/internal/registry"
)

var (
Expand Down
35 changes: 35 additions & 0 deletions providers/freebsd/arch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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

import (
"syscall"

"github.com/pkg/errors"
)

const hardwareMIB = "hw.machine"

func Architecture() (string, error) {
arch, err := syscall.Sysctl(hardwareMIB)
if err != nil {
return "", errors.Wrap(err, "failed to get architecture")
}

return arch, nil
}
Loading

0 comments on commit 932f15f

Please sign in to comment.