Closed mafer0410 closed 4 years ago
Hi @mafer0410,
The amount of memory free is measured by Memory Free sensors. If you wanted to know the amount of memory in use, you would have to calculate this based on the value of the Available Memory and Percent Available Memory channels, which I believe could be calculated as follows
Memory Used = ((100 - Percent Available Memory) * Available Memory) - Available Memory
When it comes to measuring the amount of Disk Free, you would simply retrieve the relevant channels from a Disk Free or WMI Volume sensor
For all of these scenarios, it's simply a matter of using the Get-Channel cmdlet to retrieve the channels from PRTG.
In order to use PrtgAPI successfully, you need to do the following things
For any issue, you can usually formulate your problem in such a way that you're likely to get a good Google result. e.g. you previously asked whether data from PrtgAPI could be exported to a CSV; if you had Google searched for "powershell export csv" however you would have easily found the answer to this.
While PrtgAPI is mainly targeted at sysadmins who may not have any pre-existing programming knowledge, if you can't do any basic research to solve your problems on your own (including searching the internet and using the wiki) you will likely have a very hard time using this library
hello, I have received the information, I was playing around with the information regarding the memory used, available and total.
I have the following information: And I would like to subtract both values, but I can't get it to just grab the value, I use the command:
$ channel1 = "Total Memory" $ channel2 = "Available Memory" $ channel3 = "Use Memory"
$ TotalMemory = get-device -Id 9072 | get-sensor | where Name -Match "Physical Memory" | Get-Channel | where Name -eq $ channel1 | select LastValue
$ AvailableMemory = get-device -Id 9072 | get-sensor | where Name -Match "Physical Memory" | Get-Channel | where Name -eq $ channel2 | select LastValue
But when trying to subtract it, it is not possible. Will it be due to the type of value or the content of the variable does not include only the numbers?
Hi @mafer0410,
You can do these things like this
$totalMemory = Get-Device -Id 9072 | Get-Sensor "Physical Memory" | Get-Channel "Total Memory" | select -expand LastValue
$availableMemory = Get-Device -Id 9072 | Get-Sensor "Physical Memory" | Get-Channel "Available Memory" | select -expand LastValue
The Select-Object
cmdlet allows you to create a new custom object containing one or more properties from a source object. In your code above, you wrote select LastValue
, which creates a series of objects with a single property: LastValue
. What you actually wanted was to select the value of all the LastValue
properties. To do this, you would specify the -ExpandProperty
parameter.
You can see how the output looks different when selecting a single property based on whether you specify -expand
or not
C:\> get-probe | select name
Name
----
Local Probe
C:> get-probe | select -expand name
Local Probe
Thank you very much, I will try, and tell me the results.
El lun., 28 de sep. de 2020 a la(s) 14:26, lordmilko ( notifications@github.com) escribió:
Hi @mafer0410 https://github.com/mafer0410,
You can do these things like this
$totalMemory = Get-Device -Id 9072 | Get-Sensor "Physical Memory" | Get-Channel "Total Memory" | select -expand LastValue $availableMemory = Get-Device -Id 9072 | Get-Sensor "Physical Memory" | Get-Channel "Available Memory" | select -expand LastValue
The Select-Object cmdlet allows you to create a new custom object containing one or more properties from a source object. In your code above, you wrote select LastValue, which creates a series of objects with a single property: LastValue. What you actually wanted was to select the value of all the LastValue properties. To do this, you would specify the -ExpandProperty parameter.
You can see how the output looks different when selecting a single property based on whether you specify -expand or not
C:> get-probe | select name
Name---- Local Probe
C:> get-probe | select -expand name Local Probe
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lordmilko/PrtgAPI/issues/171#issuecomment-700262764, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMGVFY2RYQJMMRDQJU6UTO3SIDWQJANCNFSM4R2NRHZA .
Thank you very much, the explanation you indicated helped me.
El vie., 25 de sep. de 2020 a la(s) 16:51, lordmilko ( notifications@github.com) escribió:
Hi @mafer0410 https://github.com/mafer0410,
The amount of memory free is measured by Memory Free sensors. If you wanted to know the amount of memory in use, you would have to calculate this based on the value of the Available Memory and Percent Available Memory channels, which I believe could be calculated as follows
Memory Used = ((100 - Percent Available Memory) * Available Memory) - Available Memory
When it comes to measuring the amount of Disk Free, you would simply retrieve the relevant channels from a Disk Free or WMI Volume sensor
For all of these scenarios, it's simply a matter of using the Get-Channel https://github.com/lordmilko/PrtgAPI/wiki/Channels cmdlet to retrieve the channels from PRTG.
In order to use PrtgAPI successfully, you need to do the following things
- Think about how you would retrieve this data within PRTG
- Read the relevant page on the wiki https://github.com/lordmilko/PrtgAPI/wiki
- Apply additional programming knowledge to supplement the native capabilities of PrtgAPI as required.
For any issue, you can usually formulate your problem in such a way that you're likely to get a good Google result. e.g. you previously asked whether data from PrtgAPI could be exported to a CSV; if you had Google searched for "powershell export csv" however you would have easily found the answer to this.
While PrtgAPI is mainly targeted at sysadmins who may not have any pre-existing programming knowledge, if you can't do any basic research to solve your problems on your own (including searching the internet and using the wiki https://github.com/lordmilko/PrtgAPI/wiki you will likely have a very hard time using this library
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lordmilko/PrtgAPI/issues/171#issuecomment-699198409, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMGVFYZDKSU2ZQBKKJEKXGTSHUNHXANCNFSM4R2NRHZA .
Hello, sorry for the inconvenience, I have been working on an idea with the PRTG and the API, and would like to know if it is possible to get the following information using both means with the Powershell: