Initial release

This commit is contained in:
Kenneth Østrup 2016-07-14 13:58:43 +02:00
parent 9d67c7d1cd
commit 0d0e2dafab
14 changed files with 267 additions and 1 deletions

View File

@ -1 +0,0 @@
# smokeping-formula

27
README.rst Normal file
View File

@ -0,0 +1,27 @@
smokeping-formula
===============
Formula to set up and configure smokeping.
.. note::
See the full `Salt Formulas installation and usage instructions
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.
Available states
================
.. contents::
:local:
``smokeping``
-----------
Installs smokeping
``smokeping.config``
------------------
Manages smokeping configuration file(s)

21
pillar.example Normal file
View File

@ -0,0 +1,21 @@
smokeping:
owner: Peter Random
contact: noc@email.to.nowhere
alerts:
from: smokealert@company.xy
to: alertee@address.somewhere
bigloss:
type: loss
pattern: ==0%,==0%,==0%,==0%,>0%,>0%,>0%
comment: suddenly there is packet loss
targets:
alerts: bigloss
LocalMachine:
menu: Local Machine
title: This host
remark: Pinging 127.0.0.1
host: localhost
alerts: someloss

26
smokeping/config.sls Normal file
View File

@ -0,0 +1,26 @@
{% from "smokeping/map.jinja" import smokeping with context %}
include:
- smokeping
smokeping_cfg:
file.managed:
- name: /etc/smokeping/config
- source: salt://smokeping/files/config
- template: jinja
- user: root
- watch_in:
- service: smokeping
- require:
- pkg: smokeping
{% for config in ['General', 'Database', 'Alerts', 'Targets', 'Presentation', 'Probes', 'pathnames'] %}
smokeping_config_d_{{config}}:
file.managed:
- name: /etc/smokeping/config.d/{{ config }}
- source: salt://smokeping/files/{{ config }}
- template: jinja
- user: root
- watch_in:
- service: smokeping
{% endfor %}

15
smokeping/files/Alerts Normal file
View File

@ -0,0 +1,15 @@
{%- from "smokeping/map.jinja" import smokeping with context -%}
*** Alerts ***
to = {{ salt['pillar.get']('smokeping:alerts:to', 'alertee@address.somewhere') }}
from = {{ salt['pillar.get']('smokeping:alerts:from', 'smokealert@company.xy') }}
{% for alert, options in smokeping.alerts.iteritems() -%}
{% if options is mapping() %}
+ {{ alert }}
{% for key, value in options.iteritems() -%}
{{ key }} = {{ value }}
{% endfor %}
{% endif %}
{% endfor %}

16
smokeping/files/Database Normal file
View File

@ -0,0 +1,16 @@
{%- from "smokeping/map.jinja" import smokeping with context -%}
*** Database ***
step = {{ smokeping.database.step }}
pings = {{ smokeping.database.pings }}
# consfn mrhb steps total
AVERAGE 0.5 1 1008
AVERAGE 0.5 12 4320
MIN 0.5 12 4320
MAX 0.5 12 4320
AVERAGE 0.5 144 720
MAX 0.5 144 720
MIN 0.5 144 720

17
smokeping/files/General Normal file
View File

@ -0,0 +1,17 @@
{%- from "smokeping/map.jinja" import smokeping with context -%}
*** General ***
owner = {{ salt['pillar.get']('smokeping:owner', 'Peter Random') }}
contact = {{ salt['pillar.get']('smokeping:contact', 'some@address.nowhere') }}
mailhost = {{ salt['pillar.get']('smokeping:mailhost', 'my.mail.host') }}
# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed ... this is not
# good for images.
cgiurl = {{ salt['pillar.get']('smokeping:cgirul', 'http://some.url/smokeping.cgi') }}
# specify this to get syslog logging
syslogfacility = {{ smokeping.syslogfacility }}
# each probe is now run in its own process
# disable this to revert to the old behaviour
# concurrentprobes = no
@include /etc/smokeping/config.d/pathnames

View File

@ -0,0 +1,57 @@
*** Presentation ***
template = /etc/smokeping/basepage.html
charset = utf-8
+ charts
menu = Charts
title = The most interesting destinations
++ stddev
sorter = StdDev(entries=>4)
title = Top Standard Deviation
menu = Std Deviation
format = Standard Deviation %f
++ max
sorter = Max(entries=>5)
title = Top Max Roundtrip Time
menu = by Max
format = Max Roundtrip Time %f seconds
++ loss
sorter = Loss(entries=>5)
title = Top Packet Loss
menu = Loss
format = Packets Lost %f
++ median
sorter = Median(entries=>5)
title = Top Median Roundtrip Time
menu = by Median
format = Median RTT %f seconds
+ overview
width = 600
height = 50
range = 10h
+ detail
width = 600
height = 200
unison_tolerance = 2
"Last 3 Hours" 3h
"Last 30 Hours" 30h
"Last 10 Days" 10d
"Last 360 Days" 360d
#+ hierarchies
#++ owner
#title = Host Owner
#++ location
#title = Location

9
smokeping/files/Probes Normal file
View File

@ -0,0 +1,9 @@
{%- from "smokeping/map.jinja" import smokeping with context -%}
*** Probes ***
{% for probe, settings in smokeping.probes.iteritems() %}
+ {{ probe }}
{% for key, value in settings.items() %}
{{ key }} = {{ value }}
{% endfor %}
{% endfor %}

20
smokeping/files/Targets Normal file
View File

@ -0,0 +1,20 @@
{%- from "smokeping/map.jinja" import smokeping with context -%}
{%- set targets = smokeping.targets -%}
*** Targets ***
probe = {{ smokeping.targets.probe }}
menu = Top
title = {{ smokeping.targets.title }}
remark = {{ salt['pillar.get']('smokeping:targets:remark', '') }}
alerts = {{ salt['pillar.get']('smokeping:targets:alerts', '') }}
{% for target, options in smokeping.targets.iteritems() -%}
{% if options is mapping() -%}
+ {{ target }}
{% for key, value in options.iteritems() -%}
{{ key }} = {{ value }}
{% endfor %}
{% endif %}
{% endfor %}

7
smokeping/files/config Normal file
View File

@ -0,0 +1,7 @@
@include /etc/smokeping/config.d/General
@include /etc/smokeping/config.d/Alerts
@include /etc/smokeping/config.d/Database
@include /etc/smokeping/config.d/Presentation
@include /etc/smokeping/config.d/Probes
@include /etc/smokeping/config.d/Slaves
@include /etc/smokeping/config.d/Targets

View File

@ -0,0 +1,8 @@
{%- from "smokeping/map.jinja" import smokeping with context -%}
sendmail = {{smokeping.lookup.sendmail}}
imgcache = {{smokeping.lookup.imgcache}}
imgurl = {{smokeping.lookup.imgurl}}
datadir = {{smokeping.lookup.datadir}}
piddir = {{smokeping.lookup.piddir}}
smokemail = {{smokeping.lookup.smokemail}}
tmail = {{smokeping.lookup.tmail}}

9
smokeping/init.sls Normal file
View File

@ -0,0 +1,9 @@
{% from "smokeping/map.jinja" import smokeping with context %}
smokeping:
pkg.installed:
- name: {{ smokeping.lookup.pkg }}
service.running:
- name: smokeping
- enable: True

35
smokeping/map.jinja Normal file
View File

@ -0,0 +1,35 @@
{% set smokeping = salt['pillar.get']('smokeping', {
'lookup': salt['grains.filter_by']({
'Debian': {
'pkg': 'smokeping',
'sendmail': '/usr/sbin/sendmail',
'imgcache': '/var/cache/smokeping/images',
'imgurl': '../smokeping/images',
'datadir': '/var/lib/smokeping',
'piddir': '/var/run/smokeping',
'smokemail': '/etc/smokeping/smokemail',
'tmail': '/etc/smokeping/tmail',
},
}),
'database': {
'step': 300,
'pings': 20,
},
'syslogfacility': 'local0',
'targets': {
'probe': 'FPing',
'title': 'Network Latency Grapher',
},
'probes': {
'FPing': {
'binary': '/usr/bin/fping',
},
},
'alerts': {
'someloss': {
'type': 'loss',
'pattern': '>0%,*12*,>0%,*12*,>0%',
'comment': 'loss 3 times in a row',
},
},
}, merge=True) %}