aboutsummaryrefslogtreecommitdiff
path: root/pkgs/check_aws_ec2_elb
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2016-09-29 13:51:44 +0300
committerIgor Pashev <pashev.igor@gmail.com>2016-09-29 13:51:44 +0300
commit62f28d30a069135f9c48678507203958adfc334f (patch)
tree7f38af0c8d3f445ee8cc50906a639baec7011127 /pkgs/check_aws_ec2_elb
parent1af9e6589bdd18e6ba7eeabf073aa7d710020cdd (diff)
downloadnixsap-62f28d30a069135f9c48678507203958adfc334f.tar.gz
Moved everything into ./modules
Diffstat (limited to 'pkgs/check_aws_ec2_elb')
-rwxr-xr-xpkgs/check_aws_ec2_elb/check_aws_ec2_elb60
-rw-r--r--pkgs/check_aws_ec2_elb/check_aws_ec2_elb.conf14
-rw-r--r--pkgs/check_aws_ec2_elb/default.nix22
3 files changed, 0 insertions, 96 deletions
diff --git a/pkgs/check_aws_ec2_elb/check_aws_ec2_elb b/pkgs/check_aws_ec2_elb/check_aws_ec2_elb
deleted file mode 100755
index 7b53cc9..0000000
--- a/pkgs/check_aws_ec2_elb/check_aws_ec2_elb
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-outOfServicePercentWarn=20
-outOfServicePercentCrit=33
-endpoint=''
-
-while [ $# -gt 0 ]; do
- case "$1" in
- -f) export BOTO_CONFIG="$2"; shift 2;;
- -h) endpoint="$2"; shift 2;;
- -w) outOfServicePercentWarn="$2"; shift 2;;
- -c) outOfServicePercentCrit="$2"; shift 2;;
- *) echo "$0: unsupported argument: $1" >&2; exit 1;;
- esac
-done
-
-cmd=( aws elb describe-instance-health )
-
-c=0
-while [[ "$endpoint" != *.*.elb.amazonaws.com* ]]; do
- endpoint=$(dig "$endpoint" CNAME +short)
- (( ++c ))
- if (( c > 10 )); then
- echo "failed to resolve '$1'" >&2
- exit 255
- fi
-done
-
-cmd+=( --region $(echo "$endpoint" | cut -d. -f2) )
-elbName=$(echo "$endpoint" | cut -d. -f1 | sed -r 's/^(internal-)?(.*)-[0-9]+$/\2/')
-cmd+=( --load-balancer-name "$elbName" )
-
-json=$("${cmd[@]}")
-
-totalCount=$(echo "$json" | jq -c '.InstanceStates | length')
-outOfServiceInfo=$(echo "$json" | jq -c '.InstanceStates | map(select(.State == "OutOfService") | .InstanceId)')
-outOfServiceCount=$(echo "$outOfServiceInfo" | jq -r 'length')
-
-outOfServiceCountWarn=${outOfServiceCountWarn:-$(( totalCount * outOfServicePercentWarn / 100 ))}
-outOfServiceCountCrit=${outOfServiceCountCrit:-$(( totalCount * outOfServicePercentCrit / 100 ))}
-
-stat="total=$totalCount out_of_service=$outOfServiceCount;$outOfServiceCountWarn;$outOfServiceCountCrit"
-outOfServiceInstances=$(echo "$outOfServiceInfo" | jq -r 'join(", ")')
-
-if [ "$outOfServiceCount" -eq 0 ]; then
- echo "OK: $elbName - $totalCount instances|$stat"
- exit 0
-elif [ "$outOfServiceCount" -ge "$outOfServiceCountCrit" ]; then
- echo "CRITICAL: $elbName - $outOfServiceCount/$totalCount out of service: $outOfServiceInstances|$stat"
- exit 2
-elif [ "$outOfServiceCount" -ge "$outOfServiceCountWarn" ]; then
- echo "WARNING: $elbName - $outOfServiceCount/$totalCount out of service: $outOfServiceInstances|$stat"
- exit 1
-else
- echo "OK: $elbName - $outOfServiceCount/$totalCount out of service: $outOfServiceInstances|$stat"
- exit 0
-fi
-
diff --git a/pkgs/check_aws_ec2_elb/check_aws_ec2_elb.conf b/pkgs/check_aws_ec2_elb/check_aws_ec2_elb.conf
deleted file mode 100644
index 9718e3c..0000000
--- a/pkgs/check_aws_ec2_elb/check_aws_ec2_elb.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-object CheckCommand "aws-ec2-elb" {
- import "plugin-check-command"
-
- command = [ "check_aws_ec2_elb" ]
-
- arguments = {
- "-h" = "$aws_ec2_elb_address$"
- "-f" = "$aws_ec2_elb_boto_config$"
- "-w" = "$aws_ec2_elb_warn$"
- "-c" = "$aws_ec2_elb_crit$"
- }
- vars.aws_ec2_elb_address = "$address$"
-}
-
diff --git a/pkgs/check_aws_ec2_elb/default.nix b/pkgs/check_aws_ec2_elb/default.nix
deleted file mode 100644
index 5162c9d..0000000
--- a/pkgs/check_aws_ec2_elb/default.nix
+++ /dev/null
@@ -1,22 +0,0 @@
-{ stdenv, pkgs, makeWrapper }:
-
-stdenv.mkDerivation {
- name = "check_aws_ec2_elb";
- outputs = [ "out" "conf" ];
- unpackPhase = ":";
- nativeBuildInputs = [ makeWrapper ];
- installPhase = ''
- mkdir -p $out/bin
-
- cp ${./check_aws_ec2_elb} $out/bin/check_aws_ec2_elb
- cp ${./check_aws_ec2_elb.conf} $conf
-
- chmod +x "$out/bin/"*
-
- substituteInPlace "$conf" \
- --replace check_aws_ec2_elb "$out/bin/check_aws_ec2_elb"
-
- wrapProgram "$out/bin/check_aws_ec2_elb" \
- --prefix PATH : "${pkgs.awscli}/bin:${pkgs.gnused}/bin:${pkgs.jq}/bin:${pkgs.bind}/bin"
- '';
-}