mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-10 04:27:25 +01:00
8d85bd53f1
* Cleanup: Remove unused code * Use Golang duration parser for 'interval' and 'duration' in main config * Update handling of LIKWID headers. Download only if not already present in the system. Fixes #73 * Units with cc-units (#64) * Add option to normalize units with cc-unit * Add unit conversion to router * Add option to change unit prefix in the router * Add to MetricRouter README * Add order of operations in router to README * Use second add_tags/del_tags only if metric gets renamed * Skip disks in DiskstatCollector that have size=0 * Check readability of sensor files in TempCollector * Fix for --once option * Rename `cpu` type to `hwthread` (#69) * Rename 'cpu' type to 'hwthread' to avoid naming clashes with MetricStore and CC-Webfrontend * Collectors in parallel (#74) * Provide info to CollectorManager whether the collector can be executed in parallel with others * Split serial and parallel collectors. Read in parallel first * Update NvidiaCollector with new metrics, MIG and NvLink support (#75) * CC topology module update (#76) * Rename CPU to hardware thread, write some comments * Do renaming in other parts * Remove CpuList and SocketList function from metricCollector. Available in ccTopology * Option to use MIG UUID as subtype-id in NvidiaCollector * Option to use MIG slice name as subtype-id in NvidiaCollector * MetricRouter: Fix JSON in README * Fix for Github Action to really use the selected version * Remove Ganglia installation in runonce Action and add Go 1.18 * Fix daemon options in init script * Add separate go.mod files to use it with deprecated 1.16 * Minor updates for Makefiles * fix string comparison * AMD ROCm SMI collector (#77) * Add collector for AMD ROCm SMI metrics * Fix import path * Fix imports * Remove Board Number * store GPU index explicitly * Remove board number from description * Use http instead of ftp to download likwid * Fix serial number in rocmCollector * Improved http sink (#78) * automatic flush in NatsSink * tweak default options of HttpSink * shorter cirt. section and retries for HttpSink * fix error handling * Remove file added by mistake. * Use http instead of ftp to download likwid * Fix serial number in rocmCollector Co-authored-by: Thomas Roehl <thomas.roehl@fau.de> Co-authored-by: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Co-authored-by: Lou <lou.knauer@gmx.de>
136 lines
5.4 KiB
Makefile
136 lines
5.4 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
|
|
GOBIN = $(shell which go)
|
|
|
|
|
|
.PHONY: all
|
|
all: $(APP)
|
|
|
|
$(APP): $(GOSRC)
|
|
if [ "$(shell $(GOBIN) version | cut -d' ' -f 3 | cut -d '.' -f1-2)" = "go1.16" ]; then \
|
|
echo "1.16"; \
|
|
cp go.mod.1.16 go.mod; \
|
|
else \
|
|
echo "1.17+"; \
|
|
cp go.mod.1.17+ go.mod; \
|
|
fi
|
|
make -C collectors
|
|
$(GOBIN) get
|
|
$(GOBIN) 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:
|
|
$(GOBIN) fmt $(GOSRC_COLLECTORS)
|
|
$(GOBIN) fmt $(GOSRC_SINKS)
|
|
$(GOBIN) fmt $(GOSRC_RECEIVERS)
|
|
$(GOBIN) fmt $(GOSRC_APP)
|
|
@for F in $(GOSRC_INTERNAL); do $(GOBIN) fmt $$F; done
|
|
|
|
|
|
# Examine Go source code and reports suspicious constructs
|
|
.PHONY: vet
|
|
vet:
|
|
$(GOBIN) 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:
|
|
$(GOBIN) install honnef.co/go/tools/cmd/staticcheck@latest
|
|
$$($(GOBIN) 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}"
|