PLCnext API Documentation 23.6.0.37
|
This Singleton class provides an Interface to manage and control the LTTng tracing on the PLCnext controller. More...
#include <TraceController.hpp>
Public Types | |
typedef std::list< Arp::String > | SessionList |
Public Member Functions | |
bool | IsSessionDaemonAlive (void) const |
Checks if the LTTng session daemon for tracing is alive. More... | |
void | LoadTracepointLibrary (void) |
Loads the PLCnext userspace Tracepoint library. More... | |
void | UnloadTracepointLibrary (void) |
Unloads the userspace Tracepoint library. More... | |
bool | LoadSessionConfiguration (const Arp::String &session, const Arp::String &config) |
Tries to loads a tracing session from a given configuration file. More... | |
SessionList | ListSessions (void) |
Queries a list of all loaded (both started and stopped sessions) LTTng tracing sessions. More... | |
bool | StartSession (const Arp::String &session) |
Starts a LTTng tracing session. More... | |
bool | StopSession (const Arp::String &session) |
Stops a LTTng tracing session. More... | |
bool | DestroySession (const Arp::String &session) |
Destroys/Unloads a LTTng tracing session. More... | |
bool | TriggerSavingTraceOutputs (const bool &stopTriggerSession) |
Triggers the recording/saving all outputs of a configured session. Saving will be performed by another thread (delayed). More... | |
bool | IsSessionInSnapshotMode (const Arp::String &session) |
Checks if a tracing session is in Snapshot Mode. More... | |
bool | IsSessionEnabled (const Arp::String &session) |
Checks if a tracing session is already enabled/started. More... | |
bool | IsSessionLoaded (const Arp::String &session) |
Checks if a trace session is already loaded. More... | |
void | SetTracesSavingConfigs (const Arp::String &triggerSession, const Arp::String &outPath, const Arp::uint32 &maxDirectorySize, const Arp::uint32 &savingDelayTimeout) |
Sets the configuration of the trigger saving function More... | |
Friends | |
class | Singleton< TraceController > |
Additional Inherited Members | |
![]() | |
static Instance & | CreateInstance (Args &&... args) |
Creates this singleton instance. More... | |
static bool | IsCreated (void) |
Determines if this singleton instance is create yet. More... | |
static Instance & | GetInstance (void) |
Gets a reference of the singleton instance. More... | |
static Instance * | GetInstancePtr (void) |
Deprecated! Gets a pointer to the singleton instance. More... | |
static void | DisposeInstance (void) |
Disposes this singleton instance. More... | |
![]() | |
typedef Singleton< TraceController > | SingletonBase |
Defines this type to be used from derived classes. | |
![]() | |
Singleton (void)=default | |
The protected default constructor. | |
~Singleton (void)=default | |
The protected default destructor. | |
![]() | |
static void | SetInstance (Instance *pOther) |
Depreacated! Sets the singleton instance. More... | |
static void | AssignInstanceFrom (Instance &other) |
Assigns the singleton instance from another singleton instance of the same type. More... | |
This Singleton class provides an Interface to manage and control the LTTng tracing on the PLCnext controller.
This service is defined in library Arp.Services.TraceController.
A recording session belongs to a session daemon (see lttng-sessiond(8)). For a given session daemon, each Unix user has its own, private recording sessions. Note, however, that the root Linux user may operate on or destroy another user's tracing session. The plcnext_firmware user will not be able to see or control tracing sessions of another users.
LTTng generally offers four recording session modes (see LTTng Documentation):
Running LTTng tracing may affect the performance of the PLCnext controller.
bool Arp::System::Commons::Diagnostics::TraceController::DestroySession | ( | const Arp::String & | session | ) |
Destroys/Unloads a LTTng tracing session.
A tracing session with the specified name must be loaded (see IsSessionLoaded) and stopped (see IsSessionEnabled).
session | Name of Session which will be destroyed/unloaded. |
Arp.Exception | if the session does not exist or an internal LTTng error is occured. |
false
if the Arp.System.Commons.Diagnostics.TraceController singleton instance was not created or if the instance was desposed, otherwise true
. bool Arp::System::Commons::Diagnostics::TraceController::IsSessionDaemonAlive | ( | void | ) | const |
Checks if the LTTng session daemon for tracing is alive.
The tracing sessions can only loaded/started if the LTTng daemon is running.
true
if the LTTng session daemon is running, otherwise false
. bool Arp::System::Commons::Diagnostics::TraceController::IsSessionEnabled | ( | const Arp::String & | session | ) |
Checks if a tracing session is already enabled/started.
A tracing session can be enabled/started with the method StartSession and stopped with the method (see StopSession)
session | Session Name, which mode will be checked |
Arp.Exception | if the session does not exist or an internal LTTng error has occurred. |
true
if the session is in enabled/started, otherwise false
bool Arp::System::Commons::Diagnostics::TraceController::IsSessionInSnapshotMode | ( | const Arp::String & | session | ) |
Checks if a tracing session is in Snapshot Mode.
The specified trace session must exist (see ListSessions and IsSessionLoaded) when this method is called .
The specified trace session must exist when this method is called (see ListSessions).
See lttng-sessiond(8) for more information about LTTng snapshot sessions.
session | Session name |
Arp.Exception | if the specified session does not exist or an internal LTTng error has occurred. |
true
if the tracing session is in snapshot mode, otherwise false
. bool Arp::System::Commons::Diagnostics::TraceController::IsSessionLoaded | ( | const Arp::String & | session | ) |
Checks if a trace session is already loaded.
session | Session Name, which mode will be checked |
Arp.Exception | if an internal LTTng error has occurred. |
true
if the session is in loaded, otherwise false
SessionList Arp::System::Commons::Diagnostics::TraceController::ListSessions | ( | void | ) |
Queries a list of all loaded (both started and stopped sessions) LTTng tracing sessions.
Arp.Exception | if an internal LTTng error has occurred. |
bool Arp::System::Commons::Diagnostics::TraceController::LoadSessionConfiguration | ( | const Arp::String & | session, |
const Arp::String & | config | ||
) |
Tries to loads a tracing session from a given configuration file.
The PLCnext firmware provides two .lttng configuration files in the folder /opt/plcnext/lttng:
See LTTng documentaion for more information about session configuration.
This method fails if a tracing session with the same name is already loaded in the system. The method IsSessionLoaded can be used to check if a tracing session is already loaded.
Restrictions:
See LTTng documentaion for more information about defined restrictions.
A tracing session can be unloaded/destroyed with the method (see DestroySession)
session | Session name, which must be identical with the trace name configured in the .lttng configuration file. |
path | Path to the .lttng configuration file of the specified tracing session. |
Arp.Exception | if the specified tracing session is already loaded or an internal LTTng error has occurred. |
true
if the session was loaded successfully, otherwise false
. void Arp::System::Commons::Diagnostics::TraceController::LoadTracepointLibrary | ( | void | ) |
Loads the PLCnext userspace Tracepoint library.
The user trace points will not be exported to lttng if the Tracepoint library is not loaded.
Arp.System.Commons.InvalidConfigException | if the path to the Tracepoint library does not exist. |
Arp.System.Commons.InvalidOperationException | if the Tracepoint library ist already loaded. |
Arp.Exception | an internal error occurred while loading the Tracepoint library. |
void Arp::System::Commons::Diagnostics::TraceController::SetTracesSavingConfigs | ( | const Arp::String & | triggerSession, |
const Arp::String & | outPath, | ||
const Arp::uint32 & | maxDirectorySize, | ||
const Arp::uint32 & | savingDelayTimeout | ||
) |
Sets the configuration of the trigger saving function
triggerSession | Session Name, which will be user for the Saving Trigger |
outPath | Output path for the Saving Trigger Function |
maxDirectorySize | Max Directory Size of the Saving Trigger Output Directory |
savingDelayTimeout | Trigger Saving Delay Timeout |
bool Arp::System::Commons::Diagnostics::TraceController::StartSession | ( | const Arp::String & | session | ) |
Starts a LTTng tracing session.
A tracing session with the specified name must have been both loaded (see IsSessionLoaded) and stopped (see IsSessionEnabled).
The Tracepoint library must be loaded to start the tracing session LoadTracepointLib.
session | Name of Session which will be started. |
Arp.Exception | an exception will be thrown if:
|
Arp.System.Commons.InvalidOperationException | if the Tracepoint library was not loaded. |
true
if the tracing session was started successfully, otherwise false
. bool Arp::System::Commons::Diagnostics::TraceController::StopSession | ( | const Arp::String & | session | ) |
Stops a LTTng tracing session.
A tracing session with the specified name must be loaded (see IsSessionLoaded) and started (see IsSessionEnabled).
session | Name of Session which will be stopped. |
Arp.Exception | an exception will be thrown if:
|
true
if the session was stopped successfully, otherwise false
. bool Arp::System::Commons::Diagnostics::TraceController::TriggerSavingTraceOutputs | ( | const bool & | stopTriggerSession | ) |
Triggers the recording/saving all outputs of a configured session. Saving will be performed by another thread (delayed).
The configuration file of the TraceController PLCnext component (under /opt/plcnext/projects/Default/Services/TraceController/) contains the following configuration parameters for the traces saving trigger:
/para>
The traces output directory works as a ring buffer. If the configured maximum size of the folder is reached, the oldest trace(s) is/are deleted from this folder as needed and the new trace is then saved.
The way the session data is stored depends on its operation mode:
true
if the recording/saving of the tracing session was successful, otherwise false
. void Arp::System::Commons::Diagnostics::TraceController::UnloadTracepointLibrary | ( | void | ) |
Unloads the userspace Tracepoint library.
All LTTng tracing sessions must be stopped before unloading the Tracepoint library (see methods ListSessions IsSessionEnabled).
Arp.System.Commons.InvalidConfigException | if the path to the Tracepoint library cannot be resolved. |
Arp.System.Commons.InvalidOperationException | if at least one tracing session still running. |
Arp.Exception | an internal error occurred while unloading the Tracepoint library. |