From 62c5b4bc3b7279cc453408d7b7c98ad7ceb3ce7b Mon Sep 17 00:00:00 2001 From: Cloud User Date: Sun, 19 Jun 2022 01:45:42 +0000 Subject: [PATCH 1/9] refactored CI build script to make directory based and added validation steps --- builds/enabled/debian8_linux_amd64/Dockerfile | 23 ++++++++ create-sensu-asset | 2 +- scripts/build_and_validate.sh | 56 +++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 builds/enabled/debian8_linux_amd64/Dockerfile create mode 100755 scripts/build_and_validate.sh diff --git a/builds/enabled/debian8_linux_amd64/Dockerfile b/builds/enabled/debian8_linux_amd64/Dockerfile new file mode 100644 index 0000000..487b7c5 --- /dev/null +++ b/builds/enabled/debian8_linux_amd64/Dockerfile @@ -0,0 +1,23 @@ +FROM debian:jessie as builder + +ARG SENSU_GO_ASSET_NAME="monitoring-plugins-debian8" +ARG SENSU_GO_ASSET_VERSION="2.7.0" +ARG PLUGINS="check_http" + +ADD create-sensu-asset /usr/bin/create-sensu-asset + +WORKDIR / + +RUN apt-get update +RUN apt-get install -y curl +RUN curl -k -s -L -O https://www.monitoring-plugins.org/download/monitoring-plugins-2.3.1.tar.gz +RUN apt-get install -y build-essential curl libexpat1-dev openssl libssl-dev libz-dev snmp dnsutils && \ + tar xzf monitoring-plugins-2.3.1.tar.gz && \ + cd monitoring-plugins-2.3.1 && \ + ./configure --prefix=/usr --libexecdir=/usr/lib/monitoring-plugins && \ + make && \ + make install + +WORKDIR /usr/lib/monitoring-plugins/ + +RUN create-sensu-asset -a $SENSU_GO_ASSET_NAME -b $PLUGINS -v $SENSU_GO_ASSET_VERSION -o / diff --git a/create-sensu-asset b/create-sensu-asset index 69fec2d..8685a19 100755 --- a/create-sensu-asset +++ b/create-sensu-asset @@ -177,7 +177,7 @@ if [[ $ASSET_ARCH = "_x86_64" ]]; then export ASSET_ARCH="_amd64" fi -ASSET="${OUTPUT_DIR}/${ASSET_NAME}${ASSET_VERSION}${ASSET_OS}${ASSET_ARCH}.tar.gz" +ASSET="${OUTPUT_DIR}/${ASSET_NAME}${ASSET_OS}${ASSET_ARCH}${ASSET_VERSION}.tar.gz" echo ""; echo "Packaging contents of ${PKG_DIR} into ${ASSET}"; echo ""; diff --git a/scripts/build_and_validate.sh b/scripts/build_and_validate.sh new file mode 100755 index 0000000..a26d28b --- /dev/null +++ b/scripts/build_and_validate.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +[ ! -d "./scripts" ] && echo "Directory ./scripts does not exist" && exit 1 +[ ! -d "./builds/enabled" ] && echo "Directory ./builds/enabled does not exist" && exit 1 + +[ ! -f "./.bonsai.yml" ] && echo "File ./.bonsai.yml does not exist" && exit 1 + +if [ -z "$PLUGINS" ] +then + PLUGINS="check_disk,check_dns,check_http,check_load,check_log,check_ntp,check_ntp_peer,check_ntp_time,check_ping,check_procs,check_smtp,check_snmp,check_ssh,check_swap,check_tcp,check_time,check_users,utils.sh" +fi +if [ -z "$ASSET_VERSION" ] +then +export ASSET_VERSION=$(git describe --abbrev=0 --tags) +fi +if [ -z "$PLATFORMS" ] +then +OLD_DIR=$(pwd) +cd builds/enabled +PLATFORMS=$(find . -maxdepth 1 -mindepth 1 -type d) +cd $OLD_DIR +fi +echo "PLATFOMRS: $PLATFORMS" + +mkdir -p assets/ +for platform in $PLATFORMS; +do + p=$(basename $platform) + ASSET_FILENAME="monitoring-plugins-${p}_${ASSET_VERSION}.tar.gz" + echo "Building: $ASSET_FILENAME" + if [ -f "./assets/$ASSET_FILENAME" ]; then + echo "File ${ASSET_FILENAME} already exists in assets dir, skippinng this build" + continue + fi + [ ! -d "./builds/enabled/${p}" ] && echo "Directory /builds/enabled/${p} does not exist" && exit 1 + docker build --no-cache --rm --build-arg "PLUGINS=$PLUGINS" --build-arg "SENSU_GO_ASSET_VERSION=$ASSET_VERSION" -t monitoring-plugins-${p}:$ASSET_VERSION -f builds/enabled/${p}/Dockerfile . + docker cp -L $(docker create --rm monitoring-plugins-${p}:$ASSET_VERSION true):/$ASSET_FILENAME ./assets/ + [ ! -f "./assets/$i{ASSET_FILENAME}" ] && echo "Error: Asset file ${ASSET_FILENAME} missing from assets directory!" && exit 1 +done + +## Lets validate .bonsai.yml +files=$(grep asset_filename .bonsai.yml | awk -F '"' '{print $2}') +for f in $files +do + filename=${f/'#{version}'/${ASSET_VERSION}} +[ ! -f "./assets/${filename}" ] && echo "Error: bonsai asset_filename ${f} missing from assets directory!" && exit 1 +done + + + +cd assets/ +CHECKSUMS_FILENAME="monitoring-plugins_${ASSET_VERSION}_sha512-checksums.txt" +if [[ $(which sha512sum) ]]; then + sha512sum ./*.tar.gz > $CHECKSUMS_FILENAME; +elif [[ $(which shasum) ]]; then + shasum -a 512 *.tar.gz > $CHECKSUMS_FILENAME; +fi; From c68ef190bf57a48ab9b75197bebd22605119e5d8 Mon Sep 17 00:00:00 2001 From: Jef Spaleta Date: Sun, 19 Jun 2022 17:10:13 +0000 Subject: [PATCH 2/9] working bonsai file validation after build --- .bonsai.yml | 153 +--------------------------------- scripts/build_and_validate.sh | 53 ++++++++---- 2 files changed, 38 insertions(+), 168 deletions(-) diff --git a/.bonsai.yml b/.bonsai.yml index 253436a..5eb66b8 100644 --- a/.bonsai.yml +++ b/.bonsai.yml @@ -1,164 +1,13 @@ --- description: "#{repo}" builds: -- platform: "alpine" - arch: "amd64" - asset_filename: "monitoring-plugins-alpine_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform == 'alpine'" - - "entity.system.arch == 'amd64'" - -- platform: "amazon1" - arch: "amd64" - asset_filename: "monitoring-plugins-amazon1_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform == 'amazon'" - # Amazon Linux 1 uses versions of the format YYYY.MM starting from 2011 and going until 2018 - # thus we are matching if the YYYY portion of platform_version contains '201' - - "entity.system.platform_version.split('.')[0].indexOf('201') !== -1" - - "entity.system.arch == 'amd64'" - -- platform: "amazon2" - arch: "amd64" - asset_filename: "monitoring-plugins-amazon2_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform == 'amazon'" - - "entity.system.platform_version == '2'" - - "entity.system.arch == 'amd64'" - -- platform: "centos6" - arch: "amd64" - asset_filename: "monitoring-plugins-centos6_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform_family == 'rhel'" - - "entity.system.platform_version.split('.')[0] == '6'" - - "entity.system.arch == 'amd64'" - -- platform: "centos7" - arch: "amd64" - asset_filename: "monitoring-plugins-centos7_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform_family == 'rhel'" - - "entity.system.platform_version.split('.')[0] == '7'" - - "entity.system.arch == 'amd64'" - -- platform: "centos8" - arch: "amd64" - asset_filename: "monitoring-plugins-centos8_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform_family == 'rhel'" - - "entity.system.platform_version.split('.')[0] == '8'" - - "entity.system.arch == 'amd64'" - - platform: "debian8" arch: "amd64" - asset_filename: "monitoring-plugins-debian8_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform_family == 'debian'" - - "entity.system.platform_version.split('.')[0] == '8'" - - "entity.system.arch == 'amd64'" - -- platform: "debian9" - arch: "amd64" - asset_filename: "monitoring-plugins-debian9_#{version}_linux_amd64.tar.gz" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" sha_filename: "#{repo}_#{version}_sha512-checksums.txt" filter: - "entity.system.os == 'linux'" - "entity.system.platform_family == 'debian'" - - "entity.system.platform_version.split('.')[0] == '9'" - - "entity.system.arch == 'amd64'" - -- platform: "debian10" - arch: "amd64" - asset_filename: "monitoring-plugins-debian10_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform_family == 'debian'" - - "entity.system.platform_version.split('.')[0] == '10'" - - "entity.system.arch == 'amd64'" - -- platform: "debian11" - arch: "amd64" - asset_filename: "monitoring-plugins-debian11_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform_family == 'debian'" - - "entity.system.platform_version.split('.')[0] == '11'" - - "entity.system.arch == 'amd64'" - -- platform: "ubuntu1404" - arch: "amd64" - asset_filename: "monitoring-plugins-ubuntu1404_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform == 'ubuntu'" - - "entity.system.platform_version.split('.')[0] == '14'" - - "entity.system.arch == 'amd64'" - -- platform: "ubuntu1604" - arch: "amd64" - asset_filename: "monitoring-plugins-ubuntu1604_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform == 'ubuntu'" - - "entity.system.platform_version.split('.')[0] == '16'" - - "entity.system.arch == 'amd64'" - -- platform: "ubuntu1804" - arch: "amd64" - asset_filename: "monitoring-plugins-ubuntu1804_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform == 'ubuntu'" - - "entity.system.platform_version.split('.')[0] == '18'" - - "entity.system.arch == 'amd64'" - -- platform: "ubuntu2004" - arch: "amd64" - asset_filename: "monitoring-plugins-ubuntu2004_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform == 'ubuntu'" - - "entity.system.platform_version.split('.')[0] == '20'" - - "entity.system.arch == 'amd64'" - -- platform: "ubuntu2204" - arch: "amd64" - asset_filename: "monitoring-plugins-ubuntu2204_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform == 'ubuntu'" - - "entity.system.platform_version.split('.')[0] == '22'" - - "entity.system.arch == 'amd64'" - -- platform: "xcp-ng8" - arch: "amd64" - asset_filename: "monitoring-plugins-centos7_#{version}_linux_amd64.tar.gz" - sha_filename: "#{repo}_#{version}_sha512-checksums.txt" - filter: - - "entity.system.os == 'linux'" - - "entity.system.platform == 'xcp-ng'" - "entity.system.platform_version.split('.')[0] == '8'" - "entity.system.arch == 'amd64'" diff --git a/scripts/build_and_validate.sh b/scripts/build_and_validate.sh index a26d28b..ad555fd 100755 --- a/scripts/build_and_validate.sh +++ b/scripts/build_and_validate.sh @@ -10,14 +10,19 @@ then fi if [ -z "$ASSET_VERSION" ] then -export ASSET_VERSION=$(git describe --abbrev=0 --tags) + export ASSET_VERSION=$(git describe --abbrev=0 --tags) fi +if [ -z "$ASSET_REPONAME" ] +then + export ASSET_REPONAME=monitoring-plugins +fi + if [ -z "$PLATFORMS" ] then -OLD_DIR=$(pwd) -cd builds/enabled -PLATFORMS=$(find . -maxdepth 1 -mindepth 1 -type d) -cd $OLD_DIR + OLD_DIR=$(pwd) + cd builds/enabled + PLATFORMS=$(find . -maxdepth 1 -mindepth 1 -type d) + cd $OLD_DIR fi echo "PLATFOMRS: $PLATFORMS" @@ -25,32 +30,48 @@ mkdir -p assets/ for platform in $PLATFORMS; do p=$(basename $platform) - ASSET_FILENAME="monitoring-plugins-${p}_${ASSET_VERSION}.tar.gz" + ASSET_FILENAME="${ASSET_REPONAME}-${p}_${ASSET_VERSION}.tar.gz" echo "Building: $ASSET_FILENAME" if [ -f "./assets/$ASSET_FILENAME" ]; then echo "File ${ASSET_FILENAME} already exists in assets dir, skippinng this build" continue fi [ ! -d "./builds/enabled/${p}" ] && echo "Directory /builds/enabled/${p} does not exist" && exit 1 - docker build --no-cache --rm --build-arg "PLUGINS=$PLUGINS" --build-arg "SENSU_GO_ASSET_VERSION=$ASSET_VERSION" -t monitoring-plugins-${p}:$ASSET_VERSION -f builds/enabled/${p}/Dockerfile . - docker cp -L $(docker create --rm monitoring-plugins-${p}:$ASSET_VERSION true):/$ASSET_FILENAME ./assets/ + docker build --no-cache --rm --build-arg "PLUGINS=$PLUGINS" --build-arg "SENSU_GO_ASSET_VERSION=$ASSET_VERSION" -t ${ASSET_REPONAME}-${p}:$ASSET_VERSION -f builds/enabled/${p}/Dockerfile . + docker cp -L $(docker create --rm ${ASSET+REPONAME}-${p}:$ASSET_VERSION true):/$ASSET_FILENAME ./assets/ [ ! -f "./assets/$i{ASSET_FILENAME}" ] && echo "Error: Asset file ${ASSET_FILENAME} missing from assets directory!" && exit 1 done +echo -e "\nDone Building, ./assets directory contains:" +find ./assets/ -maxdepth 1 -mindepth 1 -type f + +echo -e "\nGenerating checksum file" +cd assets/ +CHECKSUMS_FILENAME="${ASSET_REPONAME}_${ASSET_VERSION}_sha512-checksums.txt" +if [[ $(which sha512sum) ]]; then + sha512sum ./*.tar.gz > $CHECKSUMS_FILENAME; +elif [[ $(which shasum) ]]; then + shasum -a 512 *.tar.gz > $CHECKSUMS_FILENAME; +fi; +cd $OLD_DIR + +echo -e "\nValidating .bonsai.yml asset references" ## Lets validate .bonsai.yml files=$(grep asset_filename .bonsai.yml | awk -F '"' '{print $2}') for f in $files do filename=${f/'#{version}'/${ASSET_VERSION}} -[ ! -f "./assets/${filename}" ] && echo "Error: bonsai asset_filename ${f} missing from assets directory!" && exit 1 +[ ! -f "./assets/${filename}" ] && echo "Error: bonsai asset_filename: ${filename} missing from assets directory!" && exit 1 +done +files=$(grep sha_file .bonsai.yml | awk -F '"' '{print $2}') +for f in $files +do + filename=${f/'#{version}'/${ASSET_VERSION}} + filename=${filename/'#{repo}'/${ASSET_REPONAME}} + [ ! -f "./assets/${filename}" ] && echo "Error: bonsai sha_file: ${filename} missing from assets directory!" && exit 1 done +echo -e "\nDone Validating .bonsai.yml asset references" + -cd assets/ -CHECKSUMS_FILENAME="monitoring-plugins_${ASSET_VERSION}_sha512-checksums.txt" -if [[ $(which sha512sum) ]]; then - sha512sum ./*.tar.gz > $CHECKSUMS_FILENAME; -elif [[ $(which shasum) ]]; then - shasum -a 512 *.tar.gz > $CHECKSUMS_FILENAME; -fi; From 01d87aa1fd41a40bb039a2a13896f0f519d8a512 Mon Sep 17 00:00:00 2001 From: Jef Spaleta Date: Sun, 19 Jun 2022 18:17:44 +0000 Subject: [PATCH 3/9] add pattern for plugin testing scripts --- .../debian8_linux_amd64/test_platforms | 1 + .../enabled/debian8_linux_amd64/test_plugins | 1 + scripts/build_and_validate.sh | 41 +++++++++++++++---- scripts/test.sh | 29 +++++++++++++ scripts/test_check_disk.sh | 6 +++ scripts/test_check_dns.sh | 9 ++++ 6 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 builds/enabled/debian8_linux_amd64/test_platforms create mode 100644 builds/enabled/debian8_linux_amd64/test_plugins create mode 100755 scripts/test.sh create mode 100755 scripts/test_check_disk.sh create mode 100755 scripts/test_check_dns.sh diff --git a/builds/enabled/debian8_linux_amd64/test_platforms b/builds/enabled/debian8_linux_amd64/test_platforms new file mode 100644 index 0000000..9b4afb0 --- /dev/null +++ b/builds/enabled/debian8_linux_amd64/test_platforms @@ -0,0 +1 @@ +debian:8 debian:9 debian:10 debian:11 ubuntu:22.04 ubuntu:20.04 ubuntu:18.04 ubuntu:16.04 ubuntu:14.04 centos:7 diff --git a/builds/enabled/debian8_linux_amd64/test_plugins b/builds/enabled/debian8_linux_amd64/test_plugins new file mode 100644 index 0000000..b51aac6 --- /dev/null +++ b/builds/enabled/debian8_linux_amd64/test_plugins @@ -0,0 +1 @@ +check_disk,check_dns diff --git a/scripts/build_and_validate.sh b/scripts/build_and_validate.sh index ad555fd..a7473da 100755 --- a/scripts/build_and_validate.sh +++ b/scripts/build_and_validate.sh @@ -16,7 +16,6 @@ if [ -z "$ASSET_REPONAME" ] then export ASSET_REPONAME=monitoring-plugins fi - if [ -z "$PLATFORMS" ] then OLD_DIR=$(pwd) @@ -24,22 +23,48 @@ then PLATFORMS=$(find . -maxdepth 1 -mindepth 1 -type d) cd $OLD_DIR fi -echo "PLATFOMRS: $PLATFORMS" +echo "ENABLED PLATFOMRS: $PLATFORMS" mkdir -p assets/ for platform in $PLATFORMS; do p=$(basename $platform) ASSET_FILENAME="${ASSET_REPONAME}-${p}_${ASSET_VERSION}.tar.gz" - echo "Building: $ASSET_FILENAME" + [ ! -d "./builds/enabled/${p}" ] && echo "Directory /builds/enabled/${p} does not exist" && exit 1 if [ -f "./assets/$ASSET_FILENAME" ]; then echo "File ${ASSET_FILENAME} already exists in assets dir, skippinng this build" - continue + else + echo "Building: $ASSET_FILENAME" + docker build --no-cache --rm --build-arg "PLUGINS=$PLUGINS" --build-arg "SENSU_GO_ASSET_VERSION=$ASSET_VERSION" -t ${ASSET_REPONAME}-${p}:$ASSET_VERSION -f builds/enabled/${p}/Dockerfile . + docker cp -L $(docker create --rm ${ASSET+REPONAME}-${p}:$ASSET_VERSION true):/$ASSET_FILENAME ./assets/ + [ ! -f "./assets/$i{ASSET_FILENAME}" ] && echo "Error: Asset file ${ASSET_FILENAME} missing from assets directory!" && exit 1 fi - [ ! -d "./builds/enabled/${p}" ] && echo "Directory /builds/enabled/${p} does not exist" && exit 1 - docker build --no-cache --rm --build-arg "PLUGINS=$PLUGINS" --build-arg "SENSU_GO_ASSET_VERSION=$ASSET_VERSION" -t ${ASSET_REPONAME}-${p}:$ASSET_VERSION -f builds/enabled/${p}/Dockerfile . - docker cp -L $(docker create --rm ${ASSET+REPONAME}-${p}:$ASSET_VERSION true):/$ASSET_FILENAME ./assets/ - [ ! -f "./assets/$i{ASSET_FILENAME}" ] && echo "Error: Asset file ${ASSET_FILENAME} missing from assets directory!" && exit 1 + unset TEST_PLATFORMS + if [ -f "./builds/enabled/${p}/test_platforms" ]; then + TEST_PLATFORMS=$(cat ./builds/enabled/${p}/test_platforms) + fi + unset TEST_PLUGINS + if [ -f "./builds/enabled/${p}/test_plugins" ]; then + TEST_PLUGINS=$(cat ./builds/enabled/${p}/test_plugins) + else + TEST_PLUGINS=${PLUGINS} + fi + if [ -z "$TEST_PLATFORMS" ] + then + echo "Skipping platform tests: TEST_PLATFORMS empty" + else + test_arr=($TEST_PLATFORMS) + for test_platform in "${test_arr[@]}"; do + echo "Test: ${test_platform}" + docker run -e platform=${p} -e test_platform=${test_platform} -e plugins=${TEST_PLUGINS} -e asset_filename=${ASSET_FILENAME} -v "$PWD/scripts/:/scripts" -v "$PWD/assets:/dist" ${test_platform} /scripts/test.sh + retval=$? + if [ $retval -ne 0 ]; then + echo "!!! Error testing ${asset_filename} on ${test_platform}" + exit $retval + fi + done + fi + done echo -e "\nDone Building, ./assets directory contains:" diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..7f75afd --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,29 @@ +#!/bin/bash +echo "Test Script:" +echo " Asset Platform: ${platform}" +echo " Target Platform: ${test_platform}" +echo " Asset Tarball: ${asset_filename}" +echo " Plugin Tests: ${plugins}" +#tests=${plugins//hmm/h } +if [ -z "$asset_filename" ]; then + echo "Asset is empty" + exit 1 +fi +mkdir -p /build +cd /build +tar xzf /dist/$asset_filename +LD_LIBRARY_PATH="/build/lib:$LD_LIBRARY_PATH" +PATH="/build/bin/:$PATH" +while IFS=',' read -ra tests; do + for t in "${tests[@]}"; do + /scripts/test_${t}.sh + retval=$? + if [ $retval -ne 0 ]; then + echo "!!! Test error: test_${t}.sh" + exit $retval + fi + + done +done <<< "$plugins" + + diff --git a/scripts/test_check_disk.sh b/scripts/test_check_disk.sh new file mode 100755 index 0000000..d605549 --- /dev/null +++ b/scripts/test_check_disk.sh @@ -0,0 +1,6 @@ +#/bin/sh +check_disk -w 1% -c 1% -e -l +retval=$? +exit $retval + + diff --git a/scripts/test_check_dns.sh b/scripts/test_check_dns.sh new file mode 100755 index 0000000..38eddef --- /dev/null +++ b/scripts/test_check_dns.sh @@ -0,0 +1,9 @@ +#/bin/sh +check_dns --help +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + From 2fa51680cafcae3e10e04adbd487d8558f87aa57 Mon Sep 17 00:00:00 2001 From: Jef Spaleta Date: Sun, 19 Jun 2022 21:11:20 +0000 Subject: [PATCH 4/9] working build and test matrix for reference builds to cover existing asset build definitions. --- .bonsai.yml | 151 ++++++++++++++++++ builds/enabled/alpine_linux_amd64/Dockerfile | 21 +++ .../enabled/alpine_linux_amd64/test_platforms | 1 + .../enabled/alpine_linux_amd64/test_plugins | 1 + builds/enabled/centos6_linux_amd64/Dockerfile | 24 +++ .../centos6_linux_amd64/test_platforms | 1 + .../enabled/centos6_linux_amd64/test_plugins | 1 + .../debian8_linux_amd64/test_platforms | 2 +- .../enabled/debian8_linux_amd64/test_plugins | 2 +- scripts/build_and_validate.sh | 18 ++- scripts/test.sh | 20 +-- scripts/test_check_disk.sh | 2 +- scripts/test_check_dns.sh | 2 +- scripts/test_check_http.sh | 6 + scripts/test_check_load.sh | 8 + scripts/test_check_log.sh | 21 +++ scripts/test_check_ntp.sh | 8 + 17 files changed, 268 insertions(+), 21 deletions(-) create mode 100644 builds/enabled/alpine_linux_amd64/Dockerfile create mode 100644 builds/enabled/alpine_linux_amd64/test_platforms create mode 100644 builds/enabled/alpine_linux_amd64/test_plugins create mode 100644 builds/enabled/centos6_linux_amd64/Dockerfile create mode 100644 builds/enabled/centos6_linux_amd64/test_platforms create mode 100644 builds/enabled/centos6_linux_amd64/test_plugins create mode 100755 scripts/test_check_http.sh create mode 100755 scripts/test_check_load.sh create mode 100755 scripts/test_check_log.sh create mode 100755 scripts/test_check_ntp.sh diff --git a/.bonsai.yml b/.bonsai.yml index 5eb66b8..d5282f3 100644 --- a/.bonsai.yml +++ b/.bonsai.yml @@ -1,6 +1,67 @@ --- description: "#{repo}" builds: +- platform: "alpine" + arch: "amd64" + asset_filename: "monitoring-plugins-alpine_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform == 'alpine'" + - "entity.system.arch == 'amd64'" + +- platform: "amazon1" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform == 'amazon'" + # Amazon Linux 1 uses versions of the format YYYY.MM starting from 2011 and going until 2018 + # thus we are matching if the YYYY portion of platform_version contains '201' + - "entity.system.platform_version.split('.')[0].indexOf('201') !== -1" + - "entity.system.arch == 'amd64'" + +- platform: "amazon2" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform == 'amazon'" + - "entity.system.platform_version == '2'" + - "entity.system.arch == 'amd64'" + +- platform: "centos6" + arch: "amd64" + asset_filename: "monitoring-plugins-centos6_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform_family == 'rhel'" + - "entity.system.platform_version.split('.')[0] == '6'" + - "entity.system.arch == 'amd64'" + +- platform: "centos7" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform_family == 'rhel'" + - "entity.system.platform_version.split('.')[0] == '7'" + - "entity.system.arch == 'amd64'" + +- platform: "centos8" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform_family == 'rhel'" + - "entity.system.platform_version.split('.')[0] == '8'" + - "entity.system.arch == 'amd64'" + - platform: "debian8" arch: "amd64" asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" @@ -11,3 +72,93 @@ builds: - "entity.system.platform_version.split('.')[0] == '8'" - "entity.system.arch == 'amd64'" +- platform: "debian9" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform_family == 'debian'" + - "entity.system.platform_version.split('.')[0] == '9'" + - "entity.system.arch == 'amd64'" + +- platform: "debian10" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform_family == 'debian'" + - "entity.system.platform_version.split('.')[0] == '10'" + - "entity.system.arch == 'amd64'" + +- platform: "debian11" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform_family == 'debian'" + - "entity.system.platform_version.split('.')[0] == '11'" + - "entity.system.arch == 'amd64'" + +- platform: "ubuntu1404" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform == 'ubuntu'" + - "entity.system.platform_version.split('.')[0] == '14'" + - "entity.system.arch == 'amd64'" + +- platform: "ubuntu1604" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform == 'ubuntu'" + - "entity.system.platform_version.split('.')[0] == '16'" + - "entity.system.arch == 'amd64'" + +- platform: "ubuntu1804" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform == 'ubuntu'" + - "entity.system.platform_version.split('.')[0] == '18'" + - "entity.system.arch == 'amd64'" + +- platform: "ubuntu2004" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform == 'ubuntu'" + - "entity.system.platform_version.split('.')[0] == '20'" + - "entity.system.arch == 'amd64'" + +- platform: "ubuntu2204" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform == 'ubuntu'" + - "entity.system.platform_version.split('.')[0] == '22'" + - "entity.system.arch == 'amd64'" + +- platform: "xcp-ng8" + arch: "amd64" + asset_filename: "monitoring-plugins-debian8_linux_amd64_#{version}.tar.gz" + sha_filename: "#{repo}_#{version}_sha512-checksums.txt" + filter: + - "entity.system.os == 'linux'" + - "entity.system.platform == 'xcp-ng'" + - "entity.system.platform_version.split('.')[0] == '8'" + - "entity.system.arch == 'amd64'" + diff --git a/builds/enabled/alpine_linux_amd64/Dockerfile b/builds/enabled/alpine_linux_amd64/Dockerfile new file mode 100644 index 0000000..8588fa0 --- /dev/null +++ b/builds/enabled/alpine_linux_amd64/Dockerfile @@ -0,0 +1,21 @@ +FROM alpine:latest as builder + +ARG SENSU_GO_ASSET_NAME="monitoring-plugins-alpine" +ARG SENSU_GO_ASSET_VERSION="2.7.0" +ARG PLUGINS="check_http" + +ADD create-sensu-asset /usr/bin/create-sensu-asset + +WORKDIR / + +RUN apk --update add bash coreutils libintl curl gcc g++ make openssl-dev net-snmp-tools linux-headers procps && \ + curl -s -L -O https://www.monitoring-plugins.org/download/monitoring-plugins-2.3.1.tar.gz && \ + tar xzf monitoring-plugins-2.3.1.tar.gz && \ + cd monitoring-plugins-2.3.1 && \ + ./configure --prefix=/usr --libexecdir=/usr/lib/monitoring-plugins && \ + make && \ + make install + +WORKDIR /usr/lib/monitoring-plugins/ + +RUN create-sensu-asset -a $SENSU_GO_ASSET_NAME -b $PLUGINS -v $SENSU_GO_ASSET_VERSION -o / diff --git a/builds/enabled/alpine_linux_amd64/test_platforms b/builds/enabled/alpine_linux_amd64/test_platforms new file mode 100644 index 0000000..195132c --- /dev/null +++ b/builds/enabled/alpine_linux_amd64/test_platforms @@ -0,0 +1 @@ +frolvlad/alpine-bash diff --git a/builds/enabled/alpine_linux_amd64/test_plugins b/builds/enabled/alpine_linux_amd64/test_plugins new file mode 100644 index 0000000..0648056 --- /dev/null +++ b/builds/enabled/alpine_linux_amd64/test_plugins @@ -0,0 +1 @@ +check_disk,check_dns,check_http,check_load,check_log,check_ntp diff --git a/builds/enabled/centos6_linux_amd64/Dockerfile b/builds/enabled/centos6_linux_amd64/Dockerfile new file mode 100644 index 0000000..9b25031 --- /dev/null +++ b/builds/enabled/centos6_linux_amd64/Dockerfile @@ -0,0 +1,24 @@ +FROM centos:6 as builder + +ARG SENSU_GO_ASSET_NAME="monitoring-plugins-centos6" +ARG SENSU_GO_ASSET_VERSION="2.7.0" +ARG PLUGINS="check_http" + +ADD create-sensu-asset /usr/bin/create-sensu-asset + +WORKDIR /usr/lib64/nagios/plugins/ + +WORKDIR / + +RUN curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo +RUN yum groupinstall -y "Development Tools" && yum install -y curl expat-devel openssl openssl-devel net-snmp-utils bind-utils && \ + curl -s -L -O https://www.monitoring-plugins.org/download/monitoring-plugins-2.3.1.tar.gz && \ + tar xzf monitoring-plugins-2.3.1.tar.gz && \ + cd monitoring-plugins-2.3.1 && \ + ./configure --prefix=/usr --libexecdir=/usr/lib/monitoring-plugins && \ + make && \ + make install + +WORKDIR /usr/lib/monitoring-plugins/ + +RUN create-sensu-asset -a $SENSU_GO_ASSET_NAME -b $PLUGINS -v $SENSU_GO_ASSET_VERSION -o / diff --git a/builds/enabled/centos6_linux_amd64/test_platforms b/builds/enabled/centos6_linux_amd64/test_platforms new file mode 100644 index 0000000..61a7c7b --- /dev/null +++ b/builds/enabled/centos6_linux_amd64/test_platforms @@ -0,0 +1 @@ +centos:6 amazonlinux:1 amazonlinux:2 centos:7 centos:8 rockylinux:8 diff --git a/builds/enabled/centos6_linux_amd64/test_plugins b/builds/enabled/centos6_linux_amd64/test_plugins new file mode 100644 index 0000000..0648056 --- /dev/null +++ b/builds/enabled/centos6_linux_amd64/test_plugins @@ -0,0 +1 @@ +check_disk,check_dns,check_http,check_load,check_log,check_ntp diff --git a/builds/enabled/debian8_linux_amd64/test_platforms b/builds/enabled/debian8_linux_amd64/test_platforms index 9b4afb0..3cb7d8a 100644 --- a/builds/enabled/debian8_linux_amd64/test_platforms +++ b/builds/enabled/debian8_linux_amd64/test_platforms @@ -1 +1 @@ -debian:8 debian:9 debian:10 debian:11 ubuntu:22.04 ubuntu:20.04 ubuntu:18.04 ubuntu:16.04 ubuntu:14.04 centos:7 +debian:8 amazonlinux:1 amazonlinux:2 debian:9 debian:10 debian:11 ubuntu:22.04 ubuntu:20.04 ubuntu:18.04 ubuntu:16.04 ubuntu:14.04 centos:7 centos:8 rockylinux:8 diff --git a/builds/enabled/debian8_linux_amd64/test_plugins b/builds/enabled/debian8_linux_amd64/test_plugins index b51aac6..0648056 100644 --- a/builds/enabled/debian8_linux_amd64/test_plugins +++ b/builds/enabled/debian8_linux_amd64/test_plugins @@ -1 +1 @@ -check_disk,check_dns +check_disk,check_dns,check_http,check_load,check_log,check_ntp diff --git a/scripts/build_and_validate.sh b/scripts/build_and_validate.sh index a7473da..8d8bc50 100755 --- a/scripts/build_and_validate.sh +++ b/scripts/build_and_validate.sh @@ -10,11 +10,11 @@ then fi if [ -z "$ASSET_VERSION" ] then - export ASSET_VERSION=$(git describe --abbrev=0 --tags) + ASSET_VERSION=$(git describe --abbrev=0 --tags) fi if [ -z "$ASSET_REPONAME" ] then - export ASSET_REPONAME=monitoring-plugins + ASSET_REPONAME=monitoring-plugins fi if [ -z "$PLATFORMS" ] then @@ -36,8 +36,8 @@ do else echo "Building: $ASSET_FILENAME" docker build --no-cache --rm --build-arg "PLUGINS=$PLUGINS" --build-arg "SENSU_GO_ASSET_VERSION=$ASSET_VERSION" -t ${ASSET_REPONAME}-${p}:$ASSET_VERSION -f builds/enabled/${p}/Dockerfile . - docker cp -L $(docker create --rm ${ASSET+REPONAME}-${p}:$ASSET_VERSION true):/$ASSET_FILENAME ./assets/ - [ ! -f "./assets/$i{ASSET_FILENAME}" ] && echo "Error: Asset file ${ASSET_FILENAME} missing from assets directory!" && exit 1 + docker cp -L $(docker create --rm ${ASSET_REPONAME}-${p}:$ASSET_VERSION true):/$ASSET_FILENAME ./assets/ + [ ! -f "./assets/${ASSET_FILENAME}" ] && echo "Error: Asset file ${ASSET_FILENAME} missing from assets directory!" && exit 1 fi unset TEST_PLATFORMS if [ -f "./builds/enabled/${p}/test_platforms" ]; then @@ -51,12 +51,16 @@ do fi if [ -z "$TEST_PLATFORMS" ] then - echo "Skipping platform tests: TEST_PLATFORMS empty" + echo -e "\nSkipping platform tests: TEST_PLATFORMS empty" else + echo -e "\nPerforming Cross platform tests\n" test_arr=($TEST_PLATFORMS) + mkdir -p ./dist/${p} + cd ./dist/${p} + tar xzf $OLD_DIR/assets/$ASSET_FILENAME + cd $OLD_DIR for test_platform in "${test_arr[@]}"; do - echo "Test: ${test_platform}" - docker run -e platform=${p} -e test_platform=${test_platform} -e plugins=${TEST_PLUGINS} -e asset_filename=${ASSET_FILENAME} -v "$PWD/scripts/:/scripts" -v "$PWD/assets:/dist" ${test_platform} /scripts/test.sh + docker run -e platform=${p} -e test_platform=${test_platform} -e plugins=${TEST_PLUGINS} -e asset_filename=${ASSET_FILENAME} -v "$PWD/scripts/:/scripts" -v "$PWD//dist/${p}:/build" ${test_platform} /scripts/test.sh retval=$? if [ $retval -ne 0 ]; then echo "!!! Error testing ${asset_filename} on ${test_platform}" diff --git a/scripts/test.sh b/scripts/test.sh index 7f75afd..b942385 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,19 +1,19 @@ #!/bin/bash -echo "Test Script:" -echo " Asset Platform: ${platform}" -echo " Target Platform: ${test_platform}" -echo " Asset Tarball: ${asset_filename}" -echo " Plugin Tests: ${plugins}" +echo " Testing Parameters:" +echo " Asset Build: ${platform}" +echo " Target Platform: ${test_platform}" +echo " Asset Tarball: ${asset_filename}" +echo " Plugin Tests: ${plugins}" #tests=${plugins//hmm/h } if [ -z "$asset_filename" ]; then echo "Asset is empty" exit 1 fi -mkdir -p /build -cd /build -tar xzf /dist/$asset_filename -LD_LIBRARY_PATH="/build/lib:$LD_LIBRARY_PATH" -PATH="/build/bin/:$PATH" +#mkdir -p /build +#cd /build +#tar xzf /dist/$asset_filename +export LD_LIBRARY_PATH="/build/lib:$LD_LIBRARY_PATH" +export PATH="/build/bin/:$PATH" while IFS=',' read -ra tests; do for t in "${tests[@]}"; do /scripts/test_${t}.sh diff --git a/scripts/test_check_disk.sh b/scripts/test_check_disk.sh index d605549..65fd94f 100755 --- a/scripts/test_check_disk.sh +++ b/scripts/test_check_disk.sh @@ -1,5 +1,5 @@ #/bin/sh -check_disk -w 1% -c 1% -e -l +check_disk -w 0 -c 0 -e -l > /dev/null retval=$? exit $retval diff --git a/scripts/test_check_dns.sh b/scripts/test_check_dns.sh index 38eddef..430a6bf 100755 --- a/scripts/test_check_dns.sh +++ b/scripts/test_check_dns.sh @@ -1,5 +1,5 @@ #/bin/sh -check_dns --help +check_dns --help >> /dev/null retval=$? if [[ $retval -eq 3 ]]; then exit 0 diff --git a/scripts/test_check_http.sh b/scripts/test_check_http.sh new file mode 100755 index 0000000..bf0445f --- /dev/null +++ b/scripts/test_check_http.sh @@ -0,0 +1,6 @@ +#/bin/sh +check_http -w 5 -c 10 -H www.sensu.io > /dev/null +retval=$? +exit $retval + + diff --git a/scripts/test_check_load.sh b/scripts/test_check_load.sh new file mode 100755 index 0000000..a6a8f93 --- /dev/null +++ b/scripts/test_check_load.sh @@ -0,0 +1,8 @@ +#/bin/sh +check_load -w 100,200,300 -c 400,500,600 --help >> /dev/null +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/scripts/test_check_log.sh b/scripts/test_check_log.sh new file mode 100755 index 0000000..ccb5a69 --- /dev/null +++ b/scripts/test_check_log.sh @@ -0,0 +1,21 @@ +#/bin/sh +echo "This is a test of the emergency broadcast system" > /build/test_log.txt +check_log -F /build/test_log.txt -O /build/old_test_log.txt -q "This is a test" > stdout.txt 2>stderr.txt + +retval=$? + +error=$(cat stderr.txt) +if [ $retval -ne 0 ] +then + cat stdout.txt +fi +if [ ! -z "$error" ] +then + echo "check_log stderr is NOT empty" + echo $error + if [ "$error" = "/build/bin/check_log: line 191: diff: command not found" ]; then + exit 0 + fi + exit 1 +fi +exit $retval diff --git a/scripts/test_check_ntp.sh b/scripts/test_check_ntp.sh new file mode 100755 index 0000000..ddf6c8d --- /dev/null +++ b/scripts/test_check_ntp.sh @@ -0,0 +1,8 @@ +#/bin/sh +check_ntp -H pool.ntp.org -w 10 -c 20 >> /dev/null +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + From 6b9e404d3a8f44073b715b50852d47672ae84905 Mon Sep 17 00:00:00 2001 From: Jef Spaleta Date: Sun, 19 Jun 2022 21:18:48 +0000 Subject: [PATCH 5/9] update github release action to use new build_and_validate.sh script --- .github/workflows/release.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1bfe197..74806ff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,6 @@ on: push: tags: - '*' - jobs: build: name: Publish binaries @@ -11,21 +10,15 @@ jobs: steps: - uses: actions/checkout@v2 - name: Build - run: ./travis-build.sh - env: - TRAVIS_REPO_SLUG: ${{github.repository}} - TRAVIS_TAG: ${{github.ref_name}} - FULL_PRUNE: 1 - - name: Sha512sum - run: cd dist && sha512sum ./*.tar.gz > "./monitoring-plugins_${TRAVIS_TAG}_sha512-checksums.txt" + run: ./scripts/build_and_validate.sh env: - TRAVIS_REPO_SLUG: ${{github.repository}} - TRAVIS_TAG: ${{github.ref_name}} + ASSET_VERSION: ${{github.ref_name}} + ASSET_REPONAME: monitoring-plugins - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: dist/* + file: assets/* tag: ${{ github.ref_name }} overwrite: true file_glob: true From 5e53664e75189be468da60133b776e0313f47e44 Mon Sep 17 00:00:00 2001 From: Jef Spaleta Date: Sun, 19 Jun 2022 21:55:41 +0000 Subject: [PATCH 6/9] refactor CI scripts --- .travis.yml | 21 ----- .../centos6_linux_amd64/test_platforms | 2 +- Dockerfile.alpine => old/Dockerfile.alpine | 0 Dockerfile.amazon1 => old/Dockerfile.amazon1 | 0 Dockerfile.amazon2 => old/Dockerfile.amazon2 | 0 Dockerfile.centos6 => old/Dockerfile.centos6 | 0 Dockerfile.centos7 => old/Dockerfile.centos7 | 0 Dockerfile.centos8 => old/Dockerfile.centos8 | 0 .../Dockerfile.debian10 | 0 .../Dockerfile.debian11 | 0 Dockerfile.debian8 => old/Dockerfile.debian8 | 0 Dockerfile.debian9 => old/Dockerfile.debian9 | 0 .../Dockerfile.ubuntu1404 | 0 .../Dockerfile.ubuntu1604 | 0 .../Dockerfile.ubuntu1804 | 0 .../Dockerfile.ubuntu2004 | 0 .../Dockerfile.ubuntu2204 | 0 build.sh => old/build.sh | 0 scripts/test.sh | 1 + scripts/test_check_log.sh | 5 +- travis-build.sh | 61 -------------- travis-github-upload.sh | 80 ------------------- 22 files changed, 5 insertions(+), 165 deletions(-) delete mode 100644 .travis.yml rename Dockerfile.alpine => old/Dockerfile.alpine (100%) rename Dockerfile.amazon1 => old/Dockerfile.amazon1 (100%) rename Dockerfile.amazon2 => old/Dockerfile.amazon2 (100%) rename Dockerfile.centos6 => old/Dockerfile.centos6 (100%) rename Dockerfile.centos7 => old/Dockerfile.centos7 (100%) rename Dockerfile.centos8 => old/Dockerfile.centos8 (100%) rename Dockerfile.debian10 => old/Dockerfile.debian10 (100%) rename Dockerfile.debian11 => old/Dockerfile.debian11 (100%) rename Dockerfile.debian8 => old/Dockerfile.debian8 (100%) rename Dockerfile.debian9 => old/Dockerfile.debian9 (100%) rename Dockerfile.ubuntu1404 => old/Dockerfile.ubuntu1404 (100%) rename Dockerfile.ubuntu1604 => old/Dockerfile.ubuntu1604 (100%) rename Dockerfile.ubuntu1804 => old/Dockerfile.ubuntu1804 (100%) rename Dockerfile.ubuntu2004 => old/Dockerfile.ubuntu2004 (100%) rename Dockerfile.ubuntu2204 => old/Dockerfile.ubuntu2204 (100%) rename build.sh => old/build.sh (100%) delete mode 100755 travis-build.sh delete mode 100755 travis-github-upload.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 92e6305..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: c -compiler: -- gcc -services: -- docker -script: -- ./travis-build.sh -before_deploy: -- bash -c "[ ! -d bonsai/ ] && git clone https://github.com/sensu/sensu-go-bonsai-asset.git - bonsai || echo 'bonsai/ exists, skipping git clone'" -deploy: -- provider: script - script: ./travis-github-upload.sh - cleanup: false - skip_cleanup: true - on: - tags: true - all_branches: true -env: - global: - secure: jZIippZkdDlTLXTohWa/FTZQ/k16dfzefitCpXJpe6UxbWVF0zQrl1kfweZTh+jAQNXZoUZMAIiAYjMB0G9QZWVS2vtrl9sH53yiUC8q+R4DypTUpkOU54p1xxfyKTF4k9jzogKqjlIkH6n91XwlZsqfj1/dL0PKstfNXeGpqWWP1dCRhZftt8WWPdSTXASn0XqPWMqTEOey48CggZxWDUsqzYGjwvdgy5ZSjGTVH/SqsTNTksGV6QOaZ3WPk/PPr2sHBVSfOe9K3jPcau1P6zy17fvpwZxyTKR1ExrTjiB6WFE+cAMGs6vj5XMD3ZcWVn0nvaE3/WTjY4wn0tbvfQHzBQTMfi8dz4Fndc/gq2ioLswASQyqPmwcGva/GJ4M+R2hcREmTqhmwuRhK4gx+7vVD4WYsR7xNuD/vtOlDQpZnPxwSF9hvhYmlGMUC0vzPWuCChi/kM9tVDvtTH66W96A/lqyNUQbLIcLpyBb7jGUCckqGmJnrsuBuN+dG9Aj16cyElPKYXDGpk05zLzAVf0IVS05mAL3MplLgKDfymhmET9s6h9D1lu8KjYA8EWDwdIZH5YAspJIfbSc9cbcHrzVcuvFu1bks178Eck6vN9Cz8A65Zu/Aw4OjNoUBI/OPxpdZlAL4+MUe/7jCSn5ZnlH9ulehzWOzeZdf0VSlxI= diff --git a/builds/enabled/centos6_linux_amd64/test_platforms b/builds/enabled/centos6_linux_amd64/test_platforms index 61a7c7b..decb196 100644 --- a/builds/enabled/centos6_linux_amd64/test_platforms +++ b/builds/enabled/centos6_linux_amd64/test_platforms @@ -1 +1 @@ -centos:6 amazonlinux:1 amazonlinux:2 centos:7 centos:8 rockylinux:8 +centos:6 amazonlinux:1 amazonlinux:2 centos:7 diff --git a/Dockerfile.alpine b/old/Dockerfile.alpine similarity index 100% rename from Dockerfile.alpine rename to old/Dockerfile.alpine diff --git a/Dockerfile.amazon1 b/old/Dockerfile.amazon1 similarity index 100% rename from Dockerfile.amazon1 rename to old/Dockerfile.amazon1 diff --git a/Dockerfile.amazon2 b/old/Dockerfile.amazon2 similarity index 100% rename from Dockerfile.amazon2 rename to old/Dockerfile.amazon2 diff --git a/Dockerfile.centos6 b/old/Dockerfile.centos6 similarity index 100% rename from Dockerfile.centos6 rename to old/Dockerfile.centos6 diff --git a/Dockerfile.centos7 b/old/Dockerfile.centos7 similarity index 100% rename from Dockerfile.centos7 rename to old/Dockerfile.centos7 diff --git a/Dockerfile.centos8 b/old/Dockerfile.centos8 similarity index 100% rename from Dockerfile.centos8 rename to old/Dockerfile.centos8 diff --git a/Dockerfile.debian10 b/old/Dockerfile.debian10 similarity index 100% rename from Dockerfile.debian10 rename to old/Dockerfile.debian10 diff --git a/Dockerfile.debian11 b/old/Dockerfile.debian11 similarity index 100% rename from Dockerfile.debian11 rename to old/Dockerfile.debian11 diff --git a/Dockerfile.debian8 b/old/Dockerfile.debian8 similarity index 100% rename from Dockerfile.debian8 rename to old/Dockerfile.debian8 diff --git a/Dockerfile.debian9 b/old/Dockerfile.debian9 similarity index 100% rename from Dockerfile.debian9 rename to old/Dockerfile.debian9 diff --git a/Dockerfile.ubuntu1404 b/old/Dockerfile.ubuntu1404 similarity index 100% rename from Dockerfile.ubuntu1404 rename to old/Dockerfile.ubuntu1404 diff --git a/Dockerfile.ubuntu1604 b/old/Dockerfile.ubuntu1604 similarity index 100% rename from Dockerfile.ubuntu1604 rename to old/Dockerfile.ubuntu1604 diff --git a/Dockerfile.ubuntu1804 b/old/Dockerfile.ubuntu1804 similarity index 100% rename from Dockerfile.ubuntu1804 rename to old/Dockerfile.ubuntu1804 diff --git a/Dockerfile.ubuntu2004 b/old/Dockerfile.ubuntu2004 similarity index 100% rename from Dockerfile.ubuntu2004 rename to old/Dockerfile.ubuntu2004 diff --git a/Dockerfile.ubuntu2204 b/old/Dockerfile.ubuntu2204 similarity index 100% rename from Dockerfile.ubuntu2204 rename to old/Dockerfile.ubuntu2204 diff --git a/build.sh b/old/build.sh similarity index 100% rename from build.sh rename to old/build.sh diff --git a/scripts/test.sh b/scripts/test.sh index b942385..e1094fd 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -16,6 +16,7 @@ export LD_LIBRARY_PATH="/build/lib:$LD_LIBRARY_PATH" export PATH="/build/bin/:$PATH" while IFS=',' read -ra tests; do for t in "${tests[@]}"; do + echo " Running: /scripts/test_${t}.sh" /scripts/test_${t}.sh retval=$? if [ $retval -ne 0 ]; then diff --git a/scripts/test_check_log.sh b/scripts/test_check_log.sh index ccb5a69..11f09a3 100755 --- a/scripts/test_check_log.sh +++ b/scripts/test_check_log.sh @@ -1,6 +1,6 @@ #/bin/sh -echo "This is a test of the emergency broadcast system" > /build/test_log.txt -check_log -F /build/test_log.txt -O /build/old_test_log.txt -q "This is a test" > stdout.txt 2>stderr.txt +echo "This is a test of the emergency broadcast system" > /test_log.txt +check_log -F /test_log.txt -O /old_test_log.txt -q "This is a test" > stdout.txt 2>stderr.txt retval=$? @@ -8,6 +8,7 @@ error=$(cat stderr.txt) if [ $retval -ne 0 ] then cat stdout.txt + fi if [ ! -z "$error" ] then diff --git a/travis-build.sh b/travis-build.sh deleted file mode 100755 index 5a71780..0000000 --- a/travis-build.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash -## -# Adapted from sensu/sensu-go-bonsai-asset repo -## - -# Hardwiring repo-name for now, untile the Dockerfile logic is abstracted/tested to use name as passed to docker as build arg -REPO_NAME="monitoring-plugins" - -export PLUGINS="check_disk,check_dns,check_http,check_load,check_log,check_ntp,check_ntp_peer,check_ntp_time,check_ping,check_procs,check_smtp,check_snmp,check_ssh,check_swap,check_tcp,check_time,check_users,utils.sh" - -[[ -z "$WDIR" ]] && { echo "WDIR is empty using bonsai/" ; WDIR="bonsai/"; } - -## -# TravisCI specific asset build script. -# Uses several TravisCI specific environment variables -## -#[[ -z "$1" ]] && { echo "Parameter 1, REPO_NAME is empty" ; exit 1; } -[[ -z "$GITHUB_TOKEN" ]] && { echo "GITHUB_TOKEN is empty, upload disabled" ; } -[[ -z "$TRAVIS_REPO_SLUG" ]] && { echo "TRAVIS_REPO_SLUG is empty"; exit 1; } -if [[ -z "$1" ]]; then - echo "Parameter 1, PLATFORMS is empty, using default set" ; platforms=( alpine alpine3.8 debian8 debian9 debian10 debian11 centos8 centos7 centos6 amazon1 amazon2 ubuntu1404 ubuntu1604 ubuntu1804 ubuntu2004 ubuntu2204 ); -else - IFS=', ' read -r -a platforms <<< "$1" -fi -TAG=$TRAVIS_TAG -CURRENT_COMMIT=$(git rev-parse HEAD) -[[ -z "$TAG" ]] && { echo "TRAVIS_TAG is empty" ; TAG="0.0.1"; } -[[ -z "$TRAVIS_COMMIT" ]] && { echo "TRAVIS_COMMIT is empty, using current commit" ; TRAVIS_COMMIT=$CURRENT_COMMIT; } -echo $REPO_NAME $TRAVIS_REPO_SLUG $TAG $TRAVIS_COMMIT - -mkdir dist -GIT_REPO="https://github.com/${TRAVIS_REPO_SLUG}.git" -GIT_REF=${TRAVIS_COMMIT} - -echo "Platforms: ${platforms[@]}" - -if [ -d dist ]; then - for platform in "${platforms[@]}" - do - if [ -f "Dockerfile.${platform}" ]; then - export SENSU_GO_ASSET_FILENAME="${REPO_NAME}-${platform}_${TAG}_linux_amd64.tar.gz" - echo "Building for Platform: $platform using Dockfile.${platform} ${SENSU_GO_ASSET_FILENAME}" - docker build --no-cache --rm --build-arg "PLUGINS=$PLUGINS" --build-arg "SENSU_GO_ASSET_VERSION=${TAG}" -t ${REPO_NAME}-${platform}:$TAG -f Dockerfile.${platform} . - docker cp -L $(docker create --rm ${REPO_NAME}-${platform}:${TAG} true):/$SENSU_GO_ASSET_FILENAME ./dist/ - if [ -z ${FULL_PRUNE+x} ]; then - echo "FULL_PRUNE unset, skipping docker prune" - else - docker system prune -a -f - fi - else - echo "Skipping for Platform: $platform missing Dockfile.${platform}" - fi - done -else - echo "error dist directory is missing" -fi - - - - - diff --git a/travis-github-upload.sh b/travis-github-upload.sh deleted file mode 100755 index 749b3b0..0000000 --- a/travis-github-upload.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash -## -# Adapted from sensu/sensu-go-bonsai-asset repo -## - -[[ -z "$WDIR" ]] && { echo "WDIR is empty using bonsai/" ; WDIR="bonsai/"; } - -## -# TravisCI specific asset build script. -# Uses several TravisCI specific environment variables -## -[[ -z "$GITHUB_TOKEN" ]] && { echo "GITHUB_TOKEN is empty, upload disabled" ; } -[[ -z "$TRAVIS_REPO_SLUG" ]] && { echo "TRAVIS_REPO_SLUG is empty"; exit 1; } -TAG=$TRAVIS_TAG -CURRENT_COMMIT=$(git rev-parse HEAD) -[[ -z "$TAG" ]] && { echo "TRAVIS_TAG is empty" ; TAG="0.0.1"; } -[[ -z "$TRAVIS_COMMIT" ]] && { echo "TRAVIS_COMMIT is empty, using current commit" ; TRAVIS_COMMIT=$CURRENT_COMMIT; } - -GIT_REPO="https://github.com/${TRAVIS_REPO_SLUG}.git" -GIT_REF=${TRAVIS_COMMIT} - -if [ -d dist ]; then - # Generate the sha512sum for all the assets - files=$( ls dist/*.tar.gz ) - echo $files - for filename in $files; do - if [[ "$TRAVIS_TAG" ]]; then - if [[ "$GITHUB_TOKEN" ]]; then - if [[ "$TRAVIS_REPO_SLUG" ]]; then - echo "upload $filename" - ${WDIR}/github-release-upload.sh github_api_token=$GITHUB_TOKEN repo_slug="$TRAVIS_REPO_SLUG" tag="${TRAVIS_TAG}" filename="$filename" - else - echo "TRAVIS_REPO_SLUG unset, skipping upload of $filename" - fi - else - echo "GITUB_TOKEN unset, skipping upload of $filename" - fi - fi - done - file=$(basename "${files[0]}") - - # JDS Commenting out the automaatic package logic here for now - #IFS=_ read -r package leftover <<< "$file" - #unset leftover - package="monitoring-plugins" - if [ -n "$package" ]; then - echo "Generating sha512sum for ${package}" - cd dist || exit - sha512_file="${package}_${TAG}_sha512-checksums.txt" - #echo "${sha512_file}" > sha512_file - echo "sha512_file: ${sha512_file}" - sha512sum ./*.tar.gz > "${sha512_file}" - echo "" - cat "${sha512_file}" - cd .. - if [[ "$TRAVIS_TAG" ]]; then - if [[ "$GITHUB_TOKEN" ]]; then - echo "upload ${sha512_file}" - ${WDIR}/github-release-upload.sh github_api_token=$GITHUB_TOKEN repo_slug="$TRAVIS_REPO_SLUG" tag="${TRAVIS_TAG}" filename="dist/${sha512_file}" - else - echo "GITUB_TOKEN unset, skipping upload of ${sha512_file}" - fi - fi - fi - if [[ "$TRAVIS_TAG" ]]; then - if [[ "$GITHUB_TOKEN" ]]; then - if [[ "$TRAVIS_REPO_SLUG" ]]; then - #Generate github release edit event - ${WDIR}/github-release-event.sh github_api_token=$GITHUB_TOKEN repo_slug="$TRAVIS_REPO_SLUG" tag="${TRAVIS_TAG}" - fi - fi - fi -else - echo "error dist directory is missing" -fi - - - - - From c11f87558d82324ce71f3f8bcb14502102a73d14 Mon Sep 17 00:00:00 2001 From: Jef Spaleta Date: Sun, 19 Jun 2022 21:58:15 +0000 Subject: [PATCH 7/9] add a github action for testing --- .github/workflows/test.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a313ddd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,15 @@ +name: Test +on: [push] + +jobs: + build: + name: Build and Validate + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build and Validate + run: ./scripts/build_and_validate.sh + env: + ASSET_VERSION: ${{github.ref_name}} + ASSET_REPONAME: monitoring-plugins + From ad19d9a168c529416f213936cc124d8f05d37c9f Mon Sep 17 00:00:00 2001 From: Jef Spaleta Date: Sun, 19 Jun 2022 22:02:44 +0000 Subject: [PATCH 8/9] fix for test action --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a313ddd..1376a14 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,6 @@ jobs: - name: Build and Validate run: ./scripts/build_and_validate.sh env: - ASSET_VERSION: ${{github.ref_name}} + ASSET_VERSION: ${{github.sha}} ASSET_REPONAME: monitoring-plugins From 1da4616417ac9f3117a143eb422551ac7fa737a4 Mon Sep 17 00:00:00 2001 From: Jef Spaleta Date: Mon, 20 Jun 2022 02:22:00 +0000 Subject: [PATCH 9/9] add tests for included plugins --- builds/disabled/.touch | 0 builds/enabled/.touch | 0 builds/enabled/alpine_linux_amd64/test_plugins | 1 - builds/enabled/centos6_linux_amd64/test_plugins | 1 - builds/enabled/debian8_linux_amd64/test_plugins | 1 - scripts/build_and_validate.sh | 3 ++- scripts/test.sh | 4 ++-- {scripts => tests}/test_check_disk.sh | 0 {scripts => tests}/test_check_dns.sh | 0 {scripts => tests}/test_check_http.sh | 0 {scripts => tests}/test_check_load.sh | 1 + {scripts => tests}/test_check_log.sh | 0 {scripts => tests}/test_check_ntp.sh | 1 + tests/test_check_ntp_peer.sh | 17 +++++++++++++++++ tests/test_check_ntp_time.sh | 9 +++++++++ tests/test_check_ping.sh | 9 +++++++++ tests/test_check_procs.sh | 9 +++++++++ tests/test_check_smtp.sh | 9 +++++++++ tests/test_check_snmp.sh | 9 +++++++++ tests/test_check_ssh.sh | 9 +++++++++ tests/test_check_swap.sh | 8 ++++++++ tests/test_check_tcp.sh | 9 +++++++++ tests/test_check_time.sh | 9 +++++++++ tests/test_check_users.sh | 9 +++++++++ tests/test_utils.sh.sh | 10 ++++++++++ 25 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 builds/disabled/.touch create mode 100644 builds/enabled/.touch delete mode 100644 builds/enabled/alpine_linux_amd64/test_plugins delete mode 100644 builds/enabled/centos6_linux_amd64/test_plugins delete mode 100644 builds/enabled/debian8_linux_amd64/test_plugins rename {scripts => tests}/test_check_disk.sh (100%) rename {scripts => tests}/test_check_dns.sh (100%) rename {scripts => tests}/test_check_http.sh (100%) rename {scripts => tests}/test_check_load.sh (92%) rename {scripts => tests}/test_check_log.sh (100%) rename {scripts => tests}/test_check_ntp.sh (92%) create mode 100755 tests/test_check_ntp_peer.sh create mode 100755 tests/test_check_ntp_time.sh create mode 100755 tests/test_check_ping.sh create mode 100755 tests/test_check_procs.sh create mode 100755 tests/test_check_smtp.sh create mode 100755 tests/test_check_snmp.sh create mode 100755 tests/test_check_ssh.sh create mode 100755 tests/test_check_swap.sh create mode 100755 tests/test_check_tcp.sh create mode 100755 tests/test_check_time.sh create mode 100755 tests/test_check_users.sh create mode 100755 tests/test_utils.sh.sh diff --git a/builds/disabled/.touch b/builds/disabled/.touch new file mode 100644 index 0000000..e69de29 diff --git a/builds/enabled/.touch b/builds/enabled/.touch new file mode 100644 index 0000000..e69de29 diff --git a/builds/enabled/alpine_linux_amd64/test_plugins b/builds/enabled/alpine_linux_amd64/test_plugins deleted file mode 100644 index 0648056..0000000 --- a/builds/enabled/alpine_linux_amd64/test_plugins +++ /dev/null @@ -1 +0,0 @@ -check_disk,check_dns,check_http,check_load,check_log,check_ntp diff --git a/builds/enabled/centos6_linux_amd64/test_plugins b/builds/enabled/centos6_linux_amd64/test_plugins deleted file mode 100644 index 0648056..0000000 --- a/builds/enabled/centos6_linux_amd64/test_plugins +++ /dev/null @@ -1 +0,0 @@ -check_disk,check_dns,check_http,check_load,check_log,check_ntp diff --git a/builds/enabled/debian8_linux_amd64/test_plugins b/builds/enabled/debian8_linux_amd64/test_plugins deleted file mode 100644 index 0648056..0000000 --- a/builds/enabled/debian8_linux_amd64/test_plugins +++ /dev/null @@ -1 +0,0 @@ -check_disk,check_dns,check_http,check_load,check_log,check_ntp diff --git a/scripts/build_and_validate.sh b/scripts/build_and_validate.sh index 8d8bc50..96fd157 100755 --- a/scripts/build_and_validate.sh +++ b/scripts/build_and_validate.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash [ ! -d "./scripts" ] && echo "Directory ./scripts does not exist" && exit 1 +[ ! -d "./tests" ] && echo "Directory ./tests does not exist" && exit 1 [ ! -d "./builds/enabled" ] && echo "Directory ./builds/enabled does not exist" && exit 1 [ ! -f "./.bonsai.yml" ] && echo "File ./.bonsai.yml does not exist" && exit 1 @@ -60,7 +61,7 @@ do tar xzf $OLD_DIR/assets/$ASSET_FILENAME cd $OLD_DIR for test_platform in "${test_arr[@]}"; do - docker run -e platform=${p} -e test_platform=${test_platform} -e plugins=${TEST_PLUGINS} -e asset_filename=${ASSET_FILENAME} -v "$PWD/scripts/:/scripts" -v "$PWD//dist/${p}:/build" ${test_platform} /scripts/test.sh + docker run -e platform=${p} -e test_platform=${test_platform} -e plugins=${TEST_PLUGINS} -e asset_filename=${ASSET_FILENAME} -v "$PWD/tests/:/tests" -v "$PWD/scripts/:/scripts" -v "$PWD//dist/${p}:/build" ${test_platform} /scripts/test.sh retval=$? if [ $retval -ne 0 ]; then echo "!!! Error testing ${asset_filename} on ${test_platform}" diff --git a/scripts/test.sh b/scripts/test.sh index e1094fd..131c716 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -16,8 +16,8 @@ export LD_LIBRARY_PATH="/build/lib:$LD_LIBRARY_PATH" export PATH="/build/bin/:$PATH" while IFS=',' read -ra tests; do for t in "${tests[@]}"; do - echo " Running: /scripts/test_${t}.sh" - /scripts/test_${t}.sh + echo " Running: /tests/test_${t}.sh" + /tests/test_${t}.sh retval=$? if [ $retval -ne 0 ]; then echo "!!! Test error: test_${t}.sh" diff --git a/scripts/test_check_disk.sh b/tests/test_check_disk.sh similarity index 100% rename from scripts/test_check_disk.sh rename to tests/test_check_disk.sh diff --git a/scripts/test_check_dns.sh b/tests/test_check_dns.sh similarity index 100% rename from scripts/test_check_dns.sh rename to tests/test_check_dns.sh diff --git a/scripts/test_check_http.sh b/tests/test_check_http.sh similarity index 100% rename from scripts/test_check_http.sh rename to tests/test_check_http.sh diff --git a/scripts/test_check_load.sh b/tests/test_check_load.sh similarity index 92% rename from scripts/test_check_load.sh rename to tests/test_check_load.sh index a6a8f93..aa8a813 100755 --- a/scripts/test_check_load.sh +++ b/tests/test_check_load.sh @@ -1,5 +1,6 @@ #/bin/sh check_load -w 100,200,300 -c 400,500,600 --help >> /dev/null +retval=$? if [[ $retval -eq 3 ]]; then exit 0 fi diff --git a/scripts/test_check_log.sh b/tests/test_check_log.sh similarity index 100% rename from scripts/test_check_log.sh rename to tests/test_check_log.sh diff --git a/scripts/test_check_ntp.sh b/tests/test_check_ntp.sh similarity index 92% rename from scripts/test_check_ntp.sh rename to tests/test_check_ntp.sh index ddf6c8d..97fd11c 100755 --- a/scripts/test_check_ntp.sh +++ b/tests/test_check_ntp.sh @@ -1,5 +1,6 @@ #/bin/sh check_ntp -H pool.ntp.org -w 10 -c 20 >> /dev/null +retval=$? if [[ $retval -eq 3 ]]; then exit 0 fi diff --git a/tests/test_check_ntp_peer.sh b/tests/test_check_ntp_peer.sh new file mode 100755 index 0000000..f92b38e --- /dev/null +++ b/tests/test_check_ntp_peer.sh @@ -0,0 +1,17 @@ +#/bin/sh +check_ntp_peer -H pool.ntp.org -w 10 -c 20 -q > stdout.txt +retval=$? +error=$(cat stdout.txt) +if [[ $retval -eq 0 ]]; then + exit 0 +fi +if [[ $retval -eq 3 ]]; then + exit 0 +fi +if [ "$error" = "CRITICAL - Socket timeout after 10 seconds" ]; then + exit 0 +fi +echo $error +exit $retval + + diff --git a/tests/test_check_ntp_time.sh b/tests/test_check_ntp_time.sh new file mode 100755 index 0000000..96752b6 --- /dev/null +++ b/tests/test_check_ntp_time.sh @@ -0,0 +1,9 @@ +#/bin/sh +check_ntp_time -H pool.ntp.org -w 10 -c 20 >> /dev/null +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/tests/test_check_ping.sh b/tests/test_check_ping.sh new file mode 100755 index 0000000..a954b65 --- /dev/null +++ b/tests/test_check_ping.sh @@ -0,0 +1,9 @@ +#/bin/sh +check_ping -H localhost -w 1,100% -c 2,100% -p 1 > /dev/null +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/tests/test_check_procs.sh b/tests/test_check_procs.sh new file mode 100755 index 0000000..bdeffb1 --- /dev/null +++ b/tests/test_check_procs.sh @@ -0,0 +1,9 @@ +#/bin/sh +check_procs > /dev/null +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/tests/test_check_smtp.sh b/tests/test_check_smtp.sh new file mode 100755 index 0000000..8902181 --- /dev/null +++ b/tests/test_check_smtp.sh @@ -0,0 +1,9 @@ +#/bin/sh +check_smtp -H smtp.gmail.com > /dev/null +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/tests/test_check_snmp.sh b/tests/test_check_snmp.sh new file mode 100755 index 0000000..c66b618 --- /dev/null +++ b/tests/test_check_snmp.sh @@ -0,0 +1,9 @@ +#/bin/sh +check_snmp -H snmp.live.gambitcommunications.com -o sysContact.0 > /dev/null +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/tests/test_check_ssh.sh b/tests/test_check_ssh.sh new file mode 100755 index 0000000..2a4ce2e --- /dev/null +++ b/tests/test_check_ssh.sh @@ -0,0 +1,9 @@ +#/bin/sh +check_ssh --help > /dev/null +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/tests/test_check_swap.sh b/tests/test_check_swap.sh new file mode 100755 index 0000000..aa15d10 --- /dev/null +++ b/tests/test_check_swap.sh @@ -0,0 +1,8 @@ +#/bin/sh +check_swap -w 1 -c 1 > /dev/null +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/tests/test_check_tcp.sh b/tests/test_check_tcp.sh new file mode 100755 index 0000000..f3ccfac --- /dev/null +++ b/tests/test_check_tcp.sh @@ -0,0 +1,9 @@ +#/bin/sh +check_tcp -H www.sensu.io -p 80 > /dev/null +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/tests/test_check_time.sh b/tests/test_check_time.sh new file mode 100755 index 0000000..a9b3dc4 --- /dev/null +++ b/tests/test_check_time.sh @@ -0,0 +1,9 @@ +#/bin/sh +check_time -H Ntp-wwv.nist.gov > /dev/null +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/tests/test_check_users.sh b/tests/test_check_users.sh new file mode 100755 index 0000000..df14c0f --- /dev/null +++ b/tests/test_check_users.sh @@ -0,0 +1,9 @@ +#/bin/sh +check_users -w 1000 -c 10000 > /dev/null +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + + diff --git a/tests/test_utils.sh.sh b/tests/test_utils.sh.sh new file mode 100755 index 0000000..4120559 --- /dev/null +++ b/tests/test_utils.sh.sh @@ -0,0 +1,10 @@ +#/bin/sh +source utils.sh +check_range 1 2:8 +retval=$? +if [[ $retval -eq 3 ]]; then + exit 0 +fi +exit $retval + +