Collection based on contents of a log file?
Howdy,
I pushed out some software to a bunch of machines but some of them are not working properly even though the install worked just fine. I can narrow down the machines that aren't working based on a specific entry in a log file. All the machines have the file, but won't have a certain string if they are working.
Is there any way to setup a scan and collection based on if a specific file has a specific string inside it?
Thanks!
0
Comments
I hope i can explain my solution correct,i think you can use this good for your problem.
This is a CMD Script to check the HDD S.M.A.R:T (used before PDQ integrated a SMART check in PDQ) and checking the result text inside the file. Depending on the result text, it renames the textfile with OK or Error. Then i used the file scanner and custom collections to track the Smart_ERROR.txt and Smart_OK.txt on the devices.
======================
@echo off
md C:\pdq_status\HDD
del C:\pdq_status\HDD*.txt /Q
wmic /OUTPUT:C:\pdq_status\HDD\status.txt diskdrive get status
find "OK" C:\pdq_status\HDD\status.txt >nul
if %errorlevel%==0 GoTo doingGood
ren C:\pdq_status\HDD\status.txt Smart_ERROR.txt
GoTo done
:doingGood
ren C:\pdq_status\HDD\status.txt Smart_OK.txt
:done
======================
Explanation:
md C:\pdq_status\HDD (creates a new directory where all status files a stored)
del C:\pdq_status\HDD*.txt /Q (deletes all text files inside this folder because we only want new results if the scan is repeated)
wmic /OUTPUT:C:\pdq_status\HDD\status.txt diskdrive get status (creates the SMART status and saves the status.txt inside the new folder, this step is not neccessary for you, but we need the file, please use a copy step and copy your log file to this location)
find "OK" C:\pdq_status\HDD\status.txt >nul (this is the smoking gun, this strings searchs for "OK" inside the status.txt, you have to replace the filename and the search word with yours)
if %errorlevel%==0 GoTo doingGood (if the word is found inside the file the script jumps to :doingGood)
ren C:\pdq_status\HDD\status.txt Smart_ERROR.txt (this step only kicks in if the word was not found in the file and renames our status.txt to smart_error.txt)
GoTo done (the script jumps to the end because the result was negative)
:doingGood (this is the next step if the word was found, the negativ steps are not excecuted)
ren C:\pdq_status\HDD\status.txt Smart_OK.txt (renames the status.txt to smart_ok.txt because the word was found)
:done (ends the script)
Next thing, create a file scan for C:\pdq_status\ and then a custom collection that looks for the filenames
Greetings
Chris