Hello community,
here is the log from the commit of package prometheus-sap_host_exporter for
openSUSE:Factory checked in at 2020-07-05 01:17:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/prometheus-sap_host_exporter (Old)
and /work/SRC/openSUSE:Factory/.prometheus-sap_host_exporter.new.3060
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "prometheus-sap_host_exporter"
Sun Jul 5 01:17:12 2020 rev:5 rq:818574 version:0.5.1+git.1593777035.a5d05f8
Changes:
--------
---
/work/SRC/openSUSE:Factory/prometheus-sap_host_exporter/prometheus-sap_host_exporter.changes
2020-05-20 18:40:47.092651854 +0200
+++
/work/SRC/openSUSE:Factory/.prometheus-sap_host_exporter.new.3060/prometheus-sap_host_exporter.changes
2020-07-05 01:17:49.560928501 +0200
@@ -1,0 +2,24 @@
+Fri Jul 3 12:32:12 2020 UTC - [email protected]
+
+- Release 0.5.1
+
+ ## Fixed
+ - Make OBS RPM builds reproducible by removing the build date. (#48)
+
+-------------------------------------------------------------------
+Thu Jul 2 15:56:07 2020 UTC - [email protected]
+
+- Release 0.5.0
+
+ ## Added
+ - `--version` CLI flag (#42)
+ - Grafana dashboard is now part of the repo, although packaged independently
(#44)
+
+ ## Changed
+ - Bumped required Go version to 1.12 (#43)
+ - Switched CI from Travis to GitHub Actions (#45)
+
+ ## Fixed
+ - Some usage details are now further clarified (#47)
+
+-------------------------------------------------------------------
Old:
----
prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338.tar.gz
New:
----
prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ prometheus-sap_host_exporter.spec ++++++
--- /var/tmp/diff_new_pack.GMN7a8/_old 2020-07-05 01:17:51.632935104 +0200
+++ /var/tmp/diff_new_pack.GMN7a8/_new 2020-07-05 01:17:51.632935104 +0200
@@ -18,7 +18,7 @@
Name: prometheus-sap_host_exporter
# Version will be processed via set_version source service
-Version: 0.4.0+git.1587141635.71f3338
+Version: 0.5.1+git.1593777035.a5d05f8
Release: 0
Summary: Prometheus exporter for SAP systems (a.k.a. NetWeaver)
License: Apache-2.0
@@ -28,7 +28,7 @@
Source1: vendor.tar.gz
ExclusiveArch: aarch64 x86_64 ppc64le s390x
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-BuildRequires: go >= 1.11
+BuildRequires: go >= 1.12
Provides: sap_host_exporter = %{version}-%{release}
Provides: prometheus(sap_host_exporter) = %{version}-%{release}
# Unlike C/C++ packages, Golang packages do not have header files. They are
statically built so the main package is also the devel package.
++++++ _service ++++++
--- /var/tmp/diff_new_pack.GMN7a8/_old 2020-07-05 01:17:51.672935231 +0200
+++ /var/tmp/diff_new_pack.GMN7a8/_new 2020-07-05 01:17:51.672935231 +0200
@@ -2,9 +2,12 @@
<service name="tar_scm" mode="disabled">
<param name="url">git://github.com/SUSE/sap_host_exporter.git</param>
<param name="scm">git</param>
- <param name="revision">0.4.0</param>
+ <param name="revision">0.5.1</param>
<param name="exclude">.git</param>
- <param name="versionformat">@PARENT_TAG@+git.%ct.%h</param>
+ <param name="exclude">.github</param>
+ <param name="exclude">dashboards</param>
+ <param
name="exclude">packaging/obs/grafana-sap-netweaver-dashboards</param>
+ <param name="version">0.5.1+git.1593777035.a5d05f8</param>
<param name="filename">prometheus-sap_host_exporter</param>
</service>
<service name="set_version" mode="disabled">
++++++ prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338.tar.gz ->
prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/.ci/get_version_from_git.sh
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/.ci/get_version_from_git.sh
---
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/.ci/get_version_from_git.sh
1970-01-01 01:00:00.000000000 +0100
+++
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/.ci/get_version_from_git.sh
2020-07-03 13:50:35.000000000 +0200
@@ -0,0 +1,14 @@
+#!/bin/sh
+TAG=$(git describe --tags --abbrev=0 2>/dev/null)
+SUFFIX=$(git show -s --format=%ct.%h HEAD)
+
+if [ -n "${TAG}" ]; then
+ COMMITS_SINCE_TAG=$(git rev-list ${TAG}.. --count)
+ if [ "${COMMITS_SINCE_TAG}" -gt 0 ]; then
+ SUFFIX="dev${COMMITS_SINCE_TAG}.${SUFFIX}"
+ fi
+else
+ TAG="0"
+fi
+
+echo "${TAG}+git.${SUFFIX}"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/.travis.yml
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/.travis.yml
--- old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/.travis.yml
2020-04-17 18:40:35.000000000 +0200
+++ new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/.travis.yml
1970-01-01 01:00:00.000000000 +0100
@@ -1,62 +0,0 @@
-language: go
-go:
- - "stable"
-
-cache:
- directories:
- - $GOPATH/pkg/mod
-
-jobs:
- include:
- - stage: Test
- name: Static checks
- script: make static-checks
- - stage: Test
- name: Unit tests
- script: make test
- - stage: Release
- name: Build and upload binaries on GitHub
- if: tag IS present
- services:
- - docker
- env:
- - VERSION=$TRAVIS_TAG
- script:
- - make -j4 build-all
- deploy:
- provider: releases
- token: $GITHUB_OAUTH_TOKEN
- file_glob: true
- file: build/bin/*
- name: $TRAVIS_TAG
- skip_cleanup: true
- overwrite: true
- on:
- tags: true
- - stage: OBS delivery
- name: Commit to OBS dev project
- if: branch = master AND type != pull_request
- services:
- - docker
- env:
- - VERSION=$TRAVIS_COMMIT
- script:
- - |
- docker run --rm -t -v "$(pwd):/package" -w /package \
- -e OBS_USER -e OBS_PASS -e OBS_PROJECT -e OBS_PACKAGE -e VERSION -e
REPOSITORY=$TRAVIS_REPO_SLUG -e GITHUB_OAUTH_TOKEN \
- shap/continuous_deliver \
- bash -c "/scripts/init_osc_creds.sh && make obs-commit"
- - stage: OBS delivery
- name: Submit Request to OBS stable project
- if: tag IS present
- services:
- - docker
- env:
- - VERSION=$TRAVIS_TAG
- script:
- - |
- docker run --rm -t -v "$(pwd):/package" -w /package \
- -e OBS_USER -e OBS_PASS -e OBS_PROJECT -e OBS_PACKAGE -e VERSION -e
REPOSITORY=$TRAVIS_REPO_SLUG -e GITHUB_OAUTH_TOKEN \
- -e PACKAGE_NAME=$OBS_PACKAGE -e
TARGET_PROJECT=$OBS_DOWNSTREAM_PROJECT \
- shap/continuous_deliver \
- bash -c "/scripts/init_osc_creds.sh && make obs-commit &&
/scripts/submit.sh"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/Makefile
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/Makefile
--- old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/Makefile
2020-04-17 18:40:35.000000000 +0200
+++ new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/Makefile
2020-07-03 13:50:35.000000000 +0200
@@ -1,13 +1,17 @@
-# this is the what ends up in the RPM "Version" field and it is also used as
suffix for the built binaries
-# if you want to commit to OBS it must be a remotely available Git reference
-VERSION ?= $(shell git rev-parse --short HEAD)
+# this is the what ends up in the RPM "Version" field and embedded in the
--version CLI flag
+VERSION ?= $(shell .ci/get_version_from_git.sh)
+
+# this will be used as the build date by the Go compile task
+DATE = $(shell date --iso-8601=seconds)
+
+# if you want to release to OBS, this must be a remotely available Git
reference
+REVISION ?= $(shell git rev-parse --abbrev-ref HEAD)
# we only use this to comply with RPM changelog conventions at SUSE
AUTHOR ?= [email protected]
# you can customize any of the following to build forks
OBS_PROJECT ?= server:monitoring
-OBS_PACKAGE ?= prometheus-sap_host_exporter
REPOSITORY ?= SUSE/sap_host_exporter
# the Go archs we crosscompile to
@@ -21,11 +25,11 @@
build: amd64
-build-all: clean-bin $(ARCHS)
+build-all: clean $(ARCHS)
$(ARCHS):
@mkdir -p build/bin
- CGO_ENABLED=0 GOOS=linux GOARCH=$@ go build -trimpath -ldflags "-s -w
-X main.version=$(VERSION)" -o build/bin/sap_host_exporter-$(VERSION)-$@
+ CGO_ENABLED=0 GOOS=linux GOARCH=$@ go build -trimpath -ldflags "-s -w
-X main.version=$(VERSION) -X main.buildDate=$(DATE)" -o
build/bin/sap_host_exporter-$@
install:
go install
@@ -57,29 +61,44 @@
go test -cover -coverprofile=build/coverage ./...
go tool cover -html=build/coverage
-clean: clean-bin clean-obs
+clean:
go clean
rm -rf build
-clean-bin:
- rm -rf build/bin
-
-clean-obs:
- rm -rf build/obs
-
-obs-workdir: clean-obs
- @mkdir -p build/obs
- osc checkout $(OBS_PROJECT) $(OBS_PACKAGE) -o build/obs
- rm -f build/obs/*.tar.gz
- cp -rv packaging/obs/* build/obs/
+exporter-obs-workdir: build/obs/prometheus-sap_host_exporter
+build/obs/prometheus-sap_host_exporter:
+ @mkdir -p $@
+ osc checkout $(OBS_PROJECT) prometheus-sap_host_exporter -o $@
+ rm -f $@/*.tar.gz
+ cp -rv packaging/obs/prometheus-sap_host_exporter/* $@/
# we interpolate environment variables in OBS _service file so that we control
what is downloaded by the tar_scm source service
- sed -i 's~%%VERSION%%~$(VERSION)~' build/obs/_service
- sed -i 's~%%REPOSITORY%%~$(REPOSITORY)~' build/obs/_service
- cd build/obs; osc service runall
- .ci/gh_release_to_obs_changeset.py $(REPOSITORY) -a $(AUTHOR) -t
$(VERSION) -f build/obs/$(OBS_PACKAGE).changes || true
-
-obs-commit: obs-workdir
- cd build/obs; osc addremove
- cd build/obs; osc commit -m "Update to git ref $(VERSION)"
-
-.PHONY: default download install static-checks vet-check fmt fmt-check
mod-tidy generate test coverage clean clean-bin clean-obs build build-all
obs-commit obs-workdir $(ARCHS)
+ sed -i 's~%%VERSION%%~$(VERSION)~' $@/_service
+ sed -i 's~%%REVISION%%~$(REVISION)~' $@/_service
+ sed -i 's~%%REPOSITORY%%~$(REPOSITORY)~' $@/_service
+ cd $@; osc service runall
+
+exporter-obs-changelog: exporter-obs-workdir
+ .ci/gh_release_to_obs_changeset.py $(REPOSITORY) -a $(AUTHOR) -t
$(REVISION) -f
build/obs/prometheus-sap_host_exporter/prometheus-sap_host_exporter.changes
+
+exporter-obs-commit: exporter-obs-workdir
+ cd build/obs/prometheus-sap_host_exporter; osc addremove
+ cd build/obs/prometheus-sap_host_exporter; osc commit -m "Update from
git rev $(REVISION)"
+
+dashboards-obs-workdir: build/obs/grafana-sap-netweaver-dashboards
+build/obs/grafana-sap-netweaver-dashboards:
+ @mkdir -p $@
+ osc checkout $(OBS_PROJECT) grafana-sap-netweaver-dashboards -o $@
+ rm -f $@/*.tar.gz
+ cp -rv packaging/obs/grafana-sap-netweaver-dashboards/* $@/
+# we interpolate environment variables in OBS _service file so that we control
what is downloaded by the tar_scm source service
+ sed -i 's~%%REVISION%%~$(REVISION)~' $@/_service
+ sed -i 's~%%REPOSITORY%%~$(REPOSITORY)~' $@/_service
+ cd $@; osc service runall
+
+dashboards-obs-commit: dashboards-obs-workdir
+ cd build/obs/grafana-sap-netweaver-dashboards; osc addremove
+ cd build/obs/grafana-sap-netweaver-dashboards; osc commit -m "Update
from git rev $(REVISION)"
+
+.PHONY: $(ARCHS) build build-all checks clean coverage dashboards-obs-commit
dashboards-obs-workdir default download \
+ exporter-obs-changelog exporter-obs-commit exporter-obs-workdir
fmt fmt-check generate install mod-tidy \
+ static-checks test vet-check
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/README.md
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/README.md
--- old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/README.md
2020-04-17 18:40:35.000000000 +0200
+++ new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/README.md
2020-07-03 13:50:35.000000000 +0200
@@ -2,14 +2,17 @@
This is a bespoke Prometheus exporter enabling the monitoring of SAP systems
(a.k.a. SAP NetWeaver applications).
-[](https://travis-ci.org/SUSE/sap_host_exporter)
+[](https://github.com/SUSE/sap_host_exporter/actions?query=workflow%3A%22Exporter+CI%22)
+[](https://github.com/SUSE/sap_host_exporter/actions?query=workflow%3A%22Dashboards+CI%22)
## Table of Contents
1. [Features](#features)
2. [Installation](#installation)
3. [Usage](#usage)
- 1. [Metrics](doc/metrics.md)
+ 1. [Configuration](#configuration)
+ 2. [Metrics](#metrics)
+ 3. [systemd integration](#systemd-integration)
5. [Contributing](#contributing)
1. [Design](doc/design.md)
2. [Development](doc/development.md)
@@ -65,17 +68,18 @@
You can run the exporter as follows:
```shell
-./sap_host_exporter --sap-control-url http://$SAP_HOST:$SAP_PORT
+./sap_host_exporter --sap-control-url $SAP_HOST:$SAP_CONTROL_PORT
```
-It will export the metrics under the `/metrics` path, on port `9680` by
default.
+Though not strictly required, it is advised to run the exporter locally in the
target SAP instance host, and connect to the SAPControl web service via Unix
Domain Sockets:
-Though not strictly required, it is advised to run it in the nodes of the
cluster and access the SAPControl web service locally.
-
-The exporter won't export any metric it can't collect, but since it doesn't
care about which subsystems are present in the monitored target, failing to
collect metrics is _not_ considered a hard failure condition.
-Instead, in case some of the collectors fail to either register or perform
collect cycles, a soft warning will be printed out in the log.
+```shell
+./sap_host_exporter --sap-control-uds /tmp/.sapstream50013
+```
-Refer to [doc/metrics.md](doc/metrics.md) for extensive details about all the
exported metrics.
+For further details on SAPControl, please refer to the [official SAP
docs](https://www.sap.com/documents/2016/09/0a40e60d-8b7c-0010-82c7-eda71af511fa.html)
to properly connect to the SAPControl service.
+
+The exporter will expose the metrics under the `/metrics` path, on port `9680`
by default.
**Hint:**
You can deploy a full SAP NetWeaver cluster via Terraform with
[SUSE/ha-sap-terraform-deployments](https://github.com/SUSE/ha-sap-terraform-deployments);
@@ -95,6 +99,13 @@
Please refer to the [example YAML configuration](doc/sap_host_exporter.yaml)
for more details.
+### Metrics
+
+The exporter won't export any metric it can't collect, but since it doesn't
care about which subsystems are present in the monitored target, failing to
collect metrics is _not_ considered a hard failure condition.
+Instead, in case some of the collectors fail to either register or perform
collect cycles, a soft warning will be printed out in the log.
+
+Refer to [doc/metrics.md](doc/metrics.md) for extensive details about all the
exported metrics.
+
### systemd integration
A [systemd unit file](packaging/obs/prometheus-sap_host_exporter.spec) is
provided with the RPM packages. You can enable and start it as usual:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/doc/development.md
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/doc/development.md
---
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/doc/development.md
2020-04-17 18:40:35.000000000 +0200
+++
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/doc/development.md
2020-07-03 13:50:35.000000000 +0200
@@ -40,7 +40,7 @@
## OBS Packaging
-The CI will automatically publish GitHub releases to SUSE's Open Build
Service: to perform a new release, just publish a new GH release or push a git
tag. Tags must always follow the [SemVer](https://semver.org/) scheme.
+The CI will automatically publish GitHub releases to SUSE's Open Build
Service: to perform a new release, just publish a new GH release. Tags must
always follow the [SemVer](https://semver.org/) scheme.
If you wish to produce an OBS working directory locally, having configured
[`osc`](https://en.opensuse.org/openSUSE:OSC) already, you can run:
```
@@ -48,22 +48,26 @@
```
This will checkout the OBS project and prepare a new OBS commit in the
`build/obs` directory.
-Note that, by default, the current Git working directory HEAD reference is
used to download the sources from the remote, so this reference must have been
pushed beforehand.
-
-You can use the `OSB_PROJECT`, `OBS_PACKAGE`, `REPOSITORY` and `VERSION`
environment variables to change the behaviour of OBS-related make targets.
+You can use the `OSB_PROJECT`, `REPOSITORY`, `VERSION` and `REVISION`
environment variables to change the behaviour of OBS-related make targets.
+
+By default, the current Git working directory is used to infer the values of
`VERSION` and `REVISION`, which are used by OBS source services to generate a
compressed archive of the sources.
For example, if you were on a feature branch of your own fork, you may want to
change these variables, so:
```bash
-git push feature/yxz # don't forget to make changes remotely available
+git checkout feature/xyz
+git push johndoe feature/xyz # don't forget to push changes your own fork
remote
export OBS_PROJECT=home:JohnDoe
-export OBS_PACKAGE=my_project_branch
-export REPOSITORY=johndoe/my_forked_repo
-export VERSION=feature/yxz
-make obs-workdir
+export REPOSITORY=johndoe/sap_host_exporter
+make exporter-obs-workdir
+```
+will prepare to commit on OBS into `home:JohnDoe/sap_host_exporter` by
checking out the branch `feature/yxz` from
`github.com/johndoe/sap_host_exporter`.
+
+At last, to actually perform the commit into OBS, run:
+```bash
+make exporter-obs-commit
```
-will prepare to commit on OBS into `home:JohnDoe/my_project_branch` by
checking out the branch `feature/yxz` from `github.com/johndoe/my_forked_repo`.
-At last, to actually perform the commit into OBS, run `make obs-commit`.
+Note that that actual continuously deployed releases also involve an
intermediate step that updates the changelog automatically with the markdown
text of the GitHub release.
## SAP learning material
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/go.mod
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/go.mod
--- old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/go.mod
2020-04-17 18:40:35.000000000 +0200
+++ new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/go.mod
2020-07-03 13:50:35.000000000 +0200
@@ -1,6 +1,6 @@
module github.com/SUSE/sap_host_exporter
-go 1.11
+go 1.12
require (
github.com/golang/mock v1.4.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/internal/config/config.go
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/internal/config/config.go
---
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/internal/config/config.go
2020-04-17 18:40:35.000000000 +0200
+++
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/internal/config/config.go
2020-07-03 13:50:35.000000000 +0200
@@ -9,10 +9,10 @@
"github.com/spf13/viper"
)
-func New() (*viper.Viper, error) {
+func New(flagSet *flag.FlagSet) (*viper.Viper, error) {
config := viper.New()
- err := config.BindPFlags(flag.CommandLine)
+ err := config.BindPFlags(flagSet)
if err != nil {
return nil, errors.Wrap(err, "could not bind config to CLI
flags")
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/internal/config/loader.go
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/internal/config/loader.go
---
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/internal/config/loader.go
2020-04-17 18:40:35.000000000 +0200
+++
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/internal/config/loader.go
2020-07-03 13:50:35.000000000 +0200
@@ -47,5 +47,7 @@
return errors.Wrap(err, "could not read file")
}
+ log.Info("Using config file: ", path)
+
return nil
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/internal/sapcontrol/current_instance.go
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/internal/sapcontrol/current_instance.go
---
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/internal/sapcontrol/current_instance.go
2020-04-17 18:40:35.000000000 +0200
+++
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/internal/sapcontrol/current_instance.go
2020-07-03 13:50:35.000000000 +0200
@@ -28,7 +28,7 @@
response, err = s.GetInstanceProperties()
if err != nil {
- err = errors.Wrap(err, "could not
performGetInstanceProperties query")
+ err = errors.Wrap(err, "could not perform
GetInstanceProperties query")
return
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/main.go
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/main.go
--- old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/main.go
2020-04-17 18:40:35.000000000 +0200
+++ new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/main.go
2020-07-03 13:50:35.000000000 +0200
@@ -3,6 +3,8 @@
import (
"fmt"
"net/http"
+ "os"
+ "runtime"
"github.com/SUSE/sap_host_exporter/collector/registry"
"github.com/SUSE/sap_host_exporter/collector/start_service"
@@ -16,6 +18,17 @@
flag "github.com/spf13/pflag"
)
+var (
+ // the released version
+ version string
+ // the time the binary was built
+ buildDate string
+ // global --help flag
+ helpFlag *bool
+ // global --version flag
+ versionFlag *bool
+)
+
func init() {
flag.String("port", "9680", "The port number to listen on for HTTP
requests")
flag.String("address", "0.0.0.0", "The address to listen on for HTTP
requests")
@@ -23,19 +36,34 @@
flag.String("sap-control-url", "localhost:50013", "The URL of the
SAPControl SOAP web service, e.g. $HOST:$PORT")
flag.String("sap-control-uds", "", "The path to the SAPControl Unix
Domain Socket. If set, this will be used instead of the URL.")
flag.StringP("config", "c", "", "The path to a custom configuration
file. NOTE: it must be in yaml format.")
+ flag.CommandLine.SortFlags = false
+
+ helpFlag = flag.BoolP("help", "h", false, "show this help message")
+ versionFlag = flag.Bool("version", false, "show version and build
information")
}
func main() {
- var err error
-
flag.Parse()
- config, err := config.New()
+ switch {
+ case *helpFlag:
+ showHelp()
+ case *versionFlag:
+ showVersion()
+ default:
+ run()
+ }
+}
+
+func run() {
+ var err error
+
+ globalConfig, err := config.New(flag.CommandLine)
if err != nil {
log.Fatalf("Could not initialize config: %s", err)
}
- client := sapcontrol.NewSoapClient(config)
+ client := sapcontrol.NewSoapClient(globalConfig)
webService := sapcontrol.NewWebService(client)
currentSapInstance, err := webService.GetCurrentInstance()
if err != nil {
@@ -62,7 +90,7 @@
prometheus.Unregister(prometheus.NewGoCollector())
}
- fullListenAddress := fmt.Sprintf("%s:%s", config.Get("address"),
config.Get("port"))
+ fullListenAddress := fmt.Sprintf("%s:%s", globalConfig.Get("address"),
globalConfig.Get("port"))
http.HandleFunc("/", internal.Landing)
http.Handle("/metrics", promhttp.Handler())
@@ -70,3 +98,16 @@
log.Infof("Serving metrics on %s", fullListenAddress)
log.Fatal(http.ListenAndServe(fullListenAddress, nil))
}
+
+func showHelp() {
+ flag.Usage()
+ os.Exit(0)
+}
+
+func showVersion() {
+ if buildDate == "" {
+ buildDate = "at unknown time"
+ }
+ fmt.Printf("version %s\nbuilt with %s %s/%s %s\n", version,
runtime.Version(), runtime.GOOS, runtime.GOARCH, buildDate)
+ os.Exit(0)
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/packaging/obs/_service
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/packaging/obs/_service
---
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/packaging/obs/_service
2020-04-17 18:40:35.000000000 +0200
+++
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/packaging/obs/_service
1970-01-01 01:00:00.000000000 +0100
@@ -1,18 +0,0 @@
-<services>
- <service name="tar_scm" mode="disabled">
- <param name="url">git://github.com/%%REPOSITORY%%.git</param>
- <param name="scm">git</param>
- <param name="revision">%%VERSION%%</param>
- <param name="exclude">.git</param>
- <param name="versionformat">@PARENT_TAG@+git.%ct.%h</param>
- <param name="filename">prometheus-sap_host_exporter</param>
- </service>
- <service name="set_version" mode="disabled">
- <param name="file">prometheus-sap_host_exporter.spec</param>
- </service>
- <service name="recompress" mode="disabled">
- <param name="file">*.tar</param>
- <param name="compression">gz</param>
- </service>
- <service name="go_modules" mode="disabled" />
-</services>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/packaging/obs/prometheus-sap_host_exporter/_service
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/packaging/obs/prometheus-sap_host_exporter/_service
---
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/packaging/obs/prometheus-sap_host_exporter/_service
1970-01-01 01:00:00.000000000 +0100
+++
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/packaging/obs/prometheus-sap_host_exporter/_service
2020-07-03 13:50:35.000000000 +0200
@@ -0,0 +1,21 @@
+<services>
+ <service name="tar_scm" mode="disabled">
+ <param name="url">git://github.com/%%REPOSITORY%%.git</param>
+ <param name="scm">git</param>
+ <param name="revision">%%REVISION%%</param>
+ <param name="exclude">.git</param>
+ <param name="exclude">.github</param>
+ <param name="exclude">dashboards</param>
+ <param
name="exclude">packaging/obs/grafana-sap-netweaver-dashboards</param>
+ <param name="version">%%VERSION%%</param>
+ <param name="filename">prometheus-sap_host_exporter</param>
+ </service>
+ <service name="set_version" mode="disabled">
+ <param name="file">prometheus-sap_host_exporter.spec</param>
+ </service>
+ <service name="recompress" mode="disabled">
+ <param name="file">*.tar</param>
+ <param name="compression">gz</param>
+ </service>
+ <service name="go_modules" mode="disabled" />
+</services>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/packaging/obs/prometheus-sap_host_exporter/prometheus-sap_host_exporter.spec
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/packaging/obs/prometheus-sap_host_exporter/prometheus-sap_host_exporter.spec
---
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/packaging/obs/prometheus-sap_host_exporter/prometheus-sap_host_exporter.spec
1970-01-01 01:00:00.000000000 +0100
+++
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/packaging/obs/prometheus-sap_host_exporter/prometheus-sap_host_exporter.spec
2020-07-03 13:50:35.000000000 +0200
@@ -0,0 +1,97 @@
+#
+# Copyright 2020 SUSE LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+Name: prometheus-sap_host_exporter
+# Version will be processed via set_version source service
+Version: 0
+Release: 0
+License: Apache-2.0
+Summary: Prometheus exporter for SAP systems (a.k.a. NetWeaver)
+Group: System/Monitoring
+Url: https://github.com/SUSE/sap_host_exporter
+Source: %{name}-%{version}.tar.gz
+Source1: vendor.tar.gz
+ExclusiveArch: aarch64 x86_64 ppc64le s390x
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
+BuildRequires: go >= 1.12
+Provides: sap_host_exporter = %{version}-%{release}
+Provides: prometheus(sap_host_exporter) = %{version}-%{release}
+# Unlike C/C++ packages, Golang packages do not have header files. They are
statically built so the main package is also the devel package.
+Provides: %{name}-devel = %{version}
+Provides: %{name}-devel-static = %{version}
+
+# Make sure that the binary is not getting stripped.
+%undefine _build_create_debug
+%define __arch_install_post export NO_BRP_STRIP_DEBUG=true
+
+%description
+Prometheus exporter for Pacemaker HA clusters metrics
+
+%prep
+%setup -q # unpack project sources
+%setup -q -T -D -a 1 # unpack go dependencies in vendor.tar.gz, which was
prepared by the source services
+
+%define shortname sap_host_exporter
+
+%build
+
+export CGO_ENABLED=0
+go build -mod=vendor \
+ -ldflags="-s -w -X main.version=%{version}" \
+ -o %{shortname}
+
+%install
+
+# Install the binary.
+install -D -m 0755 %{shortname} "%{buildroot}%{_bindir}/%{shortname}"
+
+# Install the systemd unit
+install -D -m 0644 %{shortname}@.service
%{buildroot}%{_unitdir}/%{name}@.service
+
+# Install the default config
+install -D -m 0600 doc/%{shortname}.yaml
"%{buildroot}/etc/%{shortname}/default.yaml"
+
+# Install compat wrapper for legacy init systems
+install -Dd -m 0755 %{buildroot}%{_sbindir}
+ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
+
+%pre
+%service_add_pre %{name}@.service
+
+%post
+%service_add_post %{name}@.service
+
+%preun
+%service_del_preun %{name}@.service
+
+%postun
+%service_del_postun %{name}@.service
+
+%files
+%defattr(-,root,root)
+%doc *.md
+%doc doc/*.md
+%if 0%{?suse_version} >= 1500
+%license LICENSE
+%else
+%doc LICENSE
+%endif
+%{_bindir}/%{shortname}
+%{_unitdir}/%{name}@.service
+%{_sbindir}/rc%{name}
+%dir /etc/%{shortname}/
+%config /etc/%{shortname}/default.yaml
+
+%changelog
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/packaging/obs/prometheus-sap_host_exporter.spec
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/packaging/obs/prometheus-sap_host_exporter.spec
---
old/prometheus-sap_host_exporter-0.4.0+git.1587141635.71f3338/packaging/obs/prometheus-sap_host_exporter.spec
2020-04-17 18:40:35.000000000 +0200
+++
new/prometheus-sap_host_exporter-0.5.1+git.1593777035.a5d05f8/packaging/obs/prometheus-sap_host_exporter.spec
1970-01-01 01:00:00.000000000 +0100
@@ -1,97 +0,0 @@
-#
-# Copyright 2020 SUSE LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-Name: prometheus-sap_host_exporter
-# Version will be processed via set_version source service
-Version: 0
-Release: 0
-License: Apache-2.0
-Summary: Prometheus exporter for SAP systems (a.k.a. NetWeaver)
-Group: System/Monitoring
-Url: https://github.com/SUSE/sap_host_exporter
-Source: %{name}-%{version}.tar.gz
-Source1: vendor.tar.gz
-ExclusiveArch: aarch64 x86_64 ppc64le s390x
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
-BuildRequires: go >= 1.11
-Provides: sap_host_exporter = %{version}-%{release}
-Provides: prometheus(sap_host_exporter) = %{version}-%{release}
-# Unlike C/C++ packages, Golang packages do not have header files. They are
statically built so the main package is also the devel package.
-Provides: %{name}-devel = %{version}
-Provides: %{name}-devel-static = %{version}
-
-# Make sure that the binary is not getting stripped.
-%undefine _build_create_debug
-%define __arch_install_post export NO_BRP_STRIP_DEBUG=true
-
-%description
-Prometheus exporter for Pacemaker HA clusters metrics
-
-%prep
-%setup -q # unpack project sources
-%setup -q -T -D -a 1 # unpack go dependencies in vendor.tar.gz, which was
prepared by the source services
-
-%define shortname sap_host_exporter
-
-%build
-
-export CGO_ENABLED=0
-go build -mod=vendor \
- -ldflags="-s -w -X main.version=%{version}" \
- -o %{shortname}
-
-%install
-
-# Install the binary.
-install -D -m 0755 %{shortname} "%{buildroot}%{_bindir}/%{shortname}"
-
-# Install the systemd unit
-install -D -m 0644 %{shortname}@.service
%{buildroot}%{_unitdir}/%{name}@.service
-
-# Install the default config
-install -D -m 0600 doc/%{shortname}.yaml
"%{buildroot}/etc/%{shortname}/default.yaml"
-
-# Install compat wrapper for legacy init systems
-install -Dd -m 0755 %{buildroot}%{_sbindir}
-ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
-
-%pre
-%service_add_pre %{name}@.service
-
-%post
-%service_add_post %{name}@.service
-
-%preun
-%service_del_preun %{name}@.service
-
-%postun
-%service_del_postun %{name}@.service
-
-%files
-%defattr(-,root,root)
-%doc *.md
-%doc doc/*.md
-%if 0%{?suse_version} >= 1500
-%license LICENSE
-%else
-%doc LICENSE
-%endif
-%{_bindir}/%{shortname}
-%{_unitdir}/%{name}@.service
-%{_sbindir}/rc%{name}
-%dir /etc/%{shortname}/
-%config /etc/%{shortname}/default.yaml
-
-%changelog
++++++ vendor.tar.gz ++++++