Batch script
How can we call Wild value from Active Discovery output to collection code( Batch Script)?
manthena2020
Posted 2 years ago·Last reply 2 years ago
28 comments
How can we call Wild value from Active Discovery output to collection code( Batch Script)?
manthena2020
OP2 years agoI just wanted to ask you. Which way would be ideal choice. I mean looping or calling wild values into the Script
LM User
·2 years agoWhichever one works. I don't see a real advantage of one over the other.
manthena2020
OP2 years agoHello, I confirm that it is fetching Wild values list. The only thing I observed is, we have to save the Active Discovery Script & Applies (server details, where the code shall run) then only we can fetch the information .Thanks
LM User
·2 years agoYeah, it wouldn't work in test script nor in the collector debug since those aren't fully fledged collection tasks. Only when the task is scheduled as a collection task will that be present. Just like you can't fetch a single wildvalue on a test script for a script based DS.
manthena2020
OP2 years agois there any other ways apart from Looping. Like call wild value in different way
LM User
·2 years agoLike i mentioned before, yes, i believe there is a way. However, I don't know the exact code, someone from LM would need to provide that (they should).
That said, i've built hundreds of datasources and it's never really been an issue to just use the same code that produces the instance list in the first place right in the collection script. In many cases, the same call that grabs the list of instances from the target can include the metrics as well so you're still only doing one call.
So if your query calls the database to grab the list of instances during discovery, do the same thing during collection, but expand your query to include the metrics. Then loop through the rows of that query outputting the wildvalue along with the metrics.
Michael Rodrigues
·2 years agoI pinged the ME's channel and linked to this thread. If there is some way of enumerating wildaliases from within an AD batchscript, it's not something I'm aware of. There could be some new way I'm not aware of.
I wrote countless official LM modules that did the same thing with respect to running the same code in AD and collection, to get the instances.
*About 2 seconds after posting this I received this from the MEs:
manthena2020
OP2 years agoI can see issue is fixed. But my question here is why cant we call this property
def wildvalue = instanceProps.get("wildvalue")
in Collection Script?
LM User
·2 years agoBecause with batchscript, the script runs for all instances. Which instance's wildvalue did you expect back? You can only do instanceProps.get("wildvalue") on script, not batchscript.
LM User
·2 years agoI believe there is a way to grab from the deviceDatasourceProps the list of wildvalues, but i haven't been able to relocate the code where i saw that done.
It would be nice if someone from LM who knew how to do it chimed in here. Maybe someone from the ME team...
skylaurman
·2 years agoHere is a way to get a list of the wild values:
Here is a way to do as you wish with the wild values:
LM User
·2 years agoThis is the right answer. Could someone at LM please put in a DOC ticket to get this published into the support documentation or the dev guide?
skylaurman
·2 years agoYes, we will get this added to the support documentation.
skylaurman
·2 years agoDocumentation has been updated to include examples: https://www.logicmonitor.com/support/logicmodules/datasources/data-collection-methods/batchscript-data-collection
manthena2020
OP2 years agoTo test this . I Have Executed against my server. Iam not getting any output .sample print test on collection script
manthena2020
OP2 years agoskylaurman
·2 years agoI had wild value as camel case in the second example and should have used flat case. Here is the updated version.
manthena2020
OP2 years agoWhat you want me to share?
LM User
·2 years agoI was looking for a screenshot of the results of a poll now. But that doesn't matter because you have illegal characters in your wildvalue. You'll need to update your discovery and collection scripts to remove the offending characters. The link i provided in the last reply highlights which characters you can't have in your wildvalue.
manthena2020
OP2 years ago====================================================================================
Active Discovery-Script
====================================================================================
Wildvalue
D:\HP123\ramDB\DIFF\HP123_dkkDB_DIFF_20240821_160039.bak
D:\HP123\model\DIFF\HP123_model_DIFF_20240821_160038.bak
=======================================================================================
collection Output-Batchscript
=======================================================================================
D:\HP123\ramDB\DIFF\HP123_dkkDB_DIFF_20240821_160039.bak.BackupType:2
D:\HP123\ramDB\DIFF\HP123_dkkDB_DIFF_20240821_160039.bak.BackupSize: 3
D:\HP123\ramDB\DIFF\HP123_dkkDB_DIFF_20240821_160039.bak.TimeTaken: 0
D:\HP123\ramDB\DIFF\HP123_dkkDB_DIFF_20240821_160039.bak.RecoveryModel: 1
D:\HP123\ramDB\DIFF\HP123_dkkDB_DIFF_20240821_160039.bak.Native_Backup: 1
D:\HP123\model\DIFF\HP123_model_DIFF_20240821_160038.bak.BackupType:2
D:\HP123\model\DIFF\HP123_model_DIFF_20240821_160038.bak.BackupSize: 0
D:\HP123\model\DIFF\HP123_model_DIFF_20240821_160038.bak.TimeTaken: 0
D:\HP123\model\DIFF\HP123_model_DIFF_20240821_160038.bak.RecoveryModel: 2
D:\HP123\model\DIFF\HP123_model_DIFF_20240821_160038.bak.Native_Backup: 1
LM User
·2 years agoNot what i was looking for, but it highlights one problem. See this documentation.
manthena2020
OP2 years agoLM User
·2 years agoAll that seems good. Could you post a screenshot of your poll now? Redact any private information. What I'm looking to see is the script output down below so try to get the whole dialog box if possible.
manthena2020
OP2 years agowhen i try to do Pollnow from LM Console against each instance
Output : i am getting Null
script output : i am getting Data
manthena2020
OP2 years agoAs you said i done the looping in collection script using same code which i have used in Active Discovery, i am getting output. The Only Challenging here is the output is not Posting against each instance under Raw data Tab
manthena2020
OP2 years agoOk. Could you please Help me on short cut to Pull. Thanks
LM User
·2 years agoWhat does your discovery script look like?
LM User
·2 years agoFor batchscript, it's not one wildvalue, but all of the ones from discovery. Usually, I just run the same code that ran in the discovery script to the list of wildvalues. Then i loop through it. I saw some code from LM recently (I'd have to search) that had a shortcut for pulling in the wild values.