Possible status is dead (disable service by default), running (enable service by default), enabled, disabled. | Possible status is dead (disable service by default), running (enable service by default), enabled, disabled. | ||||
Linux with atop service: | |||||
.. code-block:: yaml | |||||
linux: | |||||
system: | |||||
atop: | |||||
enabled: true | |||||
interval: 20 | |||||
logpath: "/var/log/atop" | |||||
outfile: "/var/log/atop/daily.log" | |||||
RHEL / CentOS | RHEL / CentOS | ||||
^^^^^^^^^^^^^ | ^^^^^^^^^^^^^ | ||||
{%- from "linux/map.jinja" import system with context -%} | |||||
# This file /etc/default/atop is managed by Salt linux formula | |||||
INTERVAL={{ system.atop.interval }} | |||||
LOGPATH={{ system.atop.logpath }} | |||||
OUTFILE={{ system.atop.outfile }} |
{%- from "linux/map.jinja" import system with context -%} | |||||
[Unit] | |||||
Description=atop - advanced interactive monitor | |||||
After=syslog.target | |||||
ConditionPathExists={{ config_file }} | |||||
Documentation=man:atop(1) | |||||
Documentation=https://atoptool.nl | |||||
[Service] | |||||
EnvironmentFile=-{{ config_file }} | |||||
ExecStart=/usr/bin/atop -a -w ${LOGPATH}/daily.log ${INTERVAL} | |||||
Restart=always | |||||
RestartSec=10 | |||||
[Install] | |||||
WantedBy=multi-user.target |
}, | }, | ||||
'selinux': 'permissive', | 'selinux': 'permissive', | ||||
'ca_certs_dir': '/usr/local/share/ca-certificates', | 'ca_certs_dir': '/usr/local/share/ca-certificates', | ||||
'atop': { | |||||
'enabled': false, | |||||
'interval': '20', | |||||
'autostart': true, | |||||
'logpath': '/var/log/atop', | |||||
'outfile': '/var/log/atop/daily.log' | |||||
}, | |||||
}, | }, | ||||
'Debian': { | 'Debian': { | ||||
'pkgs': ['python-apt', 'apt-transport-https', 'libmnl0'], | 'pkgs': ['python-apt', 'apt-transport-https', 'libmnl0'], | ||||
}, | }, | ||||
'selinux': 'permissive', | 'selinux': 'permissive', | ||||
'ca_certs_dir': '/usr/local/share/ca-certificates', | 'ca_certs_dir': '/usr/local/share/ca-certificates', | ||||
'atop': { | |||||
'enabled': false, | |||||
'interval': '20', | |||||
'autostart': true, | |||||
'logpath': '/var/log/atop', | |||||
'outfile': '/var/log/atop/daily.log' | |||||
}, | |||||
}, | }, | ||||
'RedHat': { | 'RedHat': { | ||||
'pkgs': ['policycoreutils', 'policycoreutils-python', 'telnet', 'wget'], | 'pkgs': ['policycoreutils', 'policycoreutils-python', 'telnet', 'wget'], | ||||
}, | }, | ||||
'selinux': 'permissive', | 'selinux': 'permissive', | ||||
'ca_certs_dir': '/usr/local/share/ca-certificates', | 'ca_certs_dir': '/usr/local/share/ca-certificates', | ||||
'atop': { | |||||
'enabled': false, | |||||
'interval': '20', | |||||
'autostart': true, | |||||
'logpath': '/var/log/atop', | |||||
'outfile': '/var/log/atop/daily.log' | |||||
}, | |||||
}, | }, | ||||
}, grain='os_family', merge=salt['pillar.get']('linux:system')) %} | }, grain='os_family', merge=salt['pillar.get']('linux:system')) %} | ||||
{%- from "linux/map.jinja" import system with context -%} | |||||
{%- if system.atop.enabled %} | |||||
job: | |||||
atop: | |||||
- files: | |||||
- {{ system.atop.logpath }}/atop* | |||||
- {{ system.atop.logpath }}/{{ system.atop.outfile }} | |||||
options: | |||||
- olddir {{ system.atop.logpath }}/old | |||||
- compress | |||||
- delaycompress | |||||
- missingok | |||||
- notifempty | |||||
- rotate: 10 | |||||
- daily | |||||
- minsize: 20M | |||||
- maxsize: 500M | |||||
- postrotate: "if ! service atop status > /dev/null; then service atop restart > /dev/null; fi" | |||||
{%- endif %} |
{%- from "linux/map.jinja" import system with context %} | |||||
{%- if system.atop.enabled %} | |||||
atop_packages: | |||||
pkg.installed: | |||||
- name: atop | |||||
atop_defaults: | |||||
file.managed: | |||||
- name: /etc/default/atop | |||||
- source: salt://linux/files/atop.conf | |||||
- template: jinja | |||||
- user: root | |||||
- group: root | |||||
- mode: 644 | |||||
atop_logpath: | |||||
file.directory: | |||||
- name: {{ system.atop.logpath }} | |||||
- user: root | |||||
- group: root | |||||
- mode: 750 | |||||
- makedirs: true | |||||
{%- if grains.get('init', None) == 'systemd' %} | |||||
atop_systemd_file: | |||||
file.managed: | |||||
- name: /etc/systemd/system/atop.service | |||||
- source: salt://linux/files/atop.service | |||||
- user: root | |||||
- mode: 644 | |||||
- defaults: | |||||
service_name: atop | |||||
config_file: /etc/default/atop | |||||
autostart: {{ system.atop.autostart }} | |||||
- template: jinja | |||||
- require_in: | |||||
- service: atop_service | |||||
{%- endif %} | |||||
atop_service: | |||||
service.running: | |||||
- name: atop | |||||
- enable: {{ system.atop.autostart }} | |||||
- watch: | |||||
- file: atop_defaults | |||||
{%- if grains.get('noservices') %} | |||||
- onlyif: /bin/false | |||||
{%- endif %} | |||||
{%- else %} | |||||
atop_service_stop: | |||||
service.dead: | |||||
- name: atop | |||||
- enable: false | |||||
- require_in: | |||||
- pkg: atop_pkg_purge | |||||
{%- if grains.get('noservices') %} | |||||
- onlyif: /bin/false | |||||
{%- endif %} | |||||
atop_defaults_purge: | |||||
file.absent: | |||||
- names: | |||||
- /etc/default/atop | |||||
- /etc/systemd/system/atop.service | |||||
- require: | |||||
- pkg: atop_pkg_purge | |||||
atop_pkg_purge: | |||||
pkg.purged: | |||||
- name: atop | |||||
{%- endif %} |
{%- if system.apparmor is defined %} | {%- if system.apparmor is defined %} | ||||
- linux.system.apparmor | - linux.system.apparmor | ||||
{%- endif %} | {%- endif %} | ||||
{%- if pillar.linux.system.atop is defined %} | |||||
- linux.system.atop | |||||
{%- endif %} | |||||
{%- if system.console is defined %} | {%- if system.console is defined %} | ||||
- linux.system.console | - linux.system.console | ||||
{%- endif %} | {%- endif %} |
192.168.0.1: | 192.168.0.1: | ||||
mac: "ff:ff:ff:ff:ff:ff" | mac: "ff:ff:ff:ff:ff:ff" | ||||
interface: bond0 | interface: bond0 | ||||
atop: | |||||
enabled: true | |||||
interval: 20 | |||||
logpath: "/var/mylog/atop" | |||||
outfile: "/var/mylog/atop/daily.log" |