-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor_asterisk.sh
79 lines (54 loc) · 2.5 KB
/
monitor_asterisk.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# ---
# Created by: Jorge
# Cxlagged: 09/10/2019
# Update: 11/10/2019
# Descrição: Registra todo estado atual do SIP
# Deve Ser utilizado no SIP
#-----------------------------------------
#--- Selecao de cores
COLOR_REST='\e[0m' # ${COLOR_REST}
COLOR_YELLOW='\e[0;33m' # ${COLOR_YELLOW}
COLOR_BLUE='\e[0;36m' # ${COLOR_BLUE}
#--- Formato de data e hora
cxv_data=`date +%d-%m-%y--%R`
cxv_data_full=`date +%d-%m-%Y' as '%R:%S`
#--- Captura ip/hostname da sessao
cxv_tty=`tty | cut -d/ --complement -f1-2`
cxv_ip=`w | fgrep ${cxv_tty}`
#--- Define local aonde será salvo o log
cxv_local=/home/cx_verifica_sip.log
#--- local temporário -- não mexer
cxv_local_tmp=/tmp/cx_verifica_sip_tmp.log
#--- inicio
echo -e "${COLOR_YELLOW} ############### DATA NOVA CONSULTA ################# ${COLOR_REST}" >> ${cxv_local_tmp}
echo "Inicio da nova verificacao em ${cxv_data_full} Por:" >> ${cxv_local_tmp}
echo ' ' >> ${cxv_local_tmp}
w | grep TTY >> ${cxv_local_tmp}
echo ${cxv_ip} >> ${cxv_local_tmp}
echo ' ' >> ${cxv_local_tmp}
echo -e "${COLOR_BLUE} ############### TEMPO ATIVO DO SERVIDOR ################# ${COLOR_REST}" >> ${cxv_local_tmp}
uptime | cut -d' ' -f3-5 | sed 's/,//g'>> ${cxv_local_tmp}
echo ' ' >> ${cxv_local_tmp}
echo -e "${COLOR_BLUE} ############### PROCESSAMENTO ################# ${COLOR_REST}" >> ${cxv_local_tmp}
uptime | cut -d, -f4-6 >> ${cxv_local_tmp}
echo ' ' >> ${cxv_local_tmp}
echo -e "${COLOR_BLUE} ############### MEMORIA ####################### ${COLOR_REST}" >> ${cxv_local_tmp}
free -hgt >> ${cxv_local_tmp}
echo ' ' >> ${cxv_local_tmp}
echo -e "${COLOR_BLUE} ############### ESPAÇO EM DISCO ############### ${COLOR_REST}" >> ${cxv_local_tmp}
timeout 3 df -h >> ${cxv_local_tmp}
echo ' ' >> ${cxv_local_tmp}
echo -e "${COLOR_BLUE} ############### INODE ######################## ${COLOR_REST}" >> ${cxv_local_tmp}
timeout 3 df -ih >> ${cxv_local_tmp}
echo ' ' >> ${cxv_local_tmp}
echo -e "${COLOR_BLUE} ############### ASTERISK -- TEMPO ATIVO ######################## ${COLOR_REST}" >> ${cxv_local_tmp}
/usr/sbin/asterisk -rx 'core show uptime' >> ${cxv_local_tmp}
echo ' ' >> ${cxv_local_tmp}
echo -e "${COLOR_BLUE} ############### ASTERISK -- ENTROCAMENTOS ######################## ${COLOR_REST}" >> ${cxv_local_tmp}
/usr/sbin/asterisk -rx 'sip show peers' | egrep '5060|5061' >> ${cxv_local_tmp}
#--- printa na tela e salva o log
more ${cxv_local_tmp}
sed -i "s/^/[${cxv_data}] /g" ${cxv_local_tmp}
cat ${cxv_local_tmp} >> ${cxv_local}
rm ${cxv_local_tmp}
#---