diff --git a/Readme.md b/Readme.md index 889b0591384fd11eddbb442485bb17cebe083969..4fb5cf8d9c8afb639f027c58d36bfedd63768540 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,24 @@ Compile radvd_adv_count -g++ -Wall server_instance/zabbix_server/compile_to_radvd_adv_count.cpp -o server_instance/zabbix_server/radvd_adv_count -cp scripts/* /etc/zabbix/scripts/ -cp sudoers.d/* /etc/sudoers.d/ -cp zabbix_agentd.d/* /etc/zabbix/zabbix_agentd.conf.d/ \ No newline at end of file +apt-get install zabbix-agent dhcpd-pools + +g++ -Wall scripts/compile_to_radvd_adv_count.cpp -o scripts/radvd_adv_count + +mkdir /etc/zabbix/scripts && cp scripts/* /etc/zabbix/scripts/ + +cp sudoers /etc/sudoers.d/zabbix + +cp zabbix_agentd.conf.d/userparameter.conf /etc/zabbix/zabbix_agentd.conf.d/userparameter.conf + + +Bitte DEIN_GATEWAY_NAME mit dem Namen deines Gateways ersetzen + +sed -i 's/Server=127.0.0.1/Server=zabbix.itstall.de/g' /etc/zabbix/zabbix_agentd.conf + +sed -i 's/ServerActive=127.0.0.1/ServerActive=zabbix.itstall.de/g' /etc/zabbix/zabbix_agentd.conf + +sed -i 's/Hostname=Zabbix server/Hostname=DEIN_GATEWAY_NAME/g' /etc/zabbix/zabbix_agentd.conf + +sed -i 's/Include=\/etc\/zabbix\/zabbix_agentd.conf.d\//Include=\/etc\/zabbix\/zabbix_agentd.conf.d\/*.conf/g' /etc/zabbix/zabbix_agentd.conf + +service zabbix-agent restart \ No newline at end of file diff --git a/scripts/dhcpd-pools b/scripts/dhcpd-pools new file mode 100755 index 0000000000000000000000000000000000000000..8d7dcb1e4100957f5eeeaa6a7eae0c47a5e254af Binary files /dev/null and b/scripts/dhcpd-pools differ diff --git a/scripts/dhcppools.sh b/scripts/dhcppools.sh new file mode 100755 index 0000000000000000000000000000000000000000..9617baa5918fc96c3ae5be9547624322ac66a360 --- /dev/null +++ b/scripts/dhcppools.sh @@ -0,0 +1,16 @@ +#!/bin/bash +pools_all=`/etc/zabbix/scripts/dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L02|egrep -io "^[a-z]*(\-|\_)?[a-z]*"` +pools_qtd=`echo $pools_all|wc -w` +retorno=`echo -e "{\n\t\t"\"data\"":["` +for p in $pools_all +do + if [ "$pools_qtd" -le "1" ] + then + retorno=$retorno`echo -e "\n\t\t{\"{#DHCPPOOL}\":\"$p\"}"` + else + retorno=$retorno`echo -e "\n\t\t{\"{#DHCPPOOL}\":\"$p\"},"` + fi + pools_qtd=$(($pools_qtd - 1)) +done +retorno=$retorno`echo -e "]}"` +echo -e $retorno diff --git a/scripts/route-table42-reachable.sh b/scripts/route-table42-reachable.sh index 1d1272712f7fd27ef36e1f5abd13c894d26c8177..44b757ce4a3e3998ce3067f852f0292d5f6930da 100755 --- a/scripts/route-table42-reachable.sh +++ b/scripts/route-table42-reachable.sh @@ -1,7 +1,7 @@ #!/bin/sh TARGET=8.8.8.8 PACKETMARK=1 -GATEWAY_IP=#CHANGEME +GATEWAY_IP=$1 NUMPROBES=4 THRESHOLD=2 diff --git a/scripts/route-table42-reachable6.sh b/scripts/route-table42-reachable6.sh index f8f1237b2eadbe9ed7c311e8c7fbd9b69792e595..08c1232ca3b726c1d7811bc9af7bba9ee8b0dee3 100755 --- a/scripts/route-table42-reachable6.sh +++ b/scripts/route-table42-reachable6.sh @@ -1,7 +1,7 @@ #!/bin/sh TARGET=2001:4860:4860::8888 PACKETMARK=1 -GATEWAY_IP6=#CHANGEME +GATEWAY_IP6=$1 NUMPROBES=4 THRESHOLD=2 diff --git a/sudoers b/sudoers new file mode 100644 index 0000000000000000000000000000000000000000..28ba0bf42aaef2378ab07e413da210cbe5605a30 --- /dev/null +++ b/sudoers @@ -0,0 +1,8 @@ +zabbix ALL=NOPASSWD: /etc/zabbix/scripts/batman-gateway-mode-enabled.sh +zabbix ALL=NOPASSWD: /etc/zabbix/scripts/batman-maximum-gateway-metric.sh +zabbix ALL=NOPASSWD: /etc/zabbix/scripts/batman-visible-gateway-count.sh +zabbix ALL=NOPASSWD: /etc/zabbix/scripts/route-table42-reachable6.sh +zabbix ALL=NOPASSWD: /etc/zabbix/scripts/route-table42-reachable.sh +zabbix ALL=NOPASSWD: /etc/zabbix/scripts/batman_originators.sh +zabbix ALL=NOPASSWD: /etc/zabbix/scripts/radvd_adv_count +zabbix ALL=NOPASSWD: /usr/local/sbin/batctl diff --git a/sudoers.d/zabbix b/sudoers.d/zabbix deleted file mode 100644 index f86053adb06568eae3a463ce6434af9b2140fe9a..0000000000000000000000000000000000000000 --- a/sudoers.d/zabbix +++ /dev/null @@ -1,7 +0,0 @@ -zabbix ALL= NOPASSWD: /etc/zabbix/scripts/batman-gateway-mode-enabled.sh -zabbix ALL= NOPASSWD: /etc/zabbix/scripts/batman-maximum-gateway-metric.sh -zabbix ALL= NOPASSWD: /etc/zabbix/scripts/batman-visible-gateway-count.sh -zabbix ALL= NOPASSWD: /etc/zabbix/scripts/route-table42-reachable6.sh -zabbix ALL= NOPASSWD: /etc/zabbix/scripts/route-table42-reachable.sh -zabbix ALL= NOPASSWD: /etc/zabbix/scripts/batman_originators.sh -zabbix ALL= NOPASSWD: /etc/zabbix/scripts/radvd_adv_count \ No newline at end of file diff --git a/zabbix_agentd.conf.d/userparameter.conf b/zabbix_agentd.conf.d/userparameter.conf new file mode 100644 index 0000000000000000000000000000000000000000..c0980f3a5fc3c3edd9d11aaa0d386701f9a30133 --- /dev/null +++ b/zabbix_agentd.conf.d/userparameter.conf @@ -0,0 +1,18 @@ +UserParameter=route-table42-reachable,sudo /etc/zabbix/scripts/route-table42-reachable.sh +UserParameter=route-table42-reachable6,sudo /etc/zabbix/scripts/route-table42-reachable6.sh +UserParameter=dhcp.pool.all,/etc/zabbix/scripts/dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L22 +UserParameter=dhcp.pool.max[*],/etc/zabbix/scripts/dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L22|grep -i $1|sed 's/ \+/;/g'|cut -d';' -f2 +UserParameter=dhcp.pool.use[*],/etc/zabbix/scripts/dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L22|grep -i $1|sed 's/ \+/;/g'|cut -d';' -f3 +UserParameter=dhcp.pool.percent[*],/etc/zabbix/scripts/dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L22|grep -i $1|sed 's/ \+/;/g'|cut -d';' -f4 +UserParameter=dhcp.pool.touch[*],/etc/zabbix/scripts/dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L22|grep -i $1|sed 's/ \+/;/g'|cut -d';' -f5 +UserParameter=dhcp.pool.discovery,/etc/zabbix/scripts/dhcppools.sh +UserParameter=dhcp_server_running,/etc/zabbix/scripts/dhcp_server_running.sh +UserParameter=ip_conntrack_count,/etc/zabbix/scripts/conntrack_count.sh +UserParameter=ip_conntrack_max,/etc/zabbix/scripts/conntrack_max.sh +UserParameter=batman-gateway-mode-enabled,sudo /etc/zabbix/scripts/batman-gateway-mode-enabled.sh +UserParameter=batman-maximum-gateway-metric,sudo /etc/zabbix/scripts/batman-maximum-gateway-metric.sh +UserParameter=batman-visible-gateway-count,sudo /etc/zabbix/scripts/batman-visible-gateway-count.sh +UserParameter=batman-visible-originators,sudo /etc/zabbix/scripts/batman_originators.sh +UserParameter=radvd_adv_count,sudo /etc/zabbix/scripts/radvd_adv_count +UserParameter=batctl-announcement-down, sudo /usr/local/sbin/batctl gw | awk '{ print $4}' |tr -d ')' |tr -d 'MBit'| awk -F '/' '{print $1}' +UserParameter=batctl-announcement-up, sudo /usr/local/sbin/batctl gw | awk '{ print $4}' |tr -d ')' |tr -d 'MBit'| awk -F '/' '{print $2}' diff --git a/zabbix_agentd.d/userparameter.conf b/zabbix_agentd.d/userparameter.conf deleted file mode 100644 index c2f4e0fb3e4b508337bde2b3cf0e7ff2afcb7469..0000000000000000000000000000000000000000 --- a/zabbix_agentd.d/userparameter.conf +++ /dev/null @@ -1,16 +0,0 @@ -UserParameter=route-table42-reachable,sudo /etc/zabbix/scripts/route-table42-reachable.sh -UserParameter=route-table42-reachable6,sudo /etc/zabbix/scripts/route-table42-reachable6.sh -UserParameter=dhcp.pool.all,dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L22 -UserParameter=dhcp.pool.max[*],dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L22|grep -i $1|sed 's/ \+/;/g'|cut -d';' -f2 -UserParameter=dhcp.pool.use[*],dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L22|grep -i $1|sed 's/ \+/;/g'|cut -d';' -f3 -UserParameter=dhcp.pool.percent[*],dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L22|grep -i $1|sed 's/ \+/;/g'|cut -d';' -f4 -UserParameter=dhcp.pool.touch[*],dhcpd-pools -c /etc/dhcp/dhcpd.conf -l /var/lib/dhcp/dhcpd.leases -L22|grep -i $1|sed 's/ \+/;/g'|cut -d';' -f5 -UserParameter=dhcp.pool.discovery,/etc/zabbix/scripts/dhcppools.sh -UserParameter=dhcp_server_running,/etc/zabbix/scripts/dhcp_server_running.sh -UserParameter=ip_conntrack_count,/etc/zabbix/scripts/conntrack_count.sh -UserParameter=ip_conntrack_max,/etc/zabbix/scripts/conntrack_max.sh -UserParameter=batman-gateway-mode-enabled,sudo /etc/zabbix/scripts/batman-gateway-mode-enabled.sh -UserParameter=batman-maximum-gateway-metric,sudo /etc/zabbix/scripts/batman-maximum-gateway-metric.sh -UserParameter=batman-visible-gateway-count,sudo /etc/zabbix/scripts/batman-visible-gateway-count.sh -UserParameter=batman-visible-originators,sudo /etc/zabbix/scripts/batman_originators.sh -UserParameter=radvd_adv_count,sudo /etc/zabbix/scripts/radvd_adv_count \ No newline at end of file