1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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
- }
- fullPath := "/dev/" + deviceFile.Name()
- if !smart.IsRootDisk(fullPath) {
- continue
- }
- if !smart.IsDiskSupportedType(fullPath) {
- fmt.Println("Unsupported disk type")
- continue
- }
- fmt.Println(fullPath)
-
- smartdata, err := smart.GetSMARTData(fullPath)
- if err != nil {
- fmt.Println(err)
- }
- js, _ := json.MarshalIndent(smartdata, "", " ")
- fmt.Println(string(js))
- }
-
- }
|