snmpd.conf.tmpl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {%- set node_config = salt['pillar.get'] ('nodes:' ~ grains['id']) %}
  2. {%- set ro_community = salt['pillar.get'] ('globals:snmp:ro_community', "Configure globals:snmp:ro_community in pillar...") %}
  3. {%- set sys_contact = salt['pillar.get'] ('globals:ops_mail', "Configure globals:ops_mail in pillar...") %}
  4. {%- set sys_location = salt['pillar.get'] ('nodes:' ~ grains['id'] ~ 'location:site:code', node_config.get ('sysLocation', "Please fix sysLocation...")) %}
  5. {%- set nms_list = salt['pillar.get'] ('globals:snmp:nms_list', []) %}
  6. {%- set sites_config = salt['pillar.get'] ('sites', {}) %}
  7. {%- set ifaces = salt['ffho_net.get_interface_config'] (node_config, sites_config) %}
  8. #
  9. # /etc/snmp/snmpd.conf (Salt managed)
  10. #
  11. sysLocation {{ sys_location }}
  12. sysContact {{ sys_contact }}
  13. sysServices 72
  14. # Listen for connections from the local system
  15. agentAddress udp:127.0.0.1:161
  16. agentAddress udp6:[::1]:161
  17. # Listen for connections on Loopback-IPs
  18. agentAddress udp:{{ salt['ffho_net.get_primary_ip'] (node_config, 'v4').ip }}:161
  19. agentAddress udp6:[{{ salt['ffho_net.get_primary_ip'] (node_config, 'v6').ip }}]:161
  20. # We accept requests from those fine boxes
  21. rocommunity {{ ro_community }} 127.0.0.1
  22. rocommunity6 {{ ro_community }} ::1
  23. {%- for entry in nms_list %}
  24. {%- if ':' in entry %}
  25. rocommunity6 {{ ro_community }} {{ entry }}
  26. {%- else %}
  27. rocommunity {{ ro_community }} {{ entry }}
  28. {%- endif %}
  29. {%- endfor %}
  30. #
  31. # Network interfaces
  32. #
  33. # Set bandwidth of some virtual interfaces to meaningful values (for us).
  34. # The default is 10Mb/s which makes LibreNMS whine quite a lot if there is
  35. # a little traffic.
  36. interface lo 6 1000000000 # 1 Gb/s
  37. {%- for iface in ifaces|sort %}
  38. {%- set config = ifaces.get (iface) %}
  39. {%- if "vlan" in config or "vxlan" in config %}
  40. {%- continue %}
  41. {%- endif %}
  42. {%- if "batman" in config or "bridge" in config %}
  43. interface {{ iface }} 6 500000000 # 500 Mb/s
  44. {%- endif %}
  45. {%- if "wireguard" in config %}
  46. interface {{ iface }} 6 300000000 # 300 Mb/s
  47. {%- endif %}
  48. {%- endfor %}
  49. {%- if "fastd" in node_config.get ('roles') %}
  50. {%- for site in node_config.get ('sites') %}
  51. {%- if loop.first %}
  52. # Fastd interfaces
  53. {%- endif %}
  54. interface {{ site }}_intergw 6 500000000 # 500 Mb/s
  55. interface {{ site }}_nodes4 6 500000000 # 500 Mb/s
  56. interface {{ site }}_nodes6 6 500000000 # 500 Mb/s
  57. {%- endfor %}
  58. {%- endif %}
  59. {%- set ovpn_networks = [] %}
  60. {%- for netname, network in salt['pillar.get']('ovpn', {}).items () if grains['id'] in network %}
  61. {%- do ovpn_networks.append (netname) %}
  62. {%- endfor %}
  63. {%- for netname in ovpn_networks|sort %}
  64. {%- set network = salt['pillar.get']('ovpn:' ~ netname) %}
  65. {%- set network_config = network.get ('config') %}
  66. {%- set host_stanza = network.get (grains['id']) %}
  67. {%- set host_config = host_stanza.get ('config', {}) %}
  68. {%- set interface = host_config.get ('interface', network_config.get ('interface')) %}
  69. {%- if loop.first %}
  70. # OpenVPN tunnels
  71. {%- endif %}
  72. interface {{ interface }} 6 100000000 # 100 Mb/s
  73. {%- endfor %}
  74. {%- set vm_ifaces = [] %}
  75. {%- for vm_fqdn, vm_cfg in node_config.get ('vms', {}).items ()|sort %}
  76. {%- set vm_name = vm_fqdn.split ('.')[0].split ('-')[0] %}
  77. {%- for vm_iface, iface_cfg in vm_cfg['ifaces'].items ()|sort %}
  78. {%- if iface_cfg.get ('untagged_vlan') %}
  79. {%- set host_iface = "%s_v%s" % (vm_name, iface_cfg.get ('untagged_vlan')) %}
  80. {%- else %}
  81. {%- set host_iface = "%s_%s" % (vm_name, vm_iface.replace ('vlan', 'v')) %}
  82. {%- endif %}
  83. {%- do vm_ifaces.append (host_iface) %}
  84. {%- endfor %}
  85. {%- endfor %}
  86. {%- for iface in vm_ifaces|sort %}
  87. {%- if loop.first %}
  88. # VM interfaces
  89. {%- endif %}
  90. interface {{ iface }} 6 1000000000 # 1 Gb/s
  91. {%- endfor %}