-
Notifications
You must be signed in to change notification settings - Fork 0
/
userparameter_teamd.conf
21 lines (14 loc) · 1.65 KB
/
userparameter_teamd.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#Returns all connections that are type "team"
#Ex: {"data":[{"{#TEAM_IF}": "team0"}]}
UserParameter=team.discovery,team_list=$(nmcli con show | awk '$3 == "team" {print $1}');echo -n '{"data":[';for t in ${team_list}; do echo -n "{\"{#TEAM_IF}\": \"$t\"},";done | sed -e 's:\},$:\}:';echo -n ']}'
#Queries all connections that are 'connection.slave-type' and then returns actual device name.
#Ex: {"data":[{"{#TEAM_IF}": "team0", "{#SLAVE_IF}": "eth0"},{"{#TEAM_IF}": "team0", "{#SLAVE_IF}": "eth1"}]}
UserParameter=team.slave.discovery,slave_list=$(for i in $(nmcli connection show --active | grep -v NAME | awk '{print $1}'); do nmcli connection show id $i | grep 'connection.slave-type' | awk -v slave=$i '$2 == "team" {print slave}' | xargs nmcli connection show | grep connection.interface-name | cut -f2 -d: | tr -d ' '; done); echo -n '{"data":['; for s in $slave_list;do team_name=$(nmcli device show "$s" | grep GENERAL.CONNECTION | cut -f2 -d: | tr -d ' ' | xargs nmcli connection show | grep connection.master | cut -f2 -d: | tr -d ' '); echo -n "{\"{#TEAM_IF}\": \"$team_name\", ";echo -n "\"{#SLAVE_IF}\": \"$s\"},"; done | sed -e 's:\},$:\}:';echo -n ']}'
#Queries active state of discovered Team connection
#Ex: team.check[team0] [t|activated]
UserParameter=team.check[*],nmcli con show $1 | grep GENERAL.STATE | grep -o activated
#Queries link state and down count
#Ex: team.slave.check[team0,eth0,link:] [t|up]
#Ex: team.slave.check[team0,eth0,count] [t|0]
#Required sudo permissions for zabbix account to run teamdctl
UserParameter=team.slave.check[*],sudo teamdctl $1 state | grep $2 -A6 | grep $3 | cut -f2 -d: | tr -d ' '