diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-03-01 03:34:16 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-03-01 03:34:16 -0500 |
commit | 4670f5437abdede6c048c2b59ec6637bcfc79e54 (patch) | |
tree | 874746b1439f5b1f70c78dabb3a308d2d5626464 /modules | |
parent | 22b7d33290b1bc594c532e72d347e32eb92a981f (diff) | |
download | puppet-tozt-4670f5437abdede6c048c2b59ec6637bcfc79e54.tar.gz puppet-tozt-4670f5437abdede6c048c2b59ec6637bcfc79e54.zip |
remove munin config
Diffstat (limited to 'modules')
25 files changed, 0 insertions, 601 deletions
diff --git a/modules/munin/files/munin.conf b/modules/munin/files/munin.conf deleted file mode 100644 index bf99e1d..0000000 --- a/modules/munin/files/munin.conf +++ /dev/null @@ -1,21 +0,0 @@ -htmldir /srv/http/munin -timeout 60 - -contact.mail.command /usr/bin/perl -E 'say "To: doy\@tozt.net"; say "Subject: Munin notification"; say; print <>' | /usr/bin/msmtp -t -C /etc/munin/msmtprc - -[tozt] - address tozt.algo - use_node_name yes - contacts mail -[partofme] - address partofme.algo - use_node_name yes - contacts mail -[hush] - address hush.algo - use_node_name yes - contacts mail -[mail] - address mail.algo - use_node_name yes - contacts mail diff --git a/modules/munin/files/override.conf b/modules/munin/files/override.conf deleted file mode 100644 index 3f925fa..0000000 --- a/modules/munin/files/override.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Unit] -After=wg-quick@algo.service diff --git a/modules/munin/files/plugins/certbot b/modules/munin/files/plugins/certbot deleted file mode 100755 index ed3d13e..0000000 --- a/modules/munin/files/plugins/certbot +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env ruby - -$config_dir = ENV['CERTBOT_CONFIG_DIR'] || '/etc/letsencrypt' - -def run - require 'openssl' - - (Dir.entries("#{$config_dir}/live/") - [".", ".."]).each do |site| - cert = File.read("#{$config_dir}/live/#{site}/cert.pem") - x509 = OpenSSL::X509::Certificate.new(cert) - days = (x509.not_after - Time.now) / 60 / 60 / 24 - sanitized_site = site.gsub(/[^a-zA-Z0-9]/, '_') - puts "#{sanitized_site}.value #{days}" - end -end - -def config - puts "graph_title cert age" - puts "graph_category network" - puts "graph_vlabel time until cert expiration (days)" - puts "graph_args -l 0" - puts "graph_scale no" - - (Dir.entries("#{$config_dir}/live/") - [".", ".."]).each do |site| - sanitized_site = site.gsub(/[^a-zA-Z0-9]/, '_') - puts "#{sanitized_site}.label #{site}" - puts "#{sanitized_site}.warning 21:" - puts "#{sanitized_site}.critical 7:" - end -end - -if $0 == __FILE__ - if ARGV[0] == "config" - config - else - run - end -end diff --git a/modules/munin/files/plugins/duplicati.rb b/modules/munin/files/plugins/duplicati.rb deleted file mode 100644 index 4db6b2f..0000000 --- a/modules/munin/files/plugins/duplicati.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'date' -require 'yaml' - -def parse_duration(dur) - hours, minutes, seconds = dur.split(/:/) - 3600 * hours.to_f + 60 * minutes.to_f + seconds.to_f -end - -def field_name(name) - name.gsub(/\A[^A-Za-z_]/, '_').gsub(/[^A-Za-z0-9_]/, '_') -end - -def backup_metadata(id) - backup = YAML.load(%x{duplicati-client describe backup #{id}}) - backup[0]['Backup']['Metadata'] -end - -def all_backups - _ = %x{duplicati-client login} - backups = YAML.load(%x{duplicati-client list backups}) - ret = {} - backups.each do |backup| - name = backup.keys[0] - id = backup[name]['ID'] - ret[id] = name - end - ret -end diff --git a/modules/munin/files/plugins/duplicati_ b/modules/munin/files/plugins/duplicati_ deleted file mode 100755 index 4f526c2..0000000 --- a/modules/munin/files/plugins/duplicati_ +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -home="$(mktemp --tmpdir -d munin-duplicati.XXXXXXXXXX)" - -cleanup() { - if perl -e'exit 1 unless $ARGV[0] =~ m{^/tmp/munin-duplicati.*$}' "$home"; then - rm -rf "$home" - fi -} -trap cleanup EXIT - -export HOME="$home" -export PATH="/usr/local/bin:$PATH" -ruby "$(readlink "$0")".rb "$@" diff --git a/modules/munin/files/plugins/duplicati_duration.rb b/modules/munin/files/plugins/duplicati_duration.rb deleted file mode 100644 index d231367..0000000 --- a/modules/munin/files/plugins/duplicati_duration.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'date' -require 'yaml' - -require_relative 'duplicati' - -def run - all_backups.each do |id, name| - metadata = backup_metadata(id) - - took = parse_duration(metadata['LastBackupDuration']) - - puts "#{field_name(name)}.value #{took / 60.0}" - end -end - -def config - puts "graph_title duplicati backup duration" - puts "graph_category backups" - puts "graph_vlabel duration (min)" - puts "graph_args -l 0" - all_backups.each do |id, name| - puts "#{field_name(name)}.label #{name}" - end -end - -if $0 == __FILE__ - if ARGV[0] == "config" - config - else - run - end -end diff --git a/modules/munin/files/plugins/duplicati_file_count.rb b/modules/munin/files/plugins/duplicati_file_count.rb deleted file mode 100644 index fe4ebe9..0000000 --- a/modules/munin/files/plugins/duplicati_file_count.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'date' -require 'yaml' - -require_relative 'duplicati' - -def run - all_backups.each do |id, name| - metadata = backup_metadata(id) - - file_count = metadata['SourceFilesCount'].to_i - - puts "#{field_name(name)}.value #{file_count}" - end -end - -def config - puts "graph_title duplicati number of files" - puts "graph_category backups" - puts "graph_vlabel number of files" - puts "graph_args -l 0" - all_backups.each do |id, name| - puts "#{field_name(name)}.label #{name}" - end -end - -if $0 == __FILE__ - if ARGV[0] == "config" - config - else - run - end -end diff --git a/modules/munin/files/plugins/duplicati_file_size.rb b/modules/munin/files/plugins/duplicati_file_size.rb deleted file mode 100644 index bd4af31..0000000 --- a/modules/munin/files/plugins/duplicati_file_size.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'date' -require 'yaml' - -require_relative 'duplicati' - -def run - all_backups.each do |id, name| - metadata = backup_metadata(id) - - file_size = metadata['SourceFilesSize'].to_i - - puts "#{field_name(name)}.value #{file_size / 1024.0 / 1024.0 / 1024.0}" - end -end - -def config - puts "graph_title duplicati backup size" - puts "graph_category backups" - puts "graph_vlabel size (gb)" - puts "graph_args -l 0 --base 1024" - puts "graph_scale no" - all_backups.each do |id, name| - puts "#{field_name(name)}.label #{name}" - end -end - -if $0 == __FILE__ - if ARGV[0] == "config" - config - else - run - end -end diff --git a/modules/munin/files/plugins/duplicati_last_run.rb b/modules/munin/files/plugins/duplicati_last_run.rb deleted file mode 100644 index 412e8dc..0000000 --- a/modules/munin/files/plugins/duplicati_last_run.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'date' -require 'yaml' - -require_relative 'duplicati' - -def run - now = Time.now - - all_backups.each do |id, name| - metadata = backup_metadata(id) - - last_run_date = DateTime.iso8601(metadata['LastBackupFinished']) - ago = now - last_run_date.to_time - - puts "#{field_name(name)}.value #{ago / 60.0 / 60.0 / 24.0}" - end -end - -def config - puts "graph_title duplicati time since last run" - puts "graph_category backups" - puts "graph_vlabel time since last run (days)" - puts "graph_args -l 0" - puts "graph_scale no" - all_backups.each do |id, name| - puts "#{field_name(name)}.label #{name}" - puts "#{field_name(name)}.warning 1.05" - puts "#{field_name(name)}.critical 2" - end -end - -if $0 == __FILE__ - if ARGV[0] == "config" - config - else - run - end -end diff --git a/modules/munin/files/plugins/mail_count b/modules/munin/files/plugins/mail_count deleted file mode 100644 index 99d3a2a..0000000 --- a/modules/munin/files/plugins/mail_count +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use 5.020; - -use JSON::PP; - -if (@ARGV > 0 && $ARGV[0] eq 'config') { - say "graph_title count of processed mails"; - say "graph_category mail"; - say "graph_vlabel count"; - say "graph_args -l 0"; - say "graph_scale no"; - - say "mailcount.label count of processed mails"; - exit 0; -} - -chdir "/media/persistent"; - -my $json = `docker-compose exec imap rspamc -h antispam:11334 stat --json --compact`; -my $data = decode_json($json); - -say "mailcount.value $data->{scanned}"; diff --git a/modules/munin/files/plugins/package_updates b/modules/munin/files/plugins/package_updates deleted file mode 100755 index 9ddc924..0000000 --- a/modules/munin/files/plugins/package_updates +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -set -eu -set -o pipefail - -run() { - yaourt -Sya > /dev/null - update_count="$( (yaourt -Qua || true) | wc -l)" - echo "updates.value $update_count" -} - -config() { - echo "graph_title package updates" - echo "graph_category system" - echo "graph_vlabel number of package updates" - echo "graph_args -l 0" - echo "graph_scale no" - - echo "updates.label updates" -} - -case "${1:-}" in - config) - config - ;; - *) - run - ;; -esac diff --git a/modules/munin/files/plugins/tarsnap b/modules/munin/files/plugins/tarsnap deleted file mode 100644 index 0baa543..0000000 --- a/modules/munin/files/plugins/tarsnap +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use 5.020; - -if (@ARGV > 0 && $ARGV[0] eq 'config') { - say "graph_title tarsnap backup size"; - say "graph_category backups"; - say "graph_vlabel size (mb)"; - say "graph_args -l 0 --base 1024"; - say "graph_scale no"; - - say "tarsnap.label compressed and deduplicated size"; - exit 0; -} - -my $tarsnap_data = qx(tarsnap --print-stats); -if ($?) { - die "`tarsnap --print-stats` exited with code $?"; -} - -(my $bytes) = $tarsnap_data =~ /([0-9]+)$/; -die "failed to parse tarsnap stats" unless defined $bytes; - -say "tarsnap.value ${\($bytes / 1024 / 1024)}"; diff --git a/modules/munin/files/plugins/tarsnap_last_run b/modules/munin/files/plugins/tarsnap_last_run deleted file mode 100644 index 7dcb1ad..0000000 --- a/modules/munin/files/plugins/tarsnap_last_run +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env ruby - -require 'date' - -def parse_archive(archive) - # tozt-daily-2018-12-31_03:34:13-homedoypass - m = archive.match(/ - \A - (?<host>[a-z]+) # tozt - - - (?<period>[a-z]+) # daily - - - (?<year>[0-9]+) # 2018 - - - (?<month>[0-9]+) # 12 - - - (?<day>[0-9]+) # 31 - _ - (?<hour>[0-9]+) # 03 - : - (?<minute>[0-9]+) # 34 - : - (?<second>[0-9]+) # 13 - - - (?<name>[a-z_]+) # homedoypass - \z - /x) - raise "failed to parse archive name '#{archive}'" if m.nil? - - parsed = m.names.zip(m.captures).to_h - parsed["time"] = Time.new( - m["year"], - m["month"], - m["day"], - m["hour"], - m["minute"], - m["second"] - ) - parsed -end - -archives = %x(tarsnap --list-archives) - .lines - .map(&:chomp) - .map{|s| parse_archive(s)} -if ARGV.length > 0 && ARGV[0] == "config" - puts "graph_title tarsnap time since last run" - puts "graph_category backups" - puts "graph_vlabel time since last run (days)" - puts "graph_args -l 0" - puts "graph_scale no" - - names = archives.map{|h| h["name"]}.sort.uniq - names.each do |name| - puts "#{name}.label #{name}" - puts "#{name}.warning 1.05" - puts "#{name}.critical 2" - end -else - now = Time.now - most_recent_since = {} - archives.each do |archive| - name = archive["name"] - since = now - archive["time"] - - if most_recent_since[name].nil? || since < most_recent_since[name] - most_recent_since[name] = since - end - end - - most_recent_since.sort.each do |name, since| - puts "#{name}.value #{since.to_f / 60.0 / 60.0 / 24.0}" - end -end diff --git a/modules/munin/manifests/archlinux.pp b/modules/munin/manifests/archlinux.pp deleted file mode 100644 index 77e41c0..0000000 --- a/modules/munin/manifests/archlinux.pp +++ /dev/null @@ -1,9 +0,0 @@ -class munin::archlinux { - file { - "/usr/lib/munin/plugins/package_updates": - source => "puppet:///modules/munin/plugins/package_updates", - mode => "0755", - require => Package["munin-node"], - before => Service["munin-node"]; - } -} diff --git a/modules/munin/manifests/certbot.pp b/modules/munin/manifests/certbot.pp deleted file mode 100644 index a7ddef4..0000000 --- a/modules/munin/manifests/certbot.pp +++ /dev/null @@ -1,9 +0,0 @@ -class munin::certbot { - file { - "/usr/lib/munin/plugins/certbot": - source => "puppet:///modules/munin/plugins/certbot", - mode => "0755", - require => Package["munin-node"], - before => Service["munin-node"]; - } -} diff --git a/modules/munin/manifests/duplicati.pp b/modules/munin/manifests/duplicati.pp deleted file mode 100644 index 96292e8..0000000 --- a/modules/munin/manifests/duplicati.pp +++ /dev/null @@ -1,49 +0,0 @@ -class munin::duplicati { - file { - "/usr/lib/munin/plugins/duplicati_": - source => "puppet:///modules/munin/plugins/duplicati_", - mode => "0755", - require => Package["munin-node"], - before => Service["munin-node"]; - "/usr/lib/munin/plugins/duplicati.rb": - source => "puppet:///modules/munin/plugins/duplicati.rb", - require => Package["munin-node"], - before => Service["munin-node"]; - "/usr/lib/munin/plugins/duplicati_duration.rb": - source => "puppet:///modules/munin/plugins/duplicati_duration.rb", - require => Package["munin-node"], - before => Service["munin-node"]; - "/usr/lib/munin/plugins/duplicati_file_count.rb": - source => "puppet:///modules/munin/plugins/duplicati_file_count.rb", - require => Package["munin-node"], - before => Service["munin-node"]; - "/usr/lib/munin/plugins/duplicati_file_size.rb": - source => "puppet:///modules/munin/plugins/duplicati_file_size.rb", - require => Package["munin-node"], - before => Service["munin-node"]; - "/usr/lib/munin/plugins/duplicati_last_run.rb": - source => "puppet:///modules/munin/plugins/duplicati_last_run.rb", - require => Package["munin-node"], - before => Service["munin-node"]; - "/usr/lib/munin/plugins/duplicati_duration": - ensure => link, - target => "/usr/lib/munin/plugins/duplicati_", - require => Package["munin-node"], - before => Service["munin-node"]; - "/usr/lib/munin/plugins/duplicati_file_count": - ensure => link, - target => "/usr/lib/munin/plugins/duplicati_", - require => Package["munin-node"], - before => Service["munin-node"]; - "/usr/lib/munin/plugins/duplicati_file_size": - ensure => link, - target => "/usr/lib/munin/plugins/duplicati_", - require => Package["munin-node"], - before => Service["munin-node"]; - "/usr/lib/munin/plugins/duplicati_last_run": - ensure => link, - target => "/usr/lib/munin/plugins/duplicati_", - require => Package["munin-node"], - before => Service["munin-node"]; - } -} diff --git a/modules/munin/manifests/init.pp b/modules/munin/manifests/init.pp deleted file mode 100644 index a6798b2..0000000 --- a/modules/munin/manifests/init.pp +++ /dev/null @@ -1,32 +0,0 @@ -class munin { - include systemd - - $from = "munin" - $password = secret::value('munin_email_password') - - package { 'munin': - } - - file { - '/srv/http/munin': - ensure => directory, - owner => 'munin', - group => 'munin', - require => Package['munin']; - '/etc/munin/munin.conf': - source => 'puppet:///modules/munin/munin.conf', - require => Package['munin']; - '/etc/munin/msmtprc': - content => template('munin/msmtprc'), - owner => 'munin', - group => 'munin', - mode => '0600', - require => Package['munin']; - } - - exec { 'install munin crontab': - command => '/usr/bin/crontab /etc/munin/munin-cron-entry -u munin', - creates => '/var/spool/cron/munin', - require => Package['munin']; - } -} diff --git a/modules/munin/manifests/mailu.pp b/modules/munin/manifests/mailu.pp deleted file mode 100644 index c7daba0..0000000 --- a/modules/munin/manifests/mailu.pp +++ /dev/null @@ -1,9 +0,0 @@ -class munin::mailu { - file { - "/usr/lib/munin/plugins/mail_count": - source => "puppet:///modules/munin/plugins/mail_count", - mode => "0755", - require => Package["munin-node"], - before => Service["munin-node"]; - } -} diff --git a/modules/munin/manifests/node.pp b/modules/munin/manifests/node.pp deleted file mode 100644 index c8dc550..0000000 --- a/modules/munin/manifests/node.pp +++ /dev/null @@ -1,23 +0,0 @@ -class munin::node { - package { 'munin-node': - } - - service { 'munin-node': - ensure => running, - enable => true, - subscribe => [ - Systemd::Override['munin-node'], - File['/etc/munin/munin-node.conf'], - ], - require => Package['munin-node']; - } - - file { '/etc/munin/munin-node.conf': - content => template('munin/munin-node.conf'), - require => Package['munin-node']; - } - - systemd::override { "munin-node": - source => 'puppet:///modules/munin/override.conf'; - } -} diff --git a/modules/munin/manifests/plugin.pp b/modules/munin/manifests/plugin.pp deleted file mode 100644 index e7392b0..0000000 --- a/modules/munin/manifests/plugin.pp +++ /dev/null @@ -1,8 +0,0 @@ -define munin::plugin($source=$name) { - file { "/etc/munin/plugins/$name": - ensure => link, - target => "/usr/lib/munin/plugins/$source", - require => Package['munin-node'], - notify => Service['munin-node']; - } -} diff --git a/modules/munin/manifests/tarsnap.pp b/modules/munin/manifests/tarsnap.pp deleted file mode 100644 index b78682e..0000000 --- a/modules/munin/manifests/tarsnap.pp +++ /dev/null @@ -1,14 +0,0 @@ -class munin::tarsnap { - file { - "/usr/lib/munin/plugins/tarsnap": - source => "puppet:///modules/munin/plugins/tarsnap", - mode => "0755", - require => Package["munin-node"], - before => Service["munin-node"]; - "/usr/lib/munin/plugins/tarsnap_last_run": - source => "puppet:///modules/munin/plugins/tarsnap_last_run", - mode => "0755", - require => Package["munin-node"], - before => Service["munin-node"]; - } -} diff --git a/modules/munin/templates/msmtprc b/modules/munin/templates/msmtprc deleted file mode 100644 index a5feffe..0000000 --- a/modules/munin/templates/msmtprc +++ /dev/null @@ -1,11 +0,0 @@ -defaults -auth on -tls on -tls_starttls off - -account default -host mail.tozt.net -from <%= @from %>@tozt.net -user <%= @from %>@tozt.net -password <%= @password %> -tls_trust_file /etc/ssl/certs/ca-certificates.crt diff --git a/modules/munin/templates/munin-node.conf b/modules/munin/templates/munin-node.conf deleted file mode 100644 index c3a467a..0000000 --- a/modules/munin/templates/munin-node.conf +++ /dev/null @@ -1,22 +0,0 @@ -log_level 4 -log_file /var/log/munin/munin-node.log -pid_file /run/munin/munin-node.pid - -background 1 -setsid 1 - -user root -group root - -ignore_file [\#~]$ -ignore_file DEADJOE$ -ignore_file \.bak$ -ignore_file %$ -ignore_file \.dpkg-(tmp|new|old|dist)$ -ignore_file \.rpm(save|new)$ -ignore_file \.pod$ - -allow ^10\.19\.49\.\d+$ - -host <%= @vpn_ips[@hostname] %> -port 4949 diff --git a/modules/tozt/files/nginx/munin-tls.conf b/modules/tozt/files/nginx/munin-tls.conf deleted file mode 100644 index 0f7984d..0000000 --- a/modules/tozt/files/nginx/munin-tls.conf +++ /dev/null @@ -1,16 +0,0 @@ -server { - listen 443 ssl; - server_name munin.tozt.net; - - access_log /var/log/nginx/munin.access.log; - error_log /var/log/nginx/munin.error.log; - - include ssl; - - location / { - root /srv/http/munin; - auth_basic "munin"; - auth_basic_user_file "/media/persistent/munin.htpasswd"; - } -} -# vim:ft=nginx diff --git a/modules/tozt/files/nginx/munin.conf b/modules/tozt/files/nginx/munin.conf deleted file mode 100644 index 982fe68..0000000 --- a/modules/tozt/files/nginx/munin.conf +++ /dev/null @@ -1,10 +0,0 @@ -server { - listen 80; - server_name munin.tozt.net; - - access_log /var/log/nginx/munin.access.log; - error_log /var/log/nginx/munin.error.log; - - rewrite ^(.*) https://$host$1 permanent; -} -# vim:ft=nginx |