Closed schoenm1 closed 3 years ago
Hi @schoenm1,
PRTG does not provide any facility to modify the name of a channel after a sensor has been created. Beyond stopping the PRTG Core service and hacking your PRTG Configuration.dat
file manually, there is no way to do this
I can't believe I wasn't aware you can actually change the name of a channel in the PRTG UI! Evidently PrtgAPI does not support modifying this property, It should be relatively easily to support this property, however I will have to investigate this and get back to you
Regards, lordmilko
Hi @schoenm1,
Based on the fact the path your PowerShell output above indicates you might be a .NET developer, you should be able to easily implement this functionality yourself for now by making the following changes
In ChannelProperty.cs, add a Name
item to the ChannelProperty
enum
public enum ChannelProperty
{
Name,
In Channel.cs, add [PropertyParameter(ChannelProperty.Name)]
as an additional attribute on the Name
property
/// <summary>
/// Name of this channel.
/// </summary>
[XmlElement("name")]
[PropertyParameter(Property.Name)]
[PropertyParameter(ChannelProperty.Name)]
public string Name { get; set; }
In ObjectPropertyParser.cs, in the else
block of the method GetObjectPropertyNameViaCache
change
name = attribute.ElementName.Substring("injected_".Length);
to
if (attribute.ElementName.StartsWith(HtmlParser.DefaultPropertyPrefix))
name = attribute.ElementName.Substring(HtmlParser.DefaultPropertyPrefix.Length);
else
name = attribute.ElementName;
Also in ObjectPropertyParser.cs, in method GetPropertyInfoViaPropertyParameter
change
var prop = typeof(TObject).GetTypeCache().Properties.FirstOrDefault(p => p.GetAttribute<PropertyParameterAttribute>()?.Property.Equals(property) == true);
to
var prop = typeof(TObject).GetTypeCache().Properties.FirstOrDefault(p => p.GetAttributes<PropertyParameterAttribute>()?.FirstOrDefault(p2 => p2.Property.Equals(property) == true) != null);
You then should be able to compile PrtgAPI (easiest way is probably to restore NuGet packages then compile)
Hi @lordmilko I'm not familiar with .NET. Here you see my "REST Custom BETA" Sensor On editing the channel -id 2, I can change the Channel Name. After changing the channel Name:
FYI: I have a lot of EXE/EXEXML Sensors. When I change a channel Name, the old channel Name will always display (greyed out) and the new channel (new channel Name) will display my value. I can't get rid of the old channel, unless I create a new sensor. --> a channel Name change is in EXE/EXEXML not possible as far as I can tell.
Hi @schoenm1,
If it is an EXE/XML channel that is a different story; PRTG does not support renaming channel values, hence why this is greyed out in the PRTG UI. I did confirm however that the changes described above will allow you to rename channels on EXE/XML sensors. I am currently focusing on refactoring PrtgAPI for supporting PRTG's new API so don't currently have time to properly design and implement everything that is required to support this functionality, however judging from your initial post
C:\Visual_Studio\net-team
either you, or someone on your team is experienced working with Visual Studio, so it should be fairly straight forward to apply the patches described above and compile a local version of PrtgAPI capable of modifying channel names for use until this is implemented by this project properly
Hi @schoenm1,
Please be advised PrtgAPI 0.9.15 has now been released which includes a fix for this issue
To update PrtgAPI, please run Update-Module PrtgAPI
and reopen PowerShell
Regards, lordmilko
I'm not able to change a Channel Name, even not with -RawProperty
For a Sensor, I can set RawProperties, but not on Channels. $sensor | Set-ObjectProperty -RawProperty "name_" -RawValue "Active Session" -force => this will change the Sensor Name
for Channels:
Here is my problem, that I can not change the Channel Name ($sensor | Get-Channel -id 2).Name --> $["sessionCount"]["count"]) Is there a possibility to change the Channel Name after a sensor was created?
I could not found a "Name" Parameter in the Function "Set-ChannelProperty"