diff options
author | Rodrigo Lira <eurodrigolira@gmail.com> | 2024-09-13 06:24:47 +0900 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2024-09-14 21:14:16 +0700 |
commit | 22f78d4437b61ba4793b0a4e5f23188f7d13cd3b (patch) | |
tree | 50206f7576618dd387aa7fcd7f67ebbccb49a0c5 /network/grafana | |
parent | 19ce1d0eb5b5a27d122f63db87200b33d9051b90 (diff) | |
download | slackbuilds-22f78d4437b61ba4793b0a4e5f23188f7d13cd3b.tar.gz slackbuilds-22f78d4437b61ba4793b0a4e5f23188f7d13cd3b.tar.xz |
network/grafana: Added (monitoring tool).
Signed-off-by: Andrew Clemons <andrew.clemons@gmail.com>
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to '')
-rw-r--r-- | network/grafana/README | 6 | ||||
-rw-r--r-- | network/grafana/README.SLACKWARE | 41 | ||||
-rw-r--r-- | network/grafana/doinst.sh | 25 | ||||
-rw-r--r-- | network/grafana/grafana.SlackBuild | 112 | ||||
-rw-r--r-- | network/grafana/grafana.info | 10 | ||||
-rw-r--r-- | network/grafana/rc.grafana | 132 | ||||
-rw-r--r-- | network/grafana/slack-desc | 19 |
7 files changed, 345 insertions, 0 deletions
diff --git a/network/grafana/README b/network/grafana/README new file mode 100644 index 0000000000..d092cc7422 --- /dev/null +++ b/network/grafana/README @@ -0,0 +1,6 @@ +grafana (the open-source platform for monitoring and observability) + +Easily collect, correlate, and visualize data with beautiful dashboards +using Grafana, the open source data visualization and monitoring +solution that drives informed decisions, enhances system performance, +and streamlines troubleshooting. diff --git a/network/grafana/README.SLACKWARE b/network/grafana/README.SLACKWARE new file mode 100644 index 0000000000..4e54c30cf4 --- /dev/null +++ b/network/grafana/README.SLACKWARE @@ -0,0 +1,41 @@ +README.Slackware +================ + +This file contains some specific instructions to complete the +installation of grafana on Slackware. + +Grafana can work with SQLite, PostgreSQL, and MySQL databases. +By default, it uses SQLite, but you can modify the grafana.ini file +in the /etc/grafana directory to change the settings, including protocols, ports, etc. + +Before running the grafna.SlackBuild script, you will need to create +the 'grafana' user and group. The script won't run if these do not exist. + +The suggested UID and GID is , but you can change this as needed: + + # groupadd -g 387 grafana + # useradd -u 387 -g grafana -d /dev/null -s /bin/false grafana + +If you want to start grafana on system bootup, include these lines in +your /etc/rc.d/rc.local: + + # Start grafana + if [ -x /etc/rc.d/rc.grafana ]; then + /etc/rc.d/rc.grafana start + fi + +To guarantee a clean shutdown of grafana, include this in +/etc/rc.d/rc.local_shutdown: + + # Stop grafana + if [ -x /etc/rc.d/rc.grafana ]; then + /etc/rc.d/rc.grafana stop + fi + +Make /etc/rc.d/rc.grafana executable + + # chmod +x /etc/rc.d/rc.grafana + +Starting grafana + + # /etc/rc.d/rc.grafana start diff --git a/network/grafana/doinst.sh b/network/grafana/doinst.sh new file mode 100644 index 0000000000..8de19ff50c --- /dev/null +++ b/network/grafana/doinst.sh @@ -0,0 +1,25 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + rm $NEW + fi +} + +preserve_perms() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ -e $OLD ]; then + cp -a $OLD ${NEW}.incoming + cat $NEW > ${NEW}.incoming + mv ${NEW}.incoming $NEW + fi + config $NEW +} + +config etc/grafana/grafana.ini.new +config etc/default/grafana-server.new + +preserve_perms etc/rc.d/rc.grafana.new diff --git a/network/grafana/grafana.SlackBuild b/network/grafana/grafana.SlackBuild new file mode 100644 index 0000000000..d85cd69c2a --- /dev/null +++ b/network/grafana/grafana.SlackBuild @@ -0,0 +1,112 @@ +#!/bin/bash + +# Slackware build script for grafana + +# Copyright 2024 Rodrigo Lira <eurodrigolira@gmail.com> +# +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +cd $(dirname $0) ; CWD=$(pwd) + +PRGNAM=grafana +VERSION=${VERSION:-11.2.0} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} + +GRAFANAUSER=${GRAFANAUSER:-grafana} +GRAFANAGROUP=${GRAFANAGROUP:-grafana} +GRAFANAUID=${GRAFANAUID:-387} +GRAFANAGID=${GRAFANAGID:-387} + +if [ "$(grep ^$GRAFANAUSER: /etc/passwd)" = "" -o "$(grep ^$GRAFANAGROUP: /etc/group)" = "" ] ; then + echo " You must have a \"$GRAFANAGROUP\" group and user to run this script." + echo " # groupadd -g $GRAFANAGID $GRAFANAGROUP" + echo " # useradd -u $GRAFANAUID -g $GRAFANAGROUP -d /dev/null -s /bin/false $GRAFANAUSER" + exit 1 +fi + +if [ -z "$ARCH" ]; then + ARCH=$( uname -m ) +fi + +if [ "$ARCH" != "x86_64" ]; then + echo "Package for $ARCH architecture is not available." + exit 1 +fi + +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 +fi + +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION.linux-amd64 +tar xvf $CWD/$PRGNAM-$VERSION.linux-amd64.tar.gz +cd $PRGNAM-v$VERSION +chown -R root:root . +find -L . \ + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + +mkdir -p $PKG/var/lib/$PRGNAM +chown -R $GRAFANAUSER:$GRAFANAGROUP $PKG/var/lib/$PRGNAM + +mkdir -p $PKG/usr/sbin +cp -a bin/* $PKG/usr/sbin + +mkdir -p $PKG/etc/$PRGNAM +cp -a conf/* $PKG/etc/$PRGNAM +cp -a conf/sample.ini $PKG/etc/$PRGNAM/grafana.ini.new +chown -R :$GRAFANAGROUP $PKG/etc/$PRGNAM + +mkdir -p $PKG/etc/default +cp -a packaging/deb/default/grafana-server $PKG/etc/default/grafana-server.new + +mkdir -p $PKG/var/log/$PRGNAM +chown -R $GRAFANAUSER:$GRAFANAGROUP $PKG/var/log/$PRGNAM + +mkdir -p $PKG/usr/share/$PRGNAM +cp -a * $PKG/usr/share/$PRGNAM + +mkdir -p $PKG/etc/rc.d +cat $CWD/rc.$PRGNAM > $PKG/etc/rc.d/rc.$PRGNAM.new + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a LICENSE NOTICE.md README.md VERSION docs/sources $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild +cat $CWD/README.SLACKWARE > $PKG/usr/doc/$PRGNAM-$VERSION/README.SLACKWARE + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE diff --git a/network/grafana/grafana.info b/network/grafana/grafana.info new file mode 100644 index 0000000000..0a61936e55 --- /dev/null +++ b/network/grafana/grafana.info @@ -0,0 +1,10 @@ +PRGNAM="grafana" +VERSION="11.2.0" +HOMEPAGE="https://grafana.com" +DOWNLOAD="UNSUPPORTED" +MD5SUM="" +DOWNLOAD_x86_64="https://dl.grafana.com/oss/release/grafana-11.2.0.linux-amd64.tar.gz" +MD5SUM_x86_64="5a070334ff05fcfabddc6910720f1a91" +REQUIRES="" +MAINTAINER="Rodrigo Lira" +EMAIL="eurodrigolira@gmail.com" diff --git a/network/grafana/rc.grafana b/network/grafana/rc.grafana new file mode 100644 index 0000000000..205585cff3 --- /dev/null +++ b/network/grafana/rc.grafana @@ -0,0 +1,132 @@ +#! /usr/bin/env bash + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +PRGNAME=grafana +NAME=grafana-server +DESC="Grafana Server" +DEFAULT=/etc/sysconfig/$NAME +GRAFANA_USER=grafana +GRAFANA_GROUP=grafana +GRAFANA_HOME=/usr/share/grafana +CONF_DIR=/etc/grafana +WORK_DIR=$GRAFANA_HOME +DATA_DIR=/var/lib/grafana +PLUGINS_DIR=/var/lib/grafana/plugins +LOG_DIR=/var/log/grafana +CONF_FILE=$CONF_DIR/grafana.ini +PROVISIONING_CFG_DIR=$CONF_DIR/provisioning +MAX_OPEN_FILES=10000 +PID_FILE=/var/run/$NAME.pid +DAEMON=$GRAFANA_HOME/bin/grafana + + +if [ ! -x $DAEMON ]; then + echo "Program not installed or not executable" + exit 5 +fi + +# Source function library. +if [ -f /etc/rc.d/init.d/functions ]; then + . /etc/rc.d/init.d/functions +fi + +# overwrite settings from default file +if [ -f "$DEFAULT" ]; then + . "$DEFAULT" +fi + +DAEMON_OPTS="server --homepath=${GRAFANA_HOME} --pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.provisioning=$PROVISIONING_CFG_DIR cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR} cfg:default.paths.plugins=${PLUGINS_DIR}" + +function isRunning() { + status -p $PID_FILE $NAME > /dev/null 2>&1 +} + +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 + isRunning + if [ $? -eq 0 ]; then + echo "Already running." + exit 0 + fi + + # Prepare environment + mkdir -p "$LOG_DIR" "$DATA_DIR" && chown "$GRAFANA_USER":"$GRAFANA_GROUP" "$LOG_DIR" "$DATA_DIR" + touch "$PID_FILE" && chown "$GRAFANA_USER":"$GRAFANA_GROUP" "$PID_FILE" + + if [ -n "$MAX_OPEN_FILES" ]; then + ulimit -n $MAX_OPEN_FILES + fi + + # Start Daemon + cd $GRAFANA_HOME + action $"Starting $DESC: ..." su -s /bin/sh -c "nohup ${DAEMON} ${DAEMON_OPTS} >> ${LOG_DIR}/${PRGNAME}.log 2>&1 &" grafana + return=$? + if [ $return -eq 0 ] + then + sleep 5 + # check if pid file has been written to + if ! [[ -s $PID_FILE ]]; then + echo "FAILED" + 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 + echo "FAILED" + exit 1 + fi + done + fi + + exit $return + ;; + stop) + checkUser + echo -n "Stopping $DESC: ..." + + if [ -f "$PID_FILE" ]; then + killproc -p $PID_FILE -d 20 $NAME + if [ $? -eq 1 ]; then + echo "$DESC is not running but pid file exists, cleaning up" + elif [ $? -eq 3 ]; then + PID="`cat $PID_FILE`" + echo "Failed to stop $DESC (pid $PID)" + exit 1 + fi + rm -f "$PID_FILE" + echo "" + exit 0 + else + echo "(not running)" + fi + exit 0 + ;; + status) + status -p $PID_FILE $NAME + exit $? + ;; + restart|force-reload) + if [ -f "$PID_FILE" ]; then + $0 stop + sleep 1 + fi + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart|force-reload|status}" + exit 3 + ;; +esac diff --git a/network/grafana/slack-desc b/network/grafana/slack-desc new file mode 100644 index 0000000000..b11709c356 --- /dev/null +++ b/network/grafana/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +grafana: grafana (the open-source platform for monitoring and observability) +grafana: +grafana: Easily collect, correlate, and visualize data with beautiful +grafana: dashboards using Grafana, the open source data visualization and +grafana: monitoring solution that drives informed decisions, enhances system +grafana: performance, and streamlines troubleshooting. +grafana: +grafana: Homepage: https://grafana.com/ +grafana: +grafana: +grafana: |