Forum Discussion
Sure! Let's assume you have the right credentials to create LogicModules in LogicMonitor (if you don't, ask the IT team that administers LM). Let's also assume that you want to track the status of this thing over time.
For reference: https://www.logicmonitor.com/support/logicmodules/datasources/creating-managing-datasources/creating-datasources
You would need to create something called a DataSource. The DataSource is built through the LogicMonitor GUI. You need to configure four main areas:
1. General Information like what to call the datasource and with which device(s) you will associate the resulting data (this is done through the AppliesTo). You mention that you run the script on the collecting server. If that's the simple case, you can just configure the AppliesTo to match one or another collector. However, if the script fetches data about multiple servers (even if it doesn't touch the target server), you may consider having it apply to those servers. You can then establish a token (variable) in your powershell script that would have its value be the name of whichever server you were trying to monitor. This is like having a script that says "ping ##SYSTEM.HOSTNAME##" and the collector would execute the script once for every device the DataSource applies to, substituting the real hostname for the token each time it's executed.
It is also in this general section that you would choose how often to collect data and the "Collector". This "Collector" simply means what method you want to use to collect the data. In your case, it sounds like you are interested in one result per target server, so you could simply pick "SCRIPT" for the "Collector".
2. Since you are interested in only one result per target, you wouldn't need active discovery. Skip to step three. For completeness, know that Active Discovery is where you would configure LM to figure out the names and IDs of objects on the target server you want to monitor. For example, you could write a script that uses the invoke-command cmdlet to issue "wmic logicaldisk get name" to get the names of each logical drive on the server. The invoke-command cmdlet would use the ##SYSTEM.HOSTNAME## token to specify the target server. The result of that command would be received by LM and one "instance" created for each logical drive on each remote server.
3. This section is where you would provide your script. Make sure you pick PowerShell instead of the default Groovy. Your script would need to Write-Host the data (that's how LM reads the results of your script). You'd write the result out like this (the results have to be numerical in order for LM to bring it in*):
#For OK:
Write-Host 0
#For Warning:
Write-Host 1
#For Critical
Write-Host 2
4. The last step is to define what to do with the data that is written back to LM. Create a new datapoint called "MyCustomStatus" (or whatever you want to call it) and select "Content the script writes to the standard output". You'd want to set a threshold to have LM open an alarm, so go down to the Alert Threshold section and choose ">=" and put "1 2 2" in the text box to the right. This means that a warning alarm will be opened when the result is 1 and a critical alert when the result is 2. Save the datapoint and save your DataSource.
The collector should start running your script within a few minutes, depending on the collection interval you picked. If you navigate to the "Resources" page (on the left grey bar) and find the device you applied the datasource to, you should see your new datasource under the device. Click on your datasource under the device and select the "Raw Data" tab. You should start seeing rows show up there (you might have to sit on the refresh button for a few minutes).
The only remaining thing would be to create a graph to display your data in a more customized fashion than the default graph that is generated when you build a datasource. If you want help with that, let me know.
*There are different types of LogicModules that
Related Content
- 7 months ago
- 10 months ago