1. Arthur Lutz
  2. salt-highstate-stats

Overview

HTTPS SSH

salt-highstate-stats

salt-highstate-stats is a combination of a salt runner and outputter that will collect information about the number of states that would change in your infrastructure if a highstate was launched.

This tool is useful if you manually roll out your highstates and want to know the "distance" between your description and your infrastructure.

These statistics can be outputted as JSON and so can be integrated to a monitoring or supervision tool. An implementation of a munin plugin is included.

Examples

Single host

# salt-run stats.highstate_test 'host1.example.org'
host1.example.org               : total 142, todo 1 (0.70%), no_changes 141 (99.30%), changes 0 (0.00%), failed 0 (0.00%)

Multiple hosts

# salt-run stats.highstate_test 'host*'
host1.example.org               : total 142, todo 1 (0.70%), no_changes 141 (99.30%), changes 0 (0.00%), failed 0 (0.00%)
host2.example.org               : total 142, todo 1 (0.70%), no_changes 141 (99.30%), changes 0 (0.00%), failed 0 (0.00%)
Total                           : total 284, todo 2 (0.70%), no_changes 282 (99.30%), changes 0 (0.00%), failed 0 (0.00%)

All hosts

# salt-run stats.highstate_test
host1.example.org               : total 96, todo 3 (3.12%), no_changes 93 (96.88%), changes 0 (0.00%), failed 0 (0.00%)
host2.example.org               : total 99, todo 23 (23.23%), no_changes 75 (75.76%), changes 0 (0.00%), failed 1 (1.01%)
web1.example.org                : total 96, todo 3 (3.12%), no_changes 93 (96.88%), changes 0 (0.00%), failed 0 (0.00%)
web2.example.org                : total 96, todo 3 (3.12%), no_changes 93 (96.88%), changes 0 (0.00%), failed 0 (0.00%)
db1.example.org                 : total 90, todo 24 (26.67%), no_changes 65 (72.22%), changes 0 (0.00%), failed 1 (1.11%)
Total                           : total 477, todo 56 (11.74%), no_changes 419 (87.84%), changes 0 (0.00%), failed 2 (0.42%)

Screenshot

TODO

Install

mkdir /srv/runners
echo "runner_dirs: ['/srv/runners']" > /etc/salt/master.d/runners.conf
service salt-master restart
cp runner/stats.py in /srv/runners/
cp /srv/salt/_outputters/
cp _outputters/*.py into /srv/salt/_outputters/
cp _modules/*.py into /srv/salt/_modules/

Install munin graphs via salt

cp pillars/schedule.sls /srv/pillar/
#include schedule in your pillar/top.sls
cp states/munin* /srv/salt/
#include munin in your states/top.sls
salt '*' state.highstate