Vasyl Saienko | 1aac81e | 2025-01-18 08:40:51 +0000 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # lib/atop |
| 4 | # Functions to start and stop atop |
| 5 | |
| 6 | # Dependencies: |
| 7 | # |
| 8 | # - ``functions`` file |
| 9 | |
| 10 | # ``stack.sh`` calls the entry points in this order: |
| 11 | # |
| 12 | # - configure_atop |
| 13 | # - install_atop |
| 14 | # - start_atop |
| 15 | # - stop_atop |
| 16 | |
| 17 | # Save trace setting |
| 18 | _XTRACE_ATOP=$(set +o | grep xtrace) |
| 19 | set +o xtrace |
| 20 | |
| 21 | function configure_atop { |
| 22 | cat <<EOF | sudo tee /etc/default/atop >/dev/null |
| 23 | # /etc/default/atop |
| 24 | # see man atoprc for more possibilities to configure atop execution |
| 25 | |
| 26 | LOGOPTS="-R" |
| 27 | LOGINTERVAL=${ATOP_LOGINTERVAL:-"30"} |
| 28 | LOGGENERATIONS=${ATOP_LOGGENERATIONS:-"1"} |
| 29 | LOGPATH=$LOGDIR/atop |
| 30 | EOF |
| 31 | } |
| 32 | |
| 33 | function install_atop { |
| 34 | install_package atop |
| 35 | } |
| 36 | |
| 37 | # start_() - Start running processes |
| 38 | function start_atop { |
| 39 | start_service atop |
| 40 | } |
| 41 | |
| 42 | # stop_atop() stop atop process |
| 43 | function stop_atop { |
| 44 | stop_service atop |
| 45 | } |
| 46 | |
| 47 | # Restore xtrace |
| 48 | $_XTRACE_ATOP |