-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opcua input plugin + authentication options #8009
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the plugin. Have some change requests for you.
ReadSuccess int | ||
ReadError int | ||
NumberOfTags int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These would be good as selfstat.Stat instances. See other plugins for examples. selfstats are reported automatically as part of [[inputs.internal]]
Interval string `toml:"time_interval"` | ||
TimeOut int `toml:"timeout"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should both be a config.Duration
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may have been a solid reason for interval using a string. I'll look into it and change as appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you look into this? It seems error prone to allow people to set the interval as a string. The docs say 5s or 10s which is the format config.Duration uses.
Co-authored-by: Steven Soroka <[email protected]>
@fdamador if you're interesting in testing this code with authentication options based off your original PR that would be really helpful. |
This reverts commit 2f734bd.
…put, updated self-signed cert organization.
## Guide: | ||
## An OPC UA node ID may resemble: "n=3,s=Temperature" | ||
## In this example, n=3 is indicating the namespace is '3'. | ||
## s=Temperature is indicting that the identifier type is a 'string' and the indentifier value is 'Temperature' | ||
## This temperature node may have a current value of 79.0, which would possibly make the value a 'float'. | ||
## To gather data from this node you would need to enter the following line into 'nodes' property above: | ||
## {name="SomeLabel", namespace="3", identifier_type="s", identifier="Temperature", data_type="float", description="Some description."}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be in the sample config? Could bring it out as just plain text in the README
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds clearer to me too. Maybe make a subsection under configuration to describe how to use the nodes setting. See https://github.com/influxdata/telegraf/blob/master/plugins/inputs/EXAMPLE_README.md
@@ -0,0 +1,76 @@ | |||
# Telegraf Input Plugin: opcua_client | |||
|
|||
The opcua_client plugin retrieves data from OPCUA slave devices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "slave devices" to "client devices"
var err error | ||
|
||
o.Name = "testing" | ||
o.Endpoint = "opc.tcp://opcua.rocks:4840" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't depend on an internet test service in unit tests because the tests run in CI and need to be reliable. Either mock the endpoint you need for the test or disable the test in the short test set used in CI.
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
|
||
```toml | ||
|
||
# ## Connection Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean up the comments in the example config here and in sampleConfig. They need to match the commenting and indentation style because they are used when generating a config. See https://github.com/influxdata/telegraf/wiki/SampleConfig
Accurate default values should be included here and commented out with a single hash. Documentation is commented out with two hashes, not hash space hash hash
Interval string `toml:"time_interval"` | ||
TimeOut int `toml:"timeout"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you look into this? It seems error prone to allow people to set the interval as a string. The docs say 5s or 10s which is the format config.Duration uses.
timeout = 30 | ||
# | ||
# # Time Inteval, default = 10s | ||
time_interval = "5s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code in opcua_client.go says time_interval defaults to opcua.DefaultSubscriptionInterval. The gopcua docs say that's 100ms. https://godoc.org/github.com/gopcua/opcua#pkg-constants
Which default is right? 10s, 5s, 100ms?
## Guide: | ||
## An OPC UA node ID may resemble: "n=3,s=Temperature" | ||
## In this example, n=3 is indicating the namespace is '3'. | ||
## s=Temperature is indicting that the identifier type is a 'string' and the indentifier value is 'Temperature' | ||
## This temperature node may have a current value of 79.0, which would possibly make the value a 'float'. | ||
## To gather data from this node you would need to enter the following line into 'nodes' property above: | ||
## {name="SomeLabel", namespace="3", identifier_type="s", identifier="Temperature", data_type="float", description="Some description."}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds clearer to me too. Maybe make a subsection under configuration to describe how to use the nodes setting. See https://github.com/influxdata/telegraf/blob/master/plugins/inputs/EXAMPLE_README.md
nodes = [ | ||
{name="ProductName", namespace="0", identifier_type="i", identifier="2261", data_type="string", description="open62541 OPC UA Server"}, | ||
{name="ProductUri", namespace="0", identifier_type="i", identifier="2262", data_type="string", description="http://open62541.org"}, | ||
{name="ManufacturerName", namespace="0", identifier_type="i", identifier="2263", data_type="string", description="open62541"}, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this out of the sample config. It's a good config example and it makes sense to have it in the readme but we don't want to include it in everyone's config.
# # Security policy: None, Basic128Rsa15, Basic256, Basic256Sha256. Default: auto | ||
security_policy = "None" | ||
# | ||
# # Security mode: None, Sign, SignAndEncrypt. Default: auto | ||
security_mode = "None" | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include auto in the list of valid values. Don't set them to "None" in the sample config if they default to auto.
Also, where in the code do these default to auto? I didn't find it in a quick review.
# # password = "mypassword" | ||
# | ||
# ## Measurements | ||
# ## node id to subscribe to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use full sentences with punctuation and capitalization.
Required for all PRs:
Opcua plugin. Adapted from PR: 7213
#7213
Changes include authentication and encryption options.