From 187362f43d5f2f91176017dd4be7a49f641a4cc3 Mon Sep 17 00:00:00 2001 From: grepwood Date: Sun, 10 May 2020 13:21:47 +0200 Subject: [PATCH] Preliminary support for Sensu monitoring framework. Requires work with GCC-Go (if possible) and systemd (must-have). --- acct-group/sensu/metadata.xml | 4 + acct-group/sensu/sensu-0.ebuild | 10 + acct-user/sensu/metadata.xml | 4 + acct-user/sensu/sensu-0.ebuild | 12 ++ net-analyzer/sensu/Manifest | 3 + net-analyzer/sensu/files/conf.d/sensu-agent | 6 + net-analyzer/sensu/files/conf.d/sensu-backend | 6 + net-analyzer/sensu/files/init.d/sensu-agent | 23 +++ net-analyzer/sensu/files/init.d/sensu-backend | 23 +++ net-analyzer/sensu/metadata.xml | 17 ++ net-analyzer/sensu/sensu-5.19.3.ebuild | 190 ++++++++++++++++++ 11 files changed, 298 insertions(+) create mode 100644 acct-group/sensu/metadata.xml create mode 100644 acct-group/sensu/sensu-0.ebuild create mode 100644 acct-user/sensu/metadata.xml create mode 100644 acct-user/sensu/sensu-0.ebuild create mode 100644 net-analyzer/sensu/Manifest create mode 100644 net-analyzer/sensu/files/conf.d/sensu-agent create mode 100644 net-analyzer/sensu/files/conf.d/sensu-backend create mode 100755 net-analyzer/sensu/files/init.d/sensu-agent create mode 100755 net-analyzer/sensu/files/init.d/sensu-backend create mode 100644 net-analyzer/sensu/metadata.xml create mode 100644 net-analyzer/sensu/sensu-5.19.3.ebuild diff --git a/acct-group/sensu/metadata.xml b/acct-group/sensu/metadata.xml new file mode 100644 index 0000000..097975e --- /dev/null +++ b/acct-group/sensu/metadata.xml @@ -0,0 +1,4 @@ + + + + diff --git a/acct-group/sensu/sensu-0.ebuild b/acct-group/sensu/sensu-0.ebuild new file mode 100644 index 0000000..3ba8950 --- /dev/null +++ b/acct-group/sensu/sensu-0.ebuild @@ -0,0 +1,10 @@ +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit acct-group + +DESCRIPTION="Sensu program group" +ACCT_GROUP_ID=999 +SLOT="0" diff --git a/acct-user/sensu/metadata.xml b/acct-user/sensu/metadata.xml new file mode 100644 index 0000000..097975e --- /dev/null +++ b/acct-user/sensu/metadata.xml @@ -0,0 +1,4 @@ + + + + diff --git a/acct-user/sensu/sensu-0.ebuild b/acct-user/sensu/sensu-0.ebuild new file mode 100644 index 0000000..eda8c1e --- /dev/null +++ b/acct-user/sensu/sensu-0.ebuild @@ -0,0 +1,12 @@ +# Copyright 2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit acct-user + +DESCRIPTION="Sensu Monitoring Framework" +ACCT_USER_ID=60 +ACCT_USER_GROUPS=( sensu ) +acct-user_add_deps +SLOT="0" diff --git a/net-analyzer/sensu/Manifest b/net-analyzer/sensu/Manifest new file mode 100644 index 0000000..3dfa4da --- /dev/null +++ b/net-analyzer/sensu/Manifest @@ -0,0 +1,3 @@ +DIST sensu-5.19.3.tar.gz 2823471 BLAKE2B 8f9578285695d2d3890940a61aada03a30ee8649277fd9fa3ce651ddb0eeefae758acdb05247a346488b69e5b21fb41d50c41c868bf663406410d9995c31c663 SHA512 9084bb7ee434d9dcfd291106bc13657590bef943e08be0b7687e26730a125c1ba4ea6045d62cb946e5fa224022fcd029c208b99ce6b95abbf908f3f72b45d0ce +DIST sensu_5.19.3_agent.yml 1379 BLAKE2B b1145ec12c85950c6cae834a666bc9e8186d8072184f56b4129d9c9ab8a98454080effdbbf87bcd777d852c78acf96b53fdf865306e3d984cbdc21a2dee832dc SHA512 d70899325f16231d88ca1c1a5660b4bb2444f42ec12c11b4cb68aabc0f23a2d1e2a068362e711b1fc1b14efdc7db033ca2fc069944b554a40f35a2a160dda353 +DIST sensu_5.19.3_backend.yml 1771 BLAKE2B 4c2745f601a84e4aa444dedd4dbc2445652a94f48a784b7237038864c111b40f0370aefa9cbd7922c9881a437f0cf97d8aecb07a85d2b6723a6af3ce3555e8e2 SHA512 d6adc6180585f1505e5807a7be743b8f2e405a16aab0e54b5de0e1e64276cd8a0d93be66e72ca48f9fb8f2aebf8169b2d70ab17fc1a3aeb81e4b32a4bf757264 diff --git a/net-analyzer/sensu/files/conf.d/sensu-agent b/net-analyzer/sensu/files/conf.d/sensu-agent new file mode 100644 index 0000000..097e6f7 --- /dev/null +++ b/net-analyzer/sensu/files/conf.d/sensu-agent @@ -0,0 +1,6 @@ +# config file for /etc/init.d/sensu-agent + +SENSU_AGENT_CONFIG="/etc/sensu/agent.yml" +SENSU_AGENT_DATADIR="/var/lib/sensu" +SENSU_AGENT_LOGDIR="/var/log/sensu" +SENSU_AGENT_CACHEDIR="/var/cache/sensu" diff --git a/net-analyzer/sensu/files/conf.d/sensu-backend b/net-analyzer/sensu/files/conf.d/sensu-backend new file mode 100644 index 0000000..1867558 --- /dev/null +++ b/net-analyzer/sensu/files/conf.d/sensu-backend @@ -0,0 +1,6 @@ +# config file for /etc/init.d/sensu-backend + +SENSU_BACKEND_CONFIG="/etc/sensu/backend.yml" +SENSU_BACKEND_DATADIR="/var/lib/sensu" +SENSU_BACKEND_LOGDIR="/var/log/sensu" +SENSU_BACKEND_CACHEDIR="/var/cache/sensu" diff --git a/net-analyzer/sensu/files/init.d/sensu-agent b/net-analyzer/sensu/files/init.d/sensu-agent new file mode 100755 index 0000000..435e4c9 --- /dev/null +++ b/net-analyzer/sensu/files/init.d/sensu-agent @@ -0,0 +1,23 @@ +#!/sbin/openrc-run +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="" + +name="Sensu Agent" +command="/usr/sbin/sensu-agent" +command_args="start -c ${SENSU_AGENT_CONFIG}" +command_user="${SENSU_USER:-sensu}" +command_background=true +pidfile="/run/${SVCNAME}.pid" +required_files="${SENSU_AGENT_CONFIG}" +retry=${SENSU_AGENT_TERMTIMEOUT:-"TERM/20/KILL/5"} +start_stop_daemon_args="${SSD_OPTS:-}" + +depend() { + need localmount net +} + +start_pre() { + checkpath -d -m 0750 -o "${command_user}" "${SENSU_AGENT_LOGDIR}" "${SENSU_AGENT_DATADIR}" "${SENSU_AGENT_CACHEDIR}" +} diff --git a/net-analyzer/sensu/files/init.d/sensu-backend b/net-analyzer/sensu/files/init.d/sensu-backend new file mode 100755 index 0000000..b94ae4f --- /dev/null +++ b/net-analyzer/sensu/files/init.d/sensu-backend @@ -0,0 +1,23 @@ +#!/sbin/openrc-run +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="" + +name="Sensu Monitoring Framework" +command="/usr/sbin/sensu-backend" +command_args="start -c ${SENSU_BACKEND_CONFIG}" +command_user="sensu" +command_background=true +pidfile="/run/${SVCNAME}.pid" +required_files="${SENSU_BACKEND_CONFIG}" +retry=${SENSU_BACKEND_TERMTIMEOUT:-"TERM/20/KILL/5"} +start_stop_daemon_args="${SSD_OPTS:-}" + +depend() { + need localmount net +} + +start_pre() { + checkpath -d -m 0750 -o "${command_user}" "${SENSU_BACKEND_LOGDIR}" "${SENSU_BACKEND_DATADIR}" "${SENSU_BACKEND_CACHEDIR}" +} diff --git a/net-analyzer/sensu/metadata.xml b/net-analyzer/sensu/metadata.xml new file mode 100644 index 0000000..555311e --- /dev/null +++ b/net-analyzer/sensu/metadata.xml @@ -0,0 +1,17 @@ + + + + + + Installs Sensu agent + + + Install Sensu dashboard and backend server + + Compile with GCC's Go compiler instead of Google's reference Go compiler (NOT SUPPORTED) + + + Install systemd service units rather than OpenRC init scripts (NOT SUPPORTED) + + + diff --git a/net-analyzer/sensu/sensu-5.19.3.ebuild b/net-analyzer/sensu/sensu-5.19.3.ebuild new file mode 100644 index 0000000..57f00b3 --- /dev/null +++ b/net-analyzer/sensu/sensu-5.19.3.ebuild @@ -0,0 +1,190 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +#inherit go-module + +EGO_SUM=( + "github.com/AlecAivazis/survey v1.4.1" + "github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78" + "github.com/NYTimes/gziphandler v0.0.0-20180227021810-5032c8878b9d" + "github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f" + "github.com/ash2k/stager v0.0.0-20170622123058-6e9c7b0eacd4" + "github.com/atlassian/gostatsd v0.0.0-20180514010436-af796620006e" + "github.com/coreos/bbolt v1.3.3" + "github.com/coreos/etcd v3.3.17+incompatible" + "github.com/coreos/go-semver v0.3.0" + "github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f" + "github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f" + "github.com/dave/jennifer v0.0.0-20171207062344-d8bdbdbee4e1" + "github.com/dgrijalva/jwt-go v3.2.0+incompatible" + "github.com/docker/docker v0.0.0-20180409082103-cbde00b44273" + "github.com/echlebek/crock v1.0.1" + "github.com/echlebek/timeproxy v1.0.0" + "github.com/emicklei/proto v1.1.0" + "github.com/frankban/quicktest v1.7.2" + "github.com/ghodss/yaml v1.0.0" + "github.com/go-ole/go-ole v0.0.0-20170209151332-de8695c8edbf" + "github.com/go-resty/resty/v2 v2.1.0" + "github.com/gogo/protobuf v1.3.1" + "github.com/golang/groupcache v0.0.0-20191002201903-404acd9df4cc" + "github.com/golang/protobuf v1.3.2" + "github.com/google/uuid v1.1.1" + "github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f" + "github.com/gorilla/mux v1.6.2" + "github.com/gorilla/websocket v1.4.1" + "github.com/gotestyourself/gotestyourself v2.2.0+incompatible" + "github.com/graph-gophers/dataloader v0.0.0-20180104184831-78139374585c" + "github.com/graphql-go/graphql v0.7.9-0.20191125031726-2e2b648ecbe4" + "github.com/grpc-ecosystem/go-grpc-middleware v1.1.0" + "github.com/grpc-ecosystem/grpc-gateway v1.11.3" + "github.com/gxed/GoEndian v0.0.0-20160916112711-0f5c6873267e" + "github.com/gxed/eventfd v0.0.0-20160916113412-80a92cca79a8" + "github.com/hashicorp/go-version v1.2.0" + "github.com/ipfs/go-log v0.0.0-20180416040000-7ecd3df29a4a" + "github.com/jbenet/go-reuseport v0.0.0-20180416043609-15a1cd37f050" + "github.com/json-iterator/go v1.1.7" + "github.com/konsorten/go-windows-terminal-sequences v1.0.2" + "github.com/libp2p/go-reuseport v0.0.0-20180416043609-15a1cd37f050" + "github.com/libp2p/go-sockaddr v0.0.0-20180329070516-f3e9f73a53d1" + "github.com/mattn/go-colorable v0.0.9" + "github.com/mattn/go-isatty v0.0.2" + "github.com/mattn/go-runewidth v0.0.2" + "github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b" + "github.com/mholt/archiver/v3 v3.3.1-0.20191129193105-44285f7ed244" + "github.com/mitchellh/go-homedir v1.1.0" + "github.com/mitchellh/mapstructure v1.1.2" + "github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84" + "github.com/prometheus/client_golang v1.2.0" + "github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4" + "github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d" + "github.com/robfig/cron/v3 v3.0.0" + "github.com/sensu/lasr v1.2.1" + "github.com/shirou/gopsutil v0.0.0-20180801053943-8048a2e9c577" + "github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4" + "github.com/sirupsen/logrus v1.4.2" + "github.com/spf13/cobra v0.0.5" + "github.com/spf13/pflag v1.0.5" + "github.com/spf13/viper v1.4.0" + "github.com/stretchr/testify v1.4.0" + "github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc" + "github.com/willf/pad v0.0.0-20160331131008-b3d780601022" + "go.etcd.io/bbolt v1.3.2" + "go.uber.org/multierr v1.2.0" + "golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550" + "golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582" + "golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056" + "golang.org/x/text v0.3.2" + "golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0" + "google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03" + "google.golang.org/grpc v1.24.0" + "gopkg.in/AlecAivazis/survey.v1 v1.4.0" + "gopkg.in/h2non/filetype.v1 v1.0.3" + "gopkg.in/sourcemap.v1 v1.0.5" + "gopkg.in/yaml.v2 v2.2.4" + "gotest.tools v2.2.0+incompatible" + "sigs.k8s.io/yaml v1.1.0" +) + +#go-module_set_globals + +DESCRIPTION="Simple. Scalable. Multi-cloud monitoring." +HOMEPAGE="https://sensu.io" +#SRC_URI=" +# https://github.com/${PN}/${PN}-go/archive/v${PV}.tar.gz -> ${P}.tar.gz +# ${EGO_SUM_SRC_URI}" + +MAJOR_MINOR_VERSION="5.19" +SRC_URI=" + https://github.com/${PN}/${PN}-go/archive/v${PV}.tar.gz -> ${P}.tar.gz + backend? ( https://docs.sensu.io/sensu-go/${MAJOR_MINOR_VERSION}/files/backend.yml -> ${PN}_${PV}_backend.yml ) + agent? ( https://docs.sensu.io/sensu-go/${MAJOR_MINOR_VERSION}/files/agent.yml -> ${PN}_${PV}_agent.yml ) +" + +PROPERTIES+=" live" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~arm ~ppc64 ~x86" + +IUSE="gcc systemd backend agent" + +BDEPEND+=" + !gcc? ( dev-lang/go ) + gcc? ( sys-devel/gcc[go] ) + sys-apps/coreutils + app-arch/tar + app-arch/gzip +" + +RDEPEND+=" + virtual/libc + acct-group/sensu + acct-user/sensu +" + +#S="${S}/${PN}" +#S="${WORKDIR}/${PN}-go-${PV}" +S="${WORKDIR}" + +src_unpack() { + if [ -z ${I_KNOW_WHAT_IM_DOING} ]; then + local I_KNOW_WHAT_IM_DOING=0 + fi + if use gcc; then + die "Compilation with GCC is not supported yet." + fi + if use systemd; then + die "We don't have systemd unit files yet." + fi + if use backend && (use x86 || use arm) && [ ${I_KNOW_WHAT_IM_DOING} -eq 0 ]; then + die "Backend does not work reliably on 32bit hosts. If you really want this, re-emerge with I_KNOW_WHAT_IM_DOING=1" + fi + tar -xf ${DISTDIR}/sensu-${PV}.tar.gz + cd ${PN}-go-${PV} + local TODAY=$(date +%Y-%m-%d) + local BUILD_SIGNATURE="-X github.com/sensu/sensu-go/version.Version=${PV} -X github.com/sensu/sensu-go/version.BuildDate=${TODAY}" + if use agent; then + go build -ldflags "${BUILD_SIGNATURE}" -o bin/sensu-agent ./cmd/sensu-agent >/dev/null + cp "${DISTDIR}"/"${PN}"_"${PV}"_agent.yml "${S}"/agent.yml + fi + if use backend; then + go build -ldflags "${BUILD_SIGNATURE}" -o bin/sensu-backend ./cmd/sensu-backend >/dev/null + cp "${DISTDIR}"/"${PN}"_"${PV}"_backend.yml "${S}"/backend.yml + fi + go build -ldflags "${BUILD_SIGNATURE}" -o bin/sensuctl ./cmd/sensuctl >/dev/null +} + +src_install() { + if use agent; then + exeinto /etc/init.d + doexe "${FILESDIR}"/init.d/sensu-agent + insinto /etc/conf.d + doins "${FILESDIR}"/conf.d/sensu-agent + insinto /etc/sensu + doins agent.yml + dosbin "${PN}-go-${PV}"/bin/sensu-agent + fi + if use backend; then + exeinto /etc/init.d + doexe "${FILESDIR}"/init.d/sensu-backend + insinto /etc/conf.d + doins "${FILESDIR}"/conf.d/sensu-backend + insinto /etc/sensu + doins backend.yml + dosbin "${PN}-go-${PV}"/bin/sensu-backend + fi + dosbin "${PN}-go-${PV}"/bin/sensuctl +} + +pkg_postinst() { + if use backend; then + elog "If this is your first installation of sensu backend," + elog "you have to initialize your administrative credentials." + elog "Simply run the following: (change admin_user and admin_password)" + elog "su -s /bin/bash - sensu -c 'SENSU_BACKEND_CLUSTER_ADMIN_USERNAME=admin_user SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD=admin_pass sensu-backend init'" + elog "Remember that this command has to be run WHILE sensu-backend service is running." + fi +} +