1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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
- }
- fullPath := "/dev/" + deviceFile.Name()
- if !smart.IsRootDisk(fullPath) {
- continue
- }
- if !smart.IsDiskSupportedType(fullPath) {
- fmt.Println("Unsupported disk type")
- continue
- }
- 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)")
- httpsPort := flag.Int("ps", 443, "Port to serve TLS on")
- serveSecure := flag.Bool("s", false, "Serve HTTPS. Default false")
- flag.Parse()
- dir = *dirFlag
- */
- }
|