Skip to content

Commit

Permalink
At #57 Remove Unnecessary Conditional Code in the IPMI Parse Function
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-jinhyeong committed Oct 10, 2023
1 parent 23a3a02 commit ce11da9
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions plugins/inputs/ipmi_sensor/ipmi_sensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,17 @@ func (m *Ipmi) parse(acc telegraf.Accumulator, server string) error {

if server != "" {
server := trimAll(server)
startIndex := strings.LastIndex(server, "),{")
connInfo := regexp.MustCompile(`(.*\)),(\{.*\})`).FindStringSubmatch(server)
serverConn := server
if startIndex >= 0 && len(connInfo) > 2 {

if len(connInfo) > 2 {
serverConn = connInfo[1]
jsonBytes := []byte(strings.ReplaceAll(connInfo[2], "'", "\""))

err := json.Unmarshal(jsonBytes, &customTags)
if err != nil {
fmt.Println(err)
return fmt.Errorf("Error unmarshaling %s ", err)
}

}

conn := NewConnection(serverConn, m.Privilege, m.HexKey)
Expand Down

0 comments on commit ce11da9

Please sign in to comment.