2023-04-05 10:47:40 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2024-06-24 14:12:26 +00:00
|
|
|
local_metrics "git.frostfs.info/TrueCloudLab/frostfs-node/internal/metrics"
|
2023-05-31 09:25:32 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
2023-04-05 10:47:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
node = flag.String("node", "", "File to export storage node metrics to.")
|
|
|
|
ir = flag.String("ir", "", "File to export innerring node metrics to.")
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if *node != "" && *ir != "" {
|
|
|
|
fmt.Println("-node and -ir flags are mutually exclusive")
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
var filename string
|
|
|
|
switch {
|
|
|
|
case *node != "":
|
2023-05-31 09:25:32 +00:00
|
|
|
_ = local_metrics.NewNodeMetrics()
|
2023-04-05 10:47:40 +00:00
|
|
|
filename = *node
|
|
|
|
case *ir != "":
|
2023-05-31 09:25:32 +00:00
|
|
|
_ = local_metrics.NewInnerRingMetrics()
|
2023-04-05 10:47:40 +00:00
|
|
|
filename = *ir
|
|
|
|
|
|
|
|
default:
|
|
|
|
flag.Usage()
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2023-05-31 09:25:32 +00:00
|
|
|
ds := metrics.DescribeAll()
|
2023-04-05 10:47:40 +00:00
|
|
|
|
|
|
|
data, err := json.Marshal(ds)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "Could not parse marshal: %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2023-10-31 11:56:55 +00:00
|
|
|
if err := os.WriteFile(filename, data, 0o644); err != nil {
|
2023-04-05 10:47:40 +00:00
|
|
|
fmt.Fprintf(os.Stderr, "Could write to file: %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|