#!../common/bats/bin/bats
# -*-sh-*-

load ./common/test_helper_functions || exit 1
source ./common/functions || exit 1

if [ -s ./common/TEST_ENV ];then
    source ./common/TEST_ENV
fi

check_rms
rm=$RESOURCE_MANAGER

@test "[nagios] check for RPM" {
    run check_if_rpm_installed "nagios"
    assert_success
    if [ "x$DISTRO_FAMILY" == "xSLES"  ];then
	run check_if_rpm_installed "monitoring-plugins-ssh"
    else
	run check_if_rpm_installed "nagios-plugins-ssh"
    fi
    assert_success
    run check_if_rpm_installed "nrpe"
    assert_success
}

@test "[nagios] test nagiostats" {
    run nagiostats
    assert_success
}

@test "[nagios] test check_http" {

    if [ "x$DISTRO_FAMILY" == "xSLES"  ];then
	nagiosPath=/usr/lib/nagios/plugins
    else
	nagiosPath=/usr/lib64/nagios/plugins
    fi

    if [ $use_proxy -eq 0];then
	run ${nagiosPath}/check_http -I ${proxy_host} -p ${proxy_port} -u http://openhpc.community
    else	
	run ${nagiosPath}/check_http  -H openhpc.community
    fi
    assert_success
}
