-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctrunktr.sh
More file actions
98 lines (81 loc) · 2.33 KB
/
functrunktr.sh
File metadata and controls
98 lines (81 loc) · 2.33 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
function Log_Open() {
Pipe=tmplog.pipe
mkfifo -m 700 $Pipe
LOGFILE=trunklog.txt
exec 3>&1
tee ${LOGFILE} <$Pipe >&3 &
teepid=$!
exec 1>$Pipe
PIPE_OPENED=1
}
function Log_Close() {
if [ ${PIPE_OPENED} ]; then
exec 1<&3
sleep 0.2
ps --pid $teepid >/dev/null
if [ $? -eq 0 ]; then
sleep 1
kill $teepid
fi
rm $Pipe
unset PIPE_OPENED
fi
}
function checkG729() {
/sbin/asterisk -rx 'core show translation' | grep -q g729
codec=$(echo $?)
if [[ $codec==0 ]]; then
echo -e "~~~~~~~~~~~~~~~~~~~~"
echo -e "Codec G729 INSTALLED"
echo -e "~~~~~~~~~~~~~~~~~~~~\n"
else
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e "Codec G729 NOT INSTALLED"
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~\n"
fi
}
function ask() {
#ex : /sbin/asterisk -rx "pjsip show contacts"
# comment > command
if [[ -z $3 ]]; then
echo -e "~~~~~~~~~~~~~~~~~"
echo "$1"
echo -e "~~~~~~~~~~~~~~~~~\n"
/sbin/asterisk -rx "$2"
echo -e "\n"
else
# terzo parametro
echo -e "~~~~~~~~~~~~~~~~~"
echo "$1"
echo -e "~~~~~~~~~~~~~~~~~\n"
/sbin/asterisk -rx "$2"
/sbin/asterisk -rx "$3"
echo -e "\n"
fi
}
function query() {
echo -e "~~~~~~~~~~~~~~~~~"
echo "$1"
echo -e "~~~~~~~~~~~~~~~~~\n"
mysql -D asterisk -t -e "$2"
echo -e "\n"
}
Log_Open
ask "ASTERISK VERSION: " "core show version"
ask "ASTERISK UPTIME: " "core show uptime"
checkG729
query "CONFIGURED TRUNKS: " "select * from trunks;"
ask "REGISTERED TRUNKS: " "pjsip show registrations" "sip show registry"
ask "ACTIVE CALLS AND CHANNELS: " "core show channels verbose"
ask "PJSIP CHANNELS: " "pjsip show channels" "sip show channels"
ask "EXTENSIONS CALL FORWARD BUSY CONFIGURATION: " "database show CFB"
query "OUTBOUND ROUTE CONFIGURATION: " "select * from outbound_routes;"
query "OUTBOUND ROUTES PATTERNS: " "select * from outbound_route_patterns;"
echo -e "\n~~~~~~~~~~~~~~~~~~~~~~\n"
echo -e "Generated on $(date)\n"
Log_Close
echo -e "Please paste this link into the ticket reply: \n"
PUSH_LOG=$(curl --silent -H "Max-Days: 5" --upload-file ./$LOGFILE https://transfer.sh/)
echo "~> $PUSH_LOG <~"
echo -e "\n~~~~~~~~~~~~~~~~~~~~~~\n"