From 11ec1405467202ebb7eea2a2abd0f602b4b26772 Mon Sep 17 00:00:00 2001 From: Ankam Ravi Kumar <14858025+techarkit@users.noreply.github.com> Date: Mon, 5 Jul 2021 15:15:54 +0530 Subject: [PATCH] Create generate_win_host_config.sh To Generate Windows Host Configuration with in Minute, Generate N number of servers. --- generate_win_host_config.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 generate_win_host_config.sh diff --git a/generate_win_host_config.sh b/generate_win_host_config.sh new file mode 100644 index 0000000..cc6259e --- /dev/null +++ b/generate_win_host_config.sh @@ -0,0 +1,24 @@ +#!/bin/bash +## Purpose: To Generate Nagios Configuration files within minute of time. +## Author: Ankam Ravi Kumar + +mkdir -p /scripts/WinServers +cat /scripts/serverlist.txt | while read LINE +do + HostIP=`echo $LINE | cut -d, -f1` + HostName=`echo $LINE | cut -d, -f2` + +NSCLIENTSTATE=$(/usr/local/nagios/libexec/check_nt -H $HostIP -p 12489 -v CLIENTVERSION -s Password | echo $?) +if [ $NSCLIENTSTATE -eq 0 ]; then + sed -e "s/XXXX/$HostName/g; s/ZZZZ/$HostIP/g" /scripts/Template-Windows.cfg > /scripts/WinServers/$HostName.cfg + +for i in D E F G H I J K L M N O P Q R S T U V W X Y Z; +do +/usr/local/nagios/libexec/check_nt -H $HostIP -p 12489 -v USEDDISKSPACE -s Password -l $i -w 90 -c 95 +COMMANDSTATUS=$(echo $?) +if [ $COMMANDSTATUS -eq 0 ] || [ $COMMANDSTATUS -eq 2 ];then +sed -e "s/XXXX/$HostName/g; s/ZZZZ/$i/g" /scripts/Drives.cfg >> /scripts/WinServers/$HostName.cfg +fi +done +fi +done