123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package main
- import (
- "encoding/json"
- "fmt"
- "os"
- 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 deviceFile.Name()[:2] == "sd" || deviceFile.Name()[:4] == "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))
- }
- }
-
- }
|