Forum Discussion

Kelemvor's avatar
Kelemvor
Icon for Expert rankExpert
4 months ago

How can I run a script as a DataSource instead of an EventSource

Hi,

I don’t know if this is going to make any sense, as I’m working on something created by someone else, but here goes…

We have some servers that run some custom jobs.  We have scripts on these servers and have EventSources setup in LM to run these scripts and collect the data every X minutes.  When the scripts return data that needs to alert us, it does.  But, if it runs again 5 minutes later, and gets another results that says to alert us, it creates a new alert, instead of just chalking it up to the existing alert that’s still there.

Do we need to set this up as a Datasource instead of an Eventsource maybe?  I don’t know exactly what the scripts do yet, so I’m just looking for general info on how we can make this work.

Is it better to have LM run a script and get the result vs having the server run the script, put the results in a file, and then LM just goes and reads the file?

Anyway, that’s probably pretty vague, but if it makes sense, let me know.

Thanks.

2 Replies

  • Converting it to a standard datasource makes sense.

    And the process is basically the same, set the polling interval to 5 minutes. Lets say you have only pass/fail. Return a 1 or 0 and alert on the fail then set the clear to clear immediately when not in failure.

  • There are a few ways you could accomplish this. A datasource would definitely do it, but depending on the data it might not work as well as you’d like. 

    Another option would be to use the collector script cache to keep track of the events that were already picked up by the eventsource. If the event has some sort of unique identifier, or a string of text that could uniquely identify it, you could store that in a list in the collector script cache. Then when the eventsource runs, it would still fetch the event even though it fetched it previously. But before outputting the event to LM, it could check if the event is in the script cache. If it is, it could skip outputting that event and not open another event.