Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2afc2c2
feat(inputs.slurm): Add a SLURM input plugin
pcolladosoto Aug 1, 2024
1f29115
feat(inputs.slurm): Fix linter errors
pcolladosoto Aug 2, 2024
5581231
feat(inputs.slurm): Condense boolean into slice
pcolladosoto Aug 2, 2024
28a343a
feat(inputs.slurm): Fix remaining linter issues
pcolladosoto Aug 2, 2024
d2616c8
feat(inputs.slurm): Add link to LICENSE
pcolladosoto Aug 2, 2024
ed130f4
feat(inputs.slurm): Add URL as a tag
pcolladosoto Aug 2, 2024
37ed8d8
feat(inputs.slurm): Add trailing newline
pcolladosoto Aug 2, 2024
41b445d
feat(inputs.slurm): Remove domain and trim records
pcolladosoto Aug 5, 2024
9fca629
feat(inputs.slurm): Dereference records
pcolladosoto Aug 5, 2024
e5062f7
feat(inputs.slurm): Add Gather tests
pcolladosoto Aug 5, 2024
d830f24
feat(inputs.slurm): Add `panic()` recovery
pcolladosoto Aug 5, 2024
c67a94a
feat(inputs.slurm): Add explicitl `nil` checks
pcolladosoto Aug 6, 2024
4e43799
feat(inputs.slurm): Fix linter errors
pcolladosoto Aug 6, 2024
f05e2a2
feat(inputs.slurm): Fix linter issues
pcolladosoto Aug 6, 2024
ac2b45f
feat(inputs.slurm): Fix linter issue
pcolladosoto Aug 6, 2024
c38bb21
feat(inputs.slurm): Rename url to source
pcolladosoto Aug 6, 2024
427252e
feat(inputs.slurm): Use internal User-Agent
pcolladosoto Aug 6, 2024
64a51dd
feat(inputs.slurm): Rework client creation logic
pcolladosoto Aug 7, 2024
8a481c8
feat(inputs.slurm): Fix error handling in Gather()
pcolladosoto Aug 7, 2024
13b5da3
feat(inputs.slurm): Unexport internal gather funcs
pcolladosoto Aug 7, 2024
b35381f
feat(inputs.slurm): Fix default timeout condition
pcolladosoto Aug 7, 2024
d0486e2
feat(inputs.slurm): New metric gathering
pcolladosoto Aug 7, 2024
4797e2f
feat(inputs.slurm): New metric gathering
pcolladosoto Aug 7, 2024
9b6f764
feat(inputs.slurm): Enhance URL tests
pcolladosoto Aug 7, 2024
8fc95de
feat(inputs.slurm): Tweak error checking
pcolladosoto Aug 7, 2024
4feb62f
feat(inputs.slurm): Parse TRES fields
pcolladosoto Aug 7, 2024
9a5def7
feat(inputs.slurm): Fix linter issues
pcolladosoto Aug 7, 2024
bc8c1b1
feat(inputs.slurm): Enhance empty hostname error
pcolladosoto Aug 7, 2024
63ca276
feat(inputs.slurm): Bump goslurm version up
pcolladosoto Aug 7, 2024
2da1947
feat(inputs.slurm): Automatically add TLS options
pcolladosoto Aug 8, 2024
cfeb486
feat(inputs.slurm): Remove lingering conf
pcolladosoto Aug 8, 2024
b90417b
feat(inputs.slurm): Warn about TLS when using HTTP
pcolladosoto Aug 8, 2024
4739307
feat(inputs.slurm): Fix var scopes
pcolladosoto Aug 8, 2024
ab4d126
feat(inputs.slurm): Close response bodies ASAP
pcolladosoto Aug 8, 2024
493779f
feat(inputs.slurm): Func prototype on a single line
pcolladosoto Aug 8, 2024
8d4190b
feat(inputs.slurm): Re-add conf (whoops)
pcolladosoto Aug 8, 2024
d584d90
feat(inputs.slurm): Fix linter issues
pcolladosoto Aug 8, 2024
6096a88
feat(inputs.slurm): Func prototype on a single line
pcolladosoto Aug 8, 2024
d477095
feat(inputs.slurm): Fix timeout configuration
pcolladosoto Aug 9, 2024
a5c910f
feat(inputs.slurm): Leverage t.Run() w/ tweaks
pcolladosoto Aug 9, 2024
f943d9d
feat(inputs.slurm): Switch to enabled inputs logic
pcolladosoto Aug 9, 2024
34d2a7b
Apply suggestions from code review
pcolladosoto Aug 9, 2024
24e01e4
feat(inputs.slurm): Rework testing structure
pcolladosoto Aug 12, 2024
ab5b932
feat(inputs.slurm): Just parse float64 on TRES
pcolladosoto Aug 12, 2024
3378da5
Check enabled endpoints to catch typos
pcolladosoto Aug 14, 2024
ed20b4d
feat(inputs.slurm): Fix endpoint checks
pcolladosoto Aug 14, 2024
dacf8cb
feat(inputs.slurm): Less allocations & scope fix
pcolladosoto Aug 14, 2024
8cbbde4
Update plugins/inputs/slurm/slurm.go
srebhan Aug 14, 2024
3b5a534
feat(inputs.slurm): Add support for the P suffix
pcolladosoto Aug 14, 2024
96e6a42
feat(inputs.slurm): Preallocate tags and records
pcolladosoto Aug 14, 2024
e734140
feat(inputs.slurm): Update endpoints comment
pcolladosoto Aug 14, 2024
8d7316f
Merge branch 'master' of pcolladosoto/telegraf
pcolladosoto Aug 14, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(inputs.slurm): Fix linter errors
We just tackled a single occurrence of the `bodyclose` error to try
and see if we can fix it like we did... Judging by the implementation
of the `Execute()` method the actual body of the request should be
closed, but maybe the linter is not seeing it clearly...
  • Loading branch information
