Forum Discussion
You're thinking about it the wrong way. When you create a datasource, you need to think about what kind of data to collect for a single server or what kind of data you want concerning a single object on one server. If you want to collect one kind of data for one server and another kind for another server, you need two datasources. It seems like you would want one DS for tracking the sizes of folders under a specified directory.
I mention multi-instance datasources because it seems like you may want to monitor attributes about folders on a server. In that case, you'd think about what you want to do for one folder on one server. You'd write your script to collect the stats for one folder and LM would repeat it for all folders discovered. You'd write a separate script to identify which folders to track (the active discovery script).
So, your active discovery script would reach out to one server and fetch the list of folders. The active discovery script would run once for each server the DS applies to. Each time the active discovery script runs, the token ##SYSTEM.HOSTNAME## in your script would get replaced with the name of the server. When it runs for server1, ##SYSTEM.HOSTNAME## would be replaced with "server1" at runtime, allowing your invoke-command to fetch the folder list from server1. When it runs for server2, ##SYSTEM.HOSTNAME## would be replaced with "server2" at runtime, allowing the same invoke-command to fetch the folder list from server2. When it runs for server3, ##SYSTEM.HOSTNAME## would be replaced with "server3" at runtime, allowing the same invoke-command to fetch the folder list from server3.
Your collection script can run one of two ways, depending on whether or not you select "script" or "batchscript" in the collector field of the DS configuration.
If you chose "script", then the script will run once for each folder (instance) discovered by the active discovery script. The script would use tokens like ##SYSTEM.HOSTNAME## and ##WILDVALUE## to feed into the invoke-command to reach out to each folder on each server and obtain data for the folder. If the active discovery script had discovered 7 folders on server1, 3 folders on server2, and 5 folders on server3, then the collect script would run 15 times, once per folder. Each time it ran, the value of ##SYSTEM.HOSTNAME## and ##WILDVALUE## would change to the server name and folder name.
If the following table represents what was discovered by the active discovery script, you can see that the collection script would run 15 times, once per row in the table. Every time it ran, the value of the ##SYSTEM.HOSTNAME## and ##WILDVALUE## tokens would change to reflect the current server/folder the script was trying to collect data about.
Server Name | Folder Name | ##SYSTEM.HOSTNAME## | ##WILDVALUE## |
server1 | folderA | server1 | folderA |
server1 | folderB | server1 | folderB |
server1 | folderC | server1 | folderC |
server1 | folderD | server1 | folderD |
server1 | folderE | server1 | folderE |
server1 | folderF | server1 | folderF |
server1 | folderG | server1 | folderG |
server2 | folderA | server2 | folderA |
server2 | folderB | server2 | folderB |
server2 | folderC | server2 | folderC |
server3 | folderA | server3 | folderA |
server3 | folderB | server3 | folderB |
server3 | folderC | server3 | folderC |
server3 | folderD | server3 | folderD |
server3 | folderE | server3 | folderE |
The collection script itself can collect any number of metrics about each folder, but you only focus on the metrics about one folder. LM will take care of collecting those metrics for all folders, if you built your script using the tokens.
So you'd focus on how to do this: given the server name and the folder name, how do i find out
- 1. the size of the folder
- 2. if this folder is the largest of all the folders
- 3. if there are no files greater than a certain size.
- Your collection script need only answer those questions for one folder: the folder called ##WILDVALUE##. The server that the folder is on is called ##SYSTEM.HOSTNAME##.
If it's more efficient to run one script and fetch all the data for all the folders on one server at a time, you'd use batchscript mode.
Related Content
- 3 months ago
- 7 months ago
- 8 months ago