MikoPBX
Модули
Перевод этой страницы:
MikoPBX
Модули
Это старая версия документа!
Обратно к инструкциям Опишем ручной способ настройки и запуска Zabbix агента.
mkdir -p /storage/usbdisk1/mikopbx/custom_modules/zabbix/scripts
cat > /storage/usbdisk1/mikopbx/custom_modules/zabbix/zabbix_agentd.conf
Server=172.16.156.181 ServerActive=172.16.156.181 Hostname=mikopbx AllowRoot=1 LogType=system UserParameter=asterisk[*],/storage/usbdisk1/mikopbx/custom_modules/zabbix/scripts/asterisk-stats.sh $1
cat > /etc/zabbix/scripts/asterisk-stats.sh
#!/bin/sh ASTERISK='/usr/sbin/asterisk'; PHP_INFO="$(dirname "$0")/AsteriskInfo.php"; status(){ pidData=$(/bin/busybox ps | /bin/busybox grep '/usr/sbin/asterisk -f' | /bin/busybox grep -v grep); if [ "${pidData}x" = "x" ]; then echo 0 else echo 1 fi } statusReload(){ reloadTime=$("$ASTERISK" -rx "core show uptime seconds" | awk -F": " '/Last reload/{print$2}'); if [ -z "$reloadTime" ];then echo "Asterisk has not been reloaded yet" else printf '%dd:%dh:%dm:%ds\n' $((reloadTime/86400)) $((reloadTime%86400/3600)) $((reloadTime%3600/60)) $((reloadTime%60)) fi } statusUptime(){ upTime=$("$ASTERISK" -rx "core show uptime seconds" | awk -F ": " '/System uptime/{print$2}'); if [ -z "$upTime" ];then echo "Asterisk is not up" else printf '%dd:%dh:%dm:%ds\n' $((upTime/86400)) $((upTime%86400/3600)) $((upTime%3600/60)) $((upTime%60)) fi } callsActive(){ CALL=$("$ASTERISK" -rx "core show channels" | grep "active call"| awk '{print$1}'); echo "$CALL" } channelsActive(){ CHANNEL=$("$ASTERISK" -rx "core show channels" | grep "active channels" | awk '{print $1}') echo "$CHANNEL" } callsProcessed(){ CALL=$("$ASTERISK" -rx "core show channels" |grep "calls processed"|awk '{print$1}'); echo "$CALL" } ### Execute the argument $1
cat > /etc/zabbix/scripts/starter.sh
#!/bin/sh confFile="$(/bin/busybox dirname "$(/bin/busybox dirname "$0")")/zabbix_agentd.conf"; pidData=$(/bin/busybox ps | /bin/busybox grep "$confFile" | /bin/busybox grep -v grep); if [ -z "$pidData" ];then /usr/sbin/zabbix_agentd -c "$confFile"; fi
chmod +x /storage/usbdisk1/mikopbx/custom_modules/zabbix/scripts/*
*/5 * * * * /storage/usbdisk1/mikopbx/custom_modules/zabbix/scripts/starter.sh > /dev/null 2> /dev/null