sapnwrfc_exporter

command module
Version: v0.0.0-...-91b0819 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

README

SAP NWRFC Exporter for Prometheus Go Report Card

The purpose of this exporter is to support monitoring SAP instances with Prometheus and Grafana. It is possible to count the occurrence for some defined values of a field in a SAP function module result table - for example the number of dialog, batch and update processes or the number of the SAP lock entries at a given time. Another possibility is to use the export field results of a function module as prometheus label values - for example to record the database client version and kernel patch level of the SAP instance.

Prerequisites

!!! The new nwrfcsdk pl8 works fine for me. It looks like there are some issues with nwrfcsdk pl7. In my experience sapnwrfc_exporter v0.3 in combination with nwrfcsdk pl6 is also a good working combination.

You need the SAP NWRFC SDK 7.50 PL3 library (or later) as a prequisite for the installation of this exporter. To download this library you must have a customer or partner account on the SAP Service Marketplace. Please take a look at SAP note "2573790 - Installation, Support and Availability of the SAP NetWeaver RFC Library 7.50" and the gorfc readme.

With the nwrfcsdk zip file unpacked in /usr/sap, the following environment variables are necessary under Linux:

LD_LIBRARY_PATH="/usr/sap/nwrfcsdk/lib"
CGO_LDFLAGS="-L /usr/sap/nwrfcsdk/lib"
CGO_CFLAGS="-I /usr/sap/nwrfcsdk/include"
CGO_LDFLAGS_ALLOW=.*
CGO_CFLAGS_ALLOW=.*

Installation

To build the exporter you need the Go programming language. It can then be built with:

$ git clone git@github.com:ulranh/sapnwrfc_exporter.git
$ cd sapnwrfrc_exporter
$ go build

Preparation

SAP User

A SAP user is necessary for every SAP system with read access for all affected remote function modules.

Configfile

The next necessary piece is a toml configuration file where the encrypted passwords, the system- and metric-information are stored. The expected default name is .sapnwrfc_exporter.toml and the expected default location of this file is the home directory of the user. The flag -config can be used to assign other locations or names.

The file contains a Systems- and a Metrics-slice. After version v0.2 the metric format in the toml file has changed. Instead of a TableMetrics- and/or StructureMetrics- and/or FieldMetrics- slice, now there is only one Metrics slice where each element has the same basic fields and one additional table-, structure- or field-information struct as a sub-struct:

# user/password logon
[[Systems]]
  Name = "t01"
  Usage = "test"
  Tags = []
  User = "sapuser1"
  Lang = "en"
  Client = "100"
  Server = "host1.example.com"
  Sysnr = "01"

# load balanced logon
[[Systems]]
  Name = "t02"
  Usage = "test"
  Tags = []
  User = "sapuser2"
  Lang = "en"
  Client = "100"
  Mshost = "server2.example.com"
  Msserv = "3600"
  Group = "server2_1"

# load balanced logon and saprouter
[[Systems]]
  Name = "t03"
  Usage = "test"
  Tags = []
  User = "sapuser3"
  Lang = "en"
  Client = "100"
  Mshost = "server3.example.com"
  Msserv = "3600"
  Group = "server3_1"
  Saprouter = "/H/saprouter/W/pass/H/target"

[[metrics]]
  Name = "sap_lock_entries"
  Help = "sm12 help"
  MetricType = "gauge"
  TagFilter = []
  FunctionModule = "ENQUE_READ"
  AllServers = false
  [metrics.params]
    GARG = ""
    GCLIENT = ""
    GNAME = ""
    GUNAME = ""
  [metrics.tabledata]
    Table = "ENQ"
    [metrics.tabledata.rowcount]
      gclient = ["total", "000", "50", "60"]

[[metrics]]
  Name = "sap_stapi_version"
  Help = "SAP ST-A/Pi version info"
  MetricType = "gauge"
  TagFilter = []
  FunctionModule = "ANST_OCS_GET_COMPONENT_STATE"
  AllServers = false
  [metrics.params]
    IV_COMPONENT = "ST-A/PI"
  [metrics.fielddata]
    FieldLabels = ["ev_comp_rel", "ev_comp_spp_level"]

[[metrics]]
  Name = "sap_tune_storage_infos"
  Help = "SAP tune storage infos"
  MetricType = "gauge"
  TagFilter = []
  AllServers = true
  FunctionModule = "SAPTUNE_GET_STORAGE_INFOS"
  [metrics.fielddata]
    FieldValues = ["page_bufsz"]

[[metrics]]
  Name = "sap_tune_programs_info"
  Help = "SAP tune buffered programs info"
  MetricType = "gauge"
  TagFilter = []
  AllServers = true
  FunctionModule = "SAPTUNE_BUFFERED_PROGRAMS_INFO"
  [metrics.structuredata]
    ExportStructure = "INFO"
    StructureFields = ["prg_swap", "prg_gen"]

Below is a description of the system and metric struct fields:

