sigar_linux_test.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. package gosigar_test
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "math/rand"
  6. "os"
  7. "path/filepath"
  8. "strconv"
  9. "testing"
  10. "time"
  11. sigar "notabug.org/themusicgod1/gosigar"
  12. "github.com/stretchr/testify/assert"
  13. )
  14. var procd string
  15. func setUp(t testing.TB) {
  16. var err error
  17. procd, err = ioutil.TempDir("", "sigarTests")
  18. if err != nil {
  19. t.Fatal(err)
  20. }
  21. sigar.Procd = procd
  22. }
  23. func tearDown(t testing.TB) {
  24. sigar.Procd = "/proc"
  25. err := os.RemoveAll(procd)
  26. if err != nil {
  27. t.Fatal(err)
  28. }
  29. }
  30. func TestLinuxProcState(t *testing.T) {
  31. setUp(t)
  32. defer tearDown(t)
  33. var procNames = []string{
  34. "cron",
  35. "a very long process name",
  36. "(sd-pam)",
  37. "]",
  38. "(",
  39. }
  40. for _, n := range procNames {
  41. func() {
  42. pid := rand.Int()
  43. pidDir := filepath.Join(procd, strconv.Itoa(pid))
  44. err := os.Mkdir(pidDir, 0755)
  45. if err != nil {
  46. t.Fatal(err)
  47. }
  48. defer os.RemoveAll(pidDir)
  49. pidStatFile := filepath.Join(pidDir, "stat")
  50. writePidStats(pid, n, pidStatFile)
  51. if err != nil {
  52. t.Fatal(err)
  53. }
  54. pidStatusFile := filepath.Join(pidDir, "status")
  55. uid := 123456789
  56. writePidStatus(n, pid, uid, pidStatusFile)
  57. if err != nil {
  58. t.Fatal(err)
  59. }
  60. state := sigar.ProcState{}
  61. if assert.NoError(t, state.Get(pid)) {
  62. expected := sigar.ProcState{
  63. Name: n,
  64. Username: strconv.Itoa(uid),
  65. State: 'S',
  66. Ppid: 1,
  67. Pgid: 2,
  68. Tty: 4,
  69. Priority: 15,
  70. Nice: 16,
  71. Processor: 36,
  72. }
  73. assert.Equal(t, expected, state)
  74. }
  75. }()
  76. }
  77. }
  78. func TestLinuxCPU(t *testing.T) {
  79. setUp(t)
  80. defer tearDown(t)
  81. tests := []struct {
  82. stat string
  83. user uint64
  84. }{
  85. {"cpu 25 1 2 3 4 5 6 7", 25},
  86. // Ignore empty lines
  87. {"cpu ", 0},
  88. }
  89. statFile := procd + "/stat"
  90. for _, test := range tests {
  91. func() {
  92. statContents := []byte(test.stat)
  93. err := ioutil.WriteFile(statFile, statContents, 0644)
  94. if err != nil {
  95. t.Fatal(err)
  96. }
  97. defer os.RemoveAll(statFile)
  98. cpu := sigar.Cpu{}
  99. if assert.NoError(t, cpu.Get()) {
  100. assert.Equal(t, uint64(test.user), cpu.User, "cpu.User")
  101. }
  102. }()
  103. }
  104. }
  105. func TestLinuxCollectCpuStats(t *testing.T) {
  106. setUp(t)
  107. defer tearDown(t)
  108. statFile := procd + "/stat"
  109. statContents := []byte("cpu 25 1 2 3 4 5 6 7")
  110. err := ioutil.WriteFile(statFile, statContents, 0644)
  111. if err != nil {
  112. t.Fatal(err)
  113. }
  114. concreteSigar := &sigar.ConcreteSigar{}
  115. cpuUsages, stop := concreteSigar.CollectCpuStats(500 * time.Millisecond)
  116. assert.Equal(t, sigar.Cpu{
  117. User: uint64(25),
  118. Nice: uint64(1),
  119. Sys: uint64(2),
  120. Idle: uint64(3),
  121. Wait: uint64(4),
  122. Irq: uint64(5),
  123. SoftIrq: uint64(6),
  124. Stolen: uint64(7),
  125. }, <-cpuUsages)
  126. statContents = []byte("cpu 30 3 7 10 25 55 36 65")
  127. err = ioutil.WriteFile(statFile, statContents, 0644)
  128. if err != nil {
  129. t.Fatal(err)
  130. }
  131. assert.Equal(t, sigar.Cpu{
  132. User: uint64(5),
  133. Nice: uint64(2),
  134. Sys: uint64(5),
  135. Idle: uint64(7),
  136. Wait: uint64(21),
  137. Irq: uint64(50),
  138. SoftIrq: uint64(30),
  139. Stolen: uint64(58),
  140. }, <-cpuUsages)
  141. stop <- struct{}{}
  142. }
  143. func TestLinuxMemAndSwap(t *testing.T) {
  144. setUp(t)
  145. defer tearDown(t)
  146. meminfoContents := `
  147. MemTotal: 374256 kB
  148. MemFree: 274460 kB
  149. Buffers: 9764 kB
  150. Cached: 38648 kB
  151. SwapCached: 0 kB
  152. Active: 33772 kB
  153. Inactive: 31184 kB
  154. Active(anon): 16572 kB
  155. Inactive(anon): 552 kB
  156. Active(file): 17200 kB
  157. Inactive(file): 30632 kB
  158. Unevictable: 0 kB
  159. Mlocked: 0 kB
  160. SwapTotal: 786428 kB
  161. SwapFree: 786428 kB
  162. Dirty: 0 kB
  163. Writeback: 0 kB
  164. AnonPages: 16564 kB
  165. Mapped: 6612 kB
  166. Shmem: 584 kB
  167. Slab: 19092 kB
  168. SReclaimable: 9128 kB
  169. SUnreclaim: 9964 kB
  170. KernelStack: 672 kB
  171. PageTables: 1864 kB
  172. NFS_Unstable: 0 kB
  173. Bounce: 0 kB
  174. WritebackTmp: 0 kB
  175. CommitLimit: 973556 kB
  176. Committed_AS: 55880 kB
  177. VmallocTotal: 34359738367 kB
  178. VmallocUsed: 21428 kB
  179. VmallocChunk: 34359713596 kB
  180. HardwareCorrupted: 0 kB
  181. AnonHugePages: 0 kB
  182. HugePages_Total: 0
  183. HugePages_Free: 0
  184. HugePages_Rsvd: 0
  185. HugePages_Surp: 0
  186. Hugepagesize: 2048 kB
  187. DirectMap4k: 59328 kB
  188. DirectMap2M: 333824 kB
  189. `
  190. meminfoFile := procd + "/meminfo"
  191. err := ioutil.WriteFile(meminfoFile, []byte(meminfoContents), 0444)
  192. if err != nil {
  193. t.Fatal(err)
  194. }
  195. mem := sigar.Mem{}
  196. if assert.NoError(t, mem.Get()) {
  197. assert.Equal(t, uint64(374256*1024), mem.Total)
  198. assert.Equal(t, uint64(274460*1024), mem.Free)
  199. assert.Equal(t, uint64(mem.Total-mem.Free), mem.Used)
  200. assert.Equal(t, uint64((274460+9764+38648)*1024), mem.ActualFree)
  201. assert.Equal(t, uint64(mem.Total-mem.ActualFree), mem.ActualUsed)
  202. }
  203. swap := sigar.Swap{}
  204. if assert.NoError(t, swap.Get()) {
  205. assert.Equal(t, uint64(786428*1024), swap.Total)
  206. assert.Equal(t, uint64(786428*1024), swap.Free)
  207. }
  208. }
  209. func TestLinuxMemAndSwapKernel_3_14(t *testing.T) {
  210. setUp(t)
  211. defer tearDown(t)
  212. meminfoContents := `
  213. MemTotal: 500184 kB
  214. MemFree: 31360 kB
  215. MemAvailable: 414168 kB
  216. Buffers: 28740 kB
  217. Cached: 325408 kB
  218. SwapCached: 264 kB
  219. Active: 195476 kB
  220. Inactive: 198612 kB
  221. Active(anon): 14920 kB
  222. Inactive(anon): 27268 kB
  223. Active(file): 180556 kB
  224. Inactive(file): 171344 kB
  225. Unevictable: 0 kB
  226. Mlocked: 0 kB
  227. SwapTotal: 524284 kB
  228. SwapFree: 520352 kB
  229. Dirty: 0 kB
  230. Writeback: 0 kB
  231. AnonPages: 39772 kB
  232. Mapped: 24132 kB
  233. Shmem: 2236 kB
  234. Slab: 57988 kB
  235. SReclaimable: 43524 kB
  236. SUnreclaim: 14464 kB
  237. KernelStack: 2464 kB
  238. PageTables: 3096 kB
  239. NFS_Unstable: 0 kB
  240. Bounce: 0 kB
  241. WritebackTmp: 0 kB
  242. CommitLimit: 774376 kB
  243. Committed_AS: 490916 kB
  244. VmallocTotal: 34359738367 kB
  245. VmallocUsed: 0 kB
  246. VmallocChunk: 0 kB
  247. HardwareCorrupted: 0 kB
  248. AnonHugePages: 0 kB
  249. CmaTotal: 0 kB
  250. CmaFree: 0 kB
  251. HugePages_Total: 0
  252. HugePages_Free: 0
  253. HugePages_Rsvd: 0
  254. HugePages_Surp: 0
  255. Hugepagesize: 2048 kB
  256. DirectMap4k: 63424 kB
  257. DirectMap2M: 460800 kB
  258. `
  259. meminfoFile := procd + "/meminfo"
  260. err := ioutil.WriteFile(meminfoFile, []byte(meminfoContents), 0444)
  261. if err != nil {
  262. t.Fatal(err)
  263. }
  264. mem := sigar.Mem{}
  265. if assert.NoError(t, mem.Get()) {
  266. assert.Equal(t, uint64(500184*1024), mem.Total)
  267. assert.Equal(t, uint64(31360*1024), mem.Free)
  268. assert.Equal(t, uint64(414168*1024), mem.ActualFree)
  269. assert.Equal(t, uint64(mem.Total-mem.Free), mem.Used)
  270. assert.Equal(t, uint64(mem.Total-mem.ActualFree), mem.ActualUsed)
  271. }
  272. swap := sigar.Swap{}
  273. if assert.NoError(t, swap.Get()) {
  274. assert.Equal(t, uint64(524284*1024), swap.Total)
  275. assert.Equal(t, uint64(520352*1024), swap.Free)
  276. }
  277. }
  278. func TestLinuxMemAndSwapMissingMemTotal(t *testing.T) {
  279. setUp(t)
  280. defer tearDown(t)
  281. meminfoContents := `
  282. MemFree: 31360 kB
  283. MemAvailable: 414168 kB
  284. Buffers: 28740 kB
  285. Cached: 325408 kB
  286. SwapCached: 264 kB
  287. Active: 195476 kB
  288. Inactive: 198612 kB
  289. Active(anon): 14920 kB
  290. Inactive(anon): 27268 kB
  291. Active(file): 180556 kB
  292. Inactive(file): 171344 kB
  293. Unevictable: 0 kB
  294. Mlocked: 0 kB
  295. SwapTotal: 524284 kB
  296. SwapFree: 520352 kB
  297. Dirty: 0 kB
  298. Writeback: 0 kB
  299. AnonPages: 39772 kB
  300. Mapped: 24132 kB
  301. Shmem: 2236 kB
  302. Slab: 57988 kB
  303. SReclaimable: 43524 kB
  304. SUnreclaim: 14464 kB
  305. KernelStack: 2464 kB
  306. PageTables: 3096 kB
  307. NFS_Unstable: 0 kB
  308. Bounce: 0 kB
  309. WritebackTmp: 0 kB
  310. CommitLimit: 774376 kB
  311. Committed_AS: 490916 kB
  312. VmallocTotal: 34359738367 kB
  313. VmallocUsed: 0 kB
  314. VmallocChunk: 0 kB
  315. HardwareCorrupted: 0 kB
  316. AnonHugePages: 0 kB
  317. CmaTotal: 0 kB
  318. CmaFree: 0 kB
  319. HugePages_Total: 0
  320. HugePages_Free: 0
  321. HugePages_Rsvd: 0
  322. HugePages_Surp: 0
  323. Hugepagesize: 2048 kB
  324. DirectMap4k: 63424 kB
  325. DirectMap2M: 460800 kB
  326. `
  327. meminfoFile := procd + "/meminfo"
  328. err := ioutil.WriteFile(meminfoFile, []byte(meminfoContents), 0444)
  329. if err != nil {
  330. t.Fatal(err)
  331. }
  332. mem := sigar.Mem{}
  333. if assert.NoError(t, mem.Get()) {
  334. assert.Equal(t, uint64(0), mem.Total)
  335. assert.Equal(t, uint64(31360*1024), mem.Free)
  336. assert.Equal(t, uint64(414168*1024), mem.ActualFree)
  337. }
  338. swap := sigar.Swap{}
  339. if assert.NoError(t, swap.Get()) {
  340. assert.Equal(t, uint64(524284*1024), swap.Total)
  341. assert.Equal(t, uint64(520352*1024), swap.Free)
  342. }
  343. }
  344. func TestLinuxMemAndSwapKernel_3_14_memavailable_zero(t *testing.T) {
  345. setUp(t)
  346. defer tearDown(t)
  347. meminfoContents := `
  348. MemTotal: 148535680 kB
  349. MemFree: 417356 kB
  350. MemAvailable: 0 kB
  351. Buffers: 1728 kB
  352. Cached: 129928 kB
  353. SwapCached: 8208 kB
  354. Active: 141088676 kB
  355. Inactive: 5568132 kB
  356. Active(anon): 141076780 kB
  357. Inactive(anon): 5556936 kB
  358. Active(file): 11896 kB
  359. Inactive(file): 11196 kB
  360. Unevictable: 3648 kB
  361. Mlocked: 3648 kB
  362. SwapTotal: 4882428 kB
  363. SwapFree: 0 kB
  364. Dirty: 808 kB
  365. Writeback: 220 kB
  366. AnonPages: 146521272 kB
  367. Mapped: 41384 kB
  368. Shmem: 105864 kB
  369. Slab: 522648 kB
  370. SReclaimable: 233508 kB
  371. SUnreclaim: 289140 kB
  372. KernelStack: 85024 kB
  373. PageTables: 368760 kB
  374. NFS_Unstable: 0 kB
  375. Bounce: 0 kB
  376. WritebackTmp: 0 kB
  377. CommitLimit: 79150268 kB
  378. Committed_AS: 272491684 kB
  379. VmallocTotal: 34359738367 kB
  380. VmallocUsed: 0 kB
  381. VmallocChunk: 0 kB
  382. HardwareCorrupted: 0 kB
  383. AnonHugePages: 78061568 kB
  384. ShmemHugePages: 0 kB
  385. ShmemPmdMapped: 0 kB
  386. CmaTotal: 0 kB
  387. CmaFree: 0 kB
  388. HugePages_Total: 0
  389. HugePages_Free: 0
  390. HugePages_Rsvd: 0
  391. HugePages_Surp: 0
  392. Hugepagesize: 2048 kB
  393. DirectMap4k: 124388 kB
  394. DirectMap2M: 5105664 kB
  395. DirectMap1G: 147849216 kB
  396. `
  397. meminfoFile := procd + "/meminfo"
  398. err := ioutil.WriteFile(meminfoFile, []byte(meminfoContents), 0444)
  399. if err != nil {
  400. t.Fatal(err)
  401. }
  402. mem := sigar.Mem{}
  403. if assert.NoError(t, mem.Get()) {
  404. assert.Equal(t, uint64(148535680*1024), mem.Total)
  405. assert.Equal(t, uint64(417356*1024), mem.Free)
  406. assert.Equal(t, uint64(0), mem.ActualFree)
  407. }
  408. swap := sigar.Swap{}
  409. if assert.NoError(t, swap.Get()) {
  410. assert.Equal(t, uint64(4882428*1024), swap.Total)
  411. assert.Equal(t, uint64(0), swap.Free)
  412. }
  413. }
  414. func TestLinuxHugeTLBPages(t *testing.T) {
  415. setUp(t)
  416. defer tearDown(t)
  417. meminfoContents := `
  418. MemTotal: 374256 kB
  419. MemFree: 274460 kB
  420. Buffers: 9764 kB
  421. Cached: 38648 kB
  422. SwapCached: 0 kB
  423. Active: 33772 kB
  424. Inactive: 31184 kB
  425. Active(anon): 16572 kB
  426. Inactive(anon): 552 kB
  427. Active(file): 17200 kB
  428. Inactive(file): 30632 kB
  429. Unevictable: 0 kB
  430. Mlocked: 0 kB
  431. SwapTotal: 786428 kB
  432. SwapFree: 786428 kB
  433. Dirty: 0 kB
  434. Writeback: 0 kB
  435. AnonPages: 16564 kB
  436. Mapped: 6612 kB
  437. Shmem: 584 kB
  438. Slab: 19092 kB
  439. SReclaimable: 9128 kB
  440. SUnreclaim: 9964 kB
  441. KernelStack: 672 kB
  442. PageTables: 1864 kB
  443. NFS_Unstable: 0 kB
  444. Bounce: 0 kB
  445. WritebackTmp: 0 kB
  446. CommitLimit: 973556 kB
  447. Committed_AS: 55880 kB
  448. VmallocTotal: 34359738367 kB
  449. VmallocUsed: 21428 kB
  450. VmallocChunk: 34359713596 kB
  451. HardwareCorrupted: 0 kB
  452. AnonHugePages: 0 kB
  453. HugePages_Total: 16
  454. HugePages_Free: 14
  455. HugePages_Rsvd: 2
  456. HugePages_Surp: 0
  457. Hugepagesize: 2048 kB
  458. DirectMap4k: 59328 kB
  459. DirectMap2M: 333824 kB
  460. `
  461. meminfoFile := procd + "/meminfo"
  462. err := ioutil.WriteFile(meminfoFile, []byte(meminfoContents), 0444)
  463. if err != nil {
  464. t.Fatal(err)
  465. }
  466. hugePages := sigar.HugeTLBPages{}
  467. if assert.NoError(t, hugePages.Get()) {
  468. assert.Equal(t, uint64(16), hugePages.Total)
  469. assert.Equal(t, uint64(14), hugePages.Free)
  470. assert.Equal(t, uint64(2), hugePages.Reserved)
  471. assert.Equal(t, uint64(0), hugePages.Surplus)
  472. assert.Equal(t, uint64(2048*1024), hugePages.DefaultSize)
  473. assert.Equal(t, uint64(4*2048*1024), hugePages.TotalAllocatedSize)
  474. }
  475. }
  476. func TestFDUsage(t *testing.T) {
  477. setUp(t)
  478. defer tearDown(t)
  479. // There is no Uint63 until 2.0
  480. open := uint64(rand.Uint32())
  481. unused := uint64(rand.Uint32())
  482. max := uint64(rand.Uint32())
  483. fileNRContents := fmt.Sprintf("%d %d %d", open, unused, max)
  484. fileNRPath := procd + "/sys/fs"
  485. os.MkdirAll(fileNRPath, 0755)
  486. fileNRFile := fileNRPath + "/file-nr"
  487. err := ioutil.WriteFile(fileNRFile, []byte(fileNRContents), 0444)
  488. if err != nil {
  489. t.Fatal(err)
  490. }
  491. fd := sigar.FDUsage{}
  492. if assert.NoError(t, fd.Get()) {
  493. assert.Equal(t, open, fd.Open)
  494. assert.Equal(t, unused, fd.Unused)
  495. assert.Equal(t, max, fd.Max)
  496. }
  497. }
  498. func TestProcFDUsage(t *testing.T) {
  499. setUp(t)
  500. defer tearDown(t)
  501. pid := rand.Intn(32768)
  502. pidDir := fmt.Sprintf("%s/%d", procd, pid)
  503. err := os.Mkdir(pidDir, 0755)
  504. if err != nil {
  505. t.Fatal(err)
  506. }
  507. soft := uint64(rand.Uint32())
  508. // subtract to prevent the posibility of overflow
  509. if soft != 0 {
  510. soft -= 1
  511. }
  512. // max sure hard is always bigger than soft
  513. hard := soft + uint64(rand.Uint32())
  514. limitsContents := `Limit Soft Limit Hard Limit Units
  515. Max cpu time unlimited unlimited seconds
  516. Max file size unlimited unlimited bytes
  517. Max data size unlimited unlimited bytes
  518. Max stack size 8388608 unlimited bytes
  519. Max core file size 0 unlimited bytes
  520. Max resident set unlimited unlimited bytes
  521. Max processes 29875 29875 processes
  522. Max open files %d %d files
  523. Max locked memory 65536 65536 bytes
  524. Max address space unlimited unlimited bytes
  525. Max file locks unlimited unlimited locks
  526. Max pending signals 29875 29875 signals
  527. Max msgqueue size 819200 819200 bytes
  528. Max nice priority 0 0
  529. Max realtime priority 0 0
  530. Max realtime timeout unlimited unlimited us
  531. `
  532. limitsContents = fmt.Sprintf(limitsContents, soft, hard)
  533. limitsFile := pidDir + "/limits"
  534. err = ioutil.WriteFile(limitsFile, []byte(limitsContents), 0444)
  535. if err != nil {
  536. t.Fatal(err)
  537. }
  538. open := rand.Intn(32768)
  539. if err = writeFDs(pid, open); err != nil {
  540. t.Fatal(err)
  541. }
  542. procFD := sigar.ProcFDUsage{}
  543. if assert.NoError(t, procFD.Get(pid)) {
  544. assert.Equal(t, uint64(open), procFD.Open)
  545. assert.Equal(t, soft, procFD.SoftLimit)
  546. assert.Equal(t, hard, procFD.HardLimit)
  547. }
  548. }
  549. func writeFDs(pid int, count int) error {
  550. fdDir := fmt.Sprintf("%s/%d/fd", procd, pid)
  551. err := os.Mkdir(fdDir, 0755)
  552. if err != nil {
  553. return err
  554. }
  555. for i := 0; i < count; i++ {
  556. fdPath := fmt.Sprintf("%s/%d", fdDir, i)
  557. f, err := os.Create(fdPath)
  558. if err != nil {
  559. return err
  560. }
  561. f.Close()
  562. }
  563. return nil
  564. }
  565. func writePidStats(pid int, procName string, path string) error {
  566. stats := "S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 " +
  567. "20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 " +
  568. "35 36 37 38 39"
  569. statContents := []byte(fmt.Sprintf("%d (%s) %s", pid, procName, stats))
  570. return ioutil.WriteFile(path, statContents, 0644)
  571. }
  572. func writePidStatus(name string, pid int, uid int, pidStatusFile string) error {
  573. status := `
  574. Name: %s
  575. State: R (running)
  576. Tgid: 5452
  577. Pid: %d
  578. PPid: 743
  579. TracerPid: 0
  580. Uid: %d %d %d %d
  581. Gid: 100 100 100 100
  582. FDSize: 256
  583. Groups: 100 14 16
  584. VmPeak: 5004 kB
  585. VmSize: 5004 kB
  586. VmLck: 0 kB
  587. VmHWM: 476 kB
  588. VmRSS: 476 kB
  589. RssAnon: 352 kB
  590. RssFile: 120 kB
  591. RssShmem: 4 kB
  592. VmData: 156 kB
  593. VmStk: 88 kB
  594. VmExe: 68 kB
  595. VmLib: 1412 kB
  596. VmPTE: 20 kb
  597. VmSwap: 0 kB
  598. HugetlbPages: 0 kB
  599. Threads: 1
  600. SigQ: 0/28578
  601. SigPnd: 0000000000000000
  602. ShdPnd: 0000000000000000
  603. SigBlk: 0000000000000000
  604. SigIgn: 0000000000000000
  605. SigCgt: 0000000000000000
  606. CapInh: 00000000fffffeff
  607. CapPrm: 0000000000000000
  608. CapEff: 0000000000000000
  609. CapBnd: ffffffffffffffff
  610. Seccomp: 0
  611. voluntary_ctxt_switches: 0
  612. nonvoluntary_ctxt_switches: 1`
  613. statusContents := []byte(fmt.Sprintf(status, name, pid, uid))
  614. return ioutil.WriteFile(pidStatusFile, statusContents, 0644)
  615. }