go.ligato.io/vpp-agent/v3@v3.5.0/plugins/govppmux/client_stats.go (about)

     1  //  Copyright (c) 2019 Cisco and/or its affiliates.
     2  //
     3  //  Licensed under the Apache License, Version 2.0 (the "License");
     4  //  you may not use this file except in compliance with the License.
     5  //  You may obtain a copy of the License at:
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  //  Unless required by applicable law or agreed to in writing, software
    10  //  distributed under the License is distributed on an "AS IS" BASIS,
    11  //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  //  See the License for the specific language governing permissions and
    13  //  limitations under the License.
    14  
    15  package govppmux
    16  
    17  import (
    18  	"go.fd.io/govpp/adapter"
    19  	govppapi "go.fd.io/govpp/api"
    20  )
    21  
    22  // ListStats returns all stats names
    23  func (p *Plugin) ListStats(prefixes ...string) ([]adapter.StatIdentifier, error) {
    24  	if p.statsAdapter == nil {
    25  		return nil, nil
    26  	}
    27  	return p.statsAdapter.ListStats(prefixes...)
    28  }
    29  
    30  // DumpStats returns all stats with name, type and value
    31  func (p *Plugin) DumpStats(prefixes ...string) ([]adapter.StatEntry, error) {
    32  	if p.statsAdapter == nil {
    33  		return nil, nil
    34  	}
    35  	return p.statsAdapter.DumpStats(prefixes...)
    36  }
    37  
    38  // GetSystemStats retrieves system statistics of the connected VPP instance like Vector rate, Input rate, etc.
    39  func (p *Plugin) GetSystemStats(stats *govppapi.SystemStats) error {
    40  	if p.statsConn == nil {
    41  		return nil
    42  	}
    43  	p.statsMu.Lock()
    44  	defer p.statsMu.Unlock()
    45  	return p.statsConn.GetSystemStats(stats)
    46  }
    47  
    48  // GetNodeStats retrieves a list of Node VPP counters (vectors, clocks, ...)
    49  func (p *Plugin) GetNodeStats(stats *govppapi.NodeStats) error {
    50  	if p.statsConn == nil {
    51  		return nil
    52  	}
    53  	p.statsMu.Lock()
    54  	defer p.statsMu.Unlock()
    55  	return p.statsConn.GetNodeStats(stats)
    56  }
    57  
    58  // GetInterfaceStats retrieves all counters related to the VPP interfaces
    59  func (p *Plugin) GetInterfaceStats(stats *govppapi.InterfaceStats) error {
    60  	if p.statsConn == nil {
    61  		return nil
    62  	}
    63  	p.statsMu.Lock()
    64  	defer p.statsMu.Unlock()
    65  	return p.statsConn.GetInterfaceStats(stats)
    66  }
    67  
    68  // GetErrorStats retrieves VPP error counters
    69  func (p *Plugin) GetErrorStats(stats *govppapi.ErrorStats) error {
    70  	if p.statsConn == nil {
    71  		return nil
    72  	}
    73  	p.statsMu.Lock()
    74  	defer p.statsMu.Unlock()
    75  	return p.statsConn.GetErrorStats(stats)
    76  }
    77  
    78  // GetBufferStats retrieves VPP error counters
    79  func (p *Plugin) GetBufferStats(stats *govppapi.BufferStats) error {
    80  	if p.statsConn == nil {
    81  		return nil
    82  	}
    83  	p.statsMu.Lock()
    84  	defer p.statsMu.Unlock()
    85  	return p.statsConn.GetBufferStats(stats)
    86  }
    87  
    88  // GetMemoryStats retrieves VPP memory info
    89  func (p *Plugin) GetMemoryStats(stats *govppapi.MemoryStats) error {
    90  	if p.statsConn == nil {
    91  		return nil
    92  	}
    93  	p.statsMu.Lock()
    94  	defer p.statsMu.Unlock()
    95  	return p.statsConn.GetMemoryStats(stats)
    96  }