lordmilko / PrtgAPI

C#/PowerShell interface for PRTG Network Monitor
MIT License
305 stars 38 forks source link

Add .net Core build? #57

Closed gmeks closed 5 years ago

gmeks commented 5 years ago

Hey is it possible to add a .net core build for NuGet packages?

It would also be nice if some of the examples included how to setup snmp sensors?

lordmilko commented 5 years ago

Hi @gmeks,

.NET Core/.NET Standard support is currently on the Roadmap

It is currently blocked by two issues

I have been eagerly checking the status of both of these every day, so this is definitely something I'm keen to accomplish as soon as possible.

In regards to creating SNMP sensors, this can be easily done by following the guidelines for creating Dynamic Parameters

In short

  1. Identify the type of sensor parameters you require (via client.GetSensorTypes())
  2. Create a set of sensor parameters (via client.GetDynamicSensorParameters())
  3. Adjust the properties of your parameters object
  4. Create the sensor with client.AddSensor()

Please let me know if you have any further questions

Regards, lordmilko

gmeks commented 5 years ago

Sorry, i did not notice the roadmap.

I got the examples of when you pointed me the correct direction, but i dont see a way of finding out what the custom field is for the service snmp monitoring?

lordmilko commented 5 years ago

Sorry, I don't understand what you're asking

What type of SNMP sensor are you trying to create exactly? (i.e. what is it called on the Add Sensors page of the PRTG UI)

gmeks commented 5 years ago

My preception is that your documentation is focused around basically extracting or adjusting existing sensors. What im doing is connecting our deployment system to PRTG, and it will automatically create needed sensors as new installations are created by deployment system.

With your help i was able to create HTTP sensor, for the web part.

Im currently struggling with creating of the "snmpservice" sensor, this sensor will need the name service, and i simply cannot figure out how to do that.

lordmilko commented 5 years ago

Thanks @gmeks,

The following general outline should describe how to create a new SNMP Service sensor

  1. Create a set of sensor parameters
// Get a set of sensor parameters for creating an SNMP Service sensor from the device
// with ID 1001
var parameters = client.GetDynamicSensorParameters(1001, "snmpservice");
  1. Select the services you want to create sensors for by selecting the desired services from the Targets property of the parameters object. For more information, see Targets on the wiki
// I'm not sure what the property is called that stores the services, but you should
// be able to see in the debugger (recommended) or by inspecting the HTML of the
// SNMP Services table in the PRTG UI when trying to create the object.
// Here I've just called it "property_name"

parameters.property_name = parameters.Targets["property_name"].Where(t => t.Name.Contains("Print")).ToArray();
  1. Add the sensor(s) to as many devices as you like
// Add the sensor to any device, e.g. the one with ID 2002
client.AddSensor(2002, parameters);

I recommend having a look at both the Targets section of the DynamicSensorParameters page as well as potentially having a read through the Overview of the Sensor Targets page if there is still any confusion

Please let me know if this clears things up for you or if you have any further questions

Regards, lordmilko

gmeks commented 5 years ago

Yea i have been checking target because it seemed natural. But it was always emty.

But i think i found the actually problem on my end, the devices i was adding where added with the wrong IP address. So all SNMP sensors where not going to work.

Im gonna fix this and report back.

lordmilko commented 5 years ago

If you try and retrieve dynamic sensor parameters from a device that does not support monitoring SNMP Services then the targets list will be empty. Similarly, if you attempt to create a new SNMP Services sensor for a device using the PRTG UI, if the device does not support monitoring SNMP Services you will not have any services listed there either.

If the Add New SNMP Service Sensor page in the PRTG UI shows services for a given device, then you should also see Targets for it within PrtgAPI

gmeks commented 5 years ago

Yes thats how i discovered the error, i was gonna get a screenshot of code and UI showing they where getting different results.

I got everything working now.

Thank you for all the great support.