Skip to content

Commit fbae474

Browse files
committed
Add qstat -f and fix qhost
1 parent bb04853 commit fbae474

File tree

8 files changed

+461
-18
lines changed

8 files changed

+461
-18
lines changed

pkg/qhost/v9.0/parsers.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ func ParseHostFullMetrics(out string) ([]HostFullMetrics, error) {
148148
for i := 0; i < len(lines); i++ {
149149
line := strings.TrimSpace(lines[i])
150150
if line == "" || strings.HasPrefix(line, "HOSTNAME") ||
151-
strings.HasPrefix(line, "global") ||
152151
strings.HasPrefix(line, "----") {
153152
continue
154153
}

pkg/qhost/v9.0/parsers_test.go

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,73 @@ sim9 lx-amd64 4 1 4 4 0.60 15.6G 465.8M
404404
hl:np_load_long=0.110000
405405
hf:load_report_host=master`
406406

407+
qhostFOutput2 := `HOSTNAME ARCH NCPU NSOC NCOR NTHR LOAD MEMTOT MEMUSE SWAPTO SWAPUS
408+
----------------------------------------------------------------------------------------------
409+
global - - - - - - - - - -
410+
gc:testc=100000.000000
411+
master lx-amd64 14 1 14 14 1.50 7.7G 2.0G 1024.0M 12.0K
412+
gc:testc=100000.000000
413+
hl:load_avg=1.500000
414+
hl:load_short=1.670000
415+
hl:load_medium=1.500000
416+
hl:load_long=1.100000
417+
hl:arch=lx-amd64
418+
hl:num_proc=14.000000
419+
hl:mem_free=5.621G
420+
hl:swap_free=1023.984M
421+
hl:virtual_free=6.621G
422+
hl:mem_total=7.653G
423+
hl:swap_total=1023.996M
424+
hl:virtual_total=8.653G
425+
hl:mem_used=2.032G
426+
hl:swap_used=12.000K
427+
hl:virtual_used=2.032G
428+
hl:cpu=0.500000
429+
hl:m_topology=SCCCCCCCCCCCCCC
430+
hl:m_topology_inuse=SCCCCCCCCCCCCCC
431+
hl:m_socket=1.000000
432+
hl:m_core=14.000000
433+
hl:m_thread=14.000000
434+
hl:np_load_avg=0.107143
435+
hl:np_load_short=0.119286
436+
hl:np_load_medium=0.107143
437+
hl:np_load_long=0.078571
438+
`
439+
407440
It("should return error if output is invalid", func() {
408441
hosts, err := qhost.ParseHostFullMetrics(sample)
409442
Expect(err).To(BeNil())
410-
Expect(hosts).To(HaveLen(2))
443+
Expect(hosts).To(HaveLen(3))
411444
})
412445

413446
It("should parse host full metrics", func() {
414447
hosts, err := qhost.ParseHostFullMetrics(qhostFOutput1)
415448
Expect(err).To(BeNil())
416-
Expect(hosts).To(HaveLen(13))
417-
Expect(hosts[0].Name).To(Equal("master"))
418-
Expect(hosts[12].Name).To(Equal("sim9"))
449+
Expect(hosts).To(HaveLen(14))
450+
Expect(hosts[0].Name).To(Equal("global"))
451+
Expect(hosts[1].Name).To(Equal("master"))
452+
Expect(hosts[12].Name).To(Equal("sim8"))
453+
})
454+
455+
It("should parse host full metrics with global host values", func() {
456+
hosts, err := qhost.ParseHostFullMetrics(qhostFOutput2)
457+
Expect(err).To(BeNil())
458+
Expect(hosts).To(HaveLen(2))
459+
Expect(hosts[0].Name).To(Equal("global"))
460+
Expect(hosts[1].Name).To(Equal("master"))
461+
Expect(len(hosts[0].Resources)).To(Equal(1))
462+
Expect(hosts[0].Resources["testc"]).To(Equal(
463+
qhost.ResourceAvailability{
464+
Name: "testc",
465+
StringValue: "100000.000000",
466+
FloatValue: 100000.000000,
467+
ResourceAvailabilityLimitedBy: "g",
468+
Source: "c",
469+
FullString: "gc:testc=100000.000000",
470+
},
471+
))
419472
})
473+
420474
})
421475

422476
})

0 commit comments

Comments
 (0)