Can you suggest please : One single Datasource for Multiple server
When i use One single Datasource for Multiple servers it then displays all the Raw Data on any of the server from Datasource.
Can I force it to display only specific Data point outputs on the RawDat tab.
Thank you
Please ask me if you need more elaboration.
Ashiwad
Posted 6 years ago·Last reply 6 years ago
12 comments
LM User
·6 years agoIf you have an active discovery script, you won't need to manually add instances. If you want to discover different instances, like folders instead of partition names, you'll need to adjust your query. You might consider pulling from the Win32_Directory class instead of the Win32_LogicalDisk class.
Not sure what you tried to setup here.
From the looks of your script, you could probably do this without a script by using the built in WMI collector. To help you get started, this is how you would set it up to pull free space on each logical drive. I did this so you can compare it to what you already have in your script. To make it for folders, like I said above, you'd need to use the Win32_Directory class instead. I'm not familiar with that class, so you'd have to do a little research.
Ashiwad
OP6 years agoHey Stuart
After spending some time on it i managed to get some sample scripts and understood exactly what it does and how.
## Active Script ##
$hostname = '##SYSTEM.HOSTNAME##'
$namespace = "root\cimv2"
$query = "SELECT NAME FROM Win32_LogicalDisk"
$output = Get-WmiObject -Namespace $namespace -ComputerName $hostname -Query $query
foreach ($instance in $output) {
$name = $instance.Name
Write-Host "$name##$name"
}
exit
## Collector Script ##
$hostname = '##SYSTEM.HOSTNAME##'
$wildvalue = '##WILDVALUE##'
$namespace = "root\cimv2"
$query = "SELECT * FROM Win32_LogicalDisk WHERE NAME='$wildvalue'"
$output = Get-WmiObject -Namespace $namespace -ComputerName $hostname -Query $query
Write-Host "Size=$($output.Size)"
Write-Host "FreeSpace=$($output.FreeSpace)"
exit
Now i remain with few other questions
1. This is WMI so gets me the partition names, how can i get the paths to iterate in Active script
So I manually Added monitored instances under my resource, but didn't work for me.
2. Tried Setting up UNC.PATH, didn't work
I'll spend time trying few things here n there until I hear back from you.
Please advice
Thank you
LM User
·6 years agoYou'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.
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
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.
Ashiwad
OP6 years agoThanks 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.
LM User
·6 years agoIf 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.
Ashiwad
OP6 years agoThank 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?
LM User
·6 years agoOk, 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:
Then your invoke command would only happen once and would look like this:
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.
Ashiwad
OP6 years agoMy 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
LM User
·6 years agoOk, 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?
Ashiwad
OP6 years agoThank 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.
LM User
·6 years agoCan you post the details of the DataSource you've built? I assume this is still to do with the powershell based datasource?