lordmilko / prtgapi Goto Github PK
View Code? Open in Web Editor NEWC#/PowerShell interface for PRTG Network Monitor
License: MIT License
C#/PowerShell interface for PRTG Network Monitor
License: MIT License
When attempting to add a sensor type snmptraffic
, it appears to only grab the first interface which is a loopback adapter
PS C:\> $SensorParameters = $Device | New-SensorParameters -RawType 'snmptraffic'
PS C:\> $SensorParameters
interfacenumber : 2
interfacenumber__check : (loopback_0) Loopback Pseudo-Interface 1 Traffic
trafficmode : errors
monitorstate : 0
namein : Traffic In
nameout : Traffic Out
namesum : Traffic Total
aliasavailable :
primarychannel :
stack : 0
Targets : {[interfacenumber__check, PrtgAPI.GenericSensorTarget[]]}
Source : mydevice
SensorType : snmptraffic
Priority : Three
InheritTriggers : True
InheritInterval : True
Interval : 00:01:00
IntervalErrorMode : OneWarningThenDown
Name : Base Sensor 1
Tags : {bandwidthsensor, snmptrafficsensor}
The $SensorParameters.interfacenumber__check
only lists a single interface, as opposed to the list of interfaces available in the PRTG web UI. Am I missing a step?
The web UI loads the SNMP interfaces without issue:
It also shows the ID of the loopback
interface as 0
, but the module lists the loopback
as 1
Any direction or assistance would be great. I've already made substantial use of this module, which is fantastic!
Thanks!
Hi LordMilko,
Iโm not able to set decimal/double value in channel limits:
Here an example:
$SensorId = 12345
$channelName = "ChannelName"
$upper_error_limit = [double] 0.02
$upper_warning_limit = [double] 0.01
$error_limit_message = "Test error message"
$warning_limit_message = "Test warning message"
$CreatedSensor = Get-Sensor -Id $SensorId
$CreatedSensor | Get-Channel -Name $channelName | Set-ChannelProperty -LimitsEnabled 1 -UpperErrorLimit $upper_error_limit -UpperWarningLimit $upper_warning_limit -ErrorLimitMessage $error_limit_message -WarningLimitMessage $warning_limit_message
The result is that the limit message is set properly, but the limit value is set to 0.
Thanks in advance,
Fabio.
This could be an i18n error:
Get-Probe : An error occurred while attempting to deserialize an object of type 'Access', possibly caused by the following XML:
'<access>Vollzugriff</access>'. Der angeforderte Wert "Vollzugriff" konnte nicht gefunden werden.
In Zeile:1 Zeichen:1
+ Get-Probe
+ ~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Probe], XmlDeserializationException
+ FullyQualifiedErrorId : PrtgAPI.XmlDeserializationException,PrtgAPI.PowerShell.Cmdlets.GetProbe
This is after a successful Connect-PRTGServer and a simple Get-Probe
The translation of the german lines would be
'<access>full access</access>'. The expected value "full access" could not be found.'
in line: 1 character: 1
Good afternoon Lordmilko!
So far I'm loving this. I've been trying to audit and better utilize a PRTG installation with around 10k sensors that had very little organization before hand, this tool has been a huge time saver.
Anyways, I'm trying to add a new threshold notification trigger to all "Disk Free" sensors. I've been using code similar to the below,
$sensers = Get-Device servertest* | Get-Sensor "Disk Free*"
foreach ($s in $sensers) {
$params = New-TriggerParameters -Id $s.Id -Type Threshold
$params.Threshold = 10
$params.Condition = "Below"
$params.OnNotificationAction = Get-NotificationAction "Email Me test"
$params | Add-Trigger
}
This does build the $params variable as desired but it never actually adds the trigger,
PS H:\> $params
OffNotificationAction : None
Latency : 60
Threshold : 10
Condition : Below
Channel : Primary
ObjectId : 42612
SubId :
Action : Add
Type : Threshold
OnNotificationAction : Email Me test
I can add state triggers just fine but I've been having issues with adding a threshold. Hopefully you might be able to provide some insight on what I'm doing wrong here?
Thanks.
Edit: Markdown codeblock formatting
Hei
I get an error trying to update UpperWarningLimit in Windows Update. The default value is "0,2" and I thing the powershell module is noe happy about the comma.
PS C:\WINDOWS\system32> Get-Sensor -Filter (New-SearchFilter name equals "Windows Updates Status") | Get-Channel -Id 2 | Set-ChannelProperty UpperWarningLimit 10
Get-Channel : An error occurred while attempting to deserialize an object of type 'Nullable`1', possibly caused by the following XML: '<injected_limitmaxwarning>0,2</injected_limitmax
warning>'.
Hello
I am cloning sensors and every now and then I get a warning:
WARNING: 'Copy-Object' failed to resolve sensor: object is still being created. Retries remaining: 4
Is there anything I can do against this problem?
BR
Thomas
I have been running a script just for a while now without issues until after patching my workstation with KB4345418. Since that patch, anything using Get-Channel started producing this error:
Get-Channel : An error occurred while attempting to deserialize XML element 'injected_showchart' to property 'ShowInGraph': cannot assign 'null' to value type 'Boolean'.
At line:1 char:51
+ ... -Device servertest1 | Get-Sensor "SNMP CPU*" | Get-Channel * -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Channel], XmlDeserializationException
+ FullyQualifiedErrorId : PrtgAPI.XmlDeserializationException,PrtgAPI.PowerShell.Cmdlets.GetChannel
Microsoft has acknowledged that this patch breaks some COM components (https://support.microsoft.com/en-us/help/4345418/windows-10-update-kb4345418). However, I'm unsure how this actually affects the PrtgAPI.
I can confirm that by rolling back this patch resolved my issues though. I have not yet attempted their workaround fix with KB4346877 which was released on July 30th (https://support.microsoft.com/en-us/help/4346877/july-30-2018-kb4346877-os-build-14393-2396)
Are you able to confirm that my issues are indeed from this Windows patch or is it some other odd coincidence? I am running latest PrtgAPI version.
I am trying to get the raw property scheduledependency of a device. With "Get-ObjectProperty -Raw" the property is shown, but with "Get-ObjectProperty -RawProperty scheduledependency" I get the message:
Get-ObjectProperty : PRTG was unable to complete the request. A value for property
'scheduledependency' could not be found.
Any ideas?
BR
Thomas
Hi LordMilko, I've been getting to grips with your API for a few months now and its reallly improved my day to day life at work ๐
I am trying to create a new ping sensor to apply across many groups however am unable to quite understand how to set parameters for this. I understand that the native creation only supports service/http and exe. Is there a way of configuring more basic sensor sets to apply in bulk?
Hi Lord Milko, happy monday!
I am hoping you can help a smidge with exporting the a list of sensors which have been paused for longer than a certain amount of time (in this case 6 months). I am having issues working with the system string from get-date.adddays -182 and cant quite figure out how to assemble a filter. As such i was planning to use the sub-selection of day of year but this feels like im going down a bad path :)
Heres my horrific code
#Get paused for more than 6 months
goprtg 2
$6months = (get-date).AddDays(-182)
$allpauses =Get-Sensor -status Paused
$pauseusers =get-sensor -status PausedByUser
$filter1 = -status equals Paused
$fliter2 = get-sensor -status PausedByUser | where $allpauses.lastcheck -eq $6months
flt $allpauses.lastcheck -gt (get-date).AddDays(-30) |get-sensor -Status Paused
get-sensor * | -filter ($filter1, $filter2)
$daypaused = $allpauses.lastcheck.dayofyear | -expandpropery Name
Get-Sensor -Status PausedByUser | foreach { $_ | select LastCheck -eq (get-date).adddays(-182)| Add-Member Device $_.Device -PassThru | Add-Member Probe $_.Probe -PassThru } | Select LastCheck, Device, Probe, URL
Non of which quite works. I have the CSV exported so i can easily filter this in excel however i was hoping to be able to automatically export "whats been paused more than 6 months" reports
Kindest
Samuel
First off, loving this library. Very helpful.
One feature I very much desire is the ability to create an device. I noticed in the wiki that the features is being implemented.
When will this version be released? Are contributions desired?
It would be cool if when you did something like prtgClient.AddGroup() it would return the newly created group.
This would add an extra network call when creating it. I could see this being undesirable.
Would a PR with the change be welcomed?
public void AddGroup() -> public Group AddGroup()
Well thought out and nicely done. I would love to use and build upon the great framework you've created here, but you don't currently have a license posted on this project.
You appear to have used the MIT license with some of your past projects, would you be willing to toss that on this API as well?
PRTG Version 18.3.44.2054 added an "official" API method for getting channel properties and other subobject properties. Get-Channel and the like should be updated to use this instead of screenscraping channeledit.htm and the like.
The API call /getobjectproperty.htm now supports subnodes like, for example, channels, notification triggers, and notification contacts. For example, the call /api/getobjectproperty.htm?id=&subtype=channel&subid=0&name=limitwarningmsg&show=nohtmlencode returns the warning message that is defined for a channel limit.
Hi again @lordmilko!
I am currently trying to add a Windows Physical Disk I/O BETA wmiphysicaldiskv2
on a device.
I would like to be able to choose the disk the sensor will monitor, I have tried to modify the parameter this way (this is before the creation of the sensor):
parameters["physicaldisk"] = "0 C:";
I also tried a few other combinations of the parameter name but none worked.
Is there a way to get the list of all the parameters that can be used for the sensor creation?
Or would you know how to modify this parameter ?
Thanks again,
Eazhi
Trying to use Add-Sensor to filter SNMP Traffic Sensors to only connected sensors.
This works fine:
$snmpTrafficParams = New-SensorParameters -device $prtgDevice -RawType snmptraffic
$SNMPTrafficParams | Add-Sensor
But only adds the first sensor in the target list.
This works fine as well and adds all sensors in the target list
$snmpTrafficParams = New-SensorParameters -device $prtgDevice -RawType snmptraffic
$snmpTrafficParams.interfacenumber__check = $snmpTrafficParams.targets.interfacenumber__check
$SNMPTrafficParams | Add-Sensor
However, trying to apply any sort of filtering breaks it. This doesn't work
$snmpTrafficParams = New-SensorParameters -device $prtgDevice -RawType snmptraffic
$snmpTrafficParams.interfacenumber__check = $snmpTrafficParams.targets.interfacenumber__check | where {$PSItem.properties[2] -match '^Connected$'}
$SNMPTrafficParams | Add-Sensor
Looking at it in Fiddler, it looks like the "filtered" parameters aren't getting formatted right by PRTGAPI:
I verified the array types and objects are the same, so not sure what's happening here.
For now I have a post-creation script that goes back and deletes the sensors I didn't want, but I'd rather cut down on the API calls and "do it right the first time!" :)
Hi LordMilko,
I am having some trouble deploying new SNMP traffic sensors via the API. I have returned the params but they dont seem to apply to anything.
When calling the params of a sensor that mimics the one i would like to add i recieve
PS C:\Windows\system32> $unicastparams.properties 67:MON Lon (067) MON Lon Traffic Connected 1 GBit/s Ethernet 1 MON Lon 1000000000 3 2
However changing threshold values and disabling them does not change any of these values, the .value returns just the sensor name.
Any pointers?
Kindest
Samuel
Hi Lord Milko,
I need to pull out CSV for a number of sensor histories on traffic sensors across a number of groups with the names included. Im running into a few issues.
So far all i have is this paltry attempted :)
goprtg 1
$outside = get-group *Stratus* | get-sensor *Outside*
$thnsensor = get-device *THN*| get-sensor *stratus*
foreach ($id in $outside){
Get-sensor -id $id.id | get-sensorhistory |export-csv -path "C:\output\($thnsensor).name Report Usage.csv"
}
But thats not selecting each ID nor is it running correctly nor is it returning anything other than device ID for identification. I can add in another step to lookup ID and then attach names but i feel like thats a really crap solution for an elegant API :)
Hello!
Great framework you've created here, I've been using it some time with our setup and it works great. The lone issue I have right now is that if I create an object, set its InheritLocation property to False and its Location property to GPS coordinates, the location is set, but when I check within the PRTG GUI, it is set to a less-precise street address. However, I can enter the same coordinates via PRTG's GUI and they work fine and stay recorded as GPS coordinates.
Any ideas what the issue might be?
Thanks!!
Jonas
Hello there,
When I list all of the channels on a "SQL 2016 Buffer Manager" sensor, it lists only
Buffer cache hit ratio
when instead, it should list Buffer cache hit ratio
, Database pages
, and Page life expectancy
.
Do you know if I can do anything to solve this problem ?
If not, do you have an idea on how to go about solving it ?
I have checked in PRTG that those 3 channels do exist if I try to create a trigger on said sensor.
Thanks in advance,
Would be nice if you could assign a device template for autodiscover when adding a new device
e.g "add-device dc1 192.168.1.20 -autodiscover --template Windows_Server"
when i do:
Get-Sensor -Id 17835 | Get-ObjectProperty -RawProperty query_
i get
Get-ObjectProperty : '=' is an unexpected token. The expected token is ';'. Line 4, position 86.
At line:1 char:24
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
as my "query" field contains multiple = character...
PS C:\WINDOWS\system32> Get-Sensor -Id 17830 | Get-ObjectProperty -Raw
query : /api/Queues?subscriptionId=blabla=blabla=blabla
Hi @lordmilko !
I'm having trouble with the Trigger creation. The trigger I'm trying to add is a Threshold Trigger
and I am trying to add it to a Windows CPU Load
sensor.
At first I tried this :
var p = new ThresholdTriggerParameters(3038)
{
Channel = TriggerChannel.Total,
Condition = TriggerCondition.Above,
Latency = 120,
OnNotificationAction = client.GetNotificationActions(Property.Name, "Email to Admin")[0],
OffNotificationAction = client.GetNotificationActions(Property.Name, "Email to Admin")[0],
Threshold = 80,
};
var trigger = client.AddNotificationTrigger(p);
This gives me back :
System.InvalidOperationException: Channel 'Total' is not a valid value for sensor with ID 3038. Triggers assigned directly to sensors must refer to a specific Channel or Channel ID.
Using TriggerChannel.Primary
gives back the same error.
Which is weird because when I set Channel to something that shouldn't work:
Same code but with : Channel = TriggerChannel.TrafficIn,
It gives me back System.InvalidOperationException: Only 'Primary', 'Total' and sensor specific channels are valid for threshold triggers
I'm also not sure that this is the right way to set On/OffNotificationAction, I've tried without them (to leave them null) but I had the same errors, so it didn't seem to be the problem here.
So I tried it another way, in the Trigger Channels part of the documentation I found this :
For notification triggers that are applied directly to sensors, a Channel object must be specified, which can be achieved via an implicit cast
Therefore, I tried :
var channel = client.GetChannels(3038, "Total")[0]; // Gives back the Total Channel
var p = new ThresholdTriggerParameters(3038)
{
Channel = channel,
Condition = TriggerCondition.Above,
Latency = 120,
OnNotificationAction = client.GetNotificationActions(Property.Name, "Email to Admin")[0],
OffNotificationAction = client.GetNotificationActions(Property.Name, "Email to Admin")[0],
Threshold = 80,
};
var trigger = client.AddNotificationTrigger(p);
This still gives me the same error System.InvalidOperationException: Channel 'Total' is not a valid value for sensor with ID 3038. Triggers assigned directly to sensors must refer to a specific Channel or Channel ID.
Since these didn't work I tried creating the new Trigger from an existing one like this :
var trigger = client.GetNotificationTriggers(6887)[0]; // Gives back a threshold trigger
var p = new ThresholdTriggerParameters(3038, trigger);
var newTrigger = client.AddNotificationTrigger(p);
This also gives me back the same error System.InvalidOperationException: Channel 'Total' is not a valid value for sensor with ID 3038. Triggers assigned directly to sensors must refer to a specific Channel or Channel ID.
Doing it by hand on PRTG works fine, so I don't think that I passed any wrong parameters.
Thanks for this API and for taking the time to answer !
When creating a raw sensor the hashtabel will not acces duplicate entries. This seems required when adding an snmptraffic sensor and you want to enable errors and discards. Fiddler shows the option Trafficmode_ is added three times:
&trafficmode_=standinfornoselection
&trafficmode_=errors
&trafficmode_=discards
This seems not possible with the API.
Hi, add-group (and other add-xx) are not working it appears returning that it is not a valid cmdlet name.
any guidance appreciated :)
This api has changed my life by the way thank you so much
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 :)
Hello lordmilko,
Have you ever tried to make an import of devices into PRTG monitoring? I tried to use auto-discovery using a list of devices, but it adds reachable devices only. I'd like to add a list of devices, where both reachable and unreachable devs are added.
Thanks!
Hey love your module, using it every day these days :).
Could you add a -passthru parameter that returns the prtgclient object, so it can be interacted with directly? I have some additional cmdlets I want to write, but I'm not really a C# guy, and I'd rather use your engine than the Invoke-Restmethod-based one I have since you've already gone to a lot of trouble to optimize and stabilize it :)
Thanks!
Good day,
Having an issue with populating a sensor for a single group. For some reason it pulls all sensors instead. It appears to occur only with this particular group, as far as I see the group is the same as our others. Any further assistance would be greatly appreciated.
I believe the issue originates from this line of the beneath log. I can't figure out why it drops the
"count=*&filter_parentid=46827&" from the request, causing it to pull all the sensors down from PRTG.
VERBOSE: Get-Sensor: Synchronously executing request
https://prtg-app/api/table.xml?content=sensors&columns=probe,group,favorite,lastvalue,device,downtime,downtimetime,downtimesince,uptime,uptimetime,uptimesince,knowntime,cumsince,lastcheck,lastup,lastdown,minigraph,schedule,basetype,baselink,parentid,notifiesx,interval,intervalx,access,dependency,position,status,comments,priority,message,type,tags,active,objid,name&count=*&&username={redacted}&passhash={redacted}
It seems that the -Recurse option on "Get-Device" is irrelevant as get-device by default is recursive thus enabling more recursion is not relevant. It might be that the default should be non recursive and -Recurse enables recursion.
Example that has been somewhat anonymized:
get-device -Group (get-group -id 111781) | select Id, @{N='GroupId';E={$_.ParentId}}
Id GroupId
-- -------
111816 112487
111782 112488
112102 112486
111803 112435
112020 112484
111973 112483
111849 112482
111813 112487
112023 112486
111804 112435
112017 112484
111971 112483
111966 112482
111796 112487
112108 112486
111832 112435
112014 112484
112109 112486
111842 112435
111982 112484
112119 112486
112154 111781
112144 112486
112159 111781
112149 112486
112164 111781
112178 111781
112183 111781
112188 111781
As can be seen. Not only devices in the group with id 111781 are included but also sub groups and sub sub groups are included.
If I include the -Recurse switch I get the exact same result
get-device -Group (get-group -id 111781) -Recurse | select Id, @{N='GroupId';E={$_.ParentId}}
Id GroupId
-- -------
111816 112487
111782 112488
112102 112486
111803 112435
112020 112484
111973 112483
111849 112482
111813 112487
112023 112486
111804 112435
112017 112484
111971 112483
111966 112482
111796 112487
112108 112486
111832 112435
112014 112484
112109 112486
111842 112435
111982 112484
112119 112486
112154 111781
112144 112486
112159 111781
112149 112486
112164 111781
112178 111781
112183 111781
112188 111781
I updated my PRTGApi version to 0.8.6 from 0.8.5 to see if that helped but no luck - same problem. My suggestion would be to either make the default "Get-Device" not recursive as to allow the -Recurse switch a prupose or replace the -Recurse switch with a -NoRecurse switch that disables recursion instead.
How to rename a cloned object with use this method:
Get-Device "$Servername*" | Clone-Object -SourceId 5603 "CPU $Servername"
Hi!
I still am on the version 0.8.6 of the API, but I've encountered a problem which I think has not been fixed in 0.9, I will check soon (I need to change the code that breaks with the update).
When I try to do :
var parameters = client.GetDynamicSensorParameters(4478, "wmisqlserver2016");
parameters.Name = "This should work";
client.AddSensor(4478, parameters);
The name of the sensor ends up to
SQL Server (SQL2008R2) Buffer Manager
instead of "This should work".
I've tried with other sensor types like ''wmiprocessor" and it works just fine.
What is weird is the sensor name being like a 2008R2 SQL sensor while I am requesting the creation of a 2016 SQL sensor.
Am I doing something wrong?
EDIT: Actually there is a parameter (that I was not setting) for SQL sensors in PRTG that may override the parameters.Name
.
Thanks in advance,
-- Eazhi
Hi,
Thank you very much for your contribution, I think this is a great project.
I've encountered several XMLDeserialization Errors while pulling data from PRTG:
For example if all Sensors are queried, there is a deserialization error while trying to parse the Column "Access" when it is empty.
Another example is that the Input String was not in correct format if you try to pull all the devices from PRTG.
Will you be fixing these Issues or should I fix them by myself ?
I just wanted to inform you about this minor bug.
Thank you very much in advance and best regards,
Chris
Hi lordmilko, do you have any plans to include doesnotcontain as a filtering method or can you think of a way to select all devices which do not contain RTR in the name?
Hi there, i am trying to create the parameters for a wmiservice sensor. Could you by any chance assist me with the formatting of this?
I'm trying to use the Powershell Api behind a Proxy.
I've already set the winhttp proxy, but this didn't solve it.
How can i use the API behind a proxy?
Error message:
get-probe : The remote server returned an error: (407) Proxy Authentication Required.
Thanks.
question: can the api create new rest custom sensors with specific values in the custom header settings?
The wiki is a bit unclear for me...
Thank you very much for your work on PrtgAPI. Very straightforward to use and loving it!
I am noticing an inconsistency when performing the following operations to obtain channel values:
Client.GetChannels(ID, "Traffic In").Item(0).LastValue
Client.GetChannels(ID, "Traffic In").Item(0).LastValueNumeric
I was expecting .LastValue to be a string consisting of the .LastValueNumeric + the .Unit property (In this case, "kbits/s".
However, the .LastValue and .LastValueNumeric properties are never the same, returning values such as:
.lastValue=2,333,154 kbits/s
.lastValueNumeric=291644197.08 (with Unit equal to "kbit/s")
Am I misinterpreting the properties?
Hi there, i was wondering if it was possible to set pause parent dependencies when creating devices through script? i looked at the wiki but couldnt see an option
Expected
> get-objectproperty -Object (get-device xxx) -Property Comments
System Analysis: Cisco Device ASA Cisco IOS
Other names: xxx
System Info: Cisco Adaptive Security Appliance Version 9.0(3)
Cisco Adaptive Security Appliance Version 9.0(3)
Actual
> (device xxx).comments
System Analysis: Cisco Device ASA Cisco IOS Other names: xxx System Info: Cisco Adaptive Security Appliance Version 9.0(3) Cisco Adaptive Security Appliance Version 9.0(3)
Need
I want to be able to parse the comments field based on newline (and other regex criteria) into name-value pairs. While I can try parsing on double-space, it seems flimsier to me, and the output should be consistent across all forms of query.
When I try to create a sensor with custom parameters below the state keeps giving: WARNING: 'Add-Sensor' failed to resolve sensor: object is still being created. Retries remaining: 3
Finally it times out with:
Add-Sensor : Could not resolve object: PRTG is taking too long to create the object. Confirm the object has been created in the Web UI and then attempt resolution again manually
What i can see is that the sensortype is snmplibrary, but when the sensor is created and the type is determined with the command Get-Sensor the sensortype created is snmpcustomtable.
I tried with fiddler filters to modify the sensortype in the get status request from snmplibrary to snmpcustomtable the issue is resolved and I can see the ID of the sensor created. When I modify the sensortype in the powershell script it does not create my sensor.
Can you fix the code so it can use a different type in the status get request that in the script or is there another alternative to this problem?
GET request modified with fiddler:
GET /api/table.xml?content=sensors&columns=objid,name,probe,group,favorite,lastvalue,device,downtime,downtimetime,downtimesince,uptime,uptimetime,uptimesince,knowntime,cumsince,lastcheck,lastup,lastdown,minigraph,schedule,basetype,baselink,parentid,notifiesx,intervalx,access,dependency,position,status,comments,priority,message,tags,type,active&count=*&filter_name=@sub(KEA+DHCP)&filter_parentid=46820&username=bvanbavel&passhash=<> HTTP/1.1
Powershell code:
$table = @{
name_ = "BLA"
sensortype = "snmplibrary"
library_="C:\Program Files (x86)\PRTG Network Monitor\snmplibs\Basic Linux Library (UCD-SNMP-MIB).oidlib"
interfacenumber_ = 1
interfacenumber__check = "1.3.6.1.4.1.2021.2.1.100.1|Basic Linux Library (UCD-SNMP-MIB)|Processes: 1|Processes Error Flag|#|0|0|Processes Error Flag|2|1|0|1|A Error flag to indicate trouble with a process. It goes to 1 if there is an error, 0 if no error.|0|0|0|0||1.3.6.1.4.1.2021.2.1.100|prErrorFlag|1.3.6.1.4.1.2021.2||ASN_INTEGER|0|ASN_INTEGER||Basic Linux Library (UCD-SNMP-MIB)|Processes: #[1.3.6.1.4.1.2021.2.1.1]|100|||||||||||||||||||||||||||||||||||","1.3.6.1.4.1.2021.2.1.5.1|Basic Linux Library (UCD-SNMP-MIB)|Processes: 1|Processes Count|#|0|0|Processes Count|2|1|0|1|The number of current processes running with the name in question.|0|0|0|0||1.3.6.1.4.1.2021.2.1.5|prCount|1.3.6.1.4.1.2021.2||ASN_INTEGER|0|ASN_INTEGER||Basic Linux Library (UCD-SNMP-MIB)|Processes: #[1.3.6.1.4.1.2021.2.1.1]|5|||||||||||||||||||||||||||||||||||","1.3.6.1.4.1.2021.2.1.1.1|Basic Linux Library (UCD-SNMP-MIB)|Processes: 1|Processes Index|#|0|0|Processes Index|2|1|0|1|Reference Index for each observed process.|0|0|0|0||1.3.6.1.4.1.2021.2.1.1|prIndex|1.3.6.1.4.1.2021.2||ASN_INTEGER|0|ASN_INTEGER||Basic Linux Library (UCD-SNMP-MIB)|Processes: #[1.3.6.1.4.1.2021.2.1.1]|1|||||||||||||||||||||||||||||||||||"
}
$params = New-SensorParameters $table
$device | Add-Sensor $params -verbose
Hi LordMilko! It may well be me misusing the command but i am unable to create devices from powershell
Get-probe HmManagment | Get-group Servers | add-device HMDC 192.168.60.15
returns The tem 'add-device' is not recognized as the name of a .... etc
Same happens with querying sensor parameters. Have i somehow installed half the API :)
Kindest regards and thanks for your amazing ongoing support
sam
Hi !
It's possible to get the value GUID of an httppushdataadvanced ?
Hi LordMilko.
I am extracting lists of all traffic sensors so i can then filter in excel those which dont ever pass any data so i can send it over to networks to get them removed. Im using get-sensor history for this however i cannot work out how to pass device/probe names to the outputting CSV.
I have tried -Select in various places. Any guidance would be really appreciated.
Kindest
Samuel
Hi.
Love what you have done with the API.
One thing that I miss is commandl-lets for the Admin API.
Like referenced by(webroot\javascript_Prtg.Api.json):
createDatabaseSnapshot -> /api/savenow.htm
restartProbes -> /api/restartprobes.htm
restartServer -> /api/restartserver.htm
writeCoreStatus -> /api/writecorestatus.htm
writeProbeState -> /api/writeprobestatus.htm
Etc...
I'll be more than happy to contribute, if you can provide documentation on what to implement...
JR
Hello!
Great framework you've created here.
How I can create a new PRTG report using powershell script?
I meant the prtg reports, not the reports based on custom queries:
https://www.paessler.com/manuals/prtg/reports
Thanks in advance,
Fabio.
Hi ! How to create a wmiremoteping sensor in device (powershell) ? I have no idead to add the target (ip) parameters on this sensor
Hi LordMilko! I know we spoke a while ago about the unforseen complexities of moving objects between cores and the delays surrounding that. I was just wondering if you have any pointers on how to perhaps export a group to a bunch of csv/xml/json that can then be fed back to PRTGAPI as new devices and sensors on a new core?
when I try to use Get-Channel (I've tried passing the sensor and also just using the sensor ID), I keep getting the following
Get-Channel : An error occurred while attempting to deserialize XML element 'injected_showchart': cannot assign 'null' to value type 'Boolean'.
again I've tried doing
$sensor | Get-Channel
from a for loop where $sensor is the individual sensor. I also outputted the sensor ID just to make sure that the sensor had correct data
Get-Channel -SensorId 15210
this one I just used the ID and I still got the same error.
Hi LordMilko
I am trying to use your library but I have a problem whatever the function I try to use is.
I connected successfully on my lab and on a prod server:
PRTG LAB> Get-PrtgClient
Server : 192.168.1.100
UserName : prtgadmin
PassHash : xxxxxxxxxxxxxxx <= here I use a passhash
Version :
RetryCount : 1
RetryDelay : 3
PRTG PROD> Get-PrtgClient
Server : prtg-reseau.domain.tld
UserName : dgi <= Here it is an AD account
PassHash : xxxxx <= here it is a password, not a passhash
Version :
RetryCount : 1
RetryDelay : 3
At this stage I could think I am successfully connected but when I run a query I get this on both servers:
PRTG LAB> Get-Probe -Verbose
VERBOSE: Get-Probe: Synchronously executing request https://192.168.1.100/api/table.xml?content=probenode&columns=condition,fold,groupnum,devicenum,upsens,downsens,downacksens,partialdownsens
,<--removed-->,name&count=*&filter_parentid=0&username=prtgadmin&**passhash**=xxxxxxxxxxxxxxxx
PRTG PROD> Get-Probe -Verbose
VERBOSE: Get-Probe: Synchronously executing request https://prtg-reseau.rexel.fr/api/table.xml?content=probenode&columns=condition,fold,groupnum,devicenum,upsens,downsens,<--removed-->,name&count=*&filter_parentid=0&username=dgi&passhash=mypassword
In both cases the query is followed by:
`WARNING: 'Get-Probe' timed out: The underlying connection was closed: An unexpected error occurred on a send. Retries remaining: 1
Get-Probe : The underlying connection was closed: An unexpected error occurred on a send.
At line:1 char:1
+ Get-Probe -Verbose
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Probe], WebException
+ FullyQualifiedErrorId : System.Net.WebException,PrtgAPI.PowerShell.Cmdlets.GetProbe
`
I have removed some items from the query for clarity and took get-probe as an example but I have the same issue with other functions (get-device, get-sensor, etc.)
I also have set: [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} to avoid self-signed certificates issues
I have noticed that for both connections the query ends with passhash= while one of them should be password=
I am running Windows 10 64bits
Powershell 5.1
prtgAPI is 0.8.6
Sorry upfront if it is a dumb question. I swear I have read the doc though
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.