Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowMoon-Dev committed Feb 26, 2022
0 parents commit 730aec4
Show file tree
Hide file tree
Showing 13 changed files with 2,229 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

dist/
30 changes: 30 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
project_name: lynxi-smi-pro
dist: ./bin
before:
hooks:
- go mod tidy
- go mod download
builds:
- env:
- CGO_ENABLED=0
id: lynxi-smi-pro
main: ./cmd/lynxi-smi-pro/
binary: lynxi-smi-pro
goos:
- linux
- darwin
archives:
- replacements:
darwin: Darwin
linux: Linux
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/lynxi_smi_pro.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# lynxi-smi-pro

Get informations about the system's APU(s), through lynxi-smi.

#Features
* Get the number of APUs
* Get the driver's version
* Get the number of KA200
* Get APU or hardware Detail info.

#Usage
```
usage: lynxi-smi-pro [<flags>]
Optional flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
-q, --query Display APU or hardware Detail info.
--query-apu=name,driver_version,power,...
Query Information about APU.
-L, --list-apus Display a list of APUs connected to the system.
--chip-count Displays the number of KA200.
--chip-list Displays a list of KA200.
--debug Display Debug Info
--help-query-apu Display Help Query Information about APU.
```
64 changes: 64 additions & 0 deletions cmd/lynxi-smi-pro/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package main

import (
log "github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
"lynxi_smi_pro/internal/exporter"
)

var (
query = kingpin.Flag("query", "Display APU or hardware Detail info.").Short('q').Bool()
board_id = kingpin.Flag("index", "Target a specific Board index.").Short('i').Default("-1").Hidden().Int()
chip_id = kingpin.Flag("chip_id", "Target a specific Chip ID.").Short('c').Default("-1").Hidden().Int()
//type_info = kingpin.Flag("type", "Show information for type: board,memory, usages,temp, power, volt, ecc-enable, health, product, ecc.").Short('t').PlaceHolder("board").String()
query_apu = kingpin.Flag("query-apu", "Query Information about APU.").PlaceHolder("name,driver_version,power,...").String()
list_apus = kingpin.Flag("list-apus", "Display a list of APUs connected to the system.").Short('L').Bool()
chip_count = kingpin.Flag("chip-count", "Displays the number of KA200.").Bool()
chip_list = kingpin.Flag("chip-list", "Displays a list of KA200.").Bool()
debug = kingpin.Flag("debug", "Display Debug Info").Bool()
help_query_apu = kingpin.Flag("help-query-apu", "Display Help Query Information about APU.").Bool()
)

func main() {
log.SetReportCaller(true)
log.SetFormatter(&log.JSONFormatter{
PrettyPrint: true,
})
kingpin.HelpFlag.Short('h')
kingpin.UsageTemplate(kingpin.SeparateOptionalFlagsUsageTemplate)
kingpin.Parse()
if *debug {
log.SetLevel(log.DebugLevel)
}
switch {
case *query:
switch {
case *board_id >= 0 && *chip_id >= 0:
exporter.QueryLynSmiDetailInfoByChipIDAndBoardId(board_id, chip_id)
case *board_id >= 0:
exporter.QueryLynSmiDetailInfoByBoardId(board_id)
case *chip_id >= 0:
kingpin.Errorf("board id is requested")
default:
exporter.QueryLynSmiDetailInfo()
}
case *list_apus:
exporter.ListAPUs()
case len(*query_apu) > 0:
switch {
case len(*query_apu) < 0:
kingpin.Usage()
}
exporter.QueryLynAPUsInfo(*query_apu)
case *chip_count:
exporter.QueryLynChipTotalNum()
case *chip_list:
exporter.QueryLynChipList()
case *help_query_apu:
exporter.QueryAPUHelpInfo()
case *board_id >= 0 || *chip_id >= 0:
kingpin.Usage()
default:
exporter.QueryLynSmiInfo()
}
}
14 changes: 14 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module lynxi_smi_pro

go 1.17

require (
github.com/sirupsen/logrus v1.8.1
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)

require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
)
22 changes: 22 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Loading

0 comments on commit 730aec4

Please sign in to comment.