Skip to content

Commit

Permalink
Merge pull request #5 from traPtitech/fix-os-metrics
Browse files Browse the repository at this point in the history
ObjectStorageのメトリクス収集でpanicしていたのを修正
  • Loading branch information
hijiki51 authored Aug 6, 2022
2 parents 8652553 + 2399d79 commit 1d90b29
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bytes"
"encoding/json"
"errors"
"io/ioutil"
"log"
"net/http"
Expand Down Expand Up @@ -180,7 +181,19 @@ func (cc *ConohaClient) ObjectStorageRequests() (map[string]float64, error) {
}

// データ整形
data := uResp.Request.Data[len(uResp.Request.Data)-3]
if len(uResp.Request.Data) == 0 {
return nil, errors.New("No data")
}
data := uResp.Request.Data[0]
for i, label := range uResp.Request.Schema {
if label == "unixtime" {
for _, v := range uResp.Request.Data {
if data[i] < v[i] {
data = v
}
}
}
}
usage := make(map[string]float64)
for i, label := range uResp.Request.Schema {
usage[label] = data[i]
Expand Down

0 comments on commit 1d90b29

Please sign in to comment.