{"id":19461062,"url":"https://github.com/jtopjian/elements","last_synced_at":"2025-04-25T07:33:32.548Z","repository":{"id":50063585,"uuid":"57459830","full_name":"jtopjian/elements","owner":"jtopjian","description":"Obtain system information","archived":false,"fork":false,"pushed_at":"2022-07-27T16:50:59.000Z","size":764,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-19T11:30:11.829Z","etag":null,"topics":["facts","inventory","system"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jtopjian.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-30T20:11:22.000Z","updated_at":"2022-07-27T14:59:33.000Z","dependencies_parsed_at":"2022-09-14T00:12:21.164Z","dependency_job_id":null,"html_url":"https://github.com/jtopjian/elements","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtopjian%2Felements","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtopjian%2Felements/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtopjian%2Felements/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtopjian%2Felements/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jtopjian","download_url":"https://codeload.github.com/jtopjian/elements/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223990556,"owners_count":17237318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["facts","inventory","system"],"created_at":"2024-11-10T17:39:28.795Z","updated_at":"2024-11-10T17:39:29.380Z","avatar_url":"https://github.com/jtopjian.png","language":"Go","readme":"# Elements\n\nElements retrieves information about a system such as CPU/Processors, disks, memory, network interfaces, and cloud metadata. It is meant to be used to query a system about its static attributes.\n\nThis tool is similar to Facter, Ohai, Ansible facts, etc.\n\nFor dynamic attributes, such as load average and IOPS, use a more suitable metric collection tool.\n\n## Install\n\nDownload the latest binary [release](https://github.com/jtopjian/elements/releases). Linux, Mac, FreeBSD, and Windows binaries are currently available, though testing has only been done on Linux and Mac.\n\n## Usage\n\nRun `elements` with no arguments on the command line to see the usage and options.\n\nElements is able to detect a standard set of information about a system. Simply run `elements get` on the command line and see the result:\n\n```shell\n$ elements get\n\n{\n  \"system\": {\n    \"host\": {\n\t\"bootTime\": 1480266892,\n\t\"hostid\": \"2DAAF9F7-0ED2-4DA7-BDD7-7A03F37C091A\",\n\t\"hostname\": \"jtdev\",\n\t\"kernelVersion\": \"4.4.0-45-generic\",\n\t\"os\": \"linux\",\n\t\"platform\": \"ubuntu\",\n\t\"platformFamily\": \"debian\",\n\t\"platformVersion\": \"16.04\",\n\t\"procs\": 682,\n\t\"uptime\": 1678017,\n\t\"virtualizationRole\": \"host\",\n\t\"virtualizationSystem\": \"kvm\"\n    },\n...\n```\n\nTo retrieve a subset of elements, \"walk\" the tree using a dotted notation:\n\n```shell\n$ elements get -p system.interfaces.ens3\n\n{\n  \"flags\": [\n   \"up\",\n   \"broadcast\",\n   \"multicast\"\n  ],\n  \"hardwareaddr\": \"fa:16:3e:dc:86:b9\",\n  \"ipv4\": [\n   {\n    \"address\": \"10.1.12.176\",\n    \"cidr\": \"10.1.12.176/20\"\n   }\n  ],\n  \"ipv6\": [\n   {\n    \"address\": \"fe80::f816:3eff:fedc:86b9\",\n    \"cidr\": \"fe80::f816:3eff:fedc:86b9/64\"\n   }\n  ],\n  \"mtu\": 1500\n}\n```\n\nTo retrieve an exact value, \"walk\" the tree all the way to a final element:\n\n```shell\n$ elements get -p system.interfaces.ens3.ipv4.0.address\n\n10.1.12.176\n```\n\n### Output Formats\n\nElements can be printed out in two different formats: JSON and shell. By default, JSON will be used, but shell is useful for within shell scripts:\n\n```bash\n#!/bin/bash\n\neval $(elements get -f shell)\necho $elements_system_interfaces_ens3_ipv4_0_address\n```\n\n### Elements Daemon\n\nElements is able to be run in a daemon mode and accessed over HTTP. In one terminal, run:\n\n```shell\n$ elements serve\n```\n\nand in another, run:\n\n```shell\n$ curl localhost:8888/elements/system/interfaces/ens3\n```\n\nYou may specify the output format via the `?format=` query parameter, like so:\n\n```shell\n$ curl localhost:8888/elements/system/interfaces/ens3?format=shell\n```\n\n## External Elements in `elements.d/`\n\nYou may extend the facts elements reports by putting external sources with valid\nJSON in a configurable `elements.d` directory. By default, this directory is\n`/etc/elements/elements.d`.\n\nExecutables and static JSON files placed in `/etc/elements/elements.d` will automatically be executed and/or read when `elements` is run. If the file is executable (ie: `chmod +x`), Elements will execute it. Non-executable files with a `.json` extension will be read directly. Files in the `elements.d` directory that do not match these criteria will be ignored. Files and executables that do not contain or produce valid JSON will be ignored.\n \nFor example, given the executable file `/etc/elements/elements.d/foo.sh`:\n\n```bash\n#!/bin/bash\n\necho '{\"hello\": \"world\"}'\n```\n\nElements will output:\n\n```shell\n$ elements get\n{\n  \"external\": {\n     \"foo\": {\n        \"hello\": \"world\"\n     }\n  },\n  \"system\": {\n    ...\n```\n\nYou my specify an alternate directory location for your `elements.d` directory\nwith the `-c | --configdir` flag. For example, to source external elements from\nthe `/var/lib/cloud/data/elements.d` directory, you would specify:\n\n```shell\n$ elements get -c /var/lib/cloud/data\n```\n\n## Compile from Source\n\n1. Setup a standard Go environment.\n2. Run: `go get github.com/jtopjian/elements/...`\n3. Run: `cd $GOROOT/src/github.com/jtopjian/elements`\n4. Run: `go build -o elements cmd/*.go`\n\n## History and Credits\n\nElements was originally a large fork of [Terminus](https://github.com/kelseyhightower/terminus). The move to `gopsutil` was inspired by [go-facter](https://github.com/zstyblik/go-facter).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtopjian%2Felements","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjtopjian%2Felements","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtopjian%2Felements/lists"}