Rpc Service - ManagerDiagnostic

The ManagerDiagnostic is a remote procedure call (RPC) service available for all manager types except Data Manager. It allows you to retrieve diagnostic data using flags in C++, C#, Node.js or CTRL.

Overview

The ManagerDiagnostic is an RPC service for all WinCC OA managers excluding the Data manager. This service is accessible via multiple languages including C++, C#, Node.js, and CTRL scripting.

Clients send requests to this service using specific report flags to obtain diagnostics. These flags can be passed as a string or dyn_string. The service responds with a MappingVar structure containing the requested data.

Accepted Report Flags

The following flags can be used with the ManagerDiagnostic service:

Table 1. Accepted Flags
Flag Description
SUMMARY General summary of the manager status.
DPIDENTIFICATION Identifies datapoints known to the manager.
DISPATCH Dispatching-related information.
MSGQUEUE Status and contents of the message queue.
ALERTCOUNT Number of current alerts.
QUERY Internal queries handled by the manager.
DPCONNECTS Information on datapoint connections.

Functions

Table 2. Functions
Function Description
getMetrics() Returns a MappingVar that contains a list of supported report flags under the key metrics.
getMetricData(reportFlags)

Requests metrics data based on the passed reportFlags, which can be passed as string or dyn_string. Returns a MappingVar with the requested data.

Example (CTRL)

#uses "vrpc"

void main()
{
unsigned managerType = EVENT_MAN; // Specify the manager type - see chapter myManType().
  int managerNumber = 0;  // Specify the manager number - This is the number of the manager for which you want to call up the procedure. 
  // For the administration of managers, see chapter Administration of managers.  
  
  DebugN("The Service Manager that is used: " + "(" + managerType + ")" + ", Number: " + managerNumber);

  // Run the manager
  run(managerType, managerNumber);
}

void run(unsigned managerType, int managerNumber)
{
  // Create a client context
  VrpcClientContext clientContext = VrpcClientContext();

  // Create a stub
  VrpcStubOptions options = VrpcStubOptions();

  if (managerType != NO_MAN && managerNumber != -1)
    options.withManagerSpecificService(managerType, managerNumber);
  
  // ManagerDiagnostic is the name of the vRPC Service
  shared_ptr<VrpcStub> stub = new VrpcStub("ManagerDiagnostic", options);

  try
  {
    VrpcResponseData responseData = stub.callFunction("getMetrics", clientContext, "");

    // Check and print the response
    anytype response = responseData.getResponse();
    DebugN(response);

    // Send a request to the service
    VrpcResponseData responseData = stub.callFunction("getMetricData", clientContext, makeDynString("DISPATCH"));
    //VrpcResponseData responseData = stub.callFunction("getMetricData", clientContext, makeDynString("DPIDENTIFICATION", "DPCONNECTS,SUMMARY"));
    //VrpcResponseData responseData = stub.callFunction("getMetricData", clientContext, "MSGQUEUE");

    // Check and print the response
    anytype response = responseData.getResponse();
    DebugN(response);
  }
  catch
  {
    VrpcException exception = vrpcGetLastException();
    DebugN("Exception: " + exception.toString());
  }
}

Notes

  • Always ensure that the specified manager is active.
  • Use the function getMetrics() to check available flags.
  • Handle exceptions appropriately to avoid disruptions in diagnostics.