Forum Discussion
- Anonymous
Can you post the details of the DataSource you've built? I assume this is still to do with the powershell based datasource?
Thank you
Yes this a powershell based Datasource.
For example :
My "AppliesTo" picks 3 servers from the pool.
So now this Datasource is common to the three servers.
3 Data points are built into the Datasource.
Problem: While viewing each Server individually from "Resources"..... I can see Raw Data for all three servers.
Question : Can I make this Data point specific. I mean if I navigate to Server1, I should only see Raw Data for Server 1.
Thank you, Please questions if scenario isn't clear.
- Anonymous
Ok, what are the three datapoints for? The number of datapoints should represent the number of datapoints you'd see on one server. So, if you are collecting CPU %, Memory %, and Swap %, you'd have 9 datapoints (3 servers x 3 datapoints). If you have three datapoints, one for each server, what you really want is one datapoint.
What does the "collector" field look like? Does it say script or batchscript? What does your script output look like?
My powershell script in the datasource box is like below
Invoke command - computername Server1 - scriptblock { Logic to Size of folder = x }
Invoke command - computername Server2 - scriptblock { Logic to Size of folder = y }
Invoke command - computername Server3 - scriptblock { Logic to Size of folder = z }
So each script output is like eg: X= 20
Data points collecting key value pairs
Datapoint1 =x..... Datapoint2=y and Datapoint3=z
My Requirement : Server1 should display only Datapoint1 Raw data and not other 2 data.
Anything you could help or point me to?
Thank you
- Anonymous
Ok, cool. What you need to do is adjust your script so that it talks to only one server and outputs only one datapoint. Instead of manually specifying server1, server2, and server3 in your script, you would bring the server name in as a variable.
How you do this depends on a few things. Is this a multi-instance datasource? If so, are you in script or batchscript mode?
If it's a single instance datasource, you'll be using script mode, so the collector will run your script once for each server. To get the hostname into a variable in your powershell script like this:
$hostname = '##SYSTEM.HOSTNAME##';
Then your invoke command would only happen once and would look like this:
Invoke command - computername $hostname - scriptblock { Logic to Size of folder = x }
So, each execution of the script would output metrics for that one server. The number of metrics for one server would be the same number of datapoints defined.
Thank you for your assistance.
But if my logic within would be changing for different servers
For eg:
Invoke command - computername Server1 - scriptblock { Logic to Size of folder = x }
Invoke command - computername Server2 - scriptblock { Logic to Number of empty folder = y }
Invoke command - computername Server3 - scriptblock { Logic to Name of oldest folder = z }
So still do we see a way out of this?
Or then we have to create 2 separate Data sources?
- Anonymous
If you want different data, you need different datasources.
However, it sounds like you would probably want this all in one datasource. What's your intent? You might consider a multi-instance DS where you have an instance for each folder. Give me more of an idea what you want to accomplish.
Thanks Stuart for showing interest in helping out
Yes definitely the requirements is of varied data under one datasource.
Can be like :
Server 1 check for Size of folders at a directory
Server 2 check for Oldest file lying in the given folder
Server 3 check for certain no of files greater than certain size
Can this requirement be satisfied by multi instance Datasource?
And if yes then it maintains the raw separately?..... Meaning i cannot see other raw data from this server.
- Anonymous
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.
- On 5/8/2020 at 11:29 PM, Stuart Weenig said:
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,
Hey Stuart ..... Thanks again for the assistance so far
Considering i am very new to Logicmonitor and Powershell as well, could you please help me with a sample Activ Script for passing multiple paths ?
I couldn't decode much from the support documents.
Questions ; 1. After the activ scripting in DS, do I still need to add instance on my resource?
2. Where do I specify ##WILDVALUES##, in the instances right?..... What if they are multiple values, how does the name convention work for it ?
Also i read it that wildvalues cannot have '\' in it. So how can i specify paths to different folders.
Sorry for those Newbie noob questions
Thank you
Related Content
- 4 months ago
- 8 months ago
- 9 months ago