System information
Field Type Description Example
Name string SAP SID "P01", "q02"
Usage string SAP system usage "development", "test", "production"
Tags string array Tags describing the system ["erp"], ["bw"]
User string SAP system user
Lang string The entries of TableMetrics.RowFilterOut and TableMetrics.RowCount can differ, depending on the logon language "en", "de"
Client string SAP system client
Server string SAP system server
Sysnr string SAP system number
Mshost string Message Server
Msserv string is needed only, if the service of the message server is not defined as sapms in /etc/services 3600
Group string Logon group (transaction SMLG)
Saprouter string SAP router string
Metric information

Every entry has the same basic fields:

Field Type Description Example
Name string Metric name (words separated by underscore, otherwise a panic can occur) "sap_processes"
Help string Metric help text "Number of sm50 processes"
MetricType string Type of metric "counter" or "gauge"
TagFilter string array The metric will only be executed, if all values correspond with the existing tenant tags TagFilter ["erp"] needs at least system Tag ["erp"] otherwise the metric will not be used
FunctionModule string Function module name "TH_WPINFO"
AllServers bool When true, the metric will be created for every applicationserver of the SAP system "true","false"
[Metrics.Params] map[string]interface{} Params of the function module

For every entry one of the following special information for table-, field-, or structure data is possible:

Metric table information

[metrics.tabledata]

Field Type Description Example
table string Result table of function module "WPLIST"
metrics.tabledata.rowcount map[string]interface{} Values of a table result field, that should be counted wp_typ = ["dia"]
metrics.tabledata.rowfilter map[string]interface{} Only some values of a table field shall be considered all other lines will be skipped wp_status = ["running"]
Metric field information

[metrics.fielddata]

Field Type Description Example
fieldlabels string array Function module export field names with values that should be recorded as labels ["kern_rel","kern_patchlevel"] of function module TH_SAPREL2
fieldvalues string array Function module export field names with values that should be recorded as values ["page_bufsz"] of function module SAPTUNE_GET_STORAGE_INFOS
Metric structure information

[metrics.structuredata]

Field Type Description Example
ExportStructure string Function module export structure "INFO" - export structure of function module SAPTUNE_BUFFERED_PROGRAMS_INFO
StructureFields string array Function module export structure field names with values that should be recorded as values ["prg_swap","prg_gen"] of function module SAPTUNE_BUFFERED_PROGRAMS_INFO
Database passwords

With the following commands the passwords for the example tenants above can be written to the Secret section of the configfile:

$ ./sapnwrfc_exporter pw --system t01 # default configfile in <home>/.sapnwrfc_exporter.toml
$ ./sapnwrfc_exporter pw -s t02 -c ./sapnwrfc_exporter.toml

With one password for multiple systems, the following notation is also possible:

$ ./sapnwrfc_exporter pw -s t01,t02 --config ./.sapnwrfc_exporter.toml

Usage

Now the web server can be started:

Binary

The default port is 9663 which can be changed with the -port flag.

$ ./sapnwrfc_exporter web -config ./sapnwrfc_exporter.toml

Then you should be able to find the desired metrics after calling localhost:9663/metrics in the browser.

Docker

The Docker image can be built with the existing Dockerfile. As a prerequisite the SAP NW RFC library has to be unzipped in the working directory. Then it can be started as follows:

$ docker run -d --name=sapnwrfc_exporter --restart=always -p 9663:9663 -v /home/<user>/sapnwrfc_exporter.toml:/app/sapnwrfc_exporter.toml \<image name\>
Kubernetes

Due to the license restrictions it is not possible to publish a docker image that includes the sapnwrfc library. But all SAP customers can create their own images and use them. An example config can be found in the examples folder. First of all create a SAP namespace. Then apply the created configfile as configmap and start the deployment:

$ kubectl apply -f sap-namespace.yaml 
$ kubectl create configmap sapnwrfc-config -n sap --from-file ./sapnwrfc_exporter.toml -o yaml
$ kubectl apply -f sapnwrfc-deployment.yaml

Configfile changes can be applied in the following way:

$ kubectl create configmap sapnwrfc-config -n sap --from-file ./sapnwrfc_exporter.toml -o yaml --dry-run | sudo kubectl replace -f -
$ kubectl scale --replicas=0 -n sap deployment sapnwrfc-exporter
$ kubectl scale --replicas=1 -n sap deployment sapnwrfc-exporter
Prometheus configfile

The necessary entries in the prometheus configfile can look something like the following:

  - job_name: sap
        scrape_interval: 60s
        static_configs:
          - targets: ['172.45.111.105:9663']
            labels:  {'instance': 'sapnwrfc-exporter-test'}
          - targets: ['sapnwrfc_exporter.sap.svc.cluster.local:9663']
            labels:  {'instance': 'sapnwrfc-exporter-dev'}

Result

The resulting information can be found in the Prometheus expression browser and can be used as normal for creating alerts or displaying dashboards in Grafana.

The image below for example shows the number of active dialog, batch and update processes at a given time:

processes

More Information

Documentation

The Go Gopher

There is no documentation for this package.

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL