Closed SamuelmAsh closed 6 years ago
Hi Sam,
Yes, PrtgAPI can do this. Have you looked at the wiki to find the section the pertinent information would be under?
I have indeed, i am struggling with constructing the correct series of commands to retrieve the properties where interval -eq and then pass it to the set-objectproperty but i shall persevere :)
As one of my teachers once said to me, when asking a question be as specific as possible to demonstrate your existing knowledge and that are you are not simply asking someone else to do all the work for you. :P
You've correctly ascertained you need to do something like where interval -eq xxx | Set-ObjectProperty
, so you're 75% of the way there. The final command utilizes the 3 following cmdlets
Get-Sensor
Where-Object
Set-ObjectProperty
Can you potentially provide the best guess command you have so far and advise what's happening when you try to run it
Apologies, i didnt mean to imply that i was seeking you to do my work for a moment! Im just deep in the stage of powershell where i am confident enough to dive into something but quickly become aware of how much i dont yet know!
For example where-object didnt even enter into my mind to use for this but a few mins of reading and it seems of course the best cmdlet for it!
So at the moment i have
$10msensor = get-sensor "SNMP Traffic*" | where-object Interval -eq 00:10:00
$10msensor | set-objectproperty Interval 00:05:00
Which looks to do what i am trying to achieve! Thank you! Except that it timesout and dies when attempting to run it against so many id's due to the overloaded server, can these request be batched in smaller amounts or the speed be adjusted for a dying core server?
This does lead me onto a slightly different question, do you have a recommended format of structure for caching the most amount of data from prtg offline? We have a core that is hugely overworked and retrieving the get-senor result takes anywhere up to 15 mins. I was wondering if there as a way to cache offline the object properties from probe down to sensor for faster querying then the ability to queue these to send to the core and prevent it all falling over. I understand this is somewhat an edge case but would be handy. Im also tasked with at some point in the future with creating a monitored item asset log which im is gonna take some DB construction i fear :)
is there any feature of function to slow down or limit the amount of id's it tries to process at once aside from filtering the groups into smaller amounts earlier in the pipe? im onboard for just selecting groups at a time rather than every sensor but a rate limit function would be very helpful for our dying PRTG
WARNING: 'Set-ObjectProperty' timed out: The underlying connection was closed: The connection was closed unexpectedly. Retries remaining: 1 Set-ObjectProperty : The underlying connection was closed: The connection was closed unexpectedly. At line:1 char:15
+ CategoryInfo : NotSpecified: (:) [Set-ObjectProperty], WebException
+ FullyQualifiedErrorId : System.Net.WebException,PrtgAPI.PowerShell.Cmdlets.SetObjectProperty
In regards to your first question, you can potentially cache the results of Get-Sensor
in a $sensors
variable and then use Where-Object
queries on that variable for filtering results. In order for this to work effectively you would need to make sure to keep your PowerShell window open and not overwrite the variable. This is easier when using the ISE, as that window stands out from all your regular PowerShell windows (and also persists global variables between all open files)
In regards to your second query, by default Set-ObjectProperty
operates in Batch Mode. If your server cannot handle manipulating multiple objects at once, you can tell Set-ObjectProperty
to process items one at a time by specifying -Batch:$false
. You can also potentially look into telling your PRTG client to make multiple attempts after a connection failure and wait longer between each reattempt
Hi LordMilko, I've been performing a lot of interval changes in bulk over the last few days at the behest of the top bods at my work and have been doing so via scraping the sensors by interval webpage and performing the changes with the device ID.
Do you have any super nifty methods for finding and setting intervals at a sensor level on a huge scale (10k~ sensors). I need to find sensors that are snmp traffic and set currently to 10mins, and set them to 5 mins. I'm sure you have a much better method than my clunky set of invoke web requests :)