forked from Chatur27/aosp-builder-8_cores
-
Notifications
You must be signed in to change notification settings - Fork 3
/
monitor
executable file
·29 lines (24 loc) · 904 Bytes
/
monitor
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
#!/bin/bash
function tg_sendText() {
curl -s "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \
-d "parse_mode=html" \
-d text="${1}" \
-d chat_id=$CHAT_ID \
-d "disable_web_page_preview=true"
}
function tg_sendFile() {
curl -F chat_id=$CHAT_ID -F document=@${1} -F parse_mode=markdown https://api.telegram.org/bot$BOT_TOKEN/sendDocument
}
cd /tmp/rom
export CCACHE_DIR=/tmp/ccache
sleep 2m # We don't need those useless logs during lunching. 2 mins is better.
while : # Loop to check ccache and machine status every 10 minutes
do
(ccache -s && echo '' && free -h && echo '' && df -h) | tee monitor.txt
tg_sendFile "monitor.txt"
sleep 3s # Those sleep times are included to prevent interference issues when sending messages/files to bot.
# Save the last 25 lines of the compilation log in a file and upload to telegram.
tail -n 25 build.txt > status.txt
tg_sendFile "status.txt"
sleep 10m
done