12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package main
- import (
- "encoding/json"
- "fmt"
- "os"
- "strings"
- smart "imuslab.com/bokofs/bokofsd/mod/middleware/SMART"
- )
- var dir string
- func main() {
-
- deviceFiles, err := os.ReadDir("/dev")
- if err != nil {
- panic(err)
- }
- for _, deviceFile := range deviceFiles {
- if deviceFile.IsDir() {
- continue
- }
- if strings.HasPrefix(deviceFile.Name(), "sd") || strings.HasPrefix(deviceFile.Name(), "nvme") {
- fullPath := "/dev/" + deviceFile.Name()
- fmt.Println(fullPath)
-
- smartdata, err := smart.GetSMARTData(fullPath)
- if err != nil {
- fmt.Println(err)
- }
- js, _ := json.MarshalIndent(smartdata, "", " ")
- fmt.Println(string(js))
- }
- }
-
- }
|