-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_gitlab.php
More file actions
33 lines (31 loc) · 829 Bytes
/
check_gitlab.php
File metadata and controls
33 lines (31 loc) · 829 Bytes
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
#!/usr/bin/php
<?php
//Nagios Exit Codes
$OK = "0";
$WARNING = "1";
$CRITICAL = "2";
$UNKNOWN = "3";
//Exit Strings
$OK_STR = "Gitlab is OK! Nothing to see.";
$WARN_STR = "Warning! Gitlab is in an Unhealthy Status!";
$CRIT_STR = "Gitlab's JSON monitoring is reporting a status other than 'ok'. Check Monitoring and Logs for details.";
$UNK_STR = "Uh OH! Script is broken!";
//replace example.com with your Gitlab health status URL
$json = file_get_contents('example.com');
$output = json_decode($json, true);
$status = $output['status'];
$master = $output['master_check'];
//print_r ($token);
if ($status == "ok") {
echo ($OK_STR);
exit (0);
}
else if ($status != 'ok') {
echo $CRIT_STR;
exit (2);
}
else {
echo ("Gitlab script is probably broken, it shouldn't have ever made it to this output.");
exit (3);
}
?>