networking - salt mine for all network interfaces -


i'm having difficulty configuring collectd.conf using interface plugin through salt. collectd.conf expects list of network interfaces monitor like:

<plugin interface>   interface "em1"   interface "em2" </plugin> 

i've worked out need use salt mine pull grains master - achieved through pillar sls following:

mine_functions:   network.interfaces: [] 

and in collectd.conf have:

<plugin interface> {% host, info in salt['mine.get']('*','network.interfaces').items() %}  {% if host == grains['id'] %}   {% interface in info %}   interface "{{ interface }}"   {% endfor %}  {% endif %} {% endif %} {% endfor %} </plugin> 

however, doesn't appear work me :(

if you're looking interfaces on local host (which gather since you're filtering on grains['id']) don't need mine this. can interface names on local host grains:

{%- iface in grains['ip_interfaces'].keys() %} interface "{{ iface }}" {%- endfor %} 

if want list of local machine's addresses instead of interface names, can loop on grains['ipv4'] instead. no .keys(); grain simple list.

if need interface information other hosts, use mine. note network.interfaces returns nested dictionary, may why it's not working -- looping on if list, (at least when tested now) produces unreadable mess.

to interface names other servers, use more like:

{%- minion, ifaces in salt['mine.get']('*', 'network.interfaces').items() %} {{ minion }}: {%-   iface in ifaces.keys() %}   - {{ iface }} {%-   endfor %} {%- endfor %} 

which should output:

minion1:   - eth0   - eth1   - lo minion2:   - eth0   - eth1   - lo ...and on. 

this sort of asked doesn't seem you're trying do.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -