#!/bin/bash # Allstar get stats script by Kyle Yoksh, K0KN # March 2013 # # This script is used to read stats from Asterisk for use in other # external scripts. # if [ "$1" == "" ] ; then echo "Usage = stats [your node#]"; exit fi tempfile=/dev/shm/xstats.$1 emailfile=/dev/shm/xstatsemail.$1 asterisk -rx "rpt stats $1" > $tempfile STATISTICS=$(grep 'STATISTICS' $tempfile) SYSTEM=$(grep 'System' $tempfile) INCOMING=$(grep 'Incoming connections' $tempfile) TIMEOUTS=$(grep 'Time outs since system initialization' $tempfile) KEYUPSTODAY=$(grep 'Keyups today' $tempfile) KEYUPSTOTAL=$(grep 'Keyups since system initialization' $tempfile) DTMF_COMMANDS=$(grep 'DTMF commands today' $tempfile) TXTIME_TODAY=$(grep 'TX time today' $tempfile) TXTIME_TOTAL=$(grep 'TX time since system initialization' $tempfile) UPTIME=$(grep 'Uptime' $tempfile) NODESCONNECTEDTOUS=$(grep 'Nodes currently connected to us' $tempfile) NODESCONNECTEDTOUS2=$(grep ' : ' $tempfile) AUTOPATCH=$(grep -w "Autopatch." $tempfile) AUTOPATCH_STATE=$(grep -w "Autopatch state" $tempfile) echo "$STATISTICS" > $emailfile echo "$SYSTEM" >> $emailfile echo "$INCOMING" >> $emailfile echo "$TIMEOUTS" >> $emailfile echo "$KEYUPSTODAY" >> $emailfile echo "$KEYUPSTOTAL" >> $emailfile echo "$DTMF_COMMANDS" >> $emailfile echo "$TXTIME_TODAY" >> $emailfile echo "$TXTIME_TOTAL" >> $emailfile echo "$UPTIME" >> $emailfile echo "$NODESCONNECTEDTOUS" >> $emailfile echo "$NODESCONNECTEDTOUS2" >> $emailfile echo "$AUTOPATCH" >> $emailfile echo "$AUTOPATCH_STATE" >> $emailfile echo " " >> $emailfile echo " " >> $emailfile