Skip to content
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

feat(common.opcua): Add debug info for nodes not in server namespace #14676

Merged
merged 5 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion plugins/common/opcua/input/input_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,13 @@ func (o *OpcUAInputClient) initLastReceivedValues() {
func (o *OpcUAInputClient) UpdateNodeValue(nodeIdx int, d *ua.DataValue) {
o.LastReceivedData[nodeIdx].Quality = d.Status
if !o.StatusCodeOK(d.Status) {
o.Log.Errorf("status not OK for node %v: %v", o.NodeMetricMapping[nodeIdx].Tag.FieldName, d.Status)
// Verify NodeIDs array has been built before trying to get item; otherwise show '?' for node id
if len(o.NodeIDs) > 0 {
caallinson marked this conversation as resolved.
Show resolved Hide resolved
o.Log.Errorf("status not OK for node %v (%v): %v", o.NodeMetricMapping[nodeIdx].Tag.FieldName, o.NodeIDs[nodeIdx].String(), d.Status)
} else {
o.Log.Errorf("status not OK for node %v (%v): %v", o.NodeMetricMapping[nodeIdx].Tag.FieldName, '?', d.Status)
}

return
}

Expand Down
10 changes: 9 additions & 1 deletion plugins/inputs/opcua_listener/subscribe_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,16 @@ func (o *SubscribeClient) StartStreamValues(ctx context.Context) (<-chan telegra
}
o.Log.Debug("Monitoring items")

for _, res := range resp.Results {
for idx, res := range resp.Results {
if !o.StatusCodeOK(res.StatusCode) {
// Verify NodeIDs array has been built before trying to get item; otherwise show '?' for node id
if len(o.OpcUAInputClient.NodeIDs) > 0 {
caallinson marked this conversation as resolved.
Show resolved Hide resolved
o.Log.Debugf("Failed to create monitored item for node %v (%v)",
o.OpcUAInputClient.NodeMetricMapping[idx].Tag.FieldName, o.OpcUAInputClient.NodeIDs[idx].String())
} else {
o.Log.Debugf("Failed to create monitored item for node %v (%v)", o.OpcUAInputClient.NodeMetricMapping[idx].Tag.FieldName, '?')
}

return nil, fmt.Errorf("creating monitored item failed with status code: %w", res.StatusCode)
}
}
Expand Down
Loading