snmpd.conf.tmpl 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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-raw-device' in config %}
  40. interface {{ iface }} 6 1000000000 # 1 Gb/s
  41. {%- endif %}
  42. {%- if "batman" in config or "bridge" in config %}
  43. interface {{ iface }} 6 500000000 # 500 Mb/s
  44. {%- endif %}
  45. {%- endfor %}
  46. {%- if "fastd" in node_config.get ('roles') %}
  47. {%- for site in node_config.get ('sites') %}
  48. interface {{ site }}_intergw 6 500000000 # 500 Mb/s
  49. interface {{ site }}_nodes4 6 500000000 # 500 Mb/s
  50. interface {{ site }}_nodes6 6 500000000 # 500 Mb/s
  51. {%- endfor %}
  52. {%- endif %}
  53. {%- set ovpn_networks = [] %}
  54. {%- for netname, network in salt['pillar.get']('ovpn', {}).items () if grains['id'] in network %}
  55. {%- do ovpn_networks.append (netname) %}
  56. {%- endfor %}
  57. {%- for netname in ovpn_networks|sort %}
  58. {%- set network = salt['pillar.get']('ovpn:' ~ netname) %}
  59. {%- set network_config = network.get ('config') %}
  60. {%- set host_stanza = network.get (grains['id']) %}
  61. {%- set host_config = host_stanza.get ('config', {}) %}
  62. {%- set interface = host_config.get ('interface', network_config.get ('interface')) %}
  63. {%- if loop.first %}
  64. # OpenVPN interfaces
  65. {%- endif %}
  66. interface {{ interface }} 6 100000000 # 100 Mb/s
  67. {%- endfor %}