lordmilko / PrtgAPI

C#/PowerShell interface for PRTG Network Monitor
MIT License
301 stars 37 forks source link

Status of "Tree" / "Infrastructure as Code" feature #326

Closed PRTGC closed 1 year ago

PRTGC commented 1 year ago

What's going on?

Hi @lordmilko ,

I have a script that creates and maintains a set pf PRTG servers using PRTGAPI... Which is great, so thanks for sharing...

One of the issues I run into is that the script takes an ridiculous amount of time.. Due to all the checks, property add/update/removal, it takes forever... I have to do something to make it perform better..

So, I'm looking at the "Tree" / "Infrastructure as Code"... It should work better... Since I could pre-structure all add/update in a struct and set it off...

Which brings me to the question... What is the status of this functionality ?

If it is in a status ready to be utilized, that would be awesome, and I'll have some more questions about limitations...

Best regards.. JR

Due Dilligance

lordmilko commented 1 year ago

Hi @PRTGC,

PrtgAPI's Infrastructure As Code project has been in development on and off for several years now. Due to the massive levels of complexity this project has expanded to, I've had to stop, audit, split and stash the changes required into more manageable layers several times now. The project is currently stuck on a caching feature I'm implementing which will be essential for quickly iterating when trying to use PrtgAPI's Infrastructure As Code API.

Due to the mindbending nature of this caching feature (recursive multi-level caching of PowerShell AST trees against potentially lazily resolved, multi-scoped tree proxies) development on this has been very slow. And I haven't even begun to reincorporate the actual creation part of the API from my initial prototype - right now it's all focused on evaluating your current state. I resumed working on this a bit at the end of last year, however have taken a break again to work on other projects.

In addition, it came to my attention recently that Paessler are looking to develop their own infrastructure as code solution for PRTG using Ansible. While I'm sure their system won't be nearly as fancy as mine would be, this certainly does not help with the motivation required to work on this extremely ambitious project.

In conclusion, don't expect PrtgAPI's Infrastructure as Code API to be released any time soon. However, even if it were released, there's no guarantee that it would actually help you solve your problem; my experience (with older versions of PRTG) has shown that PRTG fundamentally has a flawed architecture, wherein API requests not only take a lot longer depending on the size of your installation, but also can affect the performance of the PRTG Web UI. Regardless of whether you're using a fancy library or your own custom script, you're still going to be executing more or less the same API requests, where PRTG will be the ultimate bottleneck.

Regards, lordmilko

PRTGC commented 1 year ago

@lordmilko ,

It is unfortunate, but I totally understand how these things go... And, yes Paessler is developing Ansible scripts for PRTG...

You are right, your would be a much more flexible. And you're right... The PRTG API dies have some fundamental issues. Along with, hammering the API for 6-8 hours can have some..."unfortunate side-effects". Like creating a lot of sensors in close succession on a probe with lots of existing sensors. The scheduler gets interrupted so much, all your sensors go Gray...

Which is part of my problem. A pre-constructed tree with all the props set, then execute... would be so much better.

Unfortunately, I'll have to duplicate some of this functionality.. Thanks again for sharing JR