-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathctbcap-healthcheck
executable file
·28 lines (19 loc) · 1.06 KB
/
ctbcap-healthcheck
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
#!/usr/bin/env bash
#
# Copyright (C) 2019-2024 KFERMercer <[email protected]>
#
[ ! ${MODEL} ] && [ ! ${LOG_PATH} ] && echo "Variables not found!" && exit 1
FFMPEG_PROCESS=$(ps -ef | grep -oE "[f]fmpeg -i.*${MODEL}.*\.m3u8*" 2>/dev/null)
WATCHDOG_PROCESS=$(ps -ef | grep -oE "[t]ee.*${MODEL}.*\.log*" 2>/dev/null)
MODEL=${MODEL,,}
MODEL=${MODEL#*"chaturbate.com/"}
MODEL=${MODEL#*"stripchat.com/"}
MODEL=${MODEL%"/"*}
[ -f ${LOG_PATH}/${MODEL}.online ] && M3U8_RESPONSE=$(curl $(cat ${LOG_PATH}/${PLATFORM}-${MODEL}.online) -4 -s -I -w %{http_code} -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36' 2>/dev/null | tail -n1)
# 无 ffmpeg 进程时 --> 正常
[ ! "${FFMPEG_PROCESS}" ] && exit 0
# 无监视进程时 --> 错误
[ ! "${WATCHDOG_PROCESS}" ] && echo "Watchdog process does not exist! (err)" && exit 1
# 有 ffmpeg 进程, 但直播流无效时 --> 错误
[ "${FFMPEG_PROCESS}" ] && [ ${M3U8_RESPONSE} -ge 400 ] && echo "FFMPEG process did not exit correctly! (err)" && exit 1
exit 0