Run several Remote Data Collectors on one machine

QUESTION

How can I run several Remote Data Collectors on the same server for several different Metric Insights instances?

ANSWER

In order to run several Remote Data Collectors (RDC) on the same server for several different Metric Insights (MI) instances you need to:

1. Clone existing RDC installed previously "Insightd", located at:

C:\Program Files (x86)\Metric Insights\Insightd

and name it "Insightd_2", so you will have the following path:

C:\Program Files (x86)\Metric Insights\Insightd_2

2. Configure different MI instance in the "Insightd_2" RDC on config.ini file.

3. Create RDC batch script that consists of ".bat" and ".ps1" files in separate folder.

4. Create a task in Windiws "Task Scheduler" to run ".bat" file every 5 minutes. This will ensure that RDC job is restarted in case of connection errors or other unexpected crashes.

Here is the detailed instruction on how to create ".bat" and ".ps1" files:

1. Create Datacollector.bat file with the following code inside:

@ECHO OFF
::Check the last 14 logs from Event Viewer of Metric Insights Daemon and search for the error with pattern "[Thread-0] ERROR". Matched error lines are then put to DatacollectorLOG.txt file.
wevtutil qe "Metric Insights Daemon" "/q:*[System]" /c:14 /rd:true /f:text | findstr /C:"[Thread-0] ERROR" > %~dpn0LOG.txt
for /f "tokens=1" %%c in ('type "%~dpn0LOG.txt" ^| find /c /v ""') ^
do set lines=%%c
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"

::If no errors detected, no action performed
) else (
echo "No recent errors detected in 14 recent Event logs"
)

@ECHO OFF
::Check if RDC is running on port 7010
netstat -o -n -a | findstr 7010

::If RDC is running, no action performed
if %ERRORLEVEL% equ 0 (
@echo "RDC is running on port 7010"

::Else script will start RDC job
) else (
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
)
timeout 10

2. Create Datacollector.ps1 file with the following code inside:

if((get-process "insightd" -ea SilentlyContinue) -eq $Null){
"Stop RDC Service"
& 'C:\Program Files (x86)\Metric Insights\Insightd_2\bin\insightd.cmd' stop -c 7010 -f 'C:\Program Files (x86)\Metric Insights\Insightd_2\conf\config.ini'
Start-Sleep -Seconds 5
 "Start RDC Service"
& 'C:\Program Files (x86)\Metric Insights\Insightd_2\bin\insightd.cmd' start -c 7010 -f 'C:\Program Files (x86)\Metric Insights\Insightd_2\conf\config.ini'
}

The above code of ".ps1" file means that RDC will be started from "Insightd_2" folder on port 7010.

3. Schedule runs of Datacollector.bat script.

- Go to Windows "Task Scheduler" and create a new Task

 

4. For the first time start Datacollecor.bat script manually from Administrator and verfy if RDC establishes connection to you MI instance. You can check it in the Windows Event Viewer for Metric Insights Daemon service.

If you need help with performing any of the above actions please write to [email protected] and we'll gladly assist you.