Last active
January 28, 2024 22:09
-
-
Save mackuba/4a486dfdf7ef87dcaa3cd1aa82004482 to your computer and use it in GitHub Desktop.
Munin configuration files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$1" = "config" ]; then | |
echo "graph_title Bluesky firehose events" | |
echo "graph_category bluesky" | |
echo "graph_vlabel Events per second" | |
echo "graph_args --base 1000 -l 0" | |
echo "events.label Events" | |
echo "events.type DERIVE" | |
echo "events.min 0" | |
else | |
db="/var/www/bluefeeds/shared/bluesky.sqlite3" | |
service="bsky.network" | |
current_cursor=$(echo "SELECT cursor FROM subscriptions WHERE service = '$service'" | sqlite3 "$db") | |
if [ -n "$current_cursor" ]; then | |
echo "events.value $current_cursor" | |
else | |
echo "events.value U" | |
fi | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$1" = "config" ]; then | |
echo "graph_title New Bluesky posts" | |
echo "graph_category bluesky" | |
echo "graph_vlabel Posts per second" | |
echo "graph_args --base 1000 -l 0" | |
echo "posts.label Posts" | |
else | |
db="/var/www/bluefeeds/shared/bluesky.sqlite3" | |
posts=$(echo "SELECT COUNT(*) / 300.0 FROM posts WHERE time > datetime('now', '-5 minutes')" | sqlite3 "$db") | |
echo "posts.value $posts" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$1" = "config" ]; then | |
echo "graph_title Stream reconnections" | |
echo "graph_category bluesky" | |
echo "graph_vlabel Incidents" | |
echo "reconnect.label Reconnects" | |
echo "timeout.label Timeouts" | |
else | |
count=$(journalctl -u bluefeeds -S -5m | grep "Connection lost, reconnecting" | wc -l) | |
echo "reconnect.value $count" | |
count=$(journalctl -u bluefeeds -S -5m | egrep "last update 10[12][0-9]\." | wc -l) | |
echo "timeout.value $count" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -z "$patterns" ]; then | |
echo 'Missing $patterns setting' | |
exit 1 | |
fi | |
title=${title:-Size of $patterns} | |
if [ "$1" = "config" ]; then | |
echo "graph_title $title" | |
echo "graph_category other" | |
echo "graph_vlabel File size (bytes)" | |
echo "graph_args --base 1024 -l 0 -r" | |
echo "filesize.label File size" | |
echo "filesize.draw AREA" | |
echo "filesize.min 0" | |
else | |
files=$(eval "echo $patterns") | |
output=$(du -bc $files) | |
if [ $? -eq 0 ]; then | |
filesize=$(echo "$output" | tail -n 1 | cut -f 1) | |
echo "filesize.value $filesize" | |
else | |
echo "filesize.value U" | |
fi | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/munin/munin-conf.d/master-conf | |
# extends /etc/munin/munin.conf - configures how charts are generated from data | |
# general | |
cgiurl_graph /munin/munin-cgi-graph | |
[zermatt.mackuba.eu] | |
# hide the apache dataset since it's always 0 | |
passenger_memory.apache_rss.graph no | |
filesize.graph_category bluesky | |
loggrep_psionides.graph_category webserver | |
loggrep_psionides.graph_period minute | |
# bluefeeds requests chart: draw a stack chart with 20-min average | |
loggrep_bluefeeds.graph_category bluesky | |
loggrep_bluefeeds.graph_period hour | |
loggrep_bluefeeds.graph_order count apple build linux mac starwars | |
loggrep_bluefeeds.graph_vlabel Requests / ${graph_period} (moving avg) | |
loggrep_bluefeeds.count.colour 00CC00 | |
loggrep_bluefeeds.count.label TOTAL | |
loggrep_bluefeeds.count.cdef count,1200,TREND | |
loggrep_bluefeeds.apple.draw AREA | |
loggrep_bluefeeds.build.draw STACK | |
loggrep_bluefeeds.linux.draw STACK | |
loggrep_bluefeeds.mac.draw STACK | |
loggrep_bluefeeds.starwars.draw STACK | |
loggrep_bluefeeds.apple.cdef apple,1200,TREND | |
loggrep_bluefeeds.build.cdef build,1200,TREND | |
loggrep_bluefeeds.linux.cdef linux,1200,TREND | |
loggrep_bluefeeds.mac.cdef mac,1200,TREND | |
loggrep_bluefeeds.starwars.cdef starwars,1200,TREND | |
loggrep_bluefeeds.apple.colour FF8000 | |
loggrep_bluefeeds.build.colour 0066B3 | |
loggrep_bluefeeds.linux.colour 00CC00 | |
loggrep_bluefeeds.mac.colour FFD000 | |
loggrep_bluefeeds.starwars.colour 330099 | |
# loggrep_bluefeeds.other.update no | |
# loggrep_bluefeeds.other.colour 808080 | |
# loggrep_bluefeeds.other.draw STACK | |
# loggrep_bluefeeds.other.label Other | |
# loggrep_bluefeeds.other.cdef count,apple,build,+,linux,+,mac,+,starwars,+,- | |
# network chart copy with only incoming traffic | |
if_ens192_down.update no | |
if_ens192_down.graph_category network | |
if_ens192_down.graph_title ens192 traffic (in) | |
if_ens192_down.graph_order down=if_ens192.down | |
if_ens192_down.graph_vlabel Bits in per ${graph_period} | |
if_ens192_down.down.label Traffic in | |
if_ens192_down.down.cdef down,8,* | |
# network chart copy with only outgoing traffic | |
if_ens192_up.update no | |
if_ens192_up.graph_category network | |
if_ens192_up.graph_title ens192 traffic (out) | |
if_ens192_up.graph_order up=if_ens192.up | |
if_ens192_up.graph_vlabel Bits out per ${graph_period} | |
if_ens192_up.up.label Traffic out | |
if_ens192_up.up.cdef up,8,* | |
# disk IO chart copy with only reads | |
diskstats_read.update no | |
diskstats_read.graph_category disk | |
diskstats_read.graph_title Disk IOs per device (read) | |
diskstats_read.graph_args --base 1000 | |
diskstats_read.graph_order \ | |
sda=diskstats_iops.sda_rdio \ | |
lv_swap=diskstats_iops.vg0_lv_swap_rdio \ | |
lv_root=diskstats_iops.vg0_lv_root_rdio | |
diskstats_read.graph_vlabel Read IOs per ${graph_period} | |
diskstats_read.sda.label sda | |
diskstats_read.lv_swap.label lv_swap | |
diskstats_read.lv_root.label lv_root | |
# disk IO chart copy with only writes | |
diskstats_write.update no | |
diskstats_write.graph_category disk | |
diskstats_write.graph_title Disk IOs per device (write) | |
diskstats_write.graph_args --base 1000 | |
diskstats_write.graph_order \ | |
sda=diskstats_iops.sda_wrio \ | |
lv_swap=diskstats_iops.vg0_lv_swap_wrio \ | |
lv_root=diskstats_iops.vg0_lv_root_wrio | |
diskstats_write.graph_vlabel Write IOs per ${graph_period} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/munin-cgi.service | |
# runs a CGI service for generating zoomed charts | |
[Unit] | |
Description=Munin graph CGI | |
After=network.target syslog.target | |
[Service] | |
Type=simple | |
User=root | |
ExecStart=/usr/bin/spawn-fcgi -n -s /var/run/munin/fastcgi-graph.sock \ | |
-U www-data -u munin -g munin /usr/lib/munin/cgi/munin-cgi-graph | |
TimeoutSec=15 | |
Restart=on-failure | |
RestartSec=1 | |
SyslogIdentifier=munin-cgi | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /munin { | |
auth_basic "You shall not pass"; | |
auth_basic_user_file /etc/nginx/htpasswd_munin; | |
alias /var/cache/munin/www/; | |
expires modified +310s; | |
access_log /var/log/nginx/munin-access.log full_with_duration buffer=16k flush=10s; | |
error_log /var/log/nginx/munin-error.log; | |
# this is only for dynamically generating charts on the "zoom" page | |
# since normally we still generate charts (html & graphs) from cron | |
location /munin/munin-cgi-graph/ { | |
access_log off; | |
# regex to split $uri to $fastcgi_script_name and $fastcgi_path | |
fastcgi_split_path_info ^(/munin/munin-cgi-graph)(.*); | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_pass unix:/var/run/munin/fastcgi-graph.sock; | |
include fastcgi.conf; | |
} | |
} | |
location /munin/static/ { | |
alias /etc/munin/static/; | |
expires modified +1w; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
command = ENV['command'] || '/usr/sbin/passenger-status' | |
name_regexp = ENV['name_regexp'] && Regexp.new(ENV['name_regexp']) | |
config = (ARGV[0] == 'config') | |
output = `#{command} --show=xml 2> /dev/null` | |
xml = Nokogiri::XML(output) | |
apps = {} | |
def make_app_name(group, env, regexp) | |
name = group.gsub(/ \(#{env}\)/, '') | |
(regexp && name =~ regexp) ? $1 : name | |
end | |
xml.css('supergroup > group').each do |group| | |
name = group.at('name').text | |
env = group.at('environment').text | |
app_name = make_app_name(name, env, name_regexp) | |
if config | |
apps[app_name] = 1 | |
else | |
processes = group.css('processes > process') | |
total_mem = processes.map { |p| p.at('real_memory').text.to_i }.reduce(&:+) * 1024 | |
apps[app_name] = total_mem | |
end | |
end | |
if config | |
puts "graph_title Passenger memory usage per app" | |
puts "graph_category webserver" | |
puts "graph_vlabel Memory used (bytes)" | |
apps.keys.sort.each do |k| | |
puts "#{k}.label #{k}" | |
end | |
else | |
apps.sort_by { |k, v| k }.each do |k, v| | |
puts "#{k}.value #{v}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# Updated version of: | |
# https://gallery.munin-monitoring.org/plugins/munin-contrib/passenger_memory/ | |
# | |
# Be sure to configure this node in the plugin configuration | |
# Memory stats must be run by root | |
# Ex: | |
# [passenger_memory] | |
# user root | |
# env.memory_stats_command path_to_passenger-memory-stats | |
# | |
memory_stats_command = ENV['memory_stats_command'] || '/usr/sbin/passenger-memory-stats' | |
stats = {} | |
section = nil | |
def key_name(section) | |
section.downcase + '_rss' | |
end | |
`#{memory_stats_command}`.each_line do |line| | |
if line =~ /\-\- (\w+) processes \-\-/ | |
section = $1 | |
elsif line =~ /### Total private dirty RSS: (\d+\.\d+) MB/ | |
stats[section] = $1 | |
end | |
end | |
if ARGV[0] == 'config' | |
puts 'graph_title Passenger Memory Usage' | |
puts 'graph_category webserver' | |
puts 'graph_vlabel MB' | |
stats.keys.each do |s| | |
puts "#{key_name(s)}.label #{s} Dirty RSS" | |
end | |
else | |
stats.each do |s, v| | |
puts "#{key_name(s)}.value #{v}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/munin/plugin-conf.d/user-conf | |
# configures plugins run by munin-node (restart munin-node after changes) | |
[bluesky_reconnects] | |
user root | |
[diskstats] | |
env.exclude /dev/loop,/dev/fd0,/dev/sr0 | |
[filesize] | |
env.patterns /var/www/bluefeeds/shared/bluesky.sqlite3* | |
env.title Size of bluesky.sqlite3 | |
[http_github] | |
env.target https://github.com | |
[http_mackuba] | |
env.target https://mackuba.eu | |
[loggrep_bluefeeds] | |
env.logfile /var/www/bluefeeds/shared/log/sinatra.log | |
env.regex getFeedSkeleton | |
env.label Requests per ${graph_period} | |
env.title Requests to getFeedSkeleton | |
env.regex_linux getFeedSkeleton.*feed\.generator%2Flinux | |
env.label_linux Linux | |
env.regex_starwars getFeedSkeleton.*feed\.generator%2Fstarwars | |
env.label_starwars Star Wars | |
env.regex_mac getFeedSkeleton.*feed\.generator%2Fmac | |
env.label_mac macOS | |
env.regex_apple getFeedSkeleton.*feed\.generator%2Fapple | |
env.label_apple Apple Dev | |
env.regex_build getFeedSkeleton.*feed\.generator%2Fbuild | |
env.label_build buildinpublic | |
[loggrep_psionides] | |
env.logfile /var/www/psionides-blog/shared/log/sinatra.log | |
env.regex . | |
env.label Requests per ${graph_period} | |
env.title Requests to mackuba.eu | |
[multips_fixed] | |
env.names firehose mysqld | |
[passenger_apps_memory] | |
user root | |
env.command /usr/sbin/passenger-status | |
env.name_regexp /var/www/([^/]+)/ | |
[passenger_memory] | |
user root | |
env.memory_stats_command /usr/sbin/passenger-memory-stats --no-apache | |
[ps_Passenger] | |
env.name Passenger | |
env.regex ruby\|Passenger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment