Updated dir and install script
This commit is contained in:
parent
3447a0374e
commit
674b6cd43e
|
|
@ -1,2 +1,83 @@
|
|||
#!/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
|
||||
|
||||
echo "Install completed!"
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#aster=$(/etc/init.d/asterisk 'status' | /bin/grep -P 'dead|inactive')
|
||||
asterctl=$(/usr/bin/sudo /usr/sbin/asterisk -rx 'module show' | grep -P 'res_rtp_asterisk.so')
|
||||
|
||||
if [ -z "$asterctl" ] # if [ -n "$aster" ]
|
||||
then
|
||||
echo 0
|
||||
else
|
||||
echo 1
|
||||
fi
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/bash
|
||||
notok=`/usr/bin/sudo /usr/sbin/asterisk -rx 'sip show peers' | grep -E "^\<[0-9]{3}\>" | grep -vc OK`
|
||||
if [ $notok == "0" ]
|
||||
then
|
||||
echo 0
|
||||
else
|
||||
peer_down=`/usr/bin/sudo /usr/sbin/asterisk -rx 'sip show peers' | grep UN | grep -oE "^\<[0-9]{3}\>"`
|
||||
echo -e "\n$peer_down" | sed 's/$/::/g' #| head -c 3
|
||||
#echo ""
|
||||
fi
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Get all pjsip trunks
|
||||
number_trunks=`/usr/bin/sudo /usr/sbin/asterisk -rx "pjsip show registrations" | grep "Objects found" | awk '{print $3}'`
|
||||
|
||||
# Get registered pjsip trunks
|
||||
reg_tranks=`/usr/bin/sudo /usr/sbin/asterisk -rx "pjsip show registrations" | grep Registered | wc -l`
|
||||
|
||||
# Calculate diff
|
||||
let result=($number_trunks-$reg_tranks)
|
||||
|
||||
# Echo result
|
||||
#echo $result
|
||||
if [ $result == "0" ]
|
||||
then
|
||||
echo 0
|
||||
else
|
||||
trunks_rej=`/usr/bin/sudo /usr/sbin/asterisk -rx 'pjsip show registrations' | grep Rejec | grep -oE "^.{12}"`
|
||||
trunks_unreg=`/usr/bin/sudo /usr/sbin/asterisk -rx 'pjsip show registrations' | grep Unregi | grep -oE "^.{12}"`
|
||||
#echo "$peer_down" | head -c 3
|
||||
trunks_down="$trunks_rej$trunks_unreg"
|
||||
echo -e "\n$trunks_down" | sed 's/$/::/g'
|
||||
#echo ""
|
||||
fi
|
||||
Loading…
Reference in New Issue