diff --git a/README.md b/README.md deleted file mode 100644 index 902d931..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# smokeping-formula \ No newline at end of file diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..5909dce --- /dev/null +++ b/README.rst @@ -0,0 +1,27 @@ +smokeping-formula +=============== + +Formula to set up and configure smokeping. + + +.. note:: + + See the full `Salt Formulas installation and usage instructions + `_. + +Available states +================ + +.. contents:: + :local: + + +``smokeping`` +----------- + +Installs smokeping + +``smokeping.config`` +------------------ + +Manages smokeping configuration file(s) diff --git a/pillar.example b/pillar.example new file mode 100644 index 0000000..5462577 --- /dev/null +++ b/pillar.example @@ -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 diff --git a/smokeping/config.sls b/smokeping/config.sls new file mode 100644 index 0000000..fa0bd90 --- /dev/null +++ b/smokeping/config.sls @@ -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 %} diff --git a/smokeping/files/Alerts b/smokeping/files/Alerts new file mode 100644 index 0000000..edd0a38 --- /dev/null +++ b/smokeping/files/Alerts @@ -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 %} diff --git a/smokeping/files/Database b/smokeping/files/Database new file mode 100644 index 0000000..a65ca9d --- /dev/null +++ b/smokeping/files/Database @@ -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 + diff --git a/smokeping/files/General b/smokeping/files/General new file mode 100644 index 0000000..01f723c --- /dev/null +++ b/smokeping/files/General @@ -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 diff --git a/smokeping/files/Presentation b/smokeping/files/Presentation new file mode 100644 index 0000000..805ba14 --- /dev/null +++ b/smokeping/files/Presentation @@ -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 + diff --git a/smokeping/files/Probes b/smokeping/files/Probes new file mode 100644 index 0000000..fa1e5b3 --- /dev/null +++ b/smokeping/files/Probes @@ -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 %} diff --git a/smokeping/files/Targets b/smokeping/files/Targets new file mode 100644 index 0000000..7aaac0e --- /dev/null +++ b/smokeping/files/Targets @@ -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 %} diff --git a/smokeping/files/config b/smokeping/files/config new file mode 100644 index 0000000..79a3613 --- /dev/null +++ b/smokeping/files/config @@ -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 diff --git a/smokeping/files/pathnames b/smokeping/files/pathnames new file mode 100644 index 0000000..9ea396b --- /dev/null +++ b/smokeping/files/pathnames @@ -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}} diff --git a/smokeping/init.sls b/smokeping/init.sls new file mode 100644 index 0000000..1c10fae --- /dev/null +++ b/smokeping/init.sls @@ -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 diff --git a/smokeping/map.jinja b/smokeping/map.jinja new file mode 100644 index 0000000..17ee531 --- /dev/null +++ b/smokeping/map.jinja @@ -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) %}