#!/bin/bash
ASTERISK="/usr/sbin/rasterisk"
FILE_COUNT=`${ASTERISK} -x 'ulimit descriptors' | cut -f9 -d" " | cut -f1 -d"."`
if [ "$FILE_COUNT" -lt 16386 ]; then
  echo -n "Max open files=16386:16386" > /proc/`pidof asterisk`/limits
fi

STATUS_FULL=`${ASTERISK} -x 'core show channels' | grep "active channels"`
STATUS_LABEL=`echo ${STATUS_FULL} | cut -f2,3 -d" "`
STATUS_COUNT=`echo ${STATUS_FULL} | cut -f1 -d" "`

if [ "${STATUS_LABEL}" == "active channels" ]; then
  # currently there is no usage of number of channels
  exit 0 # success
else
  exit 1 # error
fi
