mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 15:09:05 +01:00
3f76947f54
* Update configuration.md Add an additional receiver to have better alignment of components * Change default GpfsCollector command to `mmpmon` (#53) * Set default cmd to 'mmpmon' * Reuse looked up path * Cast const to string * Just download LIKWID to get the headers (#54) * Just download LIKWID to get the headers * Remove perl-Data-Dumper from BuildRequires, only required by LIKWID build * Add HttpReceiver as counterpart to the HttpSink (#49) * Use GBytes as unit for large memory numbers * Make maxForward configurable, save old name in meta in rename metrics and make the hostname tag key configurable * Single release action (#55) Building all RPMs and releasing in a single workflow * Makefile target to build binary-only Debian packages (#61) * Add 'install' and 'DEB' make targets to build binary-only Debian packages * Add control file for DEB builds * Use a single line for bash loop in make clean * Add config options for retry intervals of InfluxDB clients (#59) * Refactoring of LikwidCollector and metric units (#62) * Reduce complexity of LikwidCollector and allow metric units * Add unit to LikwidCollector docu and fix some typos * Make library path configurable * Use old metric name in Ganglia if rename has happened in the router (#60) * Use old metric name if rename has happened in the router * Also check for Ganglia renames for the oldname * Derived metrics (#57) * Add time-based derivatived (e.g. bandwidth) to some collectors * Add documentation * Add comments * Fix: Only compute rates with a valid previous state * Only compute rates with a valid previous state * Define const values for net/dev fields * Set default config values * Add comments * Refactor: Consolidate data structures * Refactor: Consolidate data structures * Refactor: Avoid struct deep copy * Refactor: Avoid redundant tag maps * Refactor: Use int64 type for absolut values Co-authored-by: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> * Simplified iota usage * Move unit tag to meta data tags * Derived metrics (#65) * Add time-based derivatived (e.g. bandwidth) to some collectors * Add documentation * Add comments * Fix: Only compute rates with a valid previous state * Only compute rates with a valid previous state * Define const values for net/dev fields * Set default config values * Add comments * Refactor: Consolidate data structures * Refactor: Consolidate data structures * Refactor: Avoid struct deep copy * Refactor: Avoid redundant tag maps * Refactor: Use int64 type for absolut values * Update LustreCollector Co-authored-by: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> * Meta to tags list and map for sinks (#63) * Change ccMetric->Influx functions * Use a meta_as_tags string list in config but create a lookup map afterwards * Add meta as tag logic to sampleSink * Fix staticcheck warnings (#66) Co-authored-by: Holger Obermaier <40787752+ho-ob@users.noreply.github.com>
128 lines
5.1 KiB
Makefile
128 lines
5.1 KiB
Makefile
APP = cc-metric-collector
|
|
GOSRC_APP := cc-metric-collector.go
|
|
GOSRC_COLLECTORS := $(wildcard collectors/*.go)
|
|
GOSRC_SINKS := $(wildcard sinks/*.go)
|
|
GOSRC_RECEIVERS := $(wildcard receivers/*.go)
|
|
GOSRC_INTERNAL := $(wildcard internal/*/*.go)
|
|
GOSRC := $(GOSRC_APP) $(GOSRC_COLLECTORS) $(GOSRC_SINKS) $(GOSRC_RECEIVERS) $(GOSRC_INTERNAL)
|
|
COMPONENT_DIRS := collectors \
|
|
sinks \
|
|
receivers \
|
|
internal/metricRouter \
|
|
internal/ccMetric \
|
|
internal/metricAggregator \
|
|
internal/ccLogger \
|
|
internal/ccTopology \
|
|
internal/multiChanTicker
|
|
|
|
BINDIR = bin
|
|
|
|
|
|
.PHONY: all
|
|
all: $(APP)
|
|
|
|
$(APP): $(GOSRC)
|
|
make -C collectors
|
|
go get
|
|
go build -o $(APP) $(GOSRC_APP)
|
|
|
|
install: $(APP)
|
|
@WORKSPACE=$(PREFIX)
|
|
@if [ -z "$${WORKSPACE}" ]; then exit 1; fi
|
|
@mkdir --parents --verbose $${WORKSPACE}/usr/$(BINDIR)
|
|
@install -Dpm 755 $(APP) $${WORKSPACE}/usr/$(BINDIR)/$(APP)
|
|
@mkdir --parents --verbose $${WORKSPACE}/etc/cc-metric-collector $${WORKSPACE}/etc/default $${WORKSPACE}/etc/systemd/system $${WORKSPACE}/etc/init.d
|
|
@install -Dpm 600 config.json $${WORKSPACE}/etc/cc-metric-collector/cc-metric-collector.json
|
|
@sed -i -e s+"\"./"+"\"/etc/cc-metric-collector/"+g $${WORKSPACE}/etc/cc-metric-collector/cc-metric-collector.json
|
|
@install -Dpm 600 sinks.json $${WORKSPACE}/etc/cc-metric-collector/sinks.json
|
|
@install -Dpm 600 collectors.json $${WORKSPACE}/etc/cc-metric-collector/collectors.json
|
|
@install -Dpm 600 router.json $${WORKSPACE}/etc/cc-metric-collector/router.json
|
|
@install -Dpm 600 receivers.json $${WORKSPACE}/etc/cc-metric-collector/receivers.json
|
|
@install -Dpm 600 scripts/cc-metric-collector.config $${WORKSPACE}/etc/default/cc-metric-collector
|
|
@install -Dpm 644 scripts/cc-metric-collector.service $${WORKSPACE}/etc/systemd/system/cc-metric-collector.service
|
|
@install -Dpm 644 scripts/cc-metric-collector.init $${WORKSPACE}/etc/init.d/cc-metric-collector
|
|
|
|
|
|
.PHONY: clean
|
|
.ONESHELL:
|
|
clean:
|
|
@for COMP in $(COMPONENT_DIRS); do if [ -e $$COMP/Makefile ]; then make -C $$COMP clean; fi; done
|
|
rm -f $(APP)
|
|
|
|
.PHONY: fmt
|
|
fmt:
|
|
go fmt $(GOSRC_COLLECTORS)
|
|
go fmt $(GOSRC_SINKS)
|
|
go fmt $(GOSRC_RECEIVERS)
|
|
go fmt $(GOSRC_APP)
|
|
@for F in $(GOSRC_INTERNAL); do go fmt $$F; done
|
|
|
|
|
|
# Examine Go source code and reports suspicious constructs
|
|
.PHONY: vet
|
|
vet:
|
|
go vet ./...
|
|
|
|
|
|
# Run linter for the Go programming language.
|
|
# Using static analysis, it finds bugs and performance issues, offers simplifications, and enforces style rules
|
|
.PHONY: staticcheck
|
|
staticcheck:
|
|
go install honnef.co/go/tools/cmd/staticcheck@latest
|
|
$$(go env GOPATH)/bin/staticcheck ./...
|
|
|
|
.ONESHELL:
|
|
.PHONY: RPM
|
|
RPM: scripts/cc-metric-collector.spec
|
|
@WORKSPACE="$${PWD}"
|
|
@SPECFILE="$${WORKSPACE}/scripts/cc-metric-collector.spec"
|
|
# Setup RPM build tree
|
|
@eval $$(rpm --eval "ARCH='%{_arch}' RPMDIR='%{_rpmdir}' SOURCEDIR='%{_sourcedir}' SPECDIR='%{_specdir}' SRPMDIR='%{_srcrpmdir}' BUILDDIR='%{_builddir}'")
|
|
@mkdir --parents --verbose "$${RPMDIR}" "$${SOURCEDIR}" "$${SPECDIR}" "$${SRPMDIR}" "$${BUILDDIR}"
|
|
# Create source tarball
|
|
@COMMITISH="HEAD"
|
|
@VERS=$$(git describe --tags $${COMMITISH})
|
|
@VERS=$${VERS#v}
|
|
@VERS=$$(echo $$VERS | sed -e s+'-'+'_'+g)
|
|
@eval $$(rpmspec --query --queryformat "NAME='%{name}' VERSION='%{version}' RELEASE='%{release}' NVR='%{NVR}' NVRA='%{NVRA}'" --define="VERS $${VERS}" "$${SPECFILE}")
|
|
@PREFIX="$${NAME}-$${VERSION}"
|
|
@FORMAT="tar.gz"
|
|
@SRCFILE="$${SOURCEDIR}/$${PREFIX}.$${FORMAT}"
|
|
@git archive --verbose --format "$${FORMAT}" --prefix="$${PREFIX}/" --output="$${SRCFILE}" $${COMMITISH}
|
|
# Build RPM and SRPM
|
|
@rpmbuild -ba --define="VERS $${VERS}" --rmsource --clean "$${SPECFILE}"
|
|
# Report RPMs and SRPMs when in GitHub Workflow
|
|
@if [[ "$${GITHUB_ACTIONS}" == true ]]; then
|
|
@ RPMFILE="$${RPMDIR}/$${ARCH}/$${NVRA}.rpm"
|
|
@ SRPMFILE="$${SRPMDIR}/$${NVR}.src.rpm"
|
|
@ echo "RPM: $${RPMFILE}"
|
|
@ echo "SRPM: $${SRPMFILE}"
|
|
@ echo "::set-output name=SRPM::$${SRPMFILE}"
|
|
@ echo "::set-output name=RPM::$${RPMFILE}"
|
|
@fi
|
|
|
|
.PHONY: DEB
|
|
DEB: scripts/cc-metric-collector.deb.control $(APP)
|
|
@BASEDIR=$${PWD}
|
|
@WORKSPACE=$${PWD}/.dpkgbuild
|
|
@DEBIANDIR=$${WORKSPACE}/debian
|
|
@DEBIANBINDIR=$${WORKSPACE}/DEBIAN
|
|
@mkdir --parents --verbose $$WORKSPACE $$DEBIANBINDIR
|
|
#@mkdir --parents --verbose $$DEBIANDIR
|
|
@CONTROLFILE="$${BASEDIR}/scripts/cc-metric-collector.deb.control"
|
|
@COMMITISH="HEAD"
|
|
@VERS=$$(git describe --tags --abbrev=0 $${COMMITISH})
|
|
@VERS=$${VERS#v}
|
|
@VERS=$$(echo $$VERS | sed -e s+'-'+'_'+g)
|
|
@ARCH=$$(uname -m)
|
|
@ARCH=$$(echo $$ARCH | sed -e s+'_'+'-'+g)
|
|
@PREFIX="$${NAME}-$${VERSION}_$${ARCH}"
|
|
@SIZE_BYTES=$$(du -bcs --exclude=.dpkgbuild "$$WORKSPACE"/ | awk '{print $$1}' | head -1 | sed -e 's/^0\+//')
|
|
@SIZE="$$(awk -v size="$$SIZE_BYTES" 'BEGIN {print (size/1024)+1}' | awk '{print int($$0)}')"
|
|
#@sed -e s+"{VERSION}"+"$$VERS"+g -e s+"{INSTALLED_SIZE}"+"$$SIZE"+g -e s+"{ARCH}"+"$$ARCH"+g $$CONTROLFILE > $${DEBIANDIR}/control
|
|
@sed -e s+"{VERSION}"+"$$VERS"+g -e s+"{INSTALLED_SIZE}"+"$$SIZE"+g -e s+"{ARCH}"+"$$ARCH"+g $$CONTROLFILE > $${DEBIANBINDIR}/control
|
|
@make PREFIX=$${WORKSPACE} install
|
|
@DEB_FILE="cc-metric-collector_$${VERS}_$${ARCH}.deb"
|
|
@dpkg-deb -b $${WORKSPACE} "$$DEB_FILE"
|
|
@rm -r "$${WORKSPACE}"
|