Skip to content

Commit

Permalink
Monitor: syncup from metro version
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Mar 15, 2024
1 parent 422b785 commit 84a6684
Show file tree
Hide file tree
Showing 5 changed files with 320 additions and 250 deletions.
7 changes: 5 additions & 2 deletions Monitor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ cmake_minimum_required(VERSION 3.3)

find_package(WPEFramework)

set(PLUGIN_NAME Monitor)
project_version(1.0.0)

set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME})

message("Setup ${MODULE_NAME} v${PROJECT_VERSION}")

set(PLUGIN_MONITOR_AUTOSTART "true" CACHE STRING "Automatically start Monitor plugin")
set(PLUGIN_MONITOR_STARTUPORDER "" CACHE STRING "Automatically start Monitor plugin")
# Plugins built from this repository that can be autmatically enabled or enabled manually when built externally
Expand Down Expand Up @@ -90,4 +93,4 @@ target_link_libraries(${MODULE_NAME}
install(TARGETS ${MODULE_NAME}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)

write_config(${PROJECT_NAME})
write_config()
81 changes: 81 additions & 0 deletions Monitor/Monitor.config
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ if(PLUGIN_MONITOR_OPENCDMI)
map_append(${configuration} observables ${OPENCDMI_MONITOR_CONFIG})
endif()

if(PLUGIN_MONITOR_TEXTTOSPEECH)
map()
kv(callsign org.rdk.TextToSpeech)
kv(operational 1)
key(restart)
map()
kv(window 60)
kv(limit 3)
end()
end()
ans(TEXTTOSPEECH_MONITOR_CONFIG)
map_append(${configuration} observables ___array___)
map_append(${configuration} observables ${TEXTTOSPEECH_MONITOR_CONFIG})
endif()

if(PLUGIN_MONITOR_SYSTEMAUDIOPLAYER)
map()
kv(callsign org.rdk.SystemAudioPlayer)
Expand Down Expand Up @@ -208,6 +223,72 @@ if(PLUGIN_MONITOR_WEBKITBROWSER_RESIDENT_APP)
map_append(${configuration} observables ${RESIDENT_APP_MONITOR_CONFIG})
endif()

if(PLUGIN_MONITOR_CLONED_APPS)
map()
kv(callsign "SearchAndDiscovery")
kv(operational -1)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_SEARCH_AND_DISCOVERY_MEMORYLIMIT})
end()
ans(SAD_APP_MONITOR_CONFIG)
map_append(${configuration} observables ___array___)
map_append(${configuration} observables ${SAD_APP_MONITOR_CONFIG})

foreach(N RANGE 0 3)
map()
kv(callsign "HtmlApp-${N}")
kv(operational -1)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_CLONED_APP_MEMORYLIMIT})
end()
ans(HTML_APP_MONITOR_CONFIG)
map_append(${configuration} observables ___array___)
map_append(${configuration} observables ${HTML_APP_MONITOR_CONFIG})
endforeach()

foreach(N RANGE 0 3)
map()
kv(callsign "LightningApp-${N}")
kv(operational -1)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_CLONED_APP_MEMORYLIMIT})
end()
ans(LIGHTNING_APP_MONITOR_CONFIG)
map_append(${configuration} observables ___array___)
map_append(${configuration} observables ${LIGHTNING_APP_MONITOR_CONFIG})
endforeach()

map()
kv(callsign "Cobalt-0")
kv(operational -1)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_CLONED_APP_MEMORYLIMIT})
end()
ans(COBALT_MONITOR_CONFIG)
map_append(${configuration} observables ___array___)
map_append(${configuration} observables ${COBALT_MONITOR_CONFIG})

map()
kv(callsign "Netflix-0")
kv(operational -1)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_NETFLIX_APP_MEMORYLIMIT})
end()
ans(NETFLIX_APP_MONITOR_CONFIG)
map_append(${configuration} observables ___array___)
map_append(${configuration} observables ${NETFLIX_APP_MONITOR_CONFIG})

map()
kv(callsign "JSPP")
kv(operational -1)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_CLONED_APP_MEMORYLIMIT})
end()
ans(JSPP_MONITOR_CONFIG)
map_append(${configuration} observables ___array___)
map_append(${configuration} observables ${JSPP_MONITOR_CONFIG})
endif()