pcolladosoto authored and powersj committed Aug 7, 2024
commit 1f29115c748abf1158604531237d50f977419fb9
65 changes: 34 additions & 31 deletions plugins/inputs/slurm/slurm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ package slurm
import (
"context"
_ "embed"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -81,7 +83,7 @@ func (s *Slurm) Init() error {
}

if s.URL == "" {
return fmt.Errorf("empty URL provided")
return errors.New("empty URL provided")
}

u, err := url.Parse(s.URL)
Expand Down Expand Up @@ -137,37 +139,37 @@ func (s *Slurm) GatherDiagMetrics(acc telegraf.Accumulator,

func (s *Slurm) GatherJobsMetrics(acc telegraf.Accumulator,
jobs []goslurm.V0038JobResponseProperties) {
for _, job := range jobs {
for i := range jobs {
records := make(map[string]interface{})
tags := make(map[string]string)

tags["name"] = *job.Name
tags["job_id"] = fmt.Sprintf("%d", *job.JobId)

records["state"] = job.JobState
records["state_reason"] = job.StateReason
records["partition"] = job.Partition
records["nodes"] = job.Nodes
records["node_count"] = job.NodeCount
records["priority"] = job.Priority
records["nice"] = *job.Nice
records["group_id"] = job.GroupId
records["command"] = job.Command
tags["name"] = *jobs[i].Name
tags["job_id"] = strconv.Itoa(int(*jobs[i].JobId))

records["state"] = jobs[i].JobState
records["state_reason"] = jobs[i].StateReason
records["partition"] = jobs[i].Partition
records["nodes"] = jobs[i].Nodes
records["node_count"] = jobs[i].NodeCount
records["priority"] = jobs[i].Priority
records["nice"] = *jobs[i].Nice
records["group_id"] = jobs[i].GroupId
records["command"] = jobs[i].Command
records["standard_output"] = strings.ReplaceAll(
*job.StandardOutput, "\\", "")
*jobs[i].StandardOutput, "\\", "")
records["standard_error"] = strings.ReplaceAll(
*job.StandardError, "\\", "")
*jobs[i].StandardError, "\\", "")
records["standard_input"] = strings.ReplaceAll(
*job.StandardInput, "\\", "")
*jobs[i].StandardInput, "\\", "")
records["current_working_directory"] = strings.ReplaceAll(
*job.CurrentWorkingDirectory, "\\", "")
records["submit_time"] = job.SubmitTime
records["start_time"] = job.StartTime
records["cpus"] = job.Cpus
records["cpus_per_task"] = job.CpusPerTask
records["tasks"] = job.Tasks
records["time_limit"] = job.TimeLimit
records["tres_req_str"] = job.TresReqStr
*jobs[i].CurrentWorkingDirectory, "\\", "")
records["submit_time"] = jobs[i].SubmitTime
records["start_time"] = jobs[i].StartTime
records["cpus"] = jobs[i].Cpus
records["cpus_per_task"] = jobs[i].CpusPerTask
records["tasks"] = jobs[i].Tasks
records["time_limit"] = jobs[i].TimeLimit
records["tres_req_str"] = jobs[i].TresReqStr

acc.AddFields("slurm_jobs", records, tags)
}
Expand Down Expand Up @@ -258,7 +260,7 @@ func (s *Slurm) Gather(acc telegraf.Accumulator) error {
}
diag, ok := diagResp.GetStatisticsOk()
if !ok {
return fmt.Errorf("error getting diag: %v", err)
return fmt.Errorf("error getting diag: %w", err)
}
s.GatherDiagMetrics(acc, diag)
}
Expand All @@ -270,7 +272,7 @@ func (s *Slurm) Gather(acc telegraf.Accumulator) error {
}
jobs, ok := jobsResp.GetJobsOk()
if !ok {
return fmt.Errorf("error getting jobs: %v", err)
return fmt.Errorf("error getting jobs: %w", err)
}
s.GatherJobsMetrics(acc, jobs)
}
Expand All @@ -282,7 +284,7 @@ func (s *Slurm) Gather(acc telegraf.Accumulator) error {
}
nodes, ok := nodesResp.GetNodesOk()
if !ok {
return fmt.Errorf("error getting nodes: %v", err)
return fmt.Errorf("error getting nodes: %w", err)
}
s.GatherNodesMetrics(acc, nodes)
}
Expand All @@ -295,20 +297,21 @@ func (s *Slurm) Gather(acc telegraf.Accumulator) error {
}
partitions, ok := partitionsResp.GetPartitionsOk()
if !ok {
return fmt.Errorf("error getting partitions: %v", err)
return fmt.Errorf("error getting partitions: %w", err)
}
s.GatherPartitionsMetrics(acc, partitions)
}

if !s.IgnoreReservations {
reservationsResp, _, err := s.client.SlurmAPI.SlurmV0038GetReservations(
reservationsResp, reservationsRespRaw, err := s.client.SlurmAPI.SlurmV0038GetReservations(
auth).Execute()
if err != nil {
return err
}
defer reservationsRespRaw.Body.Close()
reservations, ok := reservationsResp.GetReservationsOk()
if !ok {
return fmt.Errorf("error getting reservations: %v", err)
return fmt.Errorf("error getting reservations: %w", err)
}
s.GatherReservationsMetrics(acc, reservations)
}
Expand Down