-
Notifications
You must be signed in to change notification settings - Fork 2
/
check_eldewrito
56 lines (54 loc) · 2.33 KB
/
check_eldewrito
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
#!/usr/bin/env bash
#===============================================================================================================================================
# (C) Copyright 2018 under the United Federation of Gaming (https://ufg.gg).
#
# Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.gnu.org/licenses/gpl-3.0.en.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#===============================================================================================================================================
# title :Eldewrito-NagiosPlugin
# description :Nagios Plugin for Halo Online (Eldewrito) Servers
# author :A Project Under The United Federation of Gaming.
# contributors :Kirk
# date :12-18-2018
# version :0.0.2 Alpha
# os :Linux
# usage :check_eldewrito -H $ip $port
# notes :If you have any problems, feel free to email us: help [AT] UFG [DOT] gg
#===============================================================================================================================================
# Check Dependencies
if [[ -z $(command -v curl) || -z $(command -v jq) ]];
then
echo "Eldewrito UNKNOWN: Missing depenency. Please ensure that curl and jq are installed."
exit 3
else
# Validate Input Variables
if [[ -z "$2" || -z "$3" ]];
then
# Show Usage Information
echo "Usage: check_eldewrito -H 127.0.0.1 11775, replace 127.0.0.1 with your IP for the game server and 11775 with the query port."
exit 3
else
# Query The Game Server
players=$(curl -s -qqq http://$2:$3/ | jq -r '.numPlayers')
version=$(curl -s -qqq http://$2:$3/ | jq -r '.eldewritoVersion')
# Validate Response (just make sure values aren't blank)
if [[ -z "$players" || -z "$version" ]];
then
echo "Eldewrito CRITICAL: Server did not respond;"
exit 2
else
echo "Eldewrito OK: Version $version; | players=$players;"
exit 0
fi
fi
fi