Permalink
Find file Copy path
bcc9d77 Dec 19, 2018
3 contributors

Users who have contributed to this file

@ufgkirk @beardlyness @2E0PGS
57 lines (54 sloc) 2.33 KB
#!/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