2014-12-05 14:25:28 -05:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2014-11-18 12:30:16 +09:00
|
|
|
# lib/dstat
|
2014-08-20 00:34:55 -07:00
|
|
|
# Functions to start and stop dstat
|
|
|
|
|
|
|
|
# Dependencies:
|
|
|
|
#
|
|
|
|
# - ``functions`` file
|
|
|
|
|
|
|
|
# ``stack.sh`` calls the entry points in this order:
|
|
|
|
#
|
2020-01-24 11:44:46 +01:00
|
|
|
# - install_dstat
|
2014-08-20 00:34:55 -07:00
|
|
|
# - start_dstat
|
|
|
|
# - stop_dstat
|
|
|
|
|
|
|
|
# Save trace setting
|
2015-10-13 11:03:03 +11:00
|
|
|
_XTRACE_DSTAT=$(set +o | grep xtrace)
|
2014-08-20 00:34:55 -07:00
|
|
|
set +o xtrace
|
|
|
|
|
2020-01-24 11:44:46 +01:00
|
|
|
# install_dstat() - Install prerequisites for dstat services
|
|
|
|
function install_dstat {
|
|
|
|
if is_service_enabled memory_tracker; then
|
|
|
|
# Install python libraries required by tools/mlock_report.py
|
|
|
|
pip_install_gr psutil
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-08-30 14:16:58 -04:00
|
|
|
# start_dstat() - Start running processes
|
2014-08-20 00:34:55 -07:00
|
|
|
function start_dstat {
|
|
|
|
# A better kind of sysstat, with the top process per time slice
|
2015-08-05 10:25:00 -06:00
|
|
|
run_process dstat "$TOP_DIR/tools/dstat.sh $LOGDIR"
|
2015-04-09 13:51:23 +10:00
|
|
|
|
2017-02-10 06:17:37 +00:00
|
|
|
# To enable memory_tracker add:
|
|
|
|
# enable_service memory_tracker
|
2015-04-09 13:51:23 +10:00
|
|
|
# to your localrc
|
2017-03-21 20:50:24 -04:00
|
|
|
run_process memory_tracker "$TOP_DIR/tools/memory_tracker.sh" "" "root"
|
2017-02-10 06:17:37 +00:00
|
|
|
|
2019-02-21 12:24:17 +00:00
|
|
|
# TODO(jh): Fail when using the old service name otherwise consumers might
|
|
|
|
# never notice that is has been removed.
|
2017-02-10 06:17:37 +00:00
|
|
|
if is_service_enabled peakmem_tracker; then
|
2019-02-21 12:24:17 +00:00
|
|
|
die $LINENO "The peakmem_tracker service has been removed, use memory_tracker instead"
|
2017-02-10 06:17:37 +00:00
|
|
|
fi
|
2014-08-20 00:34:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# stop_dstat() stop dstat process
|
|
|
|
function stop_dstat {
|
2015-04-09 19:57:13 +10:00
|
|
|
stop_process dstat
|
2017-02-10 06:17:37 +00:00
|
|
|
stop_process memory_tracker
|
2014-08-20 00:34:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# Restore xtrace
|
2015-10-13 11:03:03 +11:00
|
|
|
$_XTRACE_DSTAT
|