blob: 870c901d2ab0cf81038764dc4953ea8a1e3e19e4 [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
YAMAMOTO Takashi42373c72014-11-18 12:30:16 +09003# lib/dstat
Joe Gordone0b08d02014-08-20 00:34:55 -07004# Functions to start and stop dstat
5
6# Dependencies:
7#
8# - ``functions`` file
9
10# ``stack.sh`` calls the entry points in this order:
11#
Federico Ressi19e4d972020-01-24 11:44:46 +010012# - install_dstat
Joe Gordone0b08d02014-08-20 00:34:55 -070013# - start_dstat
14# - stop_dstat
15
16# Save trace setting
Ian Wienand523f4882015-10-13 11:03:03 +110017_XTRACE_DSTAT=$(set +o | grep xtrace)
Joe Gordone0b08d02014-08-20 00:34:55 -070018set +o xtrace
19
Federico Ressi19e4d972020-01-24 11:44:46 +010020# install_dstat() - Install prerequisites for dstat services
21function install_dstat {
22 if is_service_enabled memory_tracker; then
23 # Install python libraries required by tools/mlock_report.py
24 pip_install_gr psutil
25 fi
26}
27
Sean Dague0eebeb42017-08-30 14:16:58 -040028# start_dstat() - Start running processes
Joe Gordone0b08d02014-08-20 00:34:55 -070029function start_dstat {
30 # A better kind of sysstat, with the top process per time slice
Tim Buckleya83e90b2015-08-05 10:25:00 -060031 run_process dstat "$TOP_DIR/tools/dstat.sh $LOGDIR"
Ian Wienand72a8be62015-04-09 13:51:23 +100032
Ihar Hrachyshka2b4735f2017-02-10 06:17:37 +000033 # To enable memory_tracker add:
34 # enable_service memory_tracker
Ian Wienand72a8be62015-04-09 13:51:23 +100035 # to your localrc
Sean Dague5edae542017-03-21 20:50:24 -040036 run_process memory_tracker "$TOP_DIR/tools/memory_tracker.sh" "" "root"
Ihar Hrachyshka2b4735f2017-02-10 06:17:37 +000037
Jens Harbott95634d92019-02-21 12:24:17 +000038 # TODO(jh): Fail when using the old service name otherwise consumers might
39 # never notice that is has been removed.
Ihar Hrachyshka2b4735f2017-02-10 06:17:37 +000040 if is_service_enabled peakmem_tracker; then
Jens Harbott95634d92019-02-21 12:24:17 +000041 die $LINENO "The peakmem_tracker service has been removed, use memory_tracker instead"
Ihar Hrachyshka2b4735f2017-02-10 06:17:37 +000042 fi
Rodolfo Alonso Hernandezd1c2bf52022-11-02 16:43:41 +010043
44 # To enable file_tracker add:
45 # enable_service file_tracker
46 # to your localrc
47 run_process file_tracker "$TOP_DIR/tools/file_tracker.sh"
Joe Gordone0b08d02014-08-20 00:34:55 -070048}
49
50# stop_dstat() stop dstat process
51function stop_dstat {
Ian Wienandc00d2a52015-04-09 19:57:13 +100052 stop_process dstat
Ihar Hrachyshka2b4735f2017-02-10 06:17:37 +000053 stop_process memory_tracker
Rodolfo Alonso Hernandezd1c2bf52022-11-02 16:43:41 +010054 stop_process file_tracker
Joe Gordone0b08d02014-08-20 00:34:55 -070055}
56
57# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +110058$_XTRACE_DSTAT