File tree Expand file tree Collapse file tree 3 files changed +75
-3
lines changed Expand file tree Collapse file tree 3 files changed +75
-3
lines changed Original file line number Diff line number Diff line change @@ -96,10 +96,10 @@ func (p Proc) NewStatus() (ProcStatus, error) {
9696 kv := strings .SplitN (line , ":" , 2 )
9797
9898 // removes spaces
99- k := string ( strings .TrimSpace (kv [0 ]) )
100- v := string ( strings .TrimSpace (kv [1 ]) )
99+ k := strings .TrimSpace (kv [0 ])
100+ v := strings .TrimSpace (kv [1 ])
101101 // removes "kB"
102- v = string ( bytes . Trim ([] byte ( v ) , " kB" ) )
102+ v = strings . TrimSuffix ( v , " kB" )
103103
104104 // value to int when possible
105105 // we can skip error check here, 'cause vKBytes is not used when value is a string
Original file line number Diff line number Diff line change @@ -76,6 +76,20 @@ func TestProcStatusName(t *testing.T) {
7676 }
7777}
7878
79+ func TestProcStatusNameTrim (t * testing.T ) {
80+ p , err := getProcFixtures (t ).Proc (26235 )
81+ if err != nil {
82+ t .Fatal (err )
83+ }
84+ s , err := p .NewStatus ()
85+ if err != nil {
86+ t .Fatal (err )
87+ }
88+ if want , have := "kube-proxy" , s .Name ; want != have {
89+ t .Errorf ("want name %s, have %s" , want , have )
90+ }
91+ }
92+
7993func TestProcStatusUIDs (t * testing.T ) {
8094 p , err := getProcFixtures (t ).Proc (26231 )
8195 if err != nil {
Original file line number Diff line number Diff line change @@ -748,6 +748,64 @@ Lines: 4
74874840000000-40015000 r-xp 00000000 03:01 61874 /lib/ld-2.3.2.so
749749Mode: 644
750750# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
751+ Directory: fixtures/proc/26235
752+ Mode: 755
753+ # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
754+ Path: fixtures/proc/26235/status
755+ Lines: 51
756+ Name: kube-proxy
757+ Umask: 0022
758+ State: S (sleeping)
759+ Tgid: 26235
760+ Ngid: 12345
761+ Pid: 26235
762+ PPid: 1234
763+ TracerPid: 0
764+ Uid: 0 0 0 0
765+ Gid: 0 0 0 0
766+ FDSize: 64
767+ Groups:
768+ NStgid: 26235 1
769+ NSpid: 26235 1
770+ NSpgid: 26235 1
771+ NSsid: 26235 1
772+ VmPeak: 758200 kB
773+ VmSize: 758200 kB
774+ VmLck: 0 kB
775+ VmPin: 0 kB
776+ VmHWM: 61776 kB
777+ VmRSS: 42652 kB
778+ RssAnon: 24852 kB
779+ RssFile: 17800 kB
780+ RssShmem: 0 kB
781+ VmData: 117136 kB
782+ VmStk: 132 kB
783+ VmExe: 21568 kB
784+ VmLib: 4 kB
785+ VmPTE: 264 kB
786+ VmSwap: 0 kB
787+ HugetlbPages: 0 kB
788+ Threads: 51
789+ SigQ: 9/511324
790+ SigPnd: 0000000000000000
791+ ShdPnd: 0000000000000000
792+ SigBlk: 0000000000000000
793+ SigIgn: 0000000000000000
794+ SigCgt: fffffffc7fc1feff
795+ CapInh: 0000003fffffffff
796+ CapPrm: 0000003fffffffff
797+ CapEff: 0000003fffffffff
798+ CapBnd: 0000003fffffffff
799+ CapAmb: 0000000000000000
800+ Seccomp: 0
801+ Cpus_allowed: ff
802+ Cpus_allowed_list: 0-7
803+ Mems_allowed: 00000000,00000001
804+ Mems_allowed_list: 0
805+ voluntary_ctxt_switches: 4742839
806+ nonvoluntary_ctxt_switches: 1727500
807+ Mode: 644
808+ # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
751809Directory: fixtures/proc/584
752810Mode: 755
753811# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You can’t perform that action at this time.
0 commit comments