summaryrefslogtreecommitdiffstats
path: root/examples/applicationmanager/monitor/doc/src/monitor.qdoc
blob: 5fc0faa3e6901d3e3efa23dd6d2d2e7c88a9005a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/****************************************************************************
**
** Copyright (C) 2018 Pelagicore AG
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Pelagicore Application Manager.
**
** $QT_BEGIN_LICENSE:FDL-QTAS$
** Commercial License Usage
** Licensees holding valid commercial Qt Automotive Suite licenses may use
** this file in accordance with the commercial license agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and The Qt Company.  For
** licensing terms and conditions see https://www.qt.io/terms-conditions.
** For further information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!

\example applicationmanager/monitor
\title Performance Monitoring Example
\image monitor.png Screenshot
\brief A resource and performance monitor.
\ingroup applicationmanager-examples

\section1 Introduction

This example shows the basic usage of system and process monitoring APIs offered by the
application-manager:
    \list
    \li SystemMonitor
    \li ProcessMonitor
    \endlist

The example monitors performance (frame rate), as well as rescource usage (memory and CPU).

\section2 Invocation
The example can be started from within the "monitor" folder with:
\badcode
path/to/bin/appman -c am-config.yaml
\endcode

\note The application-manager attempts to register a \c freedesktop.org compliant notification
server. DBus errors might occur if it conflicts with the server running on the host desktop
environment. In this case, a private session bus needs to be started by adding the
\c --start-session-dbus option.

\section1 Walkthrough

We will start from the bottom, because this is the essential part.

\section2 SystemMonitor and ProcessMonitor Usage

\quotefromfile applicationmanager/monitor/system-ui/main.qml
\skipto ProcessMonitor
\printuntil ApplicationManager.application(0).start()
\printline }
The ProcessMonitor will monitor the process that is associated with
its \l {ProcessMonitor::applicationId}{applicationId} property. An empty applicationId string means
that the System-UI process is monitored. By clicking the "Switch Process" button, the monitored
process can be changed to the \c tld.monitor.app application. Measurements will be performed each
second (1000 ms) and 12 reading points will be kept in the model (ProcessMonitor is a model).
The model is used below to display the bar charts.

Memory and frame rate reporting need to be enabled, since we are interested in both. For frame rate
measurements the list of \c monitoredWindows has to be filled with windows that we are interested
in. For the System-UI this is the single root window itself and for the tld.monitor.app process it
is the currently selected window. Hence the list will always include just one element. The memory
and frame rate changed signal handlers will update the current values of the corresponding views.

The Connections type is used to implement signal handlers for the property changes of the
SystemMonitor. The current values of the corresponding views are updated, as well.

For the SystemMonitor, like above, measurements will be performed each second (1000 ms) and
12 reading points will be kept in the model (the SystemMonitor is a model, as well).

The very last line will start the only application that is provided by this example. Note that, if
the application-manager is running in single-process mode, the application will run within the
System-UI process and consequently the ProcessMonitor will not report anything and the associated
ProcessMonitor::processId will be set to 0.

\section2 The User Interface

\quotefromfile applicationmanager/monitor/system-ui/main.qml
\skipto import Qt
\printto ProcessMonitor
\dots

We won't go into much detail, because it's rather conventional QML code. The MonitorChart is a
ListView that uses either an instance of a ProcessMonitor or the SystemMonitor singleton as its
model. The reading values are represented as bars. Their height is determined by the
corresponding model role, e.g. for the PSS memory consumption it is \c memoryPss.total.

When the tld.monitor.app process is monitored, its two windows will be shown (primary and
secondary). The window that is monitored in terms of frame rate can be selected and is highlighted
with a white border.

*/