mirror of
https://github.com/ClusterCockpit/cc-metric-store.git
synced 2024-12-26 00:49:05 +01:00
Further cleanup
This commit is contained in:
parent
5ca66aef87
commit
52704cabb5
314
.github/workflows/Release.yml
vendored
314
.github/workflows/Release.yml
vendored
@ -1,314 +0,0 @@
|
|||||||
# See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
|
|
||||||
|
|
||||||
# Workflow name
|
|
||||||
name: Release
|
|
||||||
|
|
||||||
# Run on tag push
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- '**'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
#
|
|
||||||
# Build on AlmaLinux 8.5 using golang-1.18.2
|
|
||||||
#
|
|
||||||
AlmaLinux-RPM-build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
# See: https://hub.docker.com/_/almalinux
|
|
||||||
container: almalinux:8.5
|
|
||||||
# The job outputs link to the outputs of the 'rpmrename' step
|
|
||||||
# Only job outputs can be used in child jobs
|
|
||||||
outputs:
|
|
||||||
rpm : ${{steps.rpmrename.outputs.RPM}}
|
|
||||||
srpm : ${{steps.rpmrename.outputs.SRPM}}
|
|
||||||
steps:
|
|
||||||
|
|
||||||
# Use dnf to install development packages
|
|
||||||
- name: Install development packages
|
|
||||||
run: |
|
|
||||||
dnf --assumeyes group install "Development Tools" "RPM Development Tools"
|
|
||||||
dnf --assumeyes install wget openssl-devel diffutils delve which
|
|
||||||
|
|
||||||
# Checkout git repository and submodules
|
|
||||||
# fetch-depth must be 0 to use git describe
|
|
||||||
# See: https://github.com/marketplace/actions/checkout
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
# Use dnf to install build dependencies
|
|
||||||
- name: Install build dependencies
|
|
||||||
run: |
|
|
||||||
wget -q http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/golang-1.18.2-1.module_el8.7.0+1173+5d37c0fd.x86_64.rpm \
|
|
||||||
http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/golang-bin-1.18.2-1.module_el8.7.0+1173+5d37c0fd.x86_64.rpm \
|
|
||||||
http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/golang-src-1.18.2-1.module_el8.7.0+1173+5d37c0fd.noarch.rpm \
|
|
||||||
http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/go-toolset-1.18.2-1.module_el8.7.0+1173+5d37c0fd.x86_64.rpm
|
|
||||||
rpm -i go*.rpm
|
|
||||||
|
|
||||||
- name: RPM build MetricStore
|
|
||||||
id: rpmbuild
|
|
||||||
run: make RPM
|
|
||||||
|
|
||||||
# AlmaLinux 8.5 is a derivate of RedHat Enterprise Linux 8 (UBI8),
|
|
||||||
# so the created RPM both contain the substring 'el8' in the RPM file names
|
|
||||||
# This step replaces the substring 'el8' to 'alma85'. It uses the move operation
|
|
||||||
# because it is unclear whether the default AlmaLinux 8.5 container contains the
|
|
||||||
# 'rename' command. This way we also get the new names for output.
|
|
||||||
- name: Rename RPMs (s/el8/alma85/)
|
|
||||||
id: rpmrename
|
|
||||||
run: |
|
|
||||||
OLD_RPM="${{steps.rpmbuild.outputs.RPM}}"
|
|
||||||
OLD_SRPM="${{steps.rpmbuild.outputs.SRPM}}"
|
|
||||||
NEW_RPM="${OLD_RPM/el8/alma85}"
|
|
||||||
NEW_SRPM=${OLD_SRPM/el8/alma85}
|
|
||||||
mv "${OLD_RPM}" "${NEW_RPM}"
|
|
||||||
mv "${OLD_SRPM}" "${NEW_SRPM}"
|
|
||||||
echo "::set-output name=SRPM::${NEW_SRPM}"
|
|
||||||
echo "::set-output name=RPM::${NEW_RPM}"
|
|
||||||
|
|
||||||
# See: https://github.com/actions/upload-artifact
|
|
||||||
- name: Save RPM as artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store RPM for AlmaLinux 8.5
|
|
||||||
path: ${{ steps.rpmrename.outputs.RPM }}
|
|
||||||
- name: Save SRPM as artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store SRPM for AlmaLinux 8.5
|
|
||||||
path: ${{ steps.rpmrename.outputs.SRPM }}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Build on UBI 8 using golang-1.18.2
|
|
||||||
#
|
|
||||||
UBI-8-RPM-build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
# See: https://catalog.redhat.com/software/containers/ubi8/ubi/5c359854d70cc534b3a3784e?container-tabs=gti
|
|
||||||
container: registry.access.redhat.com/ubi8/ubi:8.5-226.1645809065
|
|
||||||
# The job outputs link to the outputs of the 'rpmbuild' step
|
|
||||||
outputs:
|
|
||||||
rpm : ${{steps.rpmbuild.outputs.RPM}}
|
|
||||||
srpm : ${{steps.rpmbuild.outputs.SRPM}}
|
|
||||||
steps:
|
|
||||||
|
|
||||||
# Use dnf to install development packages
|
|
||||||
- name: Install development packages
|
|
||||||
run: dnf --assumeyes --disableplugin=subscription-manager install rpm-build go-srpm-macros rpm-build-libs rpm-libs gcc make python38 git wget openssl-devel diffutils delve which
|
|
||||||
|
|
||||||
# Checkout git repository and submodules
|
|
||||||
# fetch-depth must be 0 to use git describe
|
|
||||||
# See: https://github.com/marketplace/actions/checkout
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
# Use dnf to install build dependencies
|
|
||||||
- name: Install build dependencies
|
|
||||||
run: |
|
|
||||||
wget -q http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/golang-1.18.2-1.module_el8.7.0+1173+5d37c0fd.x86_64.rpm \
|
|
||||||
http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/golang-bin-1.18.2-1.module_el8.7.0+1173+5d37c0fd.x86_64.rpm \
|
|
||||||
http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/golang-src-1.18.2-1.module_el8.7.0+1173+5d37c0fd.noarch.rpm \
|
|
||||||
http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/go-toolset-1.18.2-1.module_el8.7.0+1173+5d37c0fd.x86_64.rpm
|
|
||||||
rpm -i go*.rpm
|
|
||||||
|
|
||||||
- name: RPM build MetricStore
|
|
||||||
id: rpmbuild
|
|
||||||
run: make RPM
|
|
||||||
|
|
||||||
# See: https://github.com/actions/upload-artifact
|
|
||||||
- name: Save RPM as artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store RPM for UBI 8
|
|
||||||
path: ${{ steps.rpmbuild.outputs.RPM }}
|
|
||||||
- name: Save SRPM as artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store SRPM for UBI 8
|
|
||||||
path: ${{ steps.rpmbuild.outputs.SRPM }}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Build on Ubuntu 20.04 using official go 1.19.1 package
|
|
||||||
#
|
|
||||||
Ubuntu-focal-build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: ubuntu:20.04
|
|
||||||
# The job outputs link to the outputs of the 'debrename' step
|
|
||||||
# Only job outputs can be used in child jobs
|
|
||||||
outputs:
|
|
||||||
deb : ${{steps.debrename.outputs.DEB}}
|
|
||||||
steps:
|
|
||||||
# Use apt to install development packages
|
|
||||||
- name: Install development packages
|
|
||||||
run: |
|
|
||||||
apt update && apt --assume-yes upgrade
|
|
||||||
apt --assume-yes install build-essential sed git wget bash
|
|
||||||
# Checkout git repository and submodules
|
|
||||||
# fetch-depth must be 0 to use git describe
|
|
||||||
# See: https://github.com/marketplace/actions/checkout
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
fetch-depth: 0
|
|
||||||
# Use official golang package
|
|
||||||
- name: Install Golang
|
|
||||||
run: |
|
|
||||||
wget -q https://go.dev/dl/go1.19.1.linux-amd64.tar.gz
|
|
||||||
tar -C /usr/local -xzf go1.19.1.linux-amd64.tar.gz
|
|
||||||
export PATH=/usr/local/go/bin:/usr/local/go/pkg/tool/linux_amd64:$PATH
|
|
||||||
go version
|
|
||||||
- name: DEB build MetricStore
|
|
||||||
id: dpkg-build
|
|
||||||
run: |
|
|
||||||
export PATH=/usr/local/go/bin:/usr/local/go/pkg/tool/linux_amd64:$PATH
|
|
||||||
make DEB
|
|
||||||
- name: Rename DEB (add '_ubuntu20.04')
|
|
||||||
id: debrename
|
|
||||||
run: |
|
|
||||||
OLD_DEB_NAME=$(echo "${{steps.dpkg-build.outputs.DEB}}" | rev | cut -d '.' -f 2- | rev)
|
|
||||||
NEW_DEB_FILE="${OLD_DEB_NAME}_ubuntu20.04.deb"
|
|
||||||
mv "${{steps.dpkg-build.outputs.DEB}}" "${NEW_DEB_FILE}"
|
|
||||||
echo "::set-output name=DEB::${NEW_DEB_FILE}"
|
|
||||||
# See: https://github.com/actions/upload-artifact
|
|
||||||
- name: Save DEB as artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store DEB for Ubuntu 20.04
|
|
||||||
path: ${{ steps.debrename.outputs.DEB }}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Build on Ubuntu 20.04 using official go 1.19.1 package
|
|
||||||
#
|
|
||||||
Ubuntu-jammy-build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: ubuntu:22.04
|
|
||||||
# The job outputs link to the outputs of the 'debrename' step
|
|
||||||
# Only job outputs can be used in child jobs
|
|
||||||
outputs:
|
|
||||||
deb : ${{steps.debrename.outputs.DEB}}
|
|
||||||
steps:
|
|
||||||
# Use apt to install development packages
|
|
||||||
- name: Install development packages
|
|
||||||
run: |
|
|
||||||
apt update && apt --assume-yes upgrade
|
|
||||||
apt --assume-yes install build-essential sed git wget bash
|
|
||||||
# Checkout git repository and submodules
|
|
||||||
# fetch-depth must be 0 to use git describe
|
|
||||||
# See: https://github.com/marketplace/actions/checkout
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
fetch-depth: 0
|
|
||||||
# Use official golang package
|
|
||||||
- name: Install Golang
|
|
||||||
run: |
|
|
||||||
wget -q https://go.dev/dl/go1.19.1.linux-amd64.tar.gz
|
|
||||||
tar -C /usr/local -xzf go1.19.1.linux-amd64.tar.gz
|
|
||||||
export PATH=/usr/local/go/bin:/usr/local/go/pkg/tool/linux_amd64:$PATH
|
|
||||||
go version
|
|
||||||
- name: DEB build MetricStore
|
|
||||||
id: dpkg-build
|
|
||||||
run: |
|
|
||||||
export PATH=/usr/local/go/bin:/usr/local/go/pkg/tool/linux_amd64:$PATH
|
|
||||||
make DEB
|
|
||||||
- name: Rename DEB (add '_ubuntu22.04')
|
|
||||||
id: debrename
|
|
||||||
run: |
|
|
||||||
OLD_DEB_NAME=$(echo "${{steps.dpkg-build.outputs.DEB}}" | rev | cut -d '.' -f 2- | rev)
|
|
||||||
NEW_DEB_FILE="${OLD_DEB_NAME}_ubuntu22.04.deb"
|
|
||||||
mv "${{steps.dpkg-build.outputs.DEB}}" "${NEW_DEB_FILE}"
|
|
||||||
echo "::set-output name=DEB::${NEW_DEB_FILE}"
|
|
||||||
# See: https://github.com/actions/upload-artifact
|
|
||||||
- name: Save DEB as artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store DEB for Ubuntu 22.04
|
|
||||||
path: ${{ steps.debrename.outputs.DEB }}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Create release with fresh RPMs
|
|
||||||
#
|
|
||||||
Release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
# We need the RPMs, so add dependency
|
|
||||||
needs: [AlmaLinux-RPM-build, UBI-8-RPM-build, Ubuntu-focal-build, Ubuntu-jammy-build]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# See: https://github.com/actions/download-artifact
|
|
||||||
- name: Download AlmaLinux 8.5 RPM
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store RPM for AlmaLinux 8.5
|
|
||||||
- name: Download AlmaLinux 8.5 SRPM
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store SRPM for AlmaLinux 8.5
|
|
||||||
|
|
||||||
- name: Download UBI 8 RPM
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store RPM for UBI 8
|
|
||||||
- name: Download UBI 8 SRPM
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store SRPM for UBI 8
|
|
||||||
|
|
||||||
- name: Download Ubuntu 20.04 DEB
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store DEB for Ubuntu 20.04
|
|
||||||
|
|
||||||
- name: Download Ubuntu 22.04 DEB
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cc-metric-store DEB for Ubuntu 22.04
|
|
||||||
|
|
||||||
# The download actions do not publish the name of the downloaded file,
|
|
||||||
# so we re-use the job outputs of the parent jobs. The files are all
|
|
||||||
# downloaded to the current folder.
|
|
||||||
# The gh-release action afterwards does not accept file lists but all
|
|
||||||
# files have to be listed at 'files'. The step creates one output per
|
|
||||||
# RPM package (2 per distro)
|
|
||||||
- name: Set RPM variables
|
|
||||||
id: files
|
|
||||||
run: |
|
|
||||||
ALMA_85_RPM=$(basename "${{ needs.AlmaLinux-RPM-build.outputs.rpm}}")
|
|
||||||
ALMA_85_SRPM=$(basename "${{ needs.AlmaLinux-RPM-build.outputs.srpm}}")
|
|
||||||
UBI_8_RPM=$(basename "${{ needs.UBI-8-RPM-build.outputs.rpm}}")
|
|
||||||
UBI_8_SRPM=$(basename "${{ needs.UBI-8-RPM-build.outputs.srpm}}")
|
|
||||||
U_2004_DEB=$(basename "${{ needs.Ubuntu-focal-build.outputs.deb}}")
|
|
||||||
U_2204_DEB=$(basename "${{ needs.Ubuntu-jammy-build.outputs.deb}}")
|
|
||||||
echo "ALMA_85_RPM::${ALMA_85_RPM}"
|
|
||||||
echo "ALMA_85_SRPM::${ALMA_85_SRPM}"
|
|
||||||
echo "UBI_8_RPM::${UBI_8_RPM}"
|
|
||||||
echo "UBI_8_SRPM::${UBI_8_SRPM}"
|
|
||||||
echo "U_2004_DEB::${U_2004_DEB}"
|
|
||||||
echo "U_2204_DEB::${U_2204_DEB}"
|
|
||||||
echo "::set-output name=ALMA_85_RPM::${ALMA_85_RPM}"
|
|
||||||
echo "::set-output name=ALMA_85_SRPM::${ALMA_85_SRPM}"
|
|
||||||
echo "::set-output name=UBI_8_RPM::${UBI_8_RPM}"
|
|
||||||
echo "::set-output name=UBI_8_SRPM::${UBI_8_SRPM}"
|
|
||||||
echo "::set-output name=U_2004_DEB::${U_2004_DEB}"
|
|
||||||
echo "::set-output name=U_2204_DEB::${U_2204_DEB}"
|
|
||||||
|
|
||||||
# See: https://github.com/softprops/action-gh-release
|
|
||||||
- name: Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
with:
|
|
||||||
name: cc-metric-store-${{github.ref_name}}
|
|
||||||
files: |
|
|
||||||
${{ steps.files.outputs.ALMA_85_RPM }}
|
|
||||||
${{ steps.files.outputs.ALMA_85_SRPM }}
|
|
||||||
${{ steps.files.outputs.UBI_8_RPM }}
|
|
||||||
${{ steps.files.outputs.UBI_8_SRPM }}
|
|
||||||
${{ steps.files.outputs.U_2004_DEB }}
|
|
||||||
${{ steps.files.outputs.U_2204_DEB }}
|
|
@ -1,17 +0,0 @@
|
|||||||
CC_USER=clustercockpit
|
|
||||||
|
|
||||||
CC_GROUP=clustercockpit
|
|
||||||
|
|
||||||
CC_HOME=/tmp
|
|
||||||
|
|
||||||
LOG_DIR=/var/log
|
|
||||||
|
|
||||||
DATA_DIR=/var/run/cc-metric-store
|
|
||||||
|
|
||||||
MAX_OPEN_FILES=10000
|
|
||||||
|
|
||||||
CONF_DIR=/etc/cc-metric-store
|
|
||||||
|
|
||||||
CONF_FILE=/etc/cc-metric-store/cc-metric-store.json
|
|
||||||
|
|
||||||
RESTART_ON_UPGRADE=true
|
|
@ -1,12 +0,0 @@
|
|||||||
Package: cc-metric-store
|
|
||||||
Version: {VERSION}
|
|
||||||
Installed-Size: {INSTALLED_SIZE}
|
|
||||||
Architecture: {ARCH}
|
|
||||||
Maintainer: thomas.gruber@fau.de
|
|
||||||
Depends: libc6 (>= 2.2.1)
|
|
||||||
Build-Depends: debhelper-compat (= 13), git, golang-go
|
|
||||||
Description: In-memory metric store daemon from the ClusterCockpit suite
|
|
||||||
Homepage: https://github.com/ClusterCockpit/cc-metric-store
|
|
||||||
Source: cc-metric-store
|
|
||||||
Rules-Requires-Root: no
|
|
||||||
|
|
@ -1,141 +0,0 @@
|
|||||||
#! /usr/bin/env bash
|
|
||||||
|
|
||||||
# chkconfig: 2345 80 05
|
|
||||||
# description: ClusterCockpit metric store
|
|
||||||
# processname: cc-metric-store
|
|
||||||
# config: /etc/default/cc-metric-store
|
|
||||||
# pidfile: /var/run/cc-metric-store.pid
|
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: cc-metric-store
|
|
||||||
# Required-Start: $all
|
|
||||||
# Required-Stop: $remote_fs $syslog
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: Start ClusterCockpit metric store at boot time
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
|
|
||||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
|
||||||
NAME=cc-metric-store
|
|
||||||
DESC="ClusterCockpit metric store"
|
|
||||||
DEFAULT=/etc/default/${NAME}.json
|
|
||||||
|
|
||||||
CC_USER=clustercockpit
|
|
||||||
CC_GROUP=clustercockpit
|
|
||||||
CONF_DIR=/etc/cc-metric-store
|
|
||||||
PID_FILE=/var/run/$NAME.pid
|
|
||||||
DAEMON=/usr/sbin/$NAME
|
|
||||||
CONF_FILE=${CONF_DIR}/cc-metric-store.json
|
|
||||||
|
|
||||||
umask 0027
|
|
||||||
|
|
||||||
if [ ! -x $DAEMON ]; then
|
|
||||||
echo "Program not installed or not executable"
|
|
||||||
exit 5
|
|
||||||
fi
|
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
|
||||||
|
|
||||||
if [ -r /etc/default/rcS ]; then
|
|
||||||
. /etc/default/rcS
|
|
||||||
fi
|
|
||||||
|
|
||||||
# overwrite settings from default file
|
|
||||||
if [ -f "$DEFAULT" ]; then
|
|
||||||
. "$DEFAULT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
CC_OPTS="--config=${CONF_FILE}"
|
|
||||||
|
|
||||||
function checkUser() {
|
|
||||||
if [ `id -u` -ne 0 ]; then
|
|
||||||
echo "You need root privileges to run this script"
|
|
||||||
exit 4
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
checkUser
|
|
||||||
log_daemon_msg "Starting $DESC"
|
|
||||||
|
|
||||||
pid=`pidofproc -p $PID_FILE $NAME`
|
|
||||||
if [ -n "$pid" ] ; then
|
|
||||||
log_begin_msg "Already running."
|
|
||||||
log_end_msg 0
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Prepare environment
|
|
||||||
touch "$PID_FILE" && chown "$CC_USER":"$CC_GROUP" "$PID_FILE"
|
|
||||||
|
|
||||||
if [ -n "$MAX_OPEN_FILES" ]; then
|
|
||||||
ulimit -n $MAX_OPEN_FILES
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Start Daemon
|
|
||||||
start-stop-daemon --start -b --chdir "$WORK_DIR" --user "$CC_USER" -c "$CC_USER" --pidfile "$PID_FILE" --exec $DAEMON -- $DAEMON_OPTS
|
|
||||||
return=$?
|
|
||||||
if [ $return -eq 0 ]
|
|
||||||
then
|
|
||||||
sleep 1
|
|
||||||
|
|
||||||
# check if pid file has been written to
|
|
||||||
if ! [[ -s $PID_FILE ]]; then
|
|
||||||
log_end_msg 1
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
i=0
|
|
||||||
timeout=10
|
|
||||||
# Wait for the process to be properly started before exiting
|
|
||||||
until { cat "$PID_FILE" | xargs kill -0; } >/dev/null 2>&1
|
|
||||||
do
|
|
||||||
sleep 1
|
|
||||||
i=$(($i + 1))
|
|
||||||
if [ $i -gt $timeout ]; then
|
|
||||||
log_end_msg 1
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
log_end_msg $return
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
checkUser
|
|
||||||
log_daemon_msg "Stopping $DESC"
|
|
||||||
|
|
||||||
if [ -f "$PID_FILE" ]; then
|
|
||||||
start-stop-daemon --stop --pidfile "$PID_FILE" \
|
|
||||||
--user "$CC_USER" \
|
|
||||||
--retry=TERM/20/KILL/5 >/dev/null
|
|
||||||
if [ $? -eq 1 ]; then
|
|
||||||
log_progress_msg "$DESC is not running but pid file exists, cleaning up"
|
|
||||||
elif [ $? -eq 3 ]; then
|
|
||||||
PID="`cat $PID_FILE`"
|
|
||||||
log_failure_msg "Failed to stop $DESC (pid $PID)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
rm -f "$PID_FILE"
|
|
||||||
else
|
|
||||||
log_progress_msg "(not running)"
|
|
||||||
fi
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
status_of_proc -p $PID_FILE $NAME $NAME && exit 0 || exit $?
|
|
||||||
;;
|
|
||||||
restart|force-reload)
|
|
||||||
if [ -f "$PID_FILE" ]; then
|
|
||||||
$0 stop
|
|
||||||
sleep 1
|
|
||||||
fi
|
|
||||||
$0 start
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}"
|
|
||||||
exit 3
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
|||||||
Name: cc-metric-store
|
|
||||||
Version: %{VERS}
|
|
||||||
Release: 1%{?dist}
|
|
||||||
Summary: In-memory metric database from the ClusterCockpit suite
|
|
||||||
|
|
||||||
License: MIT
|
|
||||||
Source0: %{name}-%{version}.tar.gz
|
|
||||||
|
|
||||||
BuildRequires: go-toolset
|
|
||||||
BuildRequires: systemd-rpm-macros
|
|
||||||
|
|
||||||
Provides: %{name} = %{version}
|
|
||||||
|
|
||||||
%description
|
|
||||||
In-memory metric database from the ClusterCockpit suite
|
|
||||||
|
|
||||||
%global debug_package %{nil}
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%autosetup
|
|
||||||
|
|
||||||
|
|
||||||
%build
|
|
||||||
make
|
|
||||||
|
|
||||||
|
|
||||||
%install
|
|
||||||
# Install cc-metric-store
|
|
||||||
make PREFIX=%{buildroot} install
|
|
||||||
# Integrate into system
|
|
||||||
install -Dpm 0644 scripts/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
|
|
||||||
install -Dpm 0600 scripts/%{name}.config %{buildroot}%{_sysconfdir}/default/%{name}
|
|
||||||
install -Dpm 0644 scripts/%{name}.sysusers %{buildroot}%{_sysusersdir}/%{name}.conf
|
|
||||||
|
|
||||||
|
|
||||||
%check
|
|
||||||
# go test should be here... :)
|
|
||||||
|
|
||||||
%pre
|
|
||||||
%sysusers_create_package scripts/%{name}.sysusers
|
|
||||||
|
|
||||||
%post
|
|
||||||
%systemd_post %{name}.service
|
|
||||||
|
|
||||||
%preun
|
|
||||||
%systemd_preun %{name}.service
|
|
||||||
|
|
||||||
%files
|
|
||||||
# Binary
|
|
||||||
%attr(-,clustercockpit,clustercockpit) %{_bindir}/%{name}
|
|
||||||
# Config
|
|
||||||
%dir %{_sysconfdir}/%{name}
|
|
||||||
%attr(0600,clustercockpit,clustercockpit) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.json
|
|
||||||
# Systemd
|
|
||||||
%{_unitdir}/%{name}.service
|
|
||||||
%{_sysconfdir}/default/%{name}
|
|
||||||
%{_sysusersdir}/%{name}.conf
|
|
||||||
|
|
||||||
%changelog
|
|
||||||
* Mon Mar 07 2022 Thomas Gruber - 0.1
|
|
||||||
- Initial metric store implementation
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
#Type Name ID GECOS Home directory Shell
|
|
||||||
u clustercockpit - "User for ClusterCockpit" /run/cc-metric-collector /sbin/nologin
|
|
@ -1,105 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"math"
|
|
||||||
"math/rand"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
const token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.eyJ1c2VyIjoiYWRtaW4iLCJyb2xlcyI6WyJST0xFX0FETUlOIiwiUk9MRV9BTkFMWVNUIiwiUk9MRV9VU0VSIl19.d-3_3FZTsadPjDEdsWrrQ7nS0edMAR4zjl-eK7rJU3HziNBfI9PDHDIpJVHTNN5E5SlLGLFXctWyKAkwhXL-Dw"
|
|
||||||
const ccmsurl = "http://localhost:8081/api/write"
|
|
||||||
const cluster = "fakedev"
|
|
||||||
const sockets = 2
|
|
||||||
const cpus = 8
|
|
||||||
const freq = 15 * time.Second
|
|
||||||
|
|
||||||
var hosts = []string{"fake001", "fake002", "fake003", "fake004", "fake005"}
|
|
||||||
var metrics = []struct {
|
|
||||||
Name string
|
|
||||||
Type string
|
|
||||||
AvgValue float64
|
|
||||||
}{
|
|
||||||
{"flops_any", "cpu", 10.0},
|
|
||||||
{"mem_bw", "socket", 50.0},
|
|
||||||
{"ipc", "cpu", 1.25},
|
|
||||||
{"cpu_load", "node", 4},
|
|
||||||
{"mem_used", "node", 20},
|
|
||||||
}
|
|
||||||
|
|
||||||
var states = make([]float64, 0)
|
|
||||||
|
|
||||||
func send(client *http.Client, t int64) {
|
|
||||||
msg := &bytes.Buffer{}
|
|
||||||
|
|
||||||
i := 0
|
|
||||||
for _, host := range hosts {
|
|
||||||
for _, metric := range metrics {
|
|
||||||
n := 1
|
|
||||||
if metric.Type == "socket" {
|
|
||||||
n = sockets
|
|
||||||
} else if metric.Type == "cpu" {
|
|
||||||
n = cpus
|
|
||||||
}
|
|
||||||
|
|
||||||
for j := 0; j < n; j++ {
|
|
||||||
fmt.Fprintf(msg, "%s,cluster=%s,host=%s,type=%s", metric.Name, cluster, host, metric.Type)
|
|
||||||
if metric.Type == "socket" {
|
|
||||||
fmt.Fprintf(msg, ",type-id=%d", j)
|
|
||||||
} else if metric.Type == "cpu" {
|
|
||||||
fmt.Fprintf(msg, ",type-id=%d", j)
|
|
||||||
}
|
|
||||||
|
|
||||||
x := metric.AvgValue + math.Sin(states[i])*(metric.AvgValue/10.)
|
|
||||||
states[i] += 0.1
|
|
||||||
fmt.Fprintf(msg, " value=%f ", x)
|
|
||||||
|
|
||||||
fmt.Fprintf(msg, "%d\n", t)
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
req, _ := http.NewRequest(http.MethodPost, ccmsurl, msg)
|
|
||||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
|
||||||
res, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
log.Print(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.StatusCode != http.StatusOK {
|
|
||||||
body, _ := io.ReadAll(res.Body)
|
|
||||||
log.Printf("%s: %s", res.Status, string(body))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
for range hosts {
|
|
||||||
for _, m := range metrics {
|
|
||||||
n := 1
|
|
||||||
if m.Type == "socket" {
|
|
||||||
n = sockets
|
|
||||||
} else if m.Type == "cpu" {
|
|
||||||
n = cpus
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < n; i++ {
|
|
||||||
states = append(states, rand.Float64()*100)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
client := &http.Client{}
|
|
||||||
|
|
||||||
i := 0
|
|
||||||
for t := range time.Tick(freq) {
|
|
||||||
log.Printf("tick... (#%d)", i)
|
|
||||||
i++
|
|
||||||
|
|
||||||
send(client, t.Unix())
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user