Fixes cross-platform building (func update shadowing), removes gotop-builder trigger.

This commit is contained in:
Sean E. Russell 2021-03-05 16:28:53 -06:00
parent efcb0e9d2a
commit ff2e7e2235
3 changed files with 22 additions and 13 deletions

View File

@ -14,14 +14,6 @@ jobs:
run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF##*/})" run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF##*/})"
id: tag_name id: tag_name
- name: Trigger extensions build
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: xxxserxxx/gotop-builder
event-type: my-release
client-payload: '{"tag": "${{ steps.tag_name.outputs.tag }}"}'
- name: Update Homebrew recipe - name: Update Homebrew recipe
uses: peter-evans/repository-dispatch@v1 uses: peter-evans/repository-dispatch@v1
with: with:

View File

@ -96,13 +96,13 @@ func startNVidia(vars map[string]string) error {
} }
} }
// update once to populate the device names, for the widgets. // update once to populate the device names, for the widgets.
update() updateNvidia()
// Fork off a long-running job to call the nvidia tool periodically, // Fork off a long-running job to call the nvidia tool periodically,
// parse out the values, and put them in the cache. // parse out the values, and put them in the cache.
go func() { go func() {
timer := time.Tick(refresh) timer := time.Tick(refresh)
for range timer { for range timer {
update() updateNvidia()
} }
}() }()
return nil return nil
@ -121,7 +121,7 @@ var (
var nvidiaLock sync.Mutex var nvidiaLock sync.Mutex
// update calls the nvidia tool, parses the output, and caches the results // updateNvidia calls the nvidia tool, parses the output, and caches the results
// in the various _* maps. The metric data parsed is: name, index, // in the various _* maps. The metric data parsed is: name, index,
// temperature.gpu, utilization.gpu, utilization.memory, memory.total, // temperature.gpu, utilization.gpu, utilization.memory, memory.total,
// memory.free, memory.used // memory.free, memory.used
@ -130,8 +130,8 @@ var nvidiaLock sync.Mutex
// error and returns immediately. We expect exec errors only when the tool // error and returns immediately. We expect exec errors only when the tool
// isn't available, or when it fails for some reason; no exec error cases // isn't available, or when it fails for some reason; no exec error cases
// are recoverable. This does **not** stop the cache job; that will continue // are recoverable. This does **not** stop the cache job; that will continue
// to run and continue to call update(). // to run and continue to call updateNvidia().
func update() { func updateNvidia() {
bs, err := exec.Command( bs, err := exec.Command(
"nvidia-smi", "nvidia-smi",
"--query-gpu=name,index,temperature.gpu,utilization.gpu,memory.total,memory.used", "--query-gpu=name,index,temperature.gpu,utilization.gpu,memory.total,memory.used",

17
docs/nvidia-extension.md Normal file
View File

@ -0,0 +1,17 @@
# gotop NVidia extension
Provides NVidia GPU data to gotop
To enable it, either run gotop with the `--nvidia` flag, or add the line `nvidia=true` to `gotop.config`.
## Dependencies
- [nvidia-smi](https://wiki.archlinux.org/index.php/NVIDIA/Tips_and_tricks#nvidia-smi)
## Configuration
The refresh rate of NVidia data is controlled by the `nvidia-refresh` parameter in the configuration file. This is a Go `time.Duration` format, for example `2s`, `500ms`, `1m`, etc.
## Alternatives to test
https://github.com/mindprince/gonvml