#!/bin/bash
# Script for installing WMI prerequisites
#

# Copyright (c) 2011 Nagios Enterprises, LLC.  All rights reserved.
#


# Check whether we have sufficient privileges
if [ $(( $(id -u) )) -ne 0 ]; then
	echo "This script needs to be run as root/superuser."
	exit 1
fi

echo "Nagios WMI Client Installation"
echo ""
echo "Installing required software...."

if uname -i  | grep "64"; then
	yum install perl-DateTime perl-Config-IniFiles perl-List-MoreUtils elf glibc.i686 glibc-devel.i686 cyrus-sasl-lib.i686 libcgroup-pam.i686 pam.i686 popt.i686 -y
else
	yum install perl-DateTime perl-Config-IniFiles perl-List-MoreUtils -y
fi

# Download and install WMI client binary
wget -c "http://assets.nagios.com/downloads/nagiosxi/agents/wmic-centos5-static.tar.gz"
tar -xzvf "wmic-centos5-static.tar.gz"
chmod +x wmic
cp wmic /usr/bin



echo ""
echo "==================================="
echo "Nagios WMI Client Install Complete!"
echo "==================================="

exit 0