if(PLUGIN_MONITOR_INSTANCES_LIST)

# 'PLUGIN_MONITOR_INSTANCES_LIST' contains a semi-colon (';') separated list of Monitor observable
Expand Down
30 changes: 19 additions & 11 deletions Monitor/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace Plugin {

/* virtual */ const string Monitor::Initialize(PluginHost::IShell* service)
{
ASSERT(service != nullptr);

_config.FromString(service->ConfigLine());

Expand All @@ -57,21 +58,26 @@ namespace Plugin {
Core::JSON::ArrayType<Config::Entry>::Iterator index(_config.Observables.Elements());

// Create a list of plugins to monitor..
_monitor->Open(service, index);
_monitor.Open(service, index);

// During the registartion, all Plugins, currently active are reported to the sink.
service->Register(_monitor);
service->Register(&_monitor);

RegisterAll();

// On succes return a name as a Callsign to be used in the URL, after the "service"prefix
return (_T(""));
}

/* virtual */ void Monitor::Deinitialize(PluginHost::IShell* service)
{
ASSERT(service != nullptr);

UnregisterAll();

_monitor->Close();
service->Unregister(&_monitor);

service->Unregister(_monitor);
_monitor.Close();
}

/* virtual */ string Monitor::Information() const
Expand Down Expand Up @@ -106,10 +112,10 @@ namespace Plugin {
if (request.Verb == Web::Request::HTTP_GET) {
// Let's list them all....
if (index.Next() == false) {
if (_monitor->Length() > 0) {
if (_monitor.Length() > 0) {
Core::ProxyType<Web::JSONBodyType<Core::JSON::ArrayType<Monitor::Data>>> response(jsonBodyDataFactory.Element());

_monitor->Snapshot(*response);
_monitor.Snapshot(*response);
#ifndef USE_THUNDER_R4
result->Body(Core::proxy_cast<Web::IBody>(response));
#else
Expand All @@ -118,12 +124,13 @@ namespace Plugin {
}
} else {
MetaData memoryInfo;
bool operational = false;

// Seems we only want 1 name
if (_monitor->Snapshot(index.Current().Text(), memoryInfo) == true) {
if (_monitor.Snapshot(index.Current().Text(), memoryInfo, operational) == true) {
Core::ProxyType<Web::JSONBodyType<Monitor::Data::MetaData>> response(jsonMemoryBodyDataFactory.Element());

*response = memoryInfo;
*response = Monitor::Data::MetaData(memoryInfo, operational);
#ifndef USE_THUNDER_R4
result->Body(Core::proxy_cast<Web::IBody>(response));
#else
Expand All @@ -135,12 +142,13 @@ namespace Plugin {
result->ContentType = Web::MIME_JSON;
} else if ((request.Verb == Web::Request::HTTP_PUT) && (index.Next() == true)) {
MetaData memoryInfo;
bool operational = false;

// Seems we only want 1 name
if (_monitor->Reset(index.Current().Text(), memoryInfo) == true) {
if (_monitor.Reset(index.Current().Text(), memoryInfo, operational) == true) {
Core::ProxyType<Web::JSONBodyType<Monitor::Data::MetaData>> response(jsonMemoryBodyDataFactory.Element());

*response = memoryInfo;
*response = Monitor::Data::MetaData(memoryInfo, operational);
#ifndef USE_THUNDER_R4
result->Body(Core::proxy_cast<Web::IBody>(response));
#else
Expand All @@ -161,7 +169,7 @@ namespace Plugin {
restartLimit = body->Restart.Limit;
}
TRACE(Trace::Information, (_T("Sets Restart Limits:[LIMIT:%d, WINDOW:%d]"), restartLimit, restartWindow));
_monitor->Update(observable, restartWindow, restartLimit);
_monitor.Update(observable, restartWindow, restartLimit);
} else {
result->ErrorCode = Web::STATUS_BAD_REQUEST;
result->Message = _T(" could not handle your request.");
Expand Down
Loading

0 comments on commit 84a6684

Please sign in to comment.