-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathsipcall-sample.sh
58 lines (50 loc) · 1.99 KB
/
sipcall-sample.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
#!/bin/bash
#
#=================================================================================
# Name : sipcall-sample.sh
# Version : 0.1
#
# Copyright (C) 2012 by Andre Wussow, 2012, [email protected]
#
# Description :
# Sample Script for checking average load and making call with sipcall.
#
# Dependencies:
# - sipcall
#
# References :
# http://binerry.de/post/29180946733/raspberry-pi-caller-and-answering-machine
#
#================================================================================
#This script is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This script is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#================================================================================
# define sip-settings
sip_domain="samplesip.com";
sip_user="12345678";
sip_password="XXXXXX";
play_file="play.wav";
# define number to call
phone_number="0123456789";
# define allowed load limit
maxload=0;
# read actual load values
avgload1="$(uptime |awk -F'average: ' '{print $2}' |awk -F', ' '{print $1}')";
avgload5="$(uptime |awk -F'average: ' '{print $2}' |awk -F', ' '{print $2}')";
avgload15="$(uptime |awk -F'average: ' '{print $2}' |awk -F', ' '{print $3}')";
# check average load within last 5 minutes
avgload="$(echo $avgload5 | awk -F',' '{print $1}')";
check="$(($avgload >= $maxload))";
# creating text to speak
tts="$(echo This is raspberry pi and the load is high. The average load within the last 5 minutes was $avgload5)";
if [ $check = 1 ]; then
# make call with sipcall
$(./sipcall -sd $sip_domain -su $sip_user -sp $sip_password -pn $phone_number -s 1 -mr 2 -tts "$tts" -ttsf $play_file > /dev/null);
fi