#!/bin/bash # Check zabbix dir ZBXDIR="/etc/zabbix" if [[ -d "$ZBXDIR" ]] then echo "Directory $ZBXDIR exist. Continue..." else echo "Directory $ZBXDIR does not exist! Please install zabbix (agent) first! Exiting." exit 25 fi # Creating dirs mkdir /etc/zabbix/scripts mkdir /etc/zabbix/scripts/asterisk # Install scripts echo "1 - SIP only scripts" echo "2 - SIP peers and pjsip trunks" read -r -p "Please choose agent scripts type [default: 1]:" response if [ -z "$response" ]; then response="1" fi case "$response" in "1") echo "Installing siponly agent scripts" cp -r ./siponly/* /etc/zabbix/scripts/asterisk/ ;; "2") echo "Installing sip peers and pjsip trunks agent script" /usr/sbin/fwconsole stop cp -r ./sip-peers_pjsip-trunks/* /etc/zabbix/scripts/asterisk ;; *) echo "Incorrect input. Aborted." exit 25 ;; esac chown -R zabbix:zabbix /etc/zabbix/scripts/asterisk chmod +x /etc/zabbix/scripts/asterisk/* # Check agentd dir if [[ -d "/etc/zabbix/zabbix_agentd.conf.d" ]] then AGTD="zabbix_agentd.conf.d" else AGTD="/zabbix_agentd.d" fi # add items conf touch /etc/zabbix/$AGTD/asterisk.conf echo "UserParameter=asterisk.trunk,/etc/zabbix/scripts/asterisk/trunk.sh" >> /etc/zabbix/$AGTD/asterisk.conf echo "UserParameter=asterisk.aster,/etc/zabbix/scripts/asterisk/aster.sh" >> /etc/zabbix/$AGTD/asterisk.conf echo "UserParameter=asterisk.peers,/etc/zabbix/scripts/asterisk/peers.sh" >> /etc/zabbix/$AGTD/asterisk.conf chown -R zabbix:zabbix /etc/zabbix/$AGTD/asterisk.conf # Add sudo nopasswd for zabbix echo "#zabbix-agent" >> /etc/sudoers echo "zabbix ALL= NOPASSWD: /bin/grep, /bin/cut, /usr/sbin/asterisk" >> /etc/sudoers # Restarting zabbix agent echo "Restarting zabbix agent..." systemctl restart zabbix-agent systemctl enable zabbix-agent echo "Install completed!"