snmpd.conf 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. {%- endfor %}
  50. {%- endif %}
  51. {%- set ovpn_networks = [] %}
  52. {%- for netname, network in salt['pillar.get']('ovpn', {}).items () if grains['id'] in network %}
  53. {%- do ovpn_networks.append (netname) %}
  54. {%- endfor %}
  55. {%- for netname in ovpn_networks|sort %}
  56. {%- set network = salt['pillar.get']('ovpn:' ~ netname) %}
  57. {%- set network_config = network.get ('config') %}
  58. {%- set host_stanza = network.get (grains['id']) %}
  59. {%- set host_config = host_stanza.get ('config', {}) %}
  60. {%- set interface = host_config.get ('interface', network_config.get ('interface')) %}
  61. {%- if loop.first %}
  62. # OpenVPN interfaces
  63. {%- endif %}
  64. interface {{ interface }} 6 100000000 # 100 Mb/s
  65. {%- endfor %}