New to LM: How do I refer to the local filesystem in an embedded PowerShell script of a DataSource?
How do I refer to the local filesystem in an embedded PowerShell script of a DataSource? The below works fine from a PowerShell session console on a Collector server, but fails when running embedded ...
Yes, and you see it worked for me in my screenshot with a full path. The only thing I'm aware of that LM will do to a powershell script is do a search-and-replace of ##TOKEN## but I didn't see any of that in your code. Even your error message isn't show the path getting screwed up and it's powershell telling you the file doesn't exist there.
I would 100% make sure the script is actually running on the server you think it's running on. Does "Write-Output $env:computername" show the name of the server with the file?
I resolved it a bit ago by forcing the script in Collection mode to send a 1 to the datapoint. But yes, there was a strange disconnect. Anyway, there is what I noted this morning after doing that, and I was literally about to post this question:
What could cause an alert to hang on once the underlying cause in the instance has quit notifying the datapoint from the Collection script? Alert history shows it alerted once last night then stopped, which is correct (was a test). Collection is not sending it any data, none shown received in Raw Data or Poll Now, and I confirmed with debug outputs that the block that can send 1 to the datapoint is not being executed, but still it won't clear. However, it cleared immediately when I forced-sent 0 to it.
If I understand you right. A NoData will not clear an alert. So if your threshold is >=5 and the data is (over time) 1, 1, 1, 6, NoData, NoData, 2, 2, 1, 1... the "6" will cause an alert but it will not clear that alert until it gets a valid value under the threshold. So NoData is not a condition that will clear the alert until it gets the "2" which can then clear it (assuming instant alert/clear).
WHOA! I had no idea. That explains it, I think. But now I'm thinking maybe I've been missing something fundamental about how this works, but I'm confused because I've always taken this approach in the other similar datapoints and they work like clockwork (once in a while I recall some oddball stuff like this, though):
In general, I thought that (in my case) I send a key-value pair to the datapoint in Collection and it triggers the threshold (=1 in my case). But the script logic doesn't send it anything when the condition no longer exists to justify alerting. When there is no error condition, it just skips past the part where it otherwise sends a 1 if there's an error condition. And in Raw Data, you can see it change from 1 to "No Data" and with the next polling cycle it clears.
Are you saying that even when I don't want to trigger an alert I should still send the datapoint something non-triggering if it has been previously been in alert condition? How would it know? If so, I guess you'd want to ALWAYS return a value no matter what? But then that gets into having multiple datapoints that can possibly be written to, all of which could possibly have been alerting prior, though there is no cause for the alert now... ?
You may want to look at the difference between a DataSource and an EventSource.
Kinda the idea for a DataSource is that you throw performance data at LM which can log it and graph it. Along with also doing that, LM can have thresholds that will let you set off alerts. While you can just just have a datapoint of "alert" yes/no, it's not the best way normally. But also the important part for DataSource alerting is that there will be a condition that causes an alert and a condition that clears it. There is a start and end time. If you have something that is just a point-in-time event, where there is no end time, you should look at EventSource, or JobMonitoring or something like that.
So we have gone back and forth a lot, but you haven't talked about what you are trying to accomplish in general. Perhaps if we understood that, we can make better suggestions on how to accomplish it.
I've been reading about the other forms of DataSources and I may investigate. But I feel like I'm so close, I've just hit a brick wall with my understanding of how alerting works in LM:
I'm realizing now that I'm doing testing on this multi-instance DataSource with the embedded PW script (Active Discovery in SCRIPT mode, Collection in BATCHSCRIPT mode), I still don't really understand some finer points about alert behavior. I only learned yesterday during testing that once a datapoint alerts on something, once it's time to end the alert (a contrived alert in this case by temporarily setting a specific static value in a variable), simply skipping the error part in the script and not writing anything to the datapoint (via key-value pair in a line of output) is NOT enough - a value must be sent that is lower (or different than?) the threshold for it to clear. Okay, I get that, and revised my script accordingly.
But as of last night, I'm totally stumped about the different in the Raw Data table for the instance in question versus what you see with the Poll Now results, now that the Collection script is sending a value that should clear the alert. The Raw Data table shows "No Data" rather than the value 0 (which should clear the alert, and it has before during earlier testing), while the Poll Now results (which also match the script output using the Test Collection Script feature in the DataSource) correctly show a value of 0. But I let it sit overnight and the alert still hasn't cleared, Raw Data is still showing "No Data" and Poll Now and Test script output still show a value of 0 for that datapoint. I'm so confused! What are the mechanics of that? Do they actually derive from different sources/processing internal to LogicMonitor?