· 6 years ago · Nov 09, 2019, 08:34 PM
1#!/usr/bin/env bash
2#
3# Script to test various application reverse proxies, as well as their internal pages, and report to their respective Healthchecks.io checks
4# Tronyx
5
6# Define some variables
7# Primary domain all of your reverse proxies are hosted on
8domain='apollochest.com'
9
10# Your Organizr API key to get through Org auth
11orgAPIKey='XXXXXXXXXX'
12
13# Primary Server IP address of the Server all of your applications/containers are hosted on
14# You can add/utilize more Server variables if you would like, as I did below, and if you're running more than one Server like I am
15primaryServerAddress='127.0.0.1'
16hcPingDomain='https://hc-ping.com/'
17
18# Location of the lock file that you can utilize to keep tests paused.
19tempDir='/tmp/'
20# The below temp dir is for use with the Tronitor script
21# https://github.com/christronyxyocum/tronitor
22#tempDir='/tmp/tronitor/'
23healthchecksLockFile="${tempDir}healthchecks.lock"
24
25# You will need to adjust the subDomain, appPort, subDir, and hcUUID variables for each application's function according to your setup
26# I've left in some examples to show the expected format.
27
28# Function to check for healthchecks lock file
29check_lock_file() {
30 if [ -e "${healthchecksLockFile}" ]; then
31 echo "Skipping checks due to lock file being present."
32 exit 0
33 else
34 main
35 fi
36}
37
38# Function to check Grafana
39check_grafana() {
40 subDomain='cmegraf'
41 appPort='3005'
42 hcUUID='XXXXXXXXXXXX'
43 extResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${subDomain}"."${domain}")
44 intResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}")
45 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
46 appLockFile="${tempDir}${appName}".lock
47 if [ -e "${appLockFile}" ]; then
48 :
49 else
50 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
51 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
52 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
53 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
54 fi
55 fi
56}
57
58# Function to check NZBHydra/NZBHydra2
59check_nzbhydra() {
60 appPort='5076'
61 subDomain='cmehydra'
62 hcUUID='XXXXXXXXXXXX'
63 extResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
64 intResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
65 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
66 appLockFile="${tempDir}${appName}".lock
67 if [ -e "${appLockFile}" ]; then
68 :
69 else
70 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
71 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
72 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
73 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
74 fi
75 fi
76}
77
78# Function to check Ombi
79check_ombi() {
80 subDomain='cmerequest'
81 appPort='3579'
82 hcUUID='XXXXXXXXXXXX'
83 extResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
84 intResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
85 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
86 appLockFile="${tempDir}${appName}".lock
87 if [ -e "${appLockFile}" ]; then
88 :
89 else
90 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
91 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
92 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
93 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
94 fi
95 fi
96}
97
98# Function to check PiHole
99check_pihole() {
100 subDomain='pihole'
101 subDir='/admin/'
102 hcUUID=''
103 extResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 https://"${subDomain}"."${domain}""${subDir}" -H "token: ${orgAPIKey}")
104 intResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}")
105 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
106 appLockFile="${tempDir}${appName}".lock
107 if [ -e "${appLockFile}" ]; then
108 :
109 else
110 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
111 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
112 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
113 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
114 fi
115 fi
116}
117
118# Function to check Plex
119check_plex() {
120 subDir='/plex/'
121 appPort='32400'
122 hcUUID=''
123 plexExtResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${domain}""${subDir}")
124 plexIntResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}"/web/index.html)
125 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
126 appLockFile="${tempDir}${appName}".lock
127 if [ -e "${appLockFile}" ]; then
128 :
129 else
130 if [[ "${plexExtResponse}" = '200' ]] && [[ "${plexIntResponse}" = '200' ]]; then
131 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
132 elif [[ "${plexExtResponse}" != '200' ]] || [[ "${plexIntResponse}" != '200' ]]; then
133 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
134 fi
135 fi
136}
137
138# Function to check Portainer
139check_portainer() {
140 appPort='9000'
141 subDir='/portainer/'
142 hcUUID=''
143 extResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
144 intResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}")
145 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
146 appLockFile="${tempDir}${appName}".lock
147 if [ -e "${appLockFile}" ]; then
148 :
149 else
150 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
151 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
152 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
153 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
154 fi
155 fi
156}
157
158# Function to check Radarr
159check_radarr() {
160 appPort='7878'
161 subDir='/radarr/'
162 hcUUID=''
163 extResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
164 intResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
165 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
166 appLockFile="${tempDir}${appName}".lock
167 if [ -e "${appLockFile}" ]; then
168 :
169 else
170 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
171 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
172 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
173 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
174 fi
175 fi
176}
177
178# Function to check ruTorrent
179check_rutorrent() {
180 subDomain='rutorrent'
181 appPort='9080'
182 hcUUID=''
183 extResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 https://"${subDomain}"."${domain}" -H "token: ${orgAPIKey}")
184 intResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}")
185 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
186 appLockFile="${tempDir}${appName}".lock
187 if [ -e "${appLockFile}" ]; then
188 :
189 else
190 if [[ "${extResponse}" = '401' ]] && [[ "${intResponse}" = '401' ]]; then
191 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
192 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '401' ]]; then
193 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
194 fi
195 fi
196}
197
198# Function to check Sonarr
199check_sonarr() {
200 subdomain='cmetv'
201 appPort='8989'
202 hcUUID='6cc71f57-936b-44cd-964e-3f554c5ce0db'
203 extResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
204 intResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
205 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
206 appLockFile="${tempDir}${appName}".lock
207 if [ -e "${appLockFile}" ]; then
208 :
209 else
210 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
211 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
212 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
213 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
214 fi
215 fi
216}
217
218# Function to check Tautulli
219check_tautulli() {
220 appPort='8181'
221 subDir='/tautulli/auth/login'
222 hcUUID=''
223 extResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
224 intResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
225 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
226 appLockFile="${tempDir}${appName}".lock
227 if [ -e "${appLockFile}" ]; then
228 :
229 else
230 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
231 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
232 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
233 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
234 fi
235 fi
236}
237
238# Function to check Transmission
239check_transmission() {
240 appPort='9091'
241 subDir='/transmission/web/index.html'
242 hcUUID=''
243 extResponse=$(curl -o /dev/null --connect-timeout 10 -s -w "%{http_code}\n" https://"${domain}":"${appPort}""${subDir}" -H "token: ${orgAPIKey}")
244 intResponse=$(curl -o /dev/null --connect-timeout 10 -s -w "%{http_code}\n" http://"${primaryServerAddress}":"${appPort}""${subDir}")
245 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
246 appLockFile="${tempDir}${appName}".lock
247 if [ -e "${appLockFile}" ]; then
248 :
249 else
250 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
251 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
252 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
253 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
254 fi
255 fi
256}
257
258# Function to check Deluge
259check_deluge() {
260 appPort='8112'
261 subDir='/deluge/'
262 hcUUID=''
263 extResponse=$(curl -o /dev/null --connect-timeout 10 -s -w "%{http_code}\n" https://"${domain}":"${appPort}""${subDir}" -H "token: ${orgAPIKey}")
264 intResponse=$(curl -o /dev/null --connect-timeout 10 -s -w "%{http_code}\n" http://"${primaryServerAddress}":"${appPort}")
265 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
266 appLockFile="${tempDir}${appName}".lock
267 if [ -e "${appLockFile}" ]; then
268 :
269 else
270 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
271 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
272 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
273 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
274 fi
275 fi
276}
277
278# Function to check SABnzbd
279check_sabnzbd() {
280 appPort='8580'
281 subDir='/sabnzbd/'
282 hcUUID=''
283 extResponse=$(curl -w "%{http_code}" -sI -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
284 intResponse=$(curl -w "%{http_code}" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
285 if [ -e "${appLockFile}" ]; then
286 :
287 else
288 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
289 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
290 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
291 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
292 fi
293 fi
294}
295
296# Function to check Nagios
297check_nagios() {
298 subDomain='nagios'
299 appPort='8787'
300 subDir=''
301 nagUser=''
302 nagPass=''
303 hcUUID=''
304 extResponse=$(curl -u "${nagUser}:${nagPass}" -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${subDomain}"."${domain}""${subDir}" -H "token: ${orgAPIKey}")
305 intResponse=$(curl -u "${nagUser}:${nagPass}" -k -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
306 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
307 appLockFile="${tempDir}${appName}".lock
308 if [ -e "${appLockFile}" ]; then
309 :
310 else
311 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
312 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
313 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
314 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
315 fi
316 fi
317}
318
319# Function to check TheLounge
320check_thelounge() {
321 appPort='9090'
322 subDir='/thelounge/'
323 hcUUID=''
324 extResponse=$(curl -w "%{http_code}" -sI -o /dev/null --connect-timeout 10 https://"${domain}""${subDir}" -H "token: ${orgAPIKey}")
325 intResponse=$(curl -w "%{http_code}" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}")
326 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
327 appLockFile="${tempDir}${appName}".lock
328 if [ -e "${appLockFile}" ]; then
329 :
330 else
331 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
332 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
333 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
334 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
335 fi
336 fi
337}
338
339# Main function to run all other functions
340main() {
341 check_organizr
342 check_bitwarden
343 check_gitlab
344 check_grafana
345 check_guacamole
346 check_jackett
347 check_library
348 check_lidarr
349 check_logarr
350 check_monitorr
351 check_nzbget
352 check_nzbhydra
353 check_ombi
354 check_pihole
355 check_plex
356 check_portainer
357 check_radarr
358 check_rutorrent
359 check_sonarr
360 check_tautulli
361 check_transmission
362 check_deluge
363 check_sabnzbd
364 check_nagios
365 check_thelounge
366}
367
368check_lock_file
369#!/usr/bin/env bash
370#
371# Script to test various application reverse proxies, as well as their internal pages, and report to their respective Healthchecks.io checks
372# Tronyx
373
374# Define some variables
375# Primary domain all of your reverse proxies are hosted on
376domain='apollochest.com'
377
378# Your Organizr API key to get through Org auth
379orgAPIKey='7ncjco0n8lecjpctsb1j'
380
381# Primary Server IP address of the Server all of your applications/containers are hosted on
382# You can add/utilize more Server variables if you would like, as I did below, and if you're running more than one Server like I am
383primaryServerAddress='127.0.0.1'
384hcPingDomain='https://hc-ping.com/'
385
386# Location of the lock file that you can utilize to keep tests paused.
387tempDir='/tmp/'
388# The below temp dir is for use with the Tronitor script
389# https://github.com/christronyxyocum/tronitor
390#tempDir='/tmp/tronitor/'
391healthchecksLockFile="${tempDir}healthchecks.lock"
392
393# You will need to adjust the subDomain, appPort, subDir, and hcUUID variables for each application's function according to your setup
394# I've left in some examples to show the expected format.
395
396# Function to check for healthchecks lock file
397check_lock_file() {
398 if [ -e "${healthchecksLockFile}" ]; then
399 echo "Skipping checks due to lock file being present."
400 exit 0
401 else
402 main
403 fi
404}
405
406# Function to check Grafana
407check_grafana() {
408 subDomain='cmegraf'
409 appPort='3005'
410 hcUUID='3be2c322-54e4-4e51-8e93-efc575f05233'
411 extResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${subDomain}"."${domain}")
412 intResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}")
413 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
414 appLockFile="${tempDir}${appName}".lock
415 if [ -e "${appLockFile}" ]; then
416 :
417 else
418 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
419 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
420 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
421 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
422 fi
423 fi
424}
425
426# Function to check NZBHydra/NZBHydra2
427check_nzbhydra() {
428 appPort='5076'
429 subDomain='cmehydra'
430 hcUUID='bb68e2eb-0c30-4863-a8e2-d75c85985073'
431 extResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
432 intResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
433 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
434 appLockFile="${tempDir}${appName}".lock
435 if [ -e "${appLockFile}" ]; then
436 :
437 else
438 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
439 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
440 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
441 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
442 fi
443 fi
444}
445
446# Function to check Ombi
447check_ombi() {
448 subDomain='cmerequest'
449 appPort='3579'
450 hcUUID='3c511471-8efa-4bbb-8534-1fe89c89ef4d'
451 extResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
452 intResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
453 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
454 appLockFile="${tempDir}${appName}".lock
455 if [ -e "${appLockFile}" ]; then
456 :
457 else
458 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
459 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
460 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
461 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
462 fi
463 fi
464}
465
466# Function to check PiHole
467check_pihole() {
468 subDomain='pihole'
469 subDir='/admin/'
470 hcUUID=''
471 extResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 https://"${subDomain}"."${domain}""${subDir}" -H "token: ${orgAPIKey}")
472 intResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}")
473 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
474 appLockFile="${tempDir}${appName}".lock
475 if [ -e "${appLockFile}" ]; then
476 :
477 else
478 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
479 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
480 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
481 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
482 fi
483 fi
484}
485
486# Function to check Plex
487check_plex() {
488 subDir='/plex/'
489 appPort='32400'
490 hcUUID=''
491 plexExtResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${domain}""${subDir}")
492 plexIntResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}"/web/index.html)
493 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
494 appLockFile="${tempDir}${appName}".lock
495 if [ -e "${appLockFile}" ]; then
496 :
497 else
498 if [[ "${plexExtResponse}" = '200' ]] && [[ "${plexIntResponse}" = '200' ]]; then
499 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
500 elif [[ "${plexExtResponse}" != '200' ]] || [[ "${plexIntResponse}" != '200' ]]; then
501 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
502 fi
503 fi
504}
505
506# Function to check Portainer
507check_portainer() {
508 appPort='9000'
509 subDir='/portainer/'
510 hcUUID=''
511 extResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
512 intResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}")
513 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
514 appLockFile="${tempDir}${appName}".lock
515 if [ -e "${appLockFile}" ]; then
516 :
517 else
518 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
519 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
520 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
521 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
522 fi
523 fi
524}
525
526# Function to check Radarr
527check_radarr() {
528 appPort='7878'
529 subDir='/radarr/'
530 hcUUID=''
531 extResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
532 intResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
533 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
534 appLockFile="${tempDir}${appName}".lock
535 if [ -e "${appLockFile}" ]; then
536 :
537 else
538 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
539 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
540 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
541 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
542 fi
543 fi
544}
545
546# Function to check ruTorrent
547check_rutorrent() {
548 subDomain='rutorrent'
549 appPort='9080'
550 hcUUID=''
551 extResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 https://"${subDomain}"."${domain}" -H "token: ${orgAPIKey}")
552 intResponse=$(curl -w "%{http_code}\n" -s -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}")
553 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
554 appLockFile="${tempDir}${appName}".lock
555 if [ -e "${appLockFile}" ]; then
556 :
557 else
558 if [[ "${extResponse}" = '401' ]] && [[ "${intResponse}" = '401' ]]; then
559 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
560 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '401' ]]; then
561 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
562 fi
563 fi
564}
565
566# Function to check Sonarr
567check_sonarr() {
568 subdomain='cmetv'
569 appPort='8989'
570 hcUUID='6cc71f57-936b-44cd-964e-3f554c5ce0db'
571 extResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
572 intResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
573 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
574 appLockFile="${tempDir}${appName}".lock
575 if [ -e "${appLockFile}" ]; then
576 :
577 else
578 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
579 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
580 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
581 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
582 fi
583 fi
584}
585
586# Function to check Tautulli
587check_tautulli() {
588 appPort='8181'
589 subDir='/tautulli/auth/login'
590 hcUUID=''
591 extResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
592 intResponse=$(curl -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
593 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
594 appLockFile="${tempDir}${appName}".lock
595 if [ -e "${appLockFile}" ]; then
596 :
597 else
598 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
599 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
600 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
601 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
602 fi
603 fi
604}
605
606# Function to check Transmission
607check_transmission() {
608 appPort='9091'
609 subDir='/transmission/web/index.html'
610 hcUUID=''
611 extResponse=$(curl -o /dev/null --connect-timeout 10 -s -w "%{http_code}\n" https://"${domain}":"${appPort}""${subDir}" -H "token: ${orgAPIKey}")
612 intResponse=$(curl -o /dev/null --connect-timeout 10 -s -w "%{http_code}\n" http://"${primaryServerAddress}":"${appPort}""${subDir}")
613 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
614 appLockFile="${tempDir}${appName}".lock
615 if [ -e "${appLockFile}" ]; then
616 :
617 else
618 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
619 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
620 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
621 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
622 fi
623 fi
624}
625
626# Function to check Deluge
627check_deluge() {
628 appPort='8112'
629 subDir='/deluge/'
630 hcUUID=''
631 extResponse=$(curl -o /dev/null --connect-timeout 10 -s -w "%{http_code}\n" https://"${domain}":"${appPort}""${subDir}" -H "token: ${orgAPIKey}")
632 intResponse=$(curl -o /dev/null --connect-timeout 10 -s -w "%{http_code}\n" http://"${primaryServerAddress}":"${appPort}")
633 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
634 appLockFile="${tempDir}${appName}".lock
635 if [ -e "${appLockFile}" ]; then
636 :
637 else
638 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
639 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
640 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
641 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
642 fi
643 fi
644}
645
646# Function to check SABnzbd
647check_sabnzbd() {
648 appPort='8580'
649 subDir='/sabnzbd/'
650 hcUUID=''
651 extResponse=$(curl -w "%{http_code}" -sI -o /dev/null --connect-timeout 10 https://"${domain}${subDir}" -H "token: ${orgAPIKey}")
652 intResponse=$(curl -w "%{http_code}" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
653 if [ -e "${appLockFile}" ]; then
654 :
655 else
656 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
657 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
658 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
659 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
660 fi
661 fi
662}
663
664# Function to check Nagios
665check_nagios() {
666 subDomain='nagios'
667 appPort='8787'
668 subDir=''
669 nagUser=''
670 nagPass=''
671 hcUUID=''
672 extResponse=$(curl -u "${nagUser}:${nagPass}" -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 https://"${subDomain}"."${domain}""${subDir}" -H "token: ${orgAPIKey}")
673 intResponse=$(curl -u "${nagUser}:${nagPass}" -k -w "%{http_code}\n" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}""${subDir}")
674 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
675 appLockFile="${tempDir}${appName}".lock
676 if [ -e "${appLockFile}" ]; then
677 :
678 else
679 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
680 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
681 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
682 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
683 fi
684 fi
685}
686
687# Function to check TheLounge
688check_thelounge() {
689 appPort='9090'
690 subDir='/thelounge/'
691 hcUUID=''
692 extResponse=$(curl -w "%{http_code}" -sI -o /dev/null --connect-timeout 10 https://"${domain}""${subDir}" -H "token: ${orgAPIKey}")
693 intResponse=$(curl -w "%{http_code}" -sI -o /dev/null --connect-timeout 10 http://"${primaryServerAddress}":"${appPort}")
694 appName=$(echo ${FUNCNAME[0]} |cut -c7-)
695 appLockFile="${tempDir}${appName}".lock
696 if [ -e "${appLockFile}" ]; then
697 :
698 else
699 if [[ "${extResponse}" = '200' ]] && [[ "${intResponse}" = '200' ]]; then
700 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}" > /dev/null
701 elif [[ "${extResponse}" != '200' ]] || [[ "${intResponse}" != '200' ]]; then
702 curl -fsS --retry 3 "${hcPingDomain}${hcUUID}"/fail > /dev/null
703 fi
704 fi
705}
706
707# Main function to run all other functions
708main() {
709 check_organizr
710 check_grafana
711 check_jackett
712 check_nzbhydra
713 check_ombi
714 check_radarr
715 check_rutorrent
716 check_sonarr
717 check_tautulli
718 check_deluge
719 check_sabnzbd
720}
721
722check_lock_file