3 * Copyright (C) 2018-2019 "IoT.bzh"
4 * Author Sebastien Douheret <sebastien@iot.bzh>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import { Injectable } from '@angular/core';
20 import { Observable } from 'rxjs/Observable';
22 import { XDSAgentService } from './xdsagent.service';
23 import { map } from 'rxjs/operators';
25 export interface AglTopology {
36 export interface AglLowCollectorConfig {
41 export class MonitoringService {
43 constructor(private xdsSvr: XDSAgentService) {
45 this.xdsSvr.XdsConfig$.subscribe(cfg => {
46 if (!cfg || cfg.servers.length < 1) {
53 getTopo(): Observable<AglTopology[]> {
54 return this.xdsSvr.getTopoMonitoring().pipe(
55 map((tp: AglTopology[]) => {
56 // FIXME - move filter on backend side
57 const ignored: string[] = [
64 ignored.forEach(iel => {
65 if (el.name.indexOf(iel) !== -1) {
70 // replace unix:/run/xxx/ws by nothing
71 const wsc: string[] = [];
72 el.ws_clients.forEach(s => {
73 s = s.replace('unix:/run/platform/apis/ws/', '');
74 s = s.replace('unix:/run/user/1001/apis/ws/', '');
75 s = s.replace('unix:/run/user/0/apis/ws/', '');
79 // replace sd: by nothing
80 const wss: string[] = [];
81 el.ws_servers.forEach(s => {
82 wss.push(s.replace('sd:', ''));
91 startTrace(cfg: any): Observable<any> {
92 return this.xdsSvr.startTraceMonitoring(cfg);
95 stopTrace(cfg: any): Observable<any> {
96 return this.xdsSvr.stopTraceMonitoring(cfg);
99 startLowCollector(cfg: AglLowCollectorConfig): Observable<any> {
100 return this.xdsSvr.startLowCollector(cfg);
103 stopLowCollector(): Observable<any> {
104 return this.xdsSvr.stopLowCollector();