File: stats.md

package info (click to toggle)
oomd 0.5.0-1.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,996 kB
  • sloc: cpp: 14,345; sh: 89; makefile: 7
file content (68 lines) | stat: -rw-r--r-- 1,333 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Structured stats collection

The structured stats collection is a threadsafe key-value store, with `std::string` for keys and `int` for values.

It can be also be queried from a different process using the StatsClient class.


## Internal API

### Get stats
  `std::unordered_map<std::string, int> getStats()`


  Returns an unordered map copy of the current stats.


### Increment a key-value pair in stats
  `int setStats(const std::string& key, int val)`


  This increments the value of the corresponding key by val.

  Returns 0 upon success, and 1 on error.


### Set a key-value pair in stats
  `int setStats(const std::string& key, int val)`


  Sets the corresponding key in stats to val.

  Returns 0 upon success, and 1 on error.


### Reset stats
  `int Oomd::resetStats()`


  Sets the value of all existing key-value pairs in the stats collection
  to 0.


  Returns 0 upon success, and 1 on error.



## External interface

  Command line flags:

##### `-d`

  Dumps all accumulated stats to stdout in a JSON string.
  
    $ /path/to/binary -d
    {
     "oomd.kills_structured" : 1,
     "oomd.restarts_structured" : 2
    }
    $ /path/to/binary -d | jq '.["oomd.kills_structured"]'
    1


#####`-r`

  Reset stats by setting all values to 0.

Notes: If both `-d` and `-r` are included, `-d` is completed first.