aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: ce43c42bee01c791d4e47376094a777f04d7f9bb (plain) (blame)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# MSTAT

Record the memory usage of a process over time.

## Installation

- **Requires**
  - Linux
  - `make`
  - `cmake` (>= v3.x)
  - `gcc` or `clang` (C99 compiler)
  - `gnuplot` (optional)

```shell
git clone https://github.com/jhunkeler/mstat && cd mstat
cmake -DCMAKE_INSTALL_PREFIX=/usr/local .
make
make install
```

# How to use MSTAT

```text
usage: mstat [OPTIONS] [-p PID] | {PROGRAM... ARGS}
  -c        clobber 'PID#.mstat' if it exists
  -h        this help message
  -l LIMIT  stop execution after LIMIT samples
  -o DIR    path to output directory (must exist)
  -p PID    process id to monitor
  -s RATE   samples per second (default: 1.00)
  -v        increased verbosity
```

## Monitor an existing process

```shell
$ mstat -p 12345
PID: 12345
Samples per second: 1.00
(interrupt with ctrl-c...)
```

## Monitor a new process

```shell
$ mstat -s 10000 free
PID: 12345 
Samples per second: 10000.00
(interrupt with ctrl-c...)
               total        used        free      shared  buff/cache   available
Mem:        28455904     8951836    10728332      476032     8775736    18596172
Swap:       16777212           0    16777212
pid 148257 returned 0
MSTAT file written: /path/to/12345.mstat
```

## Plotting

Requires `gnuplot` to be installed.
- Debian / Ubuntu
  - `apt update && apt install gnuplot`
- Fedora / RHEL
  - `yum install gnuplot`
- Arch Linux
  - `pacman -S gnuplot`

```text
usage: mstat_plot [OPTIONS] {FILE}
  -f NAME[,...]   mstat field(s) to plot (default: rss,pss,swap)
  -h              this help message
  -l              list mstat fields
  -v              verbose mode
```

### Render

```shell
$ mstat_plot 12345.mstat
```

## CSV export

```shell
$ mstat_export 12345.mstat > 12345.csv
```