Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
eeab38558a | |||
b93ecb13b6 | |||
f186860a45 | |||
b17feb6b54 | |||
6f7ea17a43 | |||
36999641b5 | |||
705f22bb5b | |||
e2f31a5e75 | |||
a392f5755c | |||
28721a03f7 | |||
ffa0ebc433 | |||
398d20cebb | |||
282fe70e69 | |||
e7e0720b54 | |||
c6435bbfcf | |||
b7005e085b | |||
4c990698d5 | |||
1135f06238 | |||
0714ee0d98 | |||
a1ba52e956 | |||
61f6c2b0bd | |||
3b18b3aae7 | |||
862751535f | |||
c4f54d9fa7 | |||
3b6b704f9d | |||
f0a0a5962d | |||
9521f9f091 | |||
f46be56baa | |||
193a281fd3 | |||
38f615dc88 |
40
.drone.yml
40
.drone.yml
@ -1,15 +1,15 @@
|
|||||||
---
|
---
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: "Mouse release pipeline"
|
name: mouse-release
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: dockersock
|
- name: dockersock
|
||||||
host:
|
host:
|
||||||
@ -19,26 +19,40 @@ volumes:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build amd64
|
- name: build amd64
|
||||||
image: rust:1.73
|
image: rust:1.73-alpine
|
||||||
commands:
|
commands:
|
||||||
|
- apk add --no-cache musl-dev gcc-aarch64-none-elf bash git
|
||||||
|
- git fetch --all --tags
|
||||||
|
- pwd && ls -al && sh ./version.sh
|
||||||
|
- mkdir /artifacts/mouse-amd64
|
||||||
|
- cp LICENSE.txt /artifacts/mouse-amd64/
|
||||||
|
- mkdir /artifacts/mouse-arm64
|
||||||
|
- cp LICENSE.txt /artifacts/mouse-arm64/
|
||||||
- rustup target add x86_64-unknown-linux-musl
|
- rustup target add x86_64-unknown-linux-musl
|
||||||
- rustup target add aarch64-unknown-linux-musl
|
- rustup target add aarch64-unknown-linux-musl
|
||||||
- cargo build --target x86_64-unknown-linux-musl --bins -r
|
- cargo build --target x86_64-unknown-linux-musl --bins -r
|
||||||
- cargo build --target aarch64-unknown-linux-musl --bins -r
|
- cargo build --target aarch64-unknown-linux-musl --bins -r
|
||||||
- cp target/x86_64-unknown-linux-musl/release/mouse /artifcats/mouse-amd64
|
- cp target/x86_64-unknown-linux-musl/release/mouse /artifacts/mouse-amd64/mouse
|
||||||
- cp target/aarch64-unknown-linux-musl/release/mouse /artifcats/mouse-arm64
|
- cp target/aarch64-unknown-linux-musl/release/mouse /artifacts/mouse-arm64/mouse-arm64
|
||||||
|
- cd /artifacts && tar -cvzf mouse-amd64.tar.gz mouse-amd64/*
|
||||||
|
- cd /artifacts && tar -cvzf mouse-arm64.tar.gz mouse-arm64/*
|
||||||
|
environment:
|
||||||
|
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: /usr/bin/aarch64-none-elf-gcc
|
||||||
volumes:
|
volumes:
|
||||||
- name: artifacts
|
- name: artifacts
|
||||||
path: /artifcats/
|
path: /artifacts/
|
||||||
|
|
||||||
- name: create gitea release
|
- name: create gitea release amd64
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
settings:
|
settings:
|
||||||
api_key:
|
api_key:
|
||||||
from_secret: gitea_api_key
|
from_secret: gitea_api_key
|
||||||
base_url: https://gitea.sejo-it.be
|
base_url: https://gitea.sejo-it.be
|
||||||
checksum: sha265
|
checksum: sha256
|
||||||
files: /artifacts/*
|
files: /artifacts/*.tar.gz
|
||||||
volumes:
|
volumes:
|
||||||
- name: artifacts
|
- name: artifacts
|
||||||
path: /artifcats/
|
path: /artifacts/
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
.vscode/
|
.vscode/
|
||||||
*.un~
|
*.un~
|
||||||
*.swp
|
*.swp
|
||||||
|
mouse_out.yml
|
||||||
|
188
Cargo.lock
generated
188
Cargo.lock
generated
@ -50,6 +50,18 @@ dependencies = [
|
|||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.4.7"
|
version = "4.4.7"
|
||||||
@ -96,6 +108,45 @@ version = "1.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "core-foundation-sys"
|
||||||
|
version = "0.8.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-deque"
|
||||||
|
version = "0.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-epoch",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-epoch"
|
||||||
|
version = "0.9.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-utils",
|
||||||
|
"memoffset",
|
||||||
|
"scopeguard",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.8.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "csv"
|
name = "csv"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
@ -117,6 +168,12 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "equivalent"
|
name = "equivalent"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
@ -151,23 +208,61 @@ version = "1.0.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.149"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linked-hash-map"
|
||||||
|
version = "0.5.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.6.4"
|
version = "2.6.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memoffset"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mouse"
|
name = "mouse"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"csv",
|
"csv",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
|
"sysinfo",
|
||||||
|
"yaml-rust",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ntapi"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.69"
|
version = "1.0.69"
|
||||||
@ -186,6 +281,26 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon"
|
||||||
|
version = "1.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"rayon-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon-core"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-deque",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.15"
|
version = "1.0.15"
|
||||||
@ -193,19 +308,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "scopeguard"
|
||||||
version = "1.0.189"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537"
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.190"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.189"
|
version = "1.0.190"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5"
|
checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -214,9 +335,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.107"
|
version = "1.0.108"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
|
checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"ryu",
|
"ryu",
|
||||||
@ -225,9 +346,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_yaml"
|
name = "serde_yaml"
|
||||||
version = "0.9.25"
|
version = "0.9.27"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574"
|
checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itoa",
|
"itoa",
|
||||||
@ -253,6 +374,22 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sysinfo"
|
||||||
|
version = "0.29.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0a18d114d420ada3a891e6bc8e96a2023402203296a47cdd65083377dad18ba5"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"core-foundation-sys",
|
||||||
|
"libc",
|
||||||
|
"ntapi",
|
||||||
|
"once_cell",
|
||||||
|
"rayon",
|
||||||
|
"serde",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.12"
|
version = "1.0.12"
|
||||||
@ -271,6 +408,28 @@ version = "0.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
@ -336,3 +495,12 @@ name = "windows_x86_64_msvc"
|
|||||||
version = "0.48.5"
|
version = "0.48.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "yaml-rust"
|
||||||
|
version = "0.4.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
|
||||||
|
dependencies = [
|
||||||
|
"linked-hash-map",
|
||||||
|
]
|
||||||
|
15
Cargo.toml
15
Cargo.toml
@ -2,18 +2,17 @@
|
|||||||
name = "mouse"
|
name = "mouse"
|
||||||
authors = ["Jochen Maes <jochen@sejo-it.be>"]
|
authors = ["Jochen Maes <jochen@sejo-it.be>"]
|
||||||
description = "Information gatherer for systems."
|
description = "Information gatherer for systems."
|
||||||
version = "0.1.0"
|
# this will be overwritten during builds! so ignore
|
||||||
|
version = "0.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[registries]
|
|
||||||
gitea = { index = "https://gitea.sejo-it.be/SeJo-IT/_cargo-index" }
|
|
||||||
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
sysinfo = { version = "0.29.10", features = ["serde"] }
|
||||||
|
yaml-rust = "0.4.5"
|
||||||
clap = { version = "4.4.7", features = ["derive"] }
|
clap = { version = "4.4.7", features = ["derive"] }
|
||||||
csv = "1.3.0"
|
csv = "1.3.0"
|
||||||
serde = { version = "1.0.189", features = ["std", "derive"] }
|
serde = { version = "1.0.190", features = ["std", "derive"] }
|
||||||
serde_json = "1.0.107"
|
serde_json = "1.0.108"
|
||||||
serde_yaml = "0.9.25"
|
serde_yaml = "0.9.27"
|
||||||
|
373
LICENSE.txt
Normal file
373
LICENSE.txt
Normal file
@ -0,0 +1,373 @@
|
|||||||
|
Mozilla Public License Version 2.0
|
||||||
|
==================================
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
--------------
|
||||||
|
|
||||||
|
1.1. "Contributor"
|
||||||
|
means each individual or legal entity that creates, contributes to
|
||||||
|
the creation of, or owns Covered Software.
|
||||||
|
|
||||||
|
1.2. "Contributor Version"
|
||||||
|
means the combination of the Contributions of others (if any) used
|
||||||
|
by a Contributor and that particular Contributor's Contribution.
|
||||||
|
|
||||||
|
1.3. "Contribution"
|
||||||
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
|
1.4. "Covered Software"
|
||||||
|
means Source Code Form to which the initial Contributor has attached
|
||||||
|
the notice in Exhibit A, the Executable Form of such Source Code
|
||||||
|
Form, and Modifications of such Source Code Form, in each case
|
||||||
|
including portions thereof.
|
||||||
|
|
||||||
|
1.5. "Incompatible With Secondary Licenses"
|
||||||
|
means
|
||||||
|
|
||||||
|
(a) that the initial Contributor has attached the notice described
|
||||||
|
in Exhibit B to the Covered Software; or
|
||||||
|
|
||||||
|
(b) that the Covered Software was made available under the terms of
|
||||||
|
version 1.1 or earlier of the License, but not also under the
|
||||||
|
terms of a Secondary License.
|
||||||
|
|
||||||
|
1.6. "Executable Form"
|
||||||
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
|
1.7. "Larger Work"
|
||||||
|
means a work that combines Covered Software with other material, in
|
||||||
|
a separate file or files, that is not Covered Software.
|
||||||
|
|
||||||
|
1.8. "License"
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
1.9. "Licensable"
|
||||||
|
means having the right to grant, to the maximum extent possible,
|
||||||
|
whether at the time of the initial grant or subsequently, any and
|
||||||
|
all of the rights conveyed by this License.
|
||||||
|
|
||||||
|
1.10. "Modifications"
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
(a) any file in Source Code Form that results from an addition to,
|
||||||
|
deletion from, or modification of the contents of Covered
|
||||||
|
Software; or
|
||||||
|
|
||||||
|
(b) any new file in Source Code Form that contains any Covered
|
||||||
|
Software.
|
||||||
|
|
||||||
|
1.11. "Patent Claims" of a Contributor
|
||||||
|
means any patent claim(s), including without limitation, method,
|
||||||
|
process, and apparatus claims, in any patent Licensable by such
|
||||||
|
Contributor that would be infringed, but for the grant of the
|
||||||
|
License, by the making, using, selling, offering for sale, having
|
||||||
|
made, import, or transfer of either its Contributions or its
|
||||||
|
Contributor Version.
|
||||||
|
|
||||||
|
1.12. "Secondary License"
|
||||||
|
means either the GNU General Public License, Version 2.0, the GNU
|
||||||
|
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||||
|
Public License, Version 3.0, or any later versions of those
|
||||||
|
licenses.
|
||||||
|
|
||||||
|
1.13. "Source Code Form"
|
||||||
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
|
1.14. "You" (or "Your")
|
||||||
|
means an individual or a legal entity exercising rights under this
|
||||||
|
License. For legal entities, "You" includes any entity that
|
||||||
|
controls, is controlled by, or is under common control with You. For
|
||||||
|
purposes of this definition, "control" means (a) the power, direct
|
||||||
|
or indirect, to cause the direction or management of such entity,
|
||||||
|
whether by contract or otherwise, or (b) ownership of more than
|
||||||
|
fifty percent (50%) of the outstanding shares or beneficial
|
||||||
|
ownership of such entity.
|
||||||
|
|
||||||
|
2. License Grants and Conditions
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
2.1. Grants
|
||||||
|
|
||||||
|
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license:
|
||||||
|
|
||||||
|
(a) under intellectual property rights (other than patent or trademark)
|
||||||
|
Licensable by such Contributor to use, reproduce, make available,
|
||||||
|
modify, display, perform, distribute, and otherwise exploit its
|
||||||
|
Contributions, either on an unmodified basis, with Modifications, or
|
||||||
|
as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||||
|
for sale, have made, import, and otherwise transfer either its
|
||||||
|
Contributions or its Contributor Version.
|
||||||
|
|
||||||
|
2.2. Effective Date
|
||||||
|
|
||||||
|
The licenses granted in Section 2.1 with respect to any Contribution
|
||||||
|
become effective for each Contribution on the date the Contributor first
|
||||||
|
distributes such Contribution.
|
||||||
|
|
||||||
|
2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
|
The licenses granted in this Section 2 are the only rights granted under
|
||||||
|
this License. No additional rights or licenses will be implied from the
|
||||||
|
distribution or licensing of Covered Software under this License.
|
||||||
|
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||||
|
Contributor:
|
||||||
|
|
||||||
|
(a) for any code that a Contributor has removed from Covered Software;
|
||||||
|
or
|
||||||
|
|
||||||
|
(b) for infringements caused by: (i) Your and any other third party's
|
||||||
|
modifications of Covered Software, or (ii) the combination of its
|
||||||
|
Contributions with other software (except as part of its Contributor
|
||||||
|
Version); or
|
||||||
|
|
||||||
|
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||||
|
its Contributions.
|
||||||
|
|
||||||
|
This License does not grant any rights in the trademarks, service marks,
|
||||||
|
or logos of any Contributor (except as may be necessary to comply with
|
||||||
|
the notice requirements in Section 3.4).
|
||||||
|
|
||||||
|
2.4. Subsequent Licenses
|
||||||
|
|
||||||
|
No Contributor makes additional grants as a result of Your choice to
|
||||||
|
distribute the Covered Software under a subsequent version of this
|
||||||
|
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||||
|
permitted under the terms of Section 3.3).
|
||||||
|
|
||||||
|
2.5. Representation
|
||||||
|
|
||||||
|
Each Contributor represents that the Contributor believes its
|
||||||
|
Contributions are its original creation(s) or it has sufficient rights
|
||||||
|
to grant the rights to its Contributions conveyed by this License.
|
||||||
|
|
||||||
|
2.6. Fair Use
|
||||||
|
|
||||||
|
This License is not intended to limit any rights You have under
|
||||||
|
applicable copyright doctrines of fair use, fair dealing, or other
|
||||||
|
equivalents.
|
||||||
|
|
||||||
|
2.7. Conditions
|
||||||
|
|
||||||
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||||
|
in Section 2.1.
|
||||||
|
|
||||||
|
3. Responsibilities
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
3.1. Distribution of Source Form
|
||||||
|
|
||||||
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
|
Modifications that You create or to which You contribute, must be under
|
||||||
|
the terms of this License. You must inform recipients that the Source
|
||||||
|
Code Form of the Covered Software is governed by the terms of this
|
||||||
|
License, and how they can obtain a copy of this License. You may not
|
||||||
|
attempt to alter or restrict the recipients' rights in the Source Code
|
||||||
|
Form.
|
||||||
|
|
||||||
|
3.2. Distribution of Executable Form
|
||||||
|
|
||||||
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
|
(a) such Covered Software must also be made available in Source Code
|
||||||
|
Form, as described in Section 3.1, and You must inform recipients of
|
||||||
|
the Executable Form how they can obtain a copy of such Source Code
|
||||||
|
Form by reasonable means in a timely manner, at a charge no more
|
||||||
|
than the cost of distribution to the recipient; and
|
||||||
|
|
||||||
|
(b) You may distribute such Executable Form under the terms of this
|
||||||
|
License, or sublicense it under different terms, provided that the
|
||||||
|
license for the Executable Form does not attempt to limit or alter
|
||||||
|
the recipients' rights in the Source Code Form under this License.
|
||||||
|
|
||||||
|
3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
|
You may create and distribute a Larger Work under terms of Your choice,
|
||||||
|
provided that You also comply with the requirements of this License for
|
||||||
|
the Covered Software. If the Larger Work is a combination of Covered
|
||||||
|
Software with a work governed by one or more Secondary Licenses, and the
|
||||||
|
Covered Software is not Incompatible With Secondary Licenses, this
|
||||||
|
License permits You to additionally distribute such Covered Software
|
||||||
|
under the terms of such Secondary License(s), so that the recipient of
|
||||||
|
the Larger Work may, at their option, further distribute the Covered
|
||||||
|
Software under the terms of either this License or such Secondary
|
||||||
|
License(s).
|
||||||
|
|
||||||
|
3.4. Notices
|
||||||
|
|
||||||
|
You may not remove or alter the substance of any license notices
|
||||||
|
(including copyright notices, patent notices, disclaimers of warranty,
|
||||||
|
or limitations of liability) contained within the Source Code Form of
|
||||||
|
the Covered Software, except that You may alter any license notices to
|
||||||
|
the extent required to remedy known factual inaccuracies.
|
||||||
|
|
||||||
|
3.5. Application of Additional Terms
|
||||||
|
|
||||||
|
You may choose to offer, and to charge a fee for, warranty, support,
|
||||||
|
indemnity or liability obligations to one or more recipients of Covered
|
||||||
|
Software. However, You may do so only on Your own behalf, and not on
|
||||||
|
behalf of any Contributor. You must make it absolutely clear that any
|
||||||
|
such warranty, support, indemnity, or liability obligation is offered by
|
||||||
|
You alone, and You hereby agree to indemnify every Contributor for any
|
||||||
|
liability incurred by such Contributor as a result of warranty, support,
|
||||||
|
indemnity or liability terms You offer. You may include additional
|
||||||
|
disclaimers of warranty and limitations of liability specific to any
|
||||||
|
jurisdiction.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this
|
||||||
|
License with respect to some or all of the Covered Software due to
|
||||||
|
statute, judicial order, or regulation then You must: (a) comply with
|
||||||
|
the terms of this License to the maximum extent possible; and (b)
|
||||||
|
describe the limitations and the code they affect. Such description must
|
||||||
|
be placed in a text file included with all distributions of the Covered
|
||||||
|
Software under this License. Except to the extent prohibited by statute
|
||||||
|
or regulation, such description must be sufficiently detailed for a
|
||||||
|
recipient of ordinary skill to be able to understand it.
|
||||||
|
|
||||||
|
5. Termination
|
||||||
|
--------------
|
||||||
|
|
||||||
|
5.1. The rights granted under this License will terminate automatically
|
||||||
|
if You fail to comply with any of its terms. However, if You become
|
||||||
|
compliant, then the rights granted under this License from a particular
|
||||||
|
Contributor are reinstated (a) provisionally, unless and until such
|
||||||
|
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||||
|
ongoing basis, if such Contributor fails to notify You of the
|
||||||
|
non-compliance by some reasonable means prior to 60 days after You have
|
||||||
|
come back into compliance. Moreover, Your grants from a particular
|
||||||
|
Contributor are reinstated on an ongoing basis if such Contributor
|
||||||
|
notifies You of the non-compliance by some reasonable means, this is the
|
||||||
|
first time You have received notice of non-compliance with this License
|
||||||
|
from such Contributor, and You become compliant prior to 30 days after
|
||||||
|
Your receipt of the notice.
|
||||||
|
|
||||||
|
5.2. If You initiate litigation against any entity by asserting a patent
|
||||||
|
infringement claim (excluding declaratory judgment actions,
|
||||||
|
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||||
|
directly or indirectly infringes any patent, then the rights granted to
|
||||||
|
You by any and all Contributors for the Covered Software under Section
|
||||||
|
2.1 of this License shall terminate.
|
||||||
|
|
||||||
|
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||||
|
end user license agreements (excluding distributors and resellers) which
|
||||||
|
have been validly granted by You or Your distributors under this License
|
||||||
|
prior to termination shall survive termination.
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 6. Disclaimer of Warranty *
|
||||||
|
* ------------------------- *
|
||||||
|
* *
|
||||||
|
* Covered Software is provided under this License on an "as is" *
|
||||||
|
* basis, without warranty of any kind, either expressed, implied, or *
|
||||||
|
* statutory, including, without limitation, warranties that the *
|
||||||
|
* Covered Software is free of defects, merchantable, fit for a *
|
||||||
|
* particular purpose or non-infringing. The entire risk as to the *
|
||||||
|
* quality and performance of the Covered Software is with You. *
|
||||||
|
* Should any Covered Software prove defective in any respect, You *
|
||||||
|
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||||
|
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||||
|
* essential part of this License. No use of any Covered Software is *
|
||||||
|
* authorized under this License except under this disclaimer. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 7. Limitation of Liability *
|
||||||
|
* -------------------------- *
|
||||||
|
* *
|
||||||
|
* Under no circumstances and under no legal theory, whether tort *
|
||||||
|
* (including negligence), contract, or otherwise, shall any *
|
||||||
|
* Contributor, or anyone who distributes Covered Software as *
|
||||||
|
* permitted above, be liable to You for any direct, indirect, *
|
||||||
|
* special, incidental, or consequential damages of any character *
|
||||||
|
* including, without limitation, damages for lost profits, loss of *
|
||||||
|
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||||
|
* and all other commercial damages or losses, even if such party *
|
||||||
|
* shall have been informed of the possibility of such damages. This *
|
||||||
|
* limitation of liability shall not apply to liability for death or *
|
||||||
|
* personal injury resulting from such party's negligence to the *
|
||||||
|
* extent applicable law prohibits such limitation. Some *
|
||||||
|
* jurisdictions do not allow the exclusion or limitation of *
|
||||||
|
* incidental or consequential damages, so this exclusion and *
|
||||||
|
* limitation may not apply to You. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
8. Litigation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Any litigation relating to this License may be brought only in the
|
||||||
|
courts of a jurisdiction where the defendant maintains its principal
|
||||||
|
place of business and such litigation shall be governed by laws of that
|
||||||
|
jurisdiction, without reference to its conflict-of-law provisions.
|
||||||
|
Nothing in this Section shall prevent a party's ability to bring
|
||||||
|
cross-claims or counter-claims.
|
||||||
|
|
||||||
|
9. Miscellaneous
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning the subject
|
||||||
|
matter hereof. If any provision of this License is held to be
|
||||||
|
unenforceable, such provision shall be reformed only to the extent
|
||||||
|
necessary to make it enforceable. Any law or regulation which provides
|
||||||
|
that the language of a contract shall be construed against the drafter
|
||||||
|
shall not be used to construe this License against a Contributor.
|
||||||
|
|
||||||
|
10. Versions of the License
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
10.1. New Versions
|
||||||
|
|
||||||
|
Mozilla Foundation is the license steward. Except as provided in Section
|
||||||
|
10.3, no one other than the license steward has the right to modify or
|
||||||
|
publish new versions of this License. Each version will be given a
|
||||||
|
distinguishing version number.
|
||||||
|
|
||||||
|
10.2. Effect of New Versions
|
||||||
|
|
||||||
|
You may distribute the Covered Software under the terms of the version
|
||||||
|
of the License under which You originally received the Covered Software,
|
||||||
|
or under the terms of any subsequent version published by the license
|
||||||
|
steward.
|
||||||
|
|
||||||
|
10.3. Modified Versions
|
||||||
|
|
||||||
|
If you create software not governed by this License, and you want to
|
||||||
|
create a new license for such software, you may create and use a
|
||||||
|
modified version of this License if you rename the license and remove
|
||||||
|
any references to the name of the license steward (except to note that
|
||||||
|
such modified license differs from this License).
|
||||||
|
|
||||||
|
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||||
|
Licenses
|
||||||
|
|
||||||
|
If You choose to distribute Source Code Form that is Incompatible With
|
||||||
|
Secondary Licenses under the terms of this version of the License, the
|
||||||
|
notice described in Exhibit B of this License must be attached.
|
||||||
|
|
||||||
|
Exhibit A - Source Code Form License Notice
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
If it is not possible or desirable to put the notice in a particular
|
||||||
|
file, then You may include the notice in a location (such as a LICENSE
|
||||||
|
file in a relevant directory) where a recipient would be likely to look
|
||||||
|
for such a notice.
|
||||||
|
|
||||||
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
|
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||||
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
defined by the Mozilla Public License, v. 2.0.
|
25
README.md
25
README.md
@ -8,19 +8,38 @@ Hence mouse :D.
|
|||||||
## Whut?
|
## Whut?
|
||||||
|
|
||||||
Mouse is a rust based facts gatherer that returns a list of facts of the host, it can be completely ran as user at this time and it's intended to stay that way.
|
Mouse is a rust based facts gatherer that returns a list of facts of the host, it can be completely ran as user at this time and it's intended to stay that way.
|
||||||
Mouse does not alter the system, just gathers information and returns it in a key/value way (with extra epoch timestamp).
|
Mouse does not alter the system, just gathers information and returns it in json or yaml (default). At this time I can only test on x86_64 and aarch64, so those are the only supported platforms for now.
|
||||||
|
|
||||||
## Why?
|
## Why?
|
||||||
|
|
||||||
Yes we have ohai, facter, osquery,...
|
Yes we have ohai, facter, osquery,...
|
||||||
But those won't let me learn Rust.
|
But those won't let me learn Rust.
|
||||||
|
|
||||||
|
## How?
|
||||||
|
|
||||||
|
Download the release or build locally and execute. Use --help for information.
|
||||||
|
example: `mouse -g system -o json` will output system information in json.
|
||||||
|
|
||||||
|
At this time with the latest release (v0.1.4) there are 4 gatherers:
|
||||||
|
|
||||||
|
* env
|
||||||
|
* ipaddr
|
||||||
|
* iproute
|
||||||
|
* system
|
||||||
|
|
||||||
|
|
||||||
## Contribute?
|
## Contribute?
|
||||||
|
|
||||||
Why not, but don't feel obligated.
|
Why not, but don't feel obligated.
|
||||||
|
|
||||||
|
If you want to contribute, feel free to send your patches to mouse-patch@sejo-it dot be.
|
||||||
|
|
||||||
|
## It doesn't work!
|
||||||
|
|
||||||
|
Aww, too bad, well you can always submit an issue or fix it yourself. It's open source afterall, isn't it?
|
||||||
|
|
||||||
## I have more questions:
|
## I have more questions:
|
||||||
|
|
||||||
matrix: @sejo:matrix.sejo-it.be
|
matrix: #mouse-dev:matrix.sejo-it.be
|
||||||
discord: sejoit (legacy: sejo#5402)
|
discord: sejoit (legacy: sejo#5402)
|
||||||
email: jochen@sejo-it.be
|
email: jochen@sejo-it.be
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
use crate::types::fact::Fact;
|
use crate::types::fact::Fact;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use std::{collections::HashMap, env};
|
||||||
use std::env;
|
|
||||||
|
|
||||||
pub struct EnvironmentData {}
|
pub struct EnvironmentData {}
|
||||||
impl EnvironmentData {}
|
impl EnvironmentData {}
|
||||||
@ -10,18 +13,13 @@ impl EnvironmentData {}
|
|||||||
pub struct EnvironmentValue {
|
pub struct EnvironmentValue {
|
||||||
key: String,
|
key: String,
|
||||||
value: String,
|
value: String,
|
||||||
time_set: u128,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Fact for EnvironmentData {
|
impl Fact for EnvironmentData {
|
||||||
fn gather(&self) -> String {
|
fn gather(&self) -> String {
|
||||||
let mut outmap: Vec<Value> = vec![];
|
let mut outmap: HashMap<String, String> = HashMap::new();
|
||||||
for (key, value) in env::vars() {
|
for (key, value) in env::vars() {
|
||||||
let entry = json!({
|
outmap.insert(key, value);
|
||||||
"key": &key,
|
|
||||||
"value": value,
|
|
||||||
});
|
|
||||||
outmap.append(&mut vec![entry]);
|
|
||||||
}
|
}
|
||||||
serde_json::to_string(&outmap).unwrap()
|
serde_json::to_string(&outmap).unwrap()
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
use crate::{types::fact::Fact, util::command::get_result_as_string};
|
use crate::{types::fact::Fact, util::command::get_result_as_string};
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
pub struct IPData {}
|
pub struct IPData {}
|
||||||
impl IPData {}
|
impl IPData {}
|
||||||
|
|
||||||
@ -10,7 +12,7 @@ impl Fact for IPData {
|
|||||||
fn gather(&self) -> String {
|
fn gather(&self) -> String {
|
||||||
let res = get_result_as_string("ip", vec!["-j", "addr"]);
|
let res = get_result_as_string("ip", vec!["-j", "addr"]);
|
||||||
let jsonres: Value = serde_json::from_str(res.as_str()).unwrap();
|
let jsonres: Value = serde_json::from_str(res.as_str()).unwrap();
|
||||||
let out = json!({ "ip_addr": jsonres });
|
let out = json!({ "ipaddr": jsonres });
|
||||||
out.to_string()
|
out.to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,7 +24,7 @@ impl Fact for IPRouteData {
|
|||||||
let res = get_result_as_string("ip", vec!["-j", "route"]);
|
let res = get_result_as_string("ip", vec!["-j", "route"]);
|
||||||
let jsonres: Value = serde_json::from_str(res.as_str()).unwrap();
|
let jsonres: Value = serde_json::from_str(res.as_str()).unwrap();
|
||||||
let out = json!({
|
let out = json!({
|
||||||
"ip_route": jsonres
|
"iproute": jsonres
|
||||||
});
|
});
|
||||||
out.to_string()
|
out.to_string()
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
pub mod environment;
|
pub mod environment;
|
||||||
pub mod ip;
|
pub mod ip;
|
||||||
|
pub mod system;
|
||||||
|
@ -1,105 +1,134 @@
|
|||||||
use std::process::Command;
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
use crate::types::fact::{Fact, FactData};
|
use std::{fs, io::ErrorKind, str, usize};
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
use sysinfo::{System, SystemExt};
|
||||||
|
|
||||||
|
use crate::types::fact::Fact;
|
||||||
|
|
||||||
pub struct SystemData {}
|
pub struct SystemData {}
|
||||||
|
|
||||||
impl SystemData {}
|
impl SystemData {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
struct UnameData{
|
|
||||||
kernel_name: String,
|
|
||||||
node_name: String,
|
|
||||||
kernel_release: String,
|
|
||||||
kernel_version: String,
|
|
||||||
machine: String,
|
|
||||||
processor: String,
|
|
||||||
hardware_platform: String,
|
|
||||||
operating_system: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
struct IpAddrInfo {
|
|
||||||
family: String,
|
|
||||||
local: String,
|
|
||||||
prefixlen: i32,
|
|
||||||
broadcast: Option<String>,
|
|
||||||
scope: String,
|
|
||||||
dynamic: Option<bool>,
|
|
||||||
noprefixroute: Option<bool>,
|
|
||||||
label: Option<String>,
|
|
||||||
valid_life_time: i64,
|
|
||||||
preferred_life_time: i64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
struct IpAddr {
|
|
||||||
ifindex: i32,
|
|
||||||
ifname: String,
|
|
||||||
flags: Vec<String>,
|
|
||||||
mtu: i32,
|
|
||||||
qdisc: String,
|
|
||||||
operstate: String,
|
|
||||||
group: String,
|
|
||||||
txqlen: i32,
|
|
||||||
link_type: String,
|
|
||||||
address: Option<String>,
|
|
||||||
broadcast: Option<String>,
|
|
||||||
addr_info: Vec<IpAddrInfo>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Fact for SystemData {
|
impl Fact for SystemData {
|
||||||
fn gather(&self) -> Vec<FactData> {
|
fn gather(&self) -> String {
|
||||||
let mut vfd: Vec<FactData> = vec![];
|
if System::IS_SUPPORTED {
|
||||||
let time_set = self.get_epoch_ms();
|
let mut sys = System::new();
|
||||||
let output = Command::new("ip")
|
// we only need certain values.
|
||||||
.arg("-j")
|
sys.refresh_cpu();
|
||||||
.arg("addr")
|
sys.refresh_disks();
|
||||||
.output()
|
sys.refresh_disks_list();
|
||||||
.expect("Failed to execute ip");
|
sys.refresh_memory();
|
||||||
let stdout = String::from_utf8(output.stdout).unwrap();
|
sys.refresh_system();
|
||||||
let ips: Vec<IpAddr> = serde_json::from_str(stdout.as_str()).unwrap();
|
sys.refresh_components();
|
||||||
for ip in ips {
|
sys.refresh_components_list();
|
||||||
if ip.ifname != "lo" {
|
sys.refresh_users_list();
|
||||||
for addr_info in ip.addr_info {
|
serde_json::to_string(&sys).unwrap()
|
||||||
let fd = FactData {
|
} else {
|
||||||
name: format!("ip_addr_{}_{}_addr", ip.ifname, addr_info.family),
|
"{\"error\": \"Not Supported\"}".to_string()
|
||||||
value: addr_info.local,
|
|
||||||
time_set: time_set,
|
|
||||||
};
|
|
||||||
vfd.push(fd);
|
|
||||||
vfd.push(FactData {
|
|
||||||
name: format!("ip_addr_{}_{}_prefixlen", ip.ifname, addr_info.family),
|
|
||||||
value: addr_info.prefixlen.to_string(),
|
|
||||||
time_set: time_set,
|
|
||||||
});
|
|
||||||
if addr_info.label.is_some() {
|
|
||||||
vfd.push(FactData {
|
|
||||||
name: format!("ip_addr_{}_{}_label", ip.ifname, addr_info.family),
|
|
||||||
value: addr_info.label.unwrap(),
|
|
||||||
time_set: time_set,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if addr_info.broadcast.is_some() {
|
|
||||||
vfd.push(FactData {
|
|
||||||
name: format!("ip_addr_{}_{}_broadcast", ip.ifname, addr_info.family),
|
|
||||||
value: addr_info.broadcast.unwrap(),
|
|
||||||
time_set: time_set,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if ip.address.is_some() {
|
|
||||||
vfd.push(FactData {
|
|
||||||
name: format!("ip_addr_{}_macaddr", ip.ifname),
|
|
||||||
value: ip.address.clone().unwrap(),
|
|
||||||
time_set: time_set,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return vfd;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct DMIData {}
|
||||||
|
impl DMIData {}
|
||||||
|
|
||||||
|
impl Fact for DMIData {
|
||||||
|
fn gather(&self) -> String {
|
||||||
|
json!({
|
||||||
|
"form_factor": get_form_factor("/sys/devices/virtual/dmi/id/chassis_type"),
|
||||||
|
"bios_date": get_string("/sys/devices/virtual/dmi/id/bios_date"),
|
||||||
|
"bios_vendor": get_string("/sys/devices/virtual/dmi/id/bios_vendor"),
|
||||||
|
"bios_version": get_string("/sys/devices/virtual/dmi/id/bios_version"),
|
||||||
|
"board_asset_tag": get_string("/sys/devices/virtual/dmi/id/board_asset_tag"),
|
||||||
|
"board_name": get_string("/sys/devices/virtual/dmi/id/board_name"),
|
||||||
|
"board_serial": get_string("/sys/devices/virtual/dmi/id/board_serial"),
|
||||||
|
"board_vendor": get_string("/sys/devices/virtual/dmi/id/board_vendor"),
|
||||||
|
"board_version": get_string("/sys/devices/virtual/dmi/id/board_version"),
|
||||||
|
"chassis_asset_tag": get_string("/sys/devices/virtual/dmi/id/chassis_asset_tag"),
|
||||||
|
"chassis_serial": get_string("/sys/devices/virtual/dmi/id/chassis_vendor"),
|
||||||
|
"chassis_vendor": get_string("/sys/devices/virtual/dmi/id/chassis_vendor"),
|
||||||
|
"chassis_version": get_string("/sys/devices/virtual/dmi/id/chassis_version"),
|
||||||
|
"product_name": get_string("/sys/devices/virtual/dmi/id/product_name"),
|
||||||
|
"product_serial": get_string("/sys/devices/virtual/dmi/id/product_serial"),
|
||||||
|
"product_uuid": get_string("/sys/devices/virtual/dmi/id/product_uuid"),
|
||||||
|
"product_version": get_string("/sys/devices/virtual/dmi/id/product_version"),
|
||||||
|
"system_vendor": get_string("/sys/devices/virtual/dmi/id/sys_vendor"),
|
||||||
|
})
|
||||||
|
.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_string(path: &str) -> String {
|
||||||
|
match fs::read(path) {
|
||||||
|
Ok(x) => String::from_utf8(x).unwrap().trim().to_string(),
|
||||||
|
Err(y) => match y.kind() {
|
||||||
|
ErrorKind::PermissionDenied => "This data needs sudo or root permissions".to_string(),
|
||||||
|
other_error => format!("Could not retrieve {other_error}"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_form_factor(path: &str) -> &str {
|
||||||
|
// Get form factor info
|
||||||
|
// as learned from Ansible, we need to have the list in a specific order,
|
||||||
|
// see https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.2.0.pdf
|
||||||
|
|
||||||
|
let ff: Vec<&str> = vec![
|
||||||
|
"Unknown",
|
||||||
|
"Other",
|
||||||
|
"Unknown",
|
||||||
|
"Desktop",
|
||||||
|
"Low Profile Desktop",
|
||||||
|
"Pizza Box",
|
||||||
|
"Mini Tower",
|
||||||
|
"Tower",
|
||||||
|
"Portable",
|
||||||
|
"Laptop",
|
||||||
|
"Notebook",
|
||||||
|
"Hand Held",
|
||||||
|
"Docking Station",
|
||||||
|
"All In One",
|
||||||
|
"Sub Notebook",
|
||||||
|
"Space-saving",
|
||||||
|
"Lunch Box",
|
||||||
|
"Main Server Chassis",
|
||||||
|
"Expansion Chassis",
|
||||||
|
"Sub Chassis",
|
||||||
|
"Bus Expansion Chassis",
|
||||||
|
"Peripheral Chassis",
|
||||||
|
"RAID Chassis",
|
||||||
|
"Rack Mount Chassis",
|
||||||
|
"Sealed-case PC",
|
||||||
|
"Multi-system",
|
||||||
|
"CompactPCI",
|
||||||
|
"AdvancedTCA",
|
||||||
|
"Blade",
|
||||||
|
"Blade Enclosure",
|
||||||
|
"Tablet",
|
||||||
|
"Convertible",
|
||||||
|
"Detachable",
|
||||||
|
"IoT Gateway",
|
||||||
|
"Embedded PC",
|
||||||
|
"Mini PC",
|
||||||
|
"Stick PC",
|
||||||
|
];
|
||||||
|
|
||||||
|
let filecontent: &str = match fs::read(path) {
|
||||||
|
Err(_) => ff[0],
|
||||||
|
Ok(x) => {
|
||||||
|
let ind: i32 = match str::from_utf8(&x) {
|
||||||
|
Ok(x) => x.trim().parse::<i32>().unwrap(),
|
||||||
|
Err(_) => 0,
|
||||||
|
};
|
||||||
|
let out: &str = if ff.len() <= ind as usize {
|
||||||
|
ff[0]
|
||||||
|
} else {
|
||||||
|
ff[ind as usize]
|
||||||
|
};
|
||||||
|
out
|
||||||
|
}
|
||||||
|
};
|
||||||
|
filecontent
|
||||||
|
}
|
||||||
|
52
src/main.rs
52
src/main.rs
@ -1,3 +1,7 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
mod gatherers;
|
mod gatherers;
|
||||||
mod types;
|
mod types;
|
||||||
mod util;
|
mod util;
|
||||||
@ -9,8 +13,10 @@ use crate::gatherers::environment::EnvironmentData;
|
|||||||
use crate::gatherers::ip::{IPData, IPRouteData};
|
use crate::gatherers::ip::{IPData, IPRouteData};
|
||||||
use crate::types::fact::Fact;
|
use crate::types::fact::Fact;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use gatherers::system::{DMIData, SystemData};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use yaml_rust::{YamlEmitter, YamlLoader};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[clap(author, version, about, long_about = None)]
|
||||||
@ -27,6 +33,12 @@ fn gather_list(gatherers: HashSet<String>, output: &str) -> String {
|
|||||||
let mut outmap: HashMap<String, Value> = HashMap::new();
|
let mut outmap: HashMap<String, Value> = HashMap::new();
|
||||||
for g in gatherers {
|
for g in gatherers {
|
||||||
match g.as_str() {
|
match g.as_str() {
|
||||||
|
"dmi" => {
|
||||||
|
outmap.insert(
|
||||||
|
"dmi".to_string(),
|
||||||
|
serde_json::from_str(&DMIData {}.gather()).unwrap(),
|
||||||
|
);
|
||||||
|
}
|
||||||
"env" => {
|
"env" => {
|
||||||
outmap.insert(
|
outmap.insert(
|
||||||
"environment".to_string(),
|
"environment".to_string(),
|
||||||
@ -36,13 +48,27 @@ fn gather_list(gatherers: HashSet<String>, output: &str) -> String {
|
|||||||
"ipaddr" => {
|
"ipaddr" => {
|
||||||
outmap.insert(
|
outmap.insert(
|
||||||
"ipaddr".to_string(),
|
"ipaddr".to_string(),
|
||||||
serde_json::from_str(&IPData {}.gather()).unwrap(),
|
serde_json::from_str::<Value>(&IPData {}.gather())
|
||||||
|
.unwrap()
|
||||||
|
.get("ipaddr")
|
||||||
|
.unwrap()
|
||||||
|
.clone(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
"iproute" => {
|
"iproute" => {
|
||||||
outmap.insert(
|
outmap.insert(
|
||||||
"iproute".to_string(),
|
"iproute".to_string(),
|
||||||
serde_json::from_str(&IPRouteData {}.gather()).unwrap(),
|
serde_json::from_str::<Value>(&IPRouteData {}.gather())
|
||||||
|
.unwrap()
|
||||||
|
.get("iproute")
|
||||||
|
.unwrap()
|
||||||
|
.clone(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
"system" => {
|
||||||
|
outmap.insert(
|
||||||
|
"system".to_string(),
|
||||||
|
serde_json::from_str(&SystemData {}.gather()).unwrap(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
x => {
|
x => {
|
||||||
@ -51,7 +77,7 @@ fn gather_list(gatherers: HashSet<String>, output: &str) -> String {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
match output {
|
match output {
|
||||||
"json" => serde_json::to_string(&outmap).unwrap(),
|
"json" => serde_json::to_string_pretty(&outmap).unwrap(),
|
||||||
"yaml" => serde_yaml::to_string(&outmap).unwrap(),
|
"yaml" => serde_yaml::to_string(&outmap).unwrap(),
|
||||||
x => format!("Unknown output format {x}"),
|
x => format!("Unknown output format {x}"),
|
||||||
}
|
}
|
||||||
@ -64,9 +90,11 @@ fn main() {
|
|||||||
_ => "yaml",
|
_ => "yaml",
|
||||||
};
|
};
|
||||||
let all: HashSet<String> = HashSet::from([
|
let all: HashSet<String> = HashSet::from([
|
||||||
|
"dmi".to_string(),
|
||||||
"env".to_string(),
|
"env".to_string(),
|
||||||
"ipaddr".to_string(),
|
"ipaddr".to_string(),
|
||||||
"iproute".to_string(),
|
"iproute".to_string(),
|
||||||
|
"system".to_string(),
|
||||||
]);
|
]);
|
||||||
let data_output: String = match args.gatherer {
|
let data_output: String = match args.gatherer {
|
||||||
None => gather_list(all, output_format),
|
None => gather_list(all, output_format),
|
||||||
@ -75,5 +103,21 @@ fn main() {
|
|||||||
gather_list(gatherers, output_format)
|
gather_list(gatherers, output_format)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
println!("{}", data_output);
|
match output_format {
|
||||||
|
"json" => println!("{}", data_output),
|
||||||
|
"yaml" => {
|
||||||
|
// We will run the string back through yaml_rust, for better output compatibility.
|
||||||
|
// We could choose to swwitch serde_yaml out completely but at this time I don't see
|
||||||
|
// a huge value, as once serde_yaml fixes their implementation,...
|
||||||
|
let tmp = format!("---\n{}", data_output);
|
||||||
|
let yr = YamlLoader::load_from_str(tmp.as_str()).unwrap();
|
||||||
|
let mut out = String::new();
|
||||||
|
{
|
||||||
|
let mut emitter = YamlEmitter::new(&mut out);
|
||||||
|
emitter.dump(&yr[0]).unwrap();
|
||||||
|
};
|
||||||
|
println!("{}", out)
|
||||||
|
}
|
||||||
|
x => println!("This should never print,.. but it did. Maybe this explains why: {x}"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
pub trait Fact: Send + Sync {
|
pub trait Fact: Send + Sync {
|
||||||
|
@ -1 +1,5 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
pub mod fact;
|
pub mod fact;
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
use std::process::{Command, Output};
|
use std::process::{Command, Output};
|
||||||
|
|
||||||
fn get_output_from_command(cmd: &str, args: Vec<&str>) -> Output {
|
fn get_output_from_command(cmd: &str, args: Vec<&str>) -> Output {
|
||||||
|
@ -1 +1,5 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
pub mod command;
|
pub mod command;
|
||||||
|
15
version.sh
Executable file
15
version.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -x
|
||||||
|
# Get last created tag
|
||||||
|
LTCOMMIT=$(git rev-list --abbrev-commit --tags --max-count=1)
|
||||||
|
LTAG=$(git describe --abbrev=0 --tags ${LTCOMMIT} 2>/dev/null || true)
|
||||||
|
ADC=${DRONE_COMMIT:0:7}
|
||||||
|
|
||||||
|
if [[ "${LTCOMMIT}" == "${ADC}" ]]; then
|
||||||
|
VERSION="${DRONE_TAG##v}"
|
||||||
|
else
|
||||||
|
VERSION="${LTAG##v}-next-${ADC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed -i "s/0\\.0\\.0/${VERSION}/" Cargo.toml
|
||||||
|
cat Cargo.toml
|
Loading…
Reference in New Issue
Block a user