I'm new to writing scripts for Solarwinds and wanted to try my hand at a simple start. The goal is to check for a specific number of processes on specific servers.
To achieve this and to simplify maintenace by the application support teams the goal was to have a file on each server monitored by this script containing process and occurrence count. The script would then verify all process counts in the file matched reality. So the code is:
'
' Script to validate the number of processes of a certain type running on a server
Dim processLimit
dim service, Process, ProcessName, file
dim i , pName, pCount , errorFlag
Set fso = CreateObject ("Scripting.FileSystemObject")
set service = GetObject ("winmgmts:")
Set processCount = CreateObject("scripting.dictionary")
Set stdout = fso.GetStandardStream (1)
Set stderr = fso.GetStandardStream (2)
' Count up how many of each process is running on the server
for each Process in Service.InstancesOf ("Win32_Process")
processCount(Process.Name)=processCount(Process.Name)+1
next
' open the file containing the expected number of processes
' only contains those processes that we are worried about
' Format: process|count
Set file = fso.OpenTextFile ("c:\processLimitCount.txt", 1)
' loop through the defined processes
errorFlag = 0
Do Until file.AtEndOfStream
line = file.Readline
i = instr(line,"|")
pName = left(line,i-1)
pCount = mid(line,i+1)
if trim(processCount(pName)) <> trim(pCount) then
errorFlag = 1
end if
Loop
file.Close
stdout.writeline ( "Statistic: " & Cstr(errorFlag) )
this script runs fine when run directly on the server with the following output
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Statistic: 0
but when run though Solarwinds targetting that server it comes up with:
Get Output Failed:C:\ProgramData\SolarWinds\Orion\temp\4a6c15b6-9b4a-4d4f-9a66-a12b69cc989f(24, 1) Microsoft VBScript runtime error: File not found
Any idea why the file wouldn't be found? Is it something simple I am missing?