From b1f3bdc1c1529ef545f6cdbc1c44e39d58b931bc Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Mon, 4 Oct 2021 13:48:48 -0400 Subject: [PATCH] latest updates --- .../files/drachtio.service | 4 +- packer/jambonz-feature-server/template.json | 2 +- packer/jambonz-mini/files/drachtio.conf.xml | 6 +- packer/jambonz-mini/files/drachtio.service | 2 +- packer/jambonz-mini/files/ecosystem.config.js | 197 ++- packer/jambonz-mini/files/freeswitch.service | 1 + .../files/freeswitch_log_rotation | 2 +- packer/jambonz-mini/files/mrf_sip_profile.xml | 5 +- packer/jambonz-mini/files/rtpengine.service | 6 +- packer/jambonz-mini/scripts/install_app.sh | 45 +- .../jambonz-mini/scripts/install_drachtio.sh | 19 +- .../scripts/install_freeswitch.sh | 142 +- packer/jambonz-mini/scripts/install_nodejs.sh | 2 +- .../jambonz-mini/scripts/install_rtpengine.sh | 7 + packer/jambonz-mini/template.json | 108 +- .../files/grafana-dashboard-jambonz.json | 1440 +++++++++++++++-- .../scripts/install_homer.sh | 1 + packer/jambonz-sbc-rtp/files/telegraf.conf | 2 +- packer/jambonz-sbc-rtp/template.json | 2 +- .../jambonz-sbc-sip-rtp/files/telegraf.conf | 2 +- .../files/auto-assign-elastic-ip.sh | 100 ++ packer/jambonz-sbc-sip/files/drachtio.service | 3 +- .../jambonz-sbc-sip/files/ecosystem.config.js | 28 + packer/jambonz-sbc-sip/files/vimrc.local | 5 - .../jambonz-sbc-sip/scripts/install_apiban.sh | 2 +- packer/jambonz-sbc-sip/scripts/install_app.sh | 7 +- .../scripts/install_drachtio.sh | 4 + packer/jambonz-sbc-sip/template.json | 3 +- packer/jambonz-web-server/files/telegraf.conf | 2 +- 29 files changed, 1859 insertions(+), 290 deletions(-) create mode 100644 packer/jambonz-sbc-sip/files/auto-assign-elastic-ip.sh delete mode 100644 packer/jambonz-sbc-sip/files/vimrc.local diff --git a/packer/jambonz-feature-server/files/drachtio.service b/packer/jambonz-feature-server/files/drachtio.service index 4434515..7fcc925 100644 --- a/packer/jambonz-feature-server/files/drachtio.service +++ b/packer/jambonz-feature-server/files/drachtio.service @@ -7,7 +7,9 @@ After=syslog.target network.target local-fs.target ; service Type=forking ExecStartPre=/bin/sh -c 'systemctl set-environment LOCAL_IP=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`' -ExecStart=/usr/local/bin/drachtio --daemon --contact sip:${LOCAL_IP};transport=udp,tcp --address 0.0.0.0 --port 9022 +ExecStart=/usr/local/bin/drachtio --daemon --contact sip:${LOCAL_IP};transport=udp,tcp \ +--address 0.0.0.0 --port 9022 \ +--prometheus-scrape-port 9090 TimeoutSec=15s Restart=always ; exec diff --git a/packer/jambonz-feature-server/template.json b/packer/jambonz-feature-server/template.json index 24c9189..182031d 100644 --- a/packer/jambonz-feature-server/template.json +++ b/packer/jambonz-feature-server/template.json @@ -4,7 +4,7 @@ "ssh_username": "admin", "ami_description": "jambonz feature server", "instance_type": "t2.xlarge", - "drachtio_version": "v0.8.11-rc1", + "drachtio_version": "v0.8.11-rc2", "jambonz_version": "v0.6.6", "install_telegraf": "yes", "install_datadog": "no" diff --git a/packer/jambonz-mini/files/drachtio.conf.xml b/packer/jambonz-mini/files/drachtio.conf.xml index 5716e3f..e7751b7 100644 --- a/packer/jambonz-mini/files/drachtio.conf.xml +++ b/packer/jambonz-mini/files/drachtio.conf.xml @@ -28,8 +28,8 @@ 3 - + info - - + + \ No newline at end of file diff --git a/packer/jambonz-mini/files/drachtio.service b/packer/jambonz-mini/files/drachtio.service index fe130ce..9e74366 100644 --- a/packer/jambonz-mini/files/drachtio.service +++ b/packer/jambonz-mini/files/drachtio.service @@ -10,7 +10,7 @@ ExecStartPre=/bin/sh -c 'systemctl set-environment LOCAL_IP=`curl -s http://169. ExecStartPre=/bin/sh -c 'systemctl set-environment PUBLIC_IP=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`' ExecStart=/usr/local/bin/drachtio --daemon --contact sip:${LOCAL_IP};transport=udp --external-ip ${PUBLIC_IP} \ --contact sip:${LOCAL_IP};transport=tcp \ - --address 0.0.0.0 --port 9022 + --address 0.0.0.0 --port 9022 --homer 127.0.0.1:9060 --homer-id 10 TimeoutSec=15s Restart=always ; exec diff --git a/packer/jambonz-mini/files/ecosystem.config.js b/packer/jambonz-mini/files/ecosystem.config.js index ea58046..a818a6c 100644 --- a/packer/jambonz-mini/files/ecosystem.config.js +++ b/packer/jambonz-mini/files/ecosystem.config.js @@ -1,5 +1,11 @@ module.exports = { apps : [ + { + name: 'jambonz-webapp', + script: 'npm', + cwd: '/home/admin/apps/jambonz-webapp', + args: 'run serve' + }, { name: 'jambonz-api-server', cwd: '/home/admin/apps/jambonz-api-server', @@ -15,18 +21,54 @@ module.exports = { max_memory_restart: '1G', env: { NODE_ENV: 'production', - JAMBONES_MYSQL_HOST: '$${JAMBONES_MYSQL_HOST}', - JAMBONES_MYSQL_USER: '$${JAMBONES_MYSQL_USER}', - JAMBONES_MYSQL_PASSWORD: '$${JAMBONES_MYSQL_PASSWORD}', + JAMBONES_MYSQL_HOST: '127.0.0.1', + JAMBONES_MYSQL_USER: 'admin', + JAMBONES_MYSQL_PASSWORD: 'JambonzR0ck$', JAMBONES_MYSQL_DATABASE: 'jambones', JAMBONES_MYSQL_CONNECTION_LIMIT: 10, - JAMBONES_REDIS_HOST: '$${JAMBONES_REDIS_HOST}', + JAMBONES_REDIS_HOST: '127.0.0.1', JAMBONES_REDIS_PORT: 6379, JAMBONES_LOGLEVEL: 'info', JAMBONE_API_VERSION: 'v1', - JAMBONES_CREATE_CALL_URL: 'http://127.0.0.1:4001/v1/createCall', - HTTP_PORT: 3000 - }, + JAMBONES_TIME_SERIES_HOST: '127.0.0.1', + ENABLE_METRICS: 1, + STATS_HOST: '127.0.0.1', + STATS_PORT: 8125, + STATS_PROTOCOL: 'tcp', + STATS_TELEGRAF: 1, + HTTP_PORT: 3002, + HOMER_BASE_URL: 'http://127.0.0.1:9080', + HOMER_USERNAME: 'admin', + HOMER_PASSWORD: 'sipcapture' + } + }, + { + name: 'sbc-options-handler', + cwd: '/home/admin/apps/sbc-options-handler', + script: 'app.js', + instance_var: 'INSTANCE_ID', + out_file: '/home/admin/.pm2/logs/jambonz-sbc-options-handler.log', + err_file: '/home/admin/.pm2/logs/jambonz-sbc-options-handler.log', + exec_mode: 'fork', + instances: 1, + autorestart: true, + watch: false, + max_memory_restart: '1G', + env: { + NODE_ENV: 'production', + JAMBONES_LOGLEVEL: 'info', + DRACHTIO_HOST: '127.0.0.1', + DRACHTIO_PORT: 9022, + DRACHTIO_SECRET: 'cymru', + JAMBONES_REDIS_HOST: '127.0.0.1', + JAMBONES_REDIS_PORT: 6379, + ENABLE_METRICS: 1, + STATS_HOST: '127.0.0.1', + STATS_PORT: 8125, + STATS_PROTOCOL: 'tcp', + STATS_TELEGRAF: 1, + JAMBONES_NETWORK_CIDR: 'PRIVATE_IP/32' + } }, { name: 'sbc-call-router', @@ -46,45 +88,12 @@ module.exports = { JAMBONES_INBOUND_ROUTE: '127.0.0.1:4002', JAMBONES_OUTBOUND_ROUTE: '127.0.0.1:4003', JAMBONZ_TAGGED_INBOUND: 1, - JAMBONES_NETWORK_CIDR: '172.31.32.0/24' - } - }, - { - name: 'jambonz-feature-server', - cwd: '/home/admin/apps/jambonz-feature-server', - script: 'app.js', - instance_var: 'INSTANCE_ID', - out_file: '/home/admin/.pm2/logs/jambonz-feature-server.log', - err_file: '/home/admin/.pm2/logs/jambonz-feature-server.log', - exec_mode: 'fork', - instances: 1, - autorestart: true, - watch: false, - max_memory_restart: '1G', - env: { - NODE_ENV: 'production', - GOOGLE_APPLICATION_CREDENTIALS: '/home/admin/credentials/$${GOOGLE_APPLICATION_CREDENTIALS}', - AWS_ACCESS_KEY_ID: '$${AWS_ACCESS_KEY_ID}', - AWS_SECRET_ACCESS_KEY: '${{AWS_SECRET_ACCESS_KEY}', - AWS_REGION: '$${AWS_REGION}', - ENABLE_DATADOG_METRICS: 0, - ENABLE_DATADOG_METRICS: 0, - JAMBONES_NETWORK_CIDR: '172.31.32.0/24', - JAMBONES_MYSQL_HOST: '$${JAMBONES_MYSQL_HOST}', - JAMBONES_MYSQL_USER: '$${JAMBONES_MYSQL_USER}', - JAMBONES_MYSQL_PASSWORD: '$${JAMBONES_MYSQL_PASSWORD}', - JAMBONES_MYSQL_DATABASE: 'jambones', - JAMBONES_MYSQL_CONNECTION_LIMIT: 10, - JAMBONES_REDIS_HOST: '$${JAMBONES_REDIS_HOST}', - JAMBONES_REDIS_PORT: 6379, - JAMBONES_LOGLEVEL: 'debug', - HTTP_PORT: 4001, - DRACHTIO_HOST: '127.0.0.1', - DRACHTIO_PORT: 9023, - DRACHTIO_SECRET: 'cymru', - JAMBONES_SBCS: '172.31.32.100:5060', - JAMBONES_FEATURE_SERVERS: '127.0.0.1:9023:cymru', - JAMBONES_FREESWITCH: '127.0.0.1:8021:JambonzR0ck$' + ENABLE_METRICS: 1, + STATS_HOST: '127.0.0.1', + STATS_PORT: 8125, + STATS_PROTOCOL: 'tcp', + STATS_TELEGRAF: 1, + JAMBONES_NETWORK_CIDR: 'PRIVATE_IP/32' } }, { @@ -101,18 +110,24 @@ module.exports = { max_memory_restart: '1G', env: { NODE_ENV: 'production', - ENABLE_DATADOG_METRICS: 0, JAMBONES_LOGLEVEL: 'debug', + RTPENGINE_PING_INTERVAL: 30000, DRACHTIO_HOST: '127.0.0.1', DRACHTIO_PORT: 9022, DRACHTIO_SECRET: 'cymru', - JAMBONES_MYSQL_HOST: '$${JAMBONES_MYSQL_HOST}', - JAMBONES_MYSQL_USER: '$${JAMBONES_MYSQL_USER}', - JAMBONES_MYSQL_PASSWORD: '$${JAMBONES_MYSQL_PASSWORD}', + JAMBONES_MYSQL_HOST: '127.0.0.1', + JAMBONES_MYSQL_USER: 'admin', + JAMBONES_MYSQL_PASSWORD: 'JambonzR0ck$', JAMBONES_MYSQL_DATABASE: 'jambones', JAMBONES_MYSQL_CONNECTION_LIMIT: 10, - JAMBONES_REDIS_HOST: '$${JAMBONES_REDIS_HOST}', + JAMBONES_REDIS_HOST: '127.0.0.1', JAMBONES_REDIS_PORT: 6379, + JAMBONES_TIME_SERIES_HOST: '127.0.0.1', + ENABLE_METRICS: 1, + STATS_HOST: '127.0.0.1', + STATS_PORT: 8125, + STATS_PROTOCOL: 'tcp', + STATS_TELEGRAF: 1 } }, { @@ -129,19 +144,27 @@ module.exports = { max_memory_restart: '1G', env: { NODE_ENV: 'production', - JAMBONES_LOGLEVEL: 'debug', - ENABLE_DATADOG_METRICS: 0, + JAMBONES_LOGLEVEL: 'info', + MIN_CALL_LIMIT: 9999, + RTPENGINE_PING_INTERVAL: 30000, DRACHTIO_HOST: '127.0.0.1', DRACHTIO_PORT: 9022, DRACHTIO_SECRET: 'cymru', JAMBONES_RTPENGINES: '127.0.0.1:22222', - JAMBONES_MYSQL_HOST: '$${JAMBONES_MYSQL_HOST}', - JAMBONES_MYSQL_USER: '$${JAMBONES_MYSQL_USER}', - JAMBONES_MYSQL_PASSWORD: '$${JAMBONES_MYSQL_PASSWORD}', + JAMBONES_MYSQL_HOST: '127.0.0.1', + JAMBONES_MYSQL_USER: 'admin', + JAMBONES_MYSQL_PASSWORD: 'JambonzR0ck$', JAMBONES_MYSQL_DATABASE: 'jambones', JAMBONES_MYSQL_CONNECTION_LIMIT: 10, - JAMBONES_REDIS_HOST: '$${JAMBONES_REDIS_HOST}', + JAMBONES_REDIS_HOST: '127.0.0.1', JAMBONES_REDIS_PORT: 6379, + JAMBONES_TIME_SERIES_HOST: '127.0.0.1', + ENABLE_METRICS: 1, + STATS_HOST: '127.0.0.1', + STATS_PORT: 8125, + STATS_PROTOCOL: 'tcp', + STATS_TELEGRAF: 1, + MS_TEAMS_FQDN: '' } }, { @@ -158,20 +181,66 @@ module.exports = { max_memory_restart: '1G', env: { NODE_ENV: 'production', + JAMBONES_NETWORK_CIDR: 'PRIVATE_IP/32', JAMBONES_LOGLEVEL: 'debug', - ENABLE_DATADOG_METRICS: 0, DRACHTIO_HOST: '127.0.0.1', DRACHTIO_PORT: 9022, DRACHTIO_SECRET: 'cymru', - JAMBONES_FEATURE_SERVERS: '172.31.3.33:5070', JAMBONES_RTPENGINES: '127.0.0.1:22222', - JAMBONES_MYSQL_HOST: '$${JAMBONES_MYSQL_HOST}', - JAMBONES_MYSQL_USER: '$${JAMBONES_MYSQL_USER}', - JAMBONES_MYSQL_PASSWORD: '$${JAMBONES_MYSQL_PASSWORD}', + JAMBONES_MYSQL_HOST: '127.0.0.1', + JAMBONES_MYSQL_USER: 'admin', + JAMBONES_MYSQL_PASSWORD: 'JambonzR0ck$', JAMBONES_MYSQL_DATABASE: 'jambones', JAMBONES_MYSQL_CONNECTION_LIMIT: 10, - JAMBONES_REDIS_HOST: '$${JAMBONES_REDIS_HOST}', + JAMBONES_REDIS_HOST: '127.0.0.1', JAMBONES_REDIS_PORT: 6379, + JAMBONES_TIME_SERIES_HOST: '127.0.0.1', + ENABLE_METRICS: 1, + STATS_HOST: '127.0.0.1', + STATS_PORT: 8125, + STATS_PROTOCOL: 'tcp', + STATS_TELEGRAF: 1, + MS_TEAMS_SIP_PROXY_IPS: '52.114.148.0, 52.114.132.46, 52.114.75.24, 52.114.76.76, 52.114.7.24, 52.114.14.70' } - }] + }, + { + name: 'jambonz-feature-server', + cwd: '/home/admin/apps/jambonz-feature-server', + script: 'app.js', + instance_var: 'INSTANCE_ID', + out_file: '/home/admin/.pm2/logs/jambonz-feature-server.log', + err_file: '/home/admin/.pm2/logs/jambonz-feature-server.log', + exec_mode: 'fork', + instances: 1, + autorestart: true, + watch: false, + max_memory_restart: '1G', + env: { + NODE_ENV: 'production', + GOOGLE_APPLICATION_CREDENTIALS: '/home/admin/credentials/gcp.json', + AWS_REGION: 'AWS_REGION_HERE', + ENABLE_METRICS: 1, + STATS_HOST: '127.0.0.1', + STATS_PORT: 8125, + STATS_PROTOCOL: 'tcp', + STATS_TELEGRAF: 1, + JAMBONES_NETWORK_CIDR: 'PRIVATE_IP/32', + JAMBONES_MYSQL_HOST: '127.0.0.1', + JAMBONES_MYSQL_USER: 'admin', + JAMBONES_MYSQL_PASSWORD: 'JambonzR0ck$', + JAMBONES_MYSQL_DATABASE: 'jambones', + JAMBONES_MYSQL_CONNECTION_LIMIT: 10, + JAMBONES_REDIS_HOST: '127.0.0.1', + JAMBONES_REDIS_PORT: 6379, + JAMBONES_LOGLEVEL: 'debug', + JAMBONES_TIME_SERIES_HOST: '127.0.0.1', + HTTP_PORT: 3000, + DRACHTIO_HOST: '127.0.0.1', + DRACHTIO_PORT: 9023, + DRACHTIO_SECRET: 'cymru', + JAMBONES_SBCS: 'PRIVATE_IP', + JAMBONES_FREESWITCH: '127.0.0.1:8021:JambonzR0ck$' + } + } +] }; \ No newline at end of file diff --git a/packer/jambonz-mini/files/freeswitch.service b/packer/jambonz-mini/files/freeswitch.service index 7d6a2ba..a40b612 100644 --- a/packer/jambonz-mini/files/freeswitch.service +++ b/packer/jambonz-mini/files/freeswitch.service @@ -12,6 +12,7 @@ Environment="MOD_AUDIO_FORK_SUBPROTOCOL_NAME=audio.jambonz.org" Environment="MOD_AUDIO_FORK_SERVICE_THREADS=1" Environment="MOD_AUDIO_FORK_BUFFER_SECS=3" Environment="LD_LIBRARY_PATH=/usr/local/lib" +Environment="GOOGLE_APPLICATION_CREDENTIALS=/home/admin/credentials/gcp.json" ExecStart=/usr/local/freeswitch/bin/freeswitch -nc -nonat TimeoutSec=45s Restart=always diff --git a/packer/jambonz-mini/files/freeswitch_log_rotation b/packer/jambonz-mini/files/freeswitch_log_rotation index 1ce6509..6028983 100644 --- a/packer/jambonz-mini/files/freeswitch_log_rotation +++ b/packer/jambonz-mini/files/freeswitch_log_rotation @@ -7,7 +7,7 @@ # #number of days of logs to keep -NUMBERDAYS=30 +NUMBERDAYS=5 FSPATH=/usr/local/freeswitch/ $FSPATH/bin/fs_cli -x "fsctl send_sighup" |grep '+OK' >/tmp/rotateFSlogs diff --git a/packer/jambonz-mini/files/mrf_sip_profile.xml b/packer/jambonz-mini/files/mrf_sip_profile.xml index 1dcbb26..ba7559c 100644 --- a/packer/jambonz-mini/files/mrf_sip_profile.xml +++ b/packer/jambonz-mini/files/mrf_sip_profile.xml @@ -8,7 +8,6 @@ - @@ -33,13 +32,13 @@ - + - + diff --git a/packer/jambonz-mini/files/rtpengine.service b/packer/jambonz-mini/files/rtpengine.service index 9579f5d..52361ce 100644 --- a/packer/jambonz-mini/files/rtpengine.service +++ b/packer/jambonz-mini/files/rtpengine.service @@ -6,10 +6,14 @@ After=syslog.target network.target local-fs.target [Service] ; service Type=forking +Environment="LD_LIBRARY_PATH=/usr/local/lib/" ExecStartPre=/bin/sh -c 'systemctl set-environment LOCAL_IP=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`' ExecStartPre=/bin/sh -c 'systemctl set-environment PUBLIC_IP=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`' -ExecStart=/usr/local/bin/rtpengine --interface ${LOCAL_IP}!${PUBLIC_IP} \ +ExecStart=/usr/local/bin/rtpengine \ +--interface private/${LOCAL_IP} \ +--interface public/${LOCAL_IP}!${PUBLIC_IP} \ --listen-ng=22222 \ +--listen-http=8080 \ --listen-udp=12222 \ --listen-cli=127.0.0.1:9900 \ --pidfile /var/run/rtpengine.pid \ diff --git a/packer/jambonz-mini/scripts/install_app.sh b/packer/jambonz-mini/scripts/install_app.sh index 34545aa..ff5ceb8 100755 --- a/packer/jambonz-mini/scripts/install_app.sh +++ b/packer/jambonz-mini/scripts/install_app.sh @@ -1,23 +1,36 @@ #!/bin/bash +VERSION=$1 +DB_USER=$2 +DB_PASS=$3 + cd /home/admin -mkdir apps credentials cp /tmp/ecosystem.config.js apps cd apps -git clone https://github.com/jambonz/sbc-outbound.git -git clone https://github.com/jambonz/sbc-inbound.git -git clone https://github.com/jambonz/sbc-registrar.git -git clone https://github.com/jambonz/sbc-call-router.git -git clone https://github.com/jambonz/jambonz-api-server.git -git clone https://github.com/jambonz/jambonz-feature-server.git +cd /home/admin/apps/jambonz-feature-server && sudo npm install --unsafe-perm +cd /home/admin/apps/fsw-clear-old-calls && npm install && sudo npm install -g . +cd /home/admin/apps/jambonz-api-server && sudo npm install --unsafe-perm +cd /home/admin/apps/jambonz-webapp && sudo npm install --unsafe-perm && npm run build +cd /home/admin/apps/sbc-options-handler && sudo npm install --unsafe-perm +cd /home/admin/apps/sbc-inbound && sudo npm install --unsafe-perm +cd /home/admin/apps/sbc-outbound && sudo npm install --unsafe-perm +cd /home/admin/apps/sbc-registrar && sudo npm install --unsafe-perm +cd /home/admin/apps/sbc-call-router && sudo npm install --unsafe-perm +cd /home/admin/apps/jambonz-api-server && sudo npm install --unsafe-perm -cd /home/admin/apps/sbc-inbound && npm install -cd /home/admin/apps/sbc-outbound && npm install -cd /home/admin/apps/sbc-registrar && npm install -cd /home/admin/apps/sbc-call-router && npm install -cd /home/admin/apps/jambonz-api-server && npm install -cd /home/admin/apps/jambonz-feature-server && npm install +JAMBONES_MYSQL_HOST=localhost JAMBONES_MYSQL_USER=${DB_USER} JAMBONES_MYSQL_PASSWORD=${DB_PASS} JAMBONES_MYSQL_DATABASE=jambones /home/admin/apps/jambonz-api-server/db/reset_admin_password.js -# add entries to /etc/crontab to start everything on reboot -echo "@reboot admin /usr/bin/pm2 start /home/admin/apps/ecosystem.config.js" | sudo tee -a /etc/crontab -echo "@reboot admin sudo env PATH=$PATH:/usr/bin pm2 logrotate -u admin" | sudo tee -a /etc/crontab +echo "0 * * * * root fsw-clear-old-calls --password JambonzR0ck$ >> /var/log/fsw-clear-old-calls.log 2>&1" | sudo tee -a /etc/crontab +echo "0 1 * * * root find /tmp -name \"*.mp3\" -mtime +2 -exec rm {} \; > /dev/null 2>&1" | sudo tee -a /etc/crontab + +sudo -u admin bash -c "pm2 install pm2-logrotate" +sudo -u admin bash -c "pm2 set pm2-logrotate:max_size 1G" +sudo -u admin bash -c "pm2 set pm2-logrotate:retain 5" +sudo -u admin bash -c "pm2 set pm2-logrotate:compress true" + +rm +sudo chown -R admin:admin /home/admin/apps + +sudo rm /home/admin/apps/jambonz-webapp/.env +#sudo cp /tmp/initialize-webapp-userdata.sh /var/lib/cloud/scripts/per-instance +#sudo chmod +x /var/lib/cloud/scripts/per-instance/initialize-webapp-userdata.sh \ No newline at end of file diff --git a/packer/jambonz-mini/scripts/install_drachtio.sh b/packer/jambonz-mini/scripts/install_drachtio.sh index b3102e2..935b8b9 100644 --- a/packer/jambonz-mini/scripts/install_drachtio.sh +++ b/packer/jambonz-mini/scripts/install_drachtio.sh @@ -5,20 +5,21 @@ echo "drachtio version to install is ${VERSION}" chmod 0777 /usr/local/src cd /usr/local/src -git clone https://github.com/davehorton/drachtio-server.git -b ${VERSION} +git clone https://github.com/drachtio/drachtio-server.git -b ${VERSION} cd drachtio-server git submodule update --init --recursive -./autogen.sh && mkdir -p build && cd $_ && ../configure CPPFLAGS='-DNDEBUG' && make && sudo make install +./autogen.sh && mkdir -p build && cd $_ && ../configure CPPFLAGS='-DNDEBUG -g -O0' && make -j 4 && sudo make install + sudo mv /tmp/drachtio.conf.xml /etc -sudo mv /tmp/drachtio-5070.conf.xml /etc sudo mv /tmp/drachtio.service /etc/systemd/system -sudo mv /tmp/drachtio-5070.service /etc/systemd/system -sudo mv /tmp/vimrc.local /etc/vim/vimrc.local sudo chmod 644 /etc/drachtio.conf.xml -sudo chmod 644 /etc/drachtio-5070.conf.xml sudo chmod 644 /etc/systemd/system/drachtio.service -sudo chmod 644 /etc/systemd/system/drachtio-5070.service -sudo chmod 644 /etc/vim/vimrc.local -sudo chown root:root /etc/drachtio.conf.xml /etc/systemd/system/drachtio.service /etc/drachtio-5070.conf.xml /etc/systemd/system/drachtio-5070.service /etc/vim/vimrc.local sudo systemctl enable drachtio +sudo systemctl restart drachtio + +sudo mv /tmp/drachtio-5070.conf.xml /etc +sudo mv /tmp/drachtio-5070.service /etc/systemd/system +sudo chmod 644 /etc/drachtio-5070.conf.xml +sudo chmod 644 /etc/systemd/system/drachtio-5070.service sudo systemctl enable drachtio-5070 +sudo systemctl restart drachtio-5070 diff --git a/packer/jambonz-mini/scripts/install_freeswitch.sh b/packer/jambonz-mini/scripts/install_freeswitch.sh index f2ee4d4..0220e01 100644 --- a/packer/jambonz-mini/scripts/install_freeswitch.sh +++ b/packer/jambonz-mini/scripts/install_freeswitch.sh @@ -1,16 +1,43 @@ #!/bin/bash -VERSION=v1.10.1 -GRPC_VERSION=v1.24.2 +FREESWITCH_VERSION=v1.10.5 +GRPC_VERSION=c66d2cc +#GRPC_VERSION=v1.39.1 +#GOOGLE_API_VERSION=v1p1beta1-speech +GOOGLE_API_VERSION=e9da6f8b469c52b83f900e820be30762e9e05c57 +AWS_SDK_VERSION=1.8.129 +LWS_VERSION=v3.2.3 +MODULES_VERSION=v0.4.0 -echo "freeswitch version to install is ${VERSION}" +echo "freeswitch version to install is ${FREESWITCH_VERSION}" +echo "drachtio modules version to install is ${MODULES_VERSION}" +echo "GRPC version to install is ${GRPC_VERSION}" +echo "GOOGLE_API_VERSION version to install is ${GOOGLE_API_VERSION}" +echo "AWS_SDK_VERSION version to install is ${AWS_SDK_VERSION}" +echo "LWS_VERSION version to install is ${LWS_VERSION}" + +export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH git config --global pull.rebase true cd /usr/local/src -git clone https://github.com/davehorton/freeswitch.git -b ${VERSION} -git clone https://github.com/warmcat/libwebsockets.git -b v3.2.0 -git clone https://github.com/davehorton/drachtio-freeswitch-modules.git -b master +git clone https://github.com/signalwire/freeswitch.git -b ${FREESWITCH_VERSION} +git clone https://github.com/warmcat/libwebsockets.git -b ${LWS_VERSION} +git clone https://github.com/drachtio/drachtio-freeswitch-modules.git -b ${MODULES_VERSION} +git clone https://github.com/grpc/grpc -b master +cd grpc && git checkout ${GRPC_VERSION} && cd .. + +cd freeswitch/libs + +git clone https://github.com/freeswitch/spandsp.git -b master +git clone https://github.com/freeswitch/sofia-sip.git -b master git clone https://github.com/dpirch/libfvad.git +git clone https://github.com/aws/aws-sdk-cpp.git -b ${AWS_SDK_VERSION} +git clone https://github.com/googleapis/googleapis -b master +cd googleapis && git checkout ${GOOGLE_API_VERSION} && cd .. +git clone https://github.com/awslabs/aws-c-common.git + sudo cp -r /usr/local/src/drachtio-freeswitch-modules/modules/mod_audio_fork /usr/local/src/freeswitch/src/mod/applications/mod_audio_fork +sudo cp -r /usr/local/src/drachtio-freeswitch-modules/modules/mod_aws_transcribe /usr/local/src/freeswitch/src/mod/applications/mod_aws_transcribe +sudo cp -r /usr/local/src/drachtio-freeswitch-modules/modules/mod_aws_lex /usr/local/src/freeswitch/src/mod/applications/mod_aws_lex sudo cp -r /usr/local/src/drachtio-freeswitch-modules/modules/mod_google_transcribe /usr/local/src/freeswitch/src/mod/applications/mod_google_transcribe sudo cp -r /usr/local/src/drachtio-freeswitch-modules/modules/mod_google_tts /usr/local/src/freeswitch/src/mod/applications/mod_google_tts sudo cp -r /usr/local/src/drachtio-freeswitch-modules/modules/mod_dialogflow /usr/local/src/freeswitch/src/mod/applications/mod_dialogflow @@ -24,63 +51,67 @@ sudo mkdir -p build && cd build && sudo cmake .. -DCMAKE_BUILD_TYPE=RelWithDebIn # build libfvad cd /usr/local/src/libfvad -sudo autoreconf -i && sudo ./configure && sudo make && sudo make install +sudo autoreconf -i && sudo ./configure && sudo make -j 4 && sudo make install + +# build spandsp +cd /usr/local/src/freeswitch/libs/spandsp +./bootstrap.sh && ./configure && make -j 4 && sudo make install + +# build sofia +cd /usr/local/src/freeswitch/libs/sofia-sip +./bootstrap.sh && ./configure && make -j 4 && sudo make install + +# build aws-c-common +cd /usr/local/src/freeswitch/libs/aws-c-common +mkdir -p build && cd build +cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS="-Wno-unused-parameter" +make -j 4 && sudo make install + +# build aws-sdk-cpp +cd /usr/local/src/freeswitch/libs/aws-sdk-cpp +mkdir -p build && cd build +cmake .. -DBUILD_ONLY="lexv2-runtime;transcribestreaming" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS="-Wno-unused-parameter" +make -j 4 && sudo make install + +# build grpc +cd /usr/local/src/grpc +git submodule update --init --recursive +mkdir -p cmake/build +cd cmake/build +cmake -DBUILD_SHARED_LIBS=ON -DgRPC_SSL_PROVIDER=package -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ../.. +make -j 4 +sudo make install + +# build googleapis +cd /usr/local/src/freeswitch/libs/googleapis +echo "Ref: https://github.com/GoogleCloudPlatform/cpp-samples/issues/113" +sed -i 's/\$fields/fields/' google/maps/routes/v1/route_service.proto +sed -i 's/\$fields/fields/' google/maps/routes/v1alpha/route_service.proto +LANGUAGE=cpp make -j 4 + +# copy Makefiles into place +cp /tmp/configure.ac.extra /usr/local/src/freeswitch/configure.ac +cp /tmp/Makefile.am.extra /usr/local/src/freeswitch/Makefile.am +cp /tmp/modules.conf.in.extra /usr/local/src/freeswitch/build/modules.conf.in +cp /tmp/modules.conf.vanilla.xml.extra /usr/local/src/freeswitch/conf/vanilla/autoload_configs/modules.conf.xml +cp /tmp/switch_rtp.c.patch /usr/local/src/freeswitch/src # patch freeswitch -# basic patches -echo "patching freeswitch for lws and mod_audio_fork" -cd /usr/local/src/freeswitch -sudo cp /tmp/configure.ac.patch . -sudo cp /tmp/Makefile.am.patch . -sudo cp /tmp/modules.conf.in.patch ./build -sudo cp /tmp/modules.conf.vanilla.xml.patch ./conf/vanilla/autoload_configs -sudo cp /tmp/mod_opusfile.c.patch ./src/mod/formats/mod_opusfile -sudo patch < configure.ac.patch -sudo patch < Makefile.am.patch -cd build && sudo patch < modules.conf.in.patch -cd ../conf/vanilla/autoload_configs && patch < modules.conf.vanilla.xml.patch -cd /usr/local/src/freeswitch/src/mod/formats/mod_opusfile && sudo patch < mod_opusfile.c.patch -cd /usr/local/src/freeswitch -#grpc patches -echo "patching freeswitch for GRPC" -sudo cp /tmp/configure.ac.grpc.patch . -sudo cp /tmp/Makefile.am.grpc.patch . -sudo cp /tmp/modules.conf.in.grpc.patch ./build -sudo patch < configure.ac.grpc.patch -sudo patch < Makefile.am.grpc.patch -cd build && sudo patch < modules.conf.in.grpc.patch -cd .. -sudo cp /tmp/modules.conf.vanilla.xml.grpc ./conf/vanilla/autoload_configs/modules.conf.xml - -# checkout and build grpc -echo "building GRPC" -cd /usr/local/src -git clone https://github.com/grpc/grpc -b ${GRPC_VERSION} -cd grpc -git submodule update --init --recursive -cd third_party/protobuf && ./autogen.sh && ./configure && sudo make install -cd /usr/local/src/grpc -export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH && make && sudo make install - -# checkout and build googleapis -echo "building googleapis" -cd /usr/local/src/freeswitch/libs -git clone https://github.com/davehorton/googleapis -b dialogflow-v2-support -cd googleapis -git submodule update --init --recursive -LANGUAGE=cpp make +cd /usr/local/src/freeswitch/src +patch < switch_rtp.c.patch # build freeswitch echo "building freeswitch" cd /usr/local/src/freeswitch sudo ./bootstrap.sh -j -sudo ./configure --with-lws=yes --with-grpc=yes -sudo make +sudo ./configure --with-lws=yes --with-extra=yes +sudo make -j 4 sudo make install sudo make cd-sounds-install cd-moh-install sudo cp /tmp/acl.conf.xml /usr/local/freeswitch/conf/autoload_configs sudo cp /tmp/event_socket.conf.xml /usr/local/freeswitch/conf/autoload_configs sudo cp /tmp/switch.conf.xml /usr/local/freeswitch/conf/autoload_configs +sudo cp /tmp/conference.conf.xml /usr/local/freeswitch/conf/autoload_configs sudo rm -Rf /usr/local/freeswitch/conf/dialplan/* sudo rm -Rf /usr/local/freeswitch/conf/sip_profiles/* sudo cp /tmp/mrf_dialplan.xml /usr/local/freeswitch/conf/dialplan @@ -89,14 +120,9 @@ sudo cp /usr/local/src/freeswitch/conf/vanilla/autoload_configs/modules.conf.xml sudo cp /tmp/freeswitch.service /etc/systemd/system sudo chown root:root -R /usr/local/freeswitch sudo chmod 644 /etc/systemd/system/freeswitch.service -sudo sed -i -e 's/global_codec_prefs=OPUS,G722,PCMU,PCMA,VP8/global_codec_prefs=PCMU,PCMA,OPUS,G722/g' /usr/local/freeswitch/conf/vars.xml -sudo sed -i -e 's/outbound_codec_prefs=OPUS,G722,PCMU,PCMA,VP8/outbound_codec_prefs=PCMU,PCMA,OPUS,G722/g' /usr/local/freeswitch/conf/vars.xml +sudo sed -i -e 's/global_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8/global_codec_prefs=PCMU,PCMA,OPUS,G722/g' /usr/local/freeswitch/conf/vars.xml +sudo sed -i -e 's/outbound_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8/outbound_codec_prefs=PCMU,PCMA,OPUS,G722/g' /usr/local/freeswitch/conf/vars.xml sudo systemctl enable freeswitch sudo cp /tmp/freeswitch_log_rotation /etc/cron.daily/freeswitch_log_rotation sudo chown root:root /etc/cron.daily/freeswitch_log_rotation sudo chmod a+x /etc/cron.daily/freeswitch_log_rotation - - - - - diff --git a/packer/jambonz-mini/scripts/install_nodejs.sh b/packer/jambonz-mini/scripts/install_nodejs.sh index 9eb5c72..422c8f1 100644 --- a/packer/jambonz-mini/scripts/install_nodejs.sh +++ b/packer/jambonz-mini/scripts/install_nodejs.sh @@ -1,4 +1,4 @@ #!/bin/bash -curl -sL https://deb.nodesource.com/setup_10.x | sudo bash - && sudo apt-get install -y nodejs +curl -sL https://deb.nodesource.com/setup_14.x | sudo bash - && sudo apt-get install -y nodejs sudo npm install -g pino-pretty pm2 pm2-logrotate sudo pm2 install pm2-logrotate diff --git a/packer/jambonz-mini/scripts/install_rtpengine.sh b/packer/jambonz-mini/scripts/install_rtpengine.sh index 55b909b..a2ee943 100644 --- a/packer/jambonz-mini/scripts/install_rtpengine.sh +++ b/packer/jambonz-mini/scripts/install_rtpengine.sh @@ -7,6 +7,12 @@ cd /usr/local/src git clone https://github.com/BelledonneCommunications/bcg729.git cd bcg729 cmake . -DCMAKE_INSTALL_PREFIX=/usr && make && sudo make install chdir=/usr/local/src/bcg729 +cd /usr/local/src + +git clone https://github.com/warmcat/libwebsockets.git -b v3.2.3 +cd /usr/local/src/libwebsockets +sudo mkdir -p build && cd build && sudo cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && sudo make && sudo make install + cd /usr/local/src git clone https://github.com/sipwise/rtpengine.git -b ${VERSION} cd rtpengine/daemon @@ -15,3 +21,4 @@ cp /usr/local/src/rtpengine/daemon/rtpengine /usr/local/bin sudo mv /tmp/rtpengine.service /etc/systemd/system sudo chmod 644 /etc/systemd/system/rtpengine.service sudo systemctl enable rtpengine +sudo systemctl start rtpengine diff --git a/packer/jambonz-mini/template.json b/packer/jambonz-mini/template.json index cf545af..3e6b56d 100644 --- a/packer/jambonz-mini/template.json +++ b/packer/jambonz-mini/template.json @@ -2,10 +2,20 @@ "variables": { "region": "us-east-1", "ssh_username": "admin", - "ami_description": "EC2 AMI jambonz mini", - "instance_type": "t2.medium", - "drachtio_version": "v0.8.4", - "rtp_engine_version": "mr7.4.1.5", + "ami_description": "jambonz all-in-one AMI", + "instance_type": "t2.xlarge", + "drachtio_version": "v0.8.10", + "jambonz_version": "v0.6.5", + "jambonz_user": "admin", + "jambonz_password": "JambonzR0ck$", + "install_telegraf": "yes", + "homer_user": "homer_user", + "homer_password": "XcapJTqy11LnsYRtxXGPTYQkAnI", + "install_influxdb": "yes", + "install_homer": "yes", + "install_nodered": "no", + "influxdb_ip": "127.0.0.1", + "rtp_engine_version": "mr9.3.1.8", "rtp_engine_min_port": "40000", "rtp_engine_max_port": "60000" }, @@ -23,12 +33,12 @@ }, "instance_type": "{{user `instance_type`}}", "ssh_username": "{{user `ssh_username`}}", - "ami_name": "jambonz-mini-{{user `drachtio_version`}}-{{isotime |clean_resource_name }}", + "ami_name": "jambonz-mini-{{user `jambonz_version`}}-{{isotime |clean_resource_name }}", "ami_description": "{{user `ami_description`}}", "launch_block_device_mappings": [ { "device_name": "/dev/xvda", - "volume_size": 40, + "volume_size": 60, "volume_type": "gp2", "delete_on_termination": true } @@ -42,7 +52,7 @@ "Name": "jambonz-mini" }, "run_tags": { - "Name": "jambonz-mini" + "Name": "jambonz-mini-build" } }], "provisioners": [ @@ -51,15 +61,27 @@ "inline": [ "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done", "sudo apt-get update", - "sudo apt-get -y install python gcc g++ make cmake build-essential git autoconf automake mysql-client redis-tools \\", + "sudo apt-get -y install python lsof gcc g++ make cmake build-essential git autoconf automake default-mysql-client redis-tools \\", "curl telnet libtool libtool-bin libssl-dev libcurl4-openssl-dev libz-dev systemd-coredump liblz4-tool \\", "iptables-dev libavformat-dev liblua5.1-0-dev libavfilter-dev libavcodec-dev libswresample-dev \\", "libevent-dev libpcap-dev libxmlrpc-core-c3-dev markdown libjson-glib-dev lsb-release \\", "libhiredis-dev gperf libspandsp-dev default-libmysqlclient-dev htop dnsutils gdb \\", "gnupg2 wget pkg-config ca-certificates libjpeg-dev libsqlite3-dev libpcre3-dev libldns-dev \\", - "libspeex-dev libspeexdsp-dev libedit-dev libtiff-dev yasm valgrind libswscale-dev haveged \\", + "libspeex-dev libspeexdsp-dev libedit-dev libtiff-dev yasm libswscale-dev haveged jq fail2ban \\", "libopus-dev libsndfile-dev libshout3-dev libmpg123-dev libmp3lame-dev libopusfile-dev", - "sudo chmod a+w /usr/local/src" + "sudo chmod a+w /usr/local/src", + "mkdir ~/credentials", + "mkdir ~/apps", + "cd ~/apps", + "git clone https://github.com/jambonz/sbc-options-handler.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/sbc-call-router.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/fsw-clear-old-calls.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/sbc-outbound.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/sbc-inbound.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/sbc-registrar.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/jambonz-feature-server.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/jambonz-api-server.git -b {{user `jambonz_version`}}", + "git clone https://github.com/jambonz/jambonz-webapp.git -b {{user `jambonz_version`}}" ] }, { @@ -71,18 +93,61 @@ "type": "shell", "script": "scripts/install_chrony.sh" }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `install_influxdb`}}", + "script": "scripts/install_influxdb.sh" + }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{build `ID`}}", + "script": "scripts/install_apiban.sh" + }, + { + "type": "shell", + "script": "scripts/install_nginx.sh" + }, { "type": "shell", "script": "scripts/install_nodejs.sh" }, { "type": "shell", - "script": "scripts/install_freeswitch.sh" + "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `jambonz_user`}} {{user `jambonz_password`}}", + "script": "scripts/install_mysql.sh" }, { "type": "shell", - "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `rtp_engine_version`}}", - "script": "scripts/install_rtpengine.sh" + "script": "scripts/install_redis.sh" + }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `install_nodered`}}", + "script": "scripts/install_node_red.sh" + }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `install_homer`}} {{user `homer_user`}} {{user `homer_password`}}", + "script": "scripts/install_postgresql.sh" + }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `install_homer`}} {{user `influxdb_ip`}}", + "script": "scripts/install_telegraf.sh" + }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `install_homer`}} {{user `homer_user`}} {{user `homer_password`}}", + "script": "scripts/install_homer.sh" + }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `install_influxdb`}}", + "script": "scripts/install_grafana.sh" + }, + { + "type": "shell", + "script": "scripts/install_freeswitch.sh" }, { "type": "shell", @@ -91,7 +156,24 @@ }, { "type": "shell", + "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `rtp_engine_version`}}", + "script": "scripts/install_rtpengine.sh" + }, + { + "type": "shell", + "script": "scripts/install_fail2ban.sh" + }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `jambonz_version`}} {{user `jambonz_user`}} {{user `jambonz_password`}}", "script": "scripts/install_app.sh" + }, + { + "type": "shell", + "inline": [ + "sudo rm /root/.ssh/authorized_keys", + "sudo rm /home/admin/.ssh/authorized_keys" + ] } ] } diff --git a/packer/jambonz-monitoring/files/grafana-dashboard-jambonz.json b/packer/jambonz-monitoring/files/grafana-dashboard-jambonz.json index cd705d6..5d2d807 100644 --- a/packer/jambonz-monitoring/files/grafana-dashboard-jambonz.json +++ b/packer/jambonz-monitoring/files/grafana-dashboard-jambonz.json @@ -8,6 +8,12 @@ "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, "type": "dashboard" } ] @@ -21,7 +27,9 @@ "datasource": "InfluxDB-Telegraf", "fieldConfig": { "defaults": { - "custom": {}, + "color": { + "mode": "thresholds" + }, "mappings": [], "thresholds": { "mode": "absolute", @@ -58,9 +66,10 @@ "fields": "/^sbc_sip_calls_count\\.last$/", "values": false }, + "text": {}, "textMode": "auto" }, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "targets": [ { "groupBy": [ @@ -109,7 +118,9 @@ "datasource": "InfluxDB-Telegraf", "fieldConfig": { "defaults": { - "custom": {}, + "color": { + "mode": "thresholds" + }, "mappings": [], "thresholds": { "mode": "absolute", @@ -146,9 +157,10 @@ "fields": "", "values": false }, + "text": {}, "textMode": "auto" }, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "targets": [ { "groupBy": [ @@ -194,17 +206,46 @@ "type": "stat" }, { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 120 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "1m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + } + ], + "executionErrorState": "keep_state", + "for": "5m", + "frequency": "1m", + "handler": 1, + "name": "Total Calls alert", + "noDataState": "ok", + "notifications": [] + }, "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "InfluxDB-Telegraf", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -231,7 +272,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -279,7 +320,16 @@ "tags": [] } ], - "thresholds": [], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 120, + "visible": true + } + ], "timeFrom": null, "timeRegions": [], "timeShift": null, @@ -299,14 +349,16 @@ }, "yaxes": [ { + "$$hashKey": "object:931", "format": "short", "label": null, "logBase": 1, "max": null, - "min": null, + "min": "0", "show": true }, { + "$$hashKey": "object:932", "format": "short", "label": null, "logBase": 1, @@ -321,17 +373,69 @@ } }, { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 250 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + }, + { + "evaluator": { + "params": [ + 5 + ], + "type": "lt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + } + ], + "executionErrorState": "keep_state", + "for": "1m", + "frequency": "30s", + "handler": 1, + "name": "SBC Media Calls Count alert", + "noDataState": "ok", + "notifications": [] + }, "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "InfluxDB-Telegraf", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -358,7 +462,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -411,7 +515,16 @@ "tags": [] } ], - "thresholds": [], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 250, + "visible": true + } + ], "timeFrom": null, "timeRegions": [], "timeShift": null, @@ -431,14 +544,17 @@ }, "yaxes": [ { + "$$hashKey": "object:158", + "decimals": 0, "format": "short", "label": null, "logBase": 1, "max": null, - "min": null, + "min": "0", "show": true }, { + "$$hashKey": "object:159", "format": "short", "label": null, "logBase": 1, @@ -458,12 +574,6 @@ "dashLength": 10, "dashes": false, "datasource": "InfluxDB-Telegraf", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -490,7 +600,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -597,12 +707,6 @@ "dashLength": 10, "dashes": false, "datasource": "InfluxDB-Telegraf", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -629,7 +733,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -736,12 +840,6 @@ "dashLength": 10, "dashes": false, "datasource": "InfluxDB-Telegraf", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -768,7 +866,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -842,14 +940,17 @@ }, "yaxes": [ { + "$$hashKey": "object:105", + "decimals": 0, "format": "short", "label": null, "logBase": 1, "max": null, - "min": null, + "min": "0", "show": true }, { + "$$hashKey": "object:106", "format": "short", "label": null, "logBase": 1, @@ -870,12 +971,6 @@ "dashes": false, "datasource": "InfluxDB-Telegraf", "description": "", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -902,7 +997,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -950,7 +1045,7 @@ "tags": [] }, { - "alias": "90th percentile", + "alias": "99th percentile", "groupBy": [ { "params": [ @@ -974,7 +1069,45 @@ [ { "params": [ - "90_percentile" + "99_percentile" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "Lower", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "app_hook_response_time", + "orderByTime": "ASC", + "policy": "default", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "lower" ], "type": "field" }, @@ -1007,15 +1140,17 @@ }, "yaxes": [ { + "$$hashKey": "object:1220", "decimals": 0, "format": "short", "label": "", "logBase": 1, - "max": null, + "max": "5000", "min": "0", "show": true }, { + "$$hashKey": "object:1221", "format": "short", "label": null, "logBase": 1, @@ -1035,12 +1170,6 @@ "dashLength": 10, "dashes": false, "datasource": "InfluxDB-Telegraf", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -1067,7 +1196,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -1115,7 +1244,7 @@ "tags": [] }, { - "alias": "95%", + "alias": "99%", "groupBy": [ { "params": [ @@ -1139,7 +1268,7 @@ [ { "params": [ - "95_percentile" + "99_percentile" ], "type": "field" }, @@ -1172,14 +1301,17 @@ }, "yaxes": [ { + "$$hashKey": "object:1098", + "decimals": 0, "format": "short", - "label": null, + "label": "", "logBase": 1, - "max": null, - "min": null, + "max": "1500", + "min": "0", "show": true }, { + "$$hashKey": "object:1099", "format": "short", "label": null, "logBase": 1, @@ -1200,12 +1332,6 @@ "dashes": false, "datasource": "InfluxDB-Telegraf", "description": "", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -1232,7 +1358,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -1378,12 +1504,6 @@ "dashLength": 10, "dashes": false, "datasource": "InfluxDB-Telegraf", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -1410,7 +1530,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -1511,12 +1631,6 @@ "dashes": false, "datasource": "InfluxDB-Telegraf", "description": "", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -1543,7 +1657,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -1634,18 +1748,47 @@ } }, { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 200 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "1m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + } + ], + "executionErrorState": "keep_state", + "for": "1m", + "frequency": "30s", + "handler": 1, + "name": "Freeswitch Channels alert", + "noDataState": "ok", + "notifications": [] + }, "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "InfluxDB-Telegraf", "description": "", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { @@ -1672,7 +1815,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.1", + "pluginVersion": "8.1.5", "pointradius": 2, "points": false, "renderer": "flot", @@ -1726,7 +1869,16 @@ "tags": [] } ], - "thresholds": [], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 200, + "visible": true + } + ], "timeFrom": null, "timeRegions": [], "timeShift": null, @@ -1746,6 +1898,7 @@ }, "yaxes": [ { + "$$hashKey": "object:105", "format": "short", "label": null, "logBase": 1, @@ -1754,6 +1907,1093 @@ "show": true }, { + "$$hashKey": "object:106", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB-Telegraf", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 20 + }, + "hiddenSeries": false, + "id": 22, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.1.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_host: $col", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "host" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "mem", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "available_percent" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "role", + "operator": "=", + "value": "fs" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "% free memory - FS", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:860", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "$$hashKey": "object:861", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB-Telegraf", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 20 + }, + "hiddenSeries": false, + "id": 23, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.1.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_host: $col", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "host" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "system", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load1" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "role", + "operator": "=", + "value": "fs" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Load avg - FS", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:921", + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": "4", + "min": "0", + "show": true + }, + { + "$$hashKey": "object:922", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB-Telegraf", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 28 + }, + "hiddenSeries": false, + "id": 24, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.1.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_host: $col", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "host" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "mem", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "available_percent" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "role", + "operator": "=", + "value": "sbc" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "% free memory - SBC", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:992", + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": "100", + "min": "0", + "show": true + }, + { + "$$hashKey": "object:993", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB-Telegraf", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 28 + }, + "hiddenSeries": false, + "id": 25, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.1.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_host: $col", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "host" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "system", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load1" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "role", + "operator": "=", + "value": "sbc" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Load avg - SBC", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:850", + "format": "short", + "label": null, + "logBase": 1, + "max": "4", + "min": "0", + "show": true + }, + { + "$$hashKey": "object:851", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB-Telegraf", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 36 + }, + "hiddenSeries": false, + "id": 26, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.1.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_host: $col", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "host" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "mem", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "available_percent" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "role", + "operator": "=", + "value": "rtp" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "% free memory - RTP servers", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:1045", + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": "100", + "min": "0", + "show": true + }, + { + "$$hashKey": "object:1046", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB-Telegraf", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 36 + }, + "hiddenSeries": false, + "id": 27, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.1.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_host: $col", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "host" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "system", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load1" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "role", + "operator": "=", + "value": "rtp" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Load avg - RTP servers", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:797", + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": "4", + "min": null, + "show": true + }, + { + "$$hashKey": "object:798", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB-Telegraf", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 44 + }, + "hiddenSeries": false, + "id": 29, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.1.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_host: $col", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "host" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "mem", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "available_percent" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "role", + "operator": "=", + "value": "web" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "% free memory - Web servers", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:1045", + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": "100", + "min": "0", + "show": true + }, + { + "$$hashKey": "object:1046", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB-Telegraf", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 44 + }, + "hiddenSeries": false, + "id": 28, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.1.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_host: $col", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "host" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "system", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "load1" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "role", + "operator": "=", + "value": "web" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Load avg - Web servers", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:797", + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": "4", + "min": null, + "show": true + }, + { + "$$hashKey": "object:798", "format": "short", "label": null, "logBase": 1, @@ -1768,20 +3008,20 @@ } } ], - "refresh": "5s", - "schemaVersion": 26, + "refresh": "", + "schemaVersion": 30, "style": "dark", "tags": [], "templating": { "list": [] }, "time": { - "from": "now-1d", + "from": "now-5m", "to": "now" }, "timepicker": {}, "timezone": "", - "title": "Jambonz Metrics", - "uid": "oAM51epMz", + "title": "Jambonz Metrics - Alerting", + "uid": "uCLrAZDnz", "version": 1 } \ No newline at end of file diff --git a/packer/jambonz-monitoring/scripts/install_homer.sh b/packer/jambonz-monitoring/scripts/install_homer.sh index 0d0ce10..43e3163 100644 --- a/packer/jambonz-monitoring/scripts/install_homer.sh +++ b/packer/jambonz-monitoring/scripts/install_homer.sh @@ -14,6 +14,7 @@ sudo homer-app -populate-table-db-config sudo sed -i -e "s/DBUser\s*=\s*\"postgres\"/DBUser = \"$DB_USER\"/g" /etc/heplify-server.toml sudo sed -i -e "s/DBPass\s*=\s*\"\"/DBPass = \"$DB_PASS\"/g" /etc/heplify-server.toml sudo sed -i -e "s/PromAddr\s*=\s*\"\"/PromAddr = \"0.0.0.0:9096\"/g" /etc/heplify-server.toml +sudo sed -i -e "s/^HEPWSAddr/#HEPWSAddr/g" /etc/heplify-server.toml sudo sed -i -e "s/AlegIDs\s*=\s*\[\]/AlegIDs = \[\"X-CID\"]/g" /etc/heplify-server.toml sudo sed -i -e "s/CustomHeader\s*=\s*\[\]/CustomHeader = \[\"X-Application-Sid\", \"X-Originating-Carrier\", \"X-MS-Teams-Tenant-FQDN\", \"X-Authenticated-User\"]/g" /etc/heplify-server.toml diff --git a/packer/jambonz-sbc-rtp/files/telegraf.conf b/packer/jambonz-sbc-rtp/files/telegraf.conf index 9e331f2..c0e45c2 100644 --- a/packer/jambonz-sbc-rtp/files/telegraf.conf +++ b/packer/jambonz-sbc-rtp/files/telegraf.conf @@ -16,7 +16,7 @@ # Global tags can be specified here in key="value" format. [global_tags] - role = "sbc" + role = "rtp" # dc = "us-east-1" # will tag all metrics with dc=us-east-1 # rack = "1a" ## Environment variables can be used as tags, and throughout the config file diff --git a/packer/jambonz-sbc-rtp/template.json b/packer/jambonz-sbc-rtp/template.json index 061dd7e..fffe410 100644 --- a/packer/jambonz-sbc-rtp/template.json +++ b/packer/jambonz-sbc-rtp/template.json @@ -3,7 +3,7 @@ "region": "us-east-1", "ssh_username": "admin", "ami_description": "jambonz SBC media server", - "drachtio_version": "v0.8.11-rc1", + "drachtio_version": "v0.8.11-rc2", "jambonz_version": "v0.6.6", "instance_type": "t2.medium", "rtp_engine_version": "mr9.3.1.8", diff --git a/packer/jambonz-sbc-sip-rtp/files/telegraf.conf b/packer/jambonz-sbc-sip-rtp/files/telegraf.conf index 9e331f2..c0e45c2 100644 --- a/packer/jambonz-sbc-sip-rtp/files/telegraf.conf +++ b/packer/jambonz-sbc-sip-rtp/files/telegraf.conf @@ -16,7 +16,7 @@ # Global tags can be specified here in key="value" format. [global_tags] - role = "sbc" + role = "rtp" # dc = "us-east-1" # will tag all metrics with dc=us-east-1 # rack = "1a" ## Environment variables can be used as tags, and throughout the config file diff --git a/packer/jambonz-sbc-sip/files/auto-assign-elastic-ip.sh b/packer/jambonz-sbc-sip/files/auto-assign-elastic-ip.sh new file mode 100644 index 0000000..36b710f --- /dev/null +++ b/packer/jambonz-sbc-sip/files/auto-assign-elastic-ip.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +TIMEOUT=20 +PAUSE=5 + +aws_get_instance_id() { + instance_id=$( (curl http://169.254.169.254/latest/meta-data/instance-id) ) + if [ -n "$instance_id" ]; then return 0; else return 1; fi +} + +aws_get_instance_region() { + instance_region=$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone) + # region here needs the last character removed to work + instance_region=${instance_region::-1} + if [ -n "$instance_region" ]; then return 0; else return 1; fi +} + +aws_get_instance_environment() { + instance_environment=$(aws ec2 describe-tags --region $instance_region --filters "Name=resource-id,Values=$1" "Name=key,Values=Environment" --query "Tags[*].Value" --output text) + if [ -n "$instance_environment" ]; then return 0; else return 1; fi +} + +aws_get_unassigned_eips() { + local describe_addreses_response=$(aws ec2 describe-addresses --region $instance_region --filters "Name=tag:Environment,Values=$instance_environment" --query "Addresses[?AssociationId==null].AllocationId" --output text) + eips=(${describe_addreses_response///}) + if [ -n "$describe_addreses_response" ]; then return 0; else return 1; fi +} + +aws_get_details() { + if aws_get_instance_id; then + echo "Instance ID: ${instance_id}." + if aws_get_instance_region; then + echo "Instance Region: ${instance_region}." + if aws_get_instance_environment $instance_id; then + echo "Instance Environment: ${instance_environment}." + else + echo "Failed to get Instance Environment. ${instance_environment}." + return 1 + fi + else + echo "Failed to get Instance Region. ${instance_region}." + return 1 + fi + else + echo "Failed to get Instance ID. ${instance_id}." + return 1 + fi +} + +attempt_to_assign_eip() { + local result; + local exit_code; + result=$( (aws ec2 associate-address --region $instance_region --instance-id $instance_id --allocation-id $1 --no-allow-reassociation) 2>&1 ) + exit_code=$? + if [ "$exit_code" -ne 0 ]; then + echo "Failed to assign Elastic IP [$1] to Instance [$instance_id]. ERROR: $result" + fi + return $exit_code +} + +try_to_assign() { + local last_result; + for eip_id in "${eips[@]}"; do + echo "Attempting to assign Elastic IP to instance..." + if attempt_to_assign_eip $eip_id; then + echo "Elastic IP successfully assigned to instance." + return 0 + fi + done + return 1 +} + +main() { + echo "Assigning Elastic IP..." + local end_time=$((SECONDS+TIMEOUT)) + echo "Timeout: ${end_time}" + + if ! aws_get_details; then + exit 1 + fi + + while [ $SECONDS -lt $end_time ]; do + if aws_get_unassigned_eips && try_to_assign ${eips}; then + echo "Successfully assigned EIP." + exit 0 + fi + echo "Failed to assign EIP. Pausing for $PAUSE seconds before retrying..." + sleep $PAUSE + done + + echo "Failed to assign Elastic IP after $TIMEOUT seconds. Exiting." + exit 1 +} + +declare instance_id +declare instance_region +declare instance_environment +declare eips + +main "$@" \ No newline at end of file diff --git a/packer/jambonz-sbc-sip/files/drachtio.service b/packer/jambonz-sbc-sip/files/drachtio.service index fe130ce..3d363dc 100644 --- a/packer/jambonz-sbc-sip/files/drachtio.service +++ b/packer/jambonz-sbc-sip/files/drachtio.service @@ -10,7 +10,8 @@ ExecStartPre=/bin/sh -c 'systemctl set-environment LOCAL_IP=`curl -s http://169. ExecStartPre=/bin/sh -c 'systemctl set-environment PUBLIC_IP=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`' ExecStart=/usr/local/bin/drachtio --daemon --contact sip:${LOCAL_IP};transport=udp --external-ip ${PUBLIC_IP} \ --contact sip:${LOCAL_IP};transport=tcp \ - --address 0.0.0.0 --port 9022 + --address 0.0.0.0 --port 9022 \ + --prometheus-scrape-port 9090 TimeoutSec=15s Restart=always ; exec diff --git a/packer/jambonz-sbc-sip/files/ecosystem.config.js b/packer/jambonz-sbc-sip/files/ecosystem.config.js index 5b9661b..44bf719 100644 --- a/packer/jambonz-sbc-sip/files/ecosystem.config.js +++ b/packer/jambonz-sbc-sip/files/ecosystem.config.js @@ -1,5 +1,33 @@ module.exports = { apps : [ + { + name: 'jambonz-smpp-esme', + cwd: '/home/admin/apps/jambonz-smpp-esme', + script: 'app.js', + out_file: '/home/admin/.pm2/logs/jambonz-smpp-esme.log', + err_file: '/home/admin/.pm2/logs/jambonz-smpp-esme.log', + combine_logs: true, + instance_var: 'INSTANCE_ID', + exec_mode: 'fork', + instances: 1, + autorestart: true, + watch: false, + max_memory_restart: '1G', + env: { + NODE_ENV: 'production', + AVOID_UDH: true, + JAMBONES_MYSQL_HOST: '${JAMBONES_MYSQL_HOST}', + JAMBONES_MYSQL_USER: '${JAMBONES_MYSQL_USER}', + JAMBONES_MYSQL_PASSWORD: '${JAMBONES_MYSQL_PASSWORD}', + JAMBONES_MYSQL_DATABASE: 'jambones', + JAMBONES_MYSQL_CONNECTION_LIMIT: 10, + JAMBONES_REDIS_HOST: '${JAMBONES_REDIS_HOST}', + JAMBONES_REDIS_PORT: 6379, + JAMBONES_LOGLEVEL: 'debug', + JAMBONES_CLUSTER_ID: '${JAMBONES_CLUSTER_ID}', + HTTP_PORT: 3020 + } + }, { name: 'sbc-options-handler', cwd: '/home/admin/apps/sbc-options-handler', diff --git a/packer/jambonz-sbc-sip/files/vimrc.local b/packer/jambonz-sbc-sip/files/vimrc.local deleted file mode 100644 index f0f40c1..0000000 --- a/packer/jambonz-sbc-sip/files/vimrc.local +++ /dev/null @@ -1,5 +0,0 @@ -source /usr/share/vim/vim80/defaults.vim -let skip_defaults_vim = 1 -if has('mouse') - set mouse=r -endif diff --git a/packer/jambonz-sbc-sip/scripts/install_apiban.sh b/packer/jambonz-sbc-sip/scripts/install_apiban.sh index 66d6972..8314885 100644 --- a/packer/jambonz-sbc-sip/scripts/install_apiban.sh +++ b/packer/jambonz-sbc-sip/scripts/install_apiban.sh @@ -12,4 +12,4 @@ sudo cp /tmp/apiban.logrotate /etc/logrotate.d/apiban-client sudo chmod 0644 /etc/logrotate.d/apiban-client cd /usr/local/bin/apiban/ sudo ./apiban-iptables-client FULL -echo "*/4 * * * * root cd /usr/local/bin/apiban && ./apiban-iptables-client >/dev/null 2>&1" | sudo tee -a /etc/crontab +echo "*/4 * * * * root cd /usr/local/bin/apiban && ./apiban-iptables-client >/dev/null 2>&1" | sudo tee -a /etc/crontab \ No newline at end of file diff --git a/packer/jambonz-sbc-sip/scripts/install_app.sh b/packer/jambonz-sbc-sip/scripts/install_app.sh index 0ea5e42..0eef1ae 100755 --- a/packer/jambonz-sbc-sip/scripts/install_app.sh +++ b/packer/jambonz-sbc-sip/scripts/install_app.sh @@ -6,17 +6,12 @@ mkdir apps cp /tmp/ecosystem.config.js apps cd apps -git clone https://github.com/jambonz/sbc-outbound.git -b ${VERSION} -git clone https://github.com/jambonz/sbc-inbound.git -b ${VERSION} -git clone https://github.com/jambonz/sbc-registrar.git -b ${VERSION} -git clone https://github.com/jambonz/sbc-call-router.git -b ${VERSION} -git clone https://github.com/jambonz/sbc-options-handler.git -b ${VERSION} - cd /home/admin/apps/sbc-inbound && sudo npm install --unsafe-perm cd /home/admin/apps/sbc-outbound && sudo npm install --unsafe-perm cd /home/admin/apps/sbc-registrar && sudo npm install --unsafe-perm cd /home/admin/apps/sbc-call-router && sudo npm install --unsafe-perm cd /home/admin/apps/sbc-options-handler && sudo npm install --unsafe-perm +cd /home/admin/apps/jambonz-smpp-esme && sudo npm install --unsafe-perm sudo -u admin bash -c "pm2 install pm2-logrotate" sudo -u admin bash -c "pm2 set pm2-logrotate:max_size 1G" diff --git a/packer/jambonz-sbc-sip/scripts/install_drachtio.sh b/packer/jambonz-sbc-sip/scripts/install_drachtio.sh index b9fd36c..1e4b20d 100644 --- a/packer/jambonz-sbc-sip/scripts/install_drachtio.sh +++ b/packer/jambonz-sbc-sip/scripts/install_drachtio.sh @@ -14,3 +14,7 @@ sudo mv /tmp/drachtio.service /etc/systemd/system sudo chmod 644 /etc/drachtio.conf.xml sudo chmod 644 /etc/systemd/system/drachtio.service sudo systemctl enable drachtio + + +sudo cp /tmp/auto-assign-elastic-ip.sh /usr/local/bin +sudo chmod +x /usr/local/bin/auto-assign-elastic-ip.sh \ No newline at end of file diff --git a/packer/jambonz-sbc-sip/template.json b/packer/jambonz-sbc-sip/template.json index 4a03fdd..2d9eb00 100644 --- a/packer/jambonz-sbc-sip/template.json +++ b/packer/jambonz-sbc-sip/template.json @@ -4,7 +4,7 @@ "ssh_username": "admin", "ami_description": "jambonz SBC SIP", "instance_type": "t2.medium", - "drachtio_version": "v0.8.11-rc1", + "drachtio_version": "v0.8.11-rc2", "jambonz_version": "v0.6.6", "install_datadog": "no", "install_telegraf": "yes" @@ -67,6 +67,7 @@ "git clone git@github.com:jambonz/sbc-outbound.git -b {{user `jambonz_version`}}", "git clone git@github.com:jambonz/sbc-inbound.git -b {{user `jambonz_version`}}", "git clone git@github.com:jambonz/sbc-registrar.git -b {{user `jambonz_version`}}", + "git clone git@github.com:jambonz/jambonz-smpp-esme.git -b {{user `jambonz_version`}}", "git clone git@github.com:jambonz/sbc-call-router.git" ] }, diff --git a/packer/jambonz-web-server/files/telegraf.conf b/packer/jambonz-web-server/files/telegraf.conf index 7407a6b..c0732f4 100644 --- a/packer/jambonz-web-server/files/telegraf.conf +++ b/packer/jambonz-web-server/files/telegraf.conf @@ -16,7 +16,7 @@ # Global tags can be specified here in key="value" format. [global_tags] - role = "webserver" + role = "web" # dc = "us-east-1" # will tag all metrics with dc=us-east-1 # rack = "1a" ## Environment variables can be used as tags, and throughout the config file