Browse Source

Add atop

Change-Id: I59297736406469e5314236cb40851d9a6f94386e
pull/122/head
Serhiy Ovsianikov 7 years ago
parent
commit
67bd56a83c
8 changed files with 158 additions and 0 deletions
  1. +12
    -0
      README.rst
  2. +5
    -0
      linux/files/atop.conf
  3. +16
    -0
      linux/files/atop.systemd
  4. +21
    -0
      linux/map.jinja
  5. +20
    -0
      linux/meta/logrotate.yml
  6. +76
    -0
      linux/system/atop.sls
  7. +3
    -0
      linux/system/init.sls
  8. +5
    -0
      tests/pillar/system.sls

+ 12
- 0
README.rst View File



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
^^^^^^^^^^^^^ ^^^^^^^^^^^^^



+ 5
- 0
linux/files/atop.conf View File

{%- 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 }}

+ 16
- 0
linux/files/atop.systemd View File

{%- 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

+ 21
- 0
linux/map.jinja View File

}, },
'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')) %}



+ 20
- 0
linux/meta/logrotate.yml View File

{%- 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 %}

+ 76
- 0
linux/system/atop.sls View File

{%- 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 %}

+ 3
- 0
linux/system/init.sls View File

{%- 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 %}

+ 5
- 0
tests/pillar/system.sls View File

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"

Loading…
Cancel
Save