|
@@ -1,9 +1,42 @@
|
|
|
package main
|
|
|
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "os"
|
|
|
+
|
|
|
+ smart "imuslab.com/bokofs/bokofsd/mod/middleware/SMART"
|
|
|
+)
|
|
|
+
|
|
|
var dir string
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
+ //Get all the devices under /dev that is either sd or nvme
|
|
|
+ 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)
|
|
|
+
|
|
|
+ //Get the SMART data printout in json
|
|
|
+ smartdata, err := smart.GetSMARTData(fullPath)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ js, _ := json.MarshalIndent(smartdata, "", " ")
|
|
|
+ fmt.Println(string(js))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
dirFlag := flag.String("d", "./", "Directory to serve from. Default is CWD")
|
|
|
httpPort := flag.Int("p", 80, "Port to serve on (Plain HTTP)")
|