# /etc/munin/munin-node.conf - config-file for munin-node
#
# This file is handled by puppet, any local changes will be lost
#
<%
  require 'ipaddr'

  addresses = []
  unrecognized = []

  Array(@allow).flatten.each do |line|
    begin
      a = IPAddr.new(line)
      if a.ipv4? or a.ipv6?
        addresses << line
      end
    rescue ArgumentError, IPAddr::InvalidAddressError
      # Treat invalid addresses as "allow" arguments, as they can be
      # regular expressions.
      unrecognized << line
    end
  end
-%>

host_name  <%= @host_name %>
log_level  4
log_file   <%= @_log_file %>
<% if @log_destination == 'syslog' -%>
<%     if @syslog_ident -%>
syslog_ident "<%= @syslog_ident %>"
<%     end -%>
<%     if @syslog_facility -%>
syslog_facility <%= @syslog_facility %>
<%     end -%>
<% end -%>
port       4949
pid_file   /var/run/munin/munin-node.pid
background 1
setsid     1

# Which port to bind to;

user  root
group <%= @file_group %>

# Regexps for files to ignore

ignore_file ~$
ignore_file \.bak$
ignore_file %$
ignore_file \.dpkg-(tmp|new|old|dist)$
ignore_file \.rpm(save|new)$
ignore_file \.puppet-bak$

# Hosts to allow
<% addresses.each do |line| -%>
<%   if line.match(/\//) -%>
cidr_allow <%= line %>
<%   else -%>
allow ^<%= Regexp.quote(line) %>$
<%   end -%>
<% end -%>
<% unrecognized.each do |line| -%>
allow <%= line %>
<% end -%>

<% Array(@nodeconfig).each do |line| -%>
<%= line %>
<% end -%>
