diff options
author | zux | 2024-03-15 14:30:29 +0100 |
---|---|---|
committer | Willy Sudiarto Raharjo | 2024-03-22 15:14:34 +0100 |
commit | f9af490972d0ccc9912ee7283309a3d7c3488421 (patch) | |
tree | 9c021d8384f0939b483f339a516367a14b414d8b | |
parent | 4d19d94646bb151a84d8ed75e86e7cdf0eff017b (diff) | |
download | slackbuilds-f9af490972d0ccc9912ee7283309a3d7c3488421.tar.gz |
network/zabbix_agent2: Added (new generation of Zabbix agent).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Signed-off-by: Andrew Clemons <andrew.clemons@gmail.com>
-rw-r--r-- | network/zabbix_agent2/README | 19 | ||||
-rw-r--r-- | network/zabbix_agent2/README.SLACKWARE | 75 | ||||
-rw-r--r-- | network/zabbix_agent2/doinst.sh | 28 | ||||
-rw-r--r-- | network/zabbix_agent2/rc.zabbix_agent2 | 78 | ||||
-rw-r--r-- | network/zabbix_agent2/slack-desc | 19 | ||||
-rw-r--r-- | network/zabbix_agent2/zabbix_agent2.SlackBuild | 168 | ||||
-rw-r--r-- | network/zabbix_agent2/zabbix_agent2.info | 10 |
7 files changed, 397 insertions, 0 deletions
diff --git a/network/zabbix_agent2/README b/network/zabbix_agent2/README new file mode 100644 index 0000000000..e5f26a7986 --- /dev/null +++ b/network/zabbix_agent2/README @@ -0,0 +1,19 @@ +zabbix_agent2 is the new generation Linux agent written on golang. +Used to monitor Linux boxes and send the data to the zabbix server. + +Zabbix offers advanced monitoring, alerting and visualization +features, including distributed monitoring, auto-discovery, +notifications, etcetera. + +zabbix_agent2 needs to run under its own user/group. This has been +assigned to the following by SlackBuilds.org, but feel free to change +it on your system for consistency with local assignments. + User: zabbixagent UID: 266 GID: 266 + group: zabbixagent GID: 266 + +You can pass alternate values for the user and group using +ZABBIXAGENTUSER and ZABBIXAGENTGROUP variables when running the build +script. + +For some important post-build and basic configuration instructions, +see the included README.SLACKWARE file. diff --git a/network/zabbix_agent2/README.SLACKWARE b/network/zabbix_agent2/README.SLACKWARE new file mode 100644 index 0000000000..13fd88d3e8 --- /dev/null +++ b/network/zabbix_agent2/README.SLACKWARE @@ -0,0 +1,75 @@ +README.Slackware +================ + +This file contains some specific instructions to complete the +installation of zabbix_agent2 on Slackware. + +0) Before running the SlackBuild script +--------------------------------------- + +0.1) zabbix group & user + +Before running the zabbix_agent2.SlackBuild script, you will need to create +the 'zabbix' user and group as well as 'zabbixagent' user. The script won't +run if these do not exist. + +The suggested UID and GID is 228 for 'zabbix' and 266 for 'zabbixagent', +but you can change this as needed: + + # groupadd -g 228 zabbix + # useradd -u 266 -g zabbix -d /dev/null -s /bin/false zabbixagent + +1) Configuring zabbix_agent2 +---------------------------- + +A standard configuration file is installed as /etc/zabbix/zabbix_agent2.conf + +At least the following lines need to be configured: + For passive checks: + Server=<ip_of_your_zabbix_server> + For active checks + Hostname=<hostname_of_your_zabbix_agent> + ServerActive=<ip_of_your_zabbix_server> + +2) Start & Stop scripts for zabbix agent daemon +----------------------------------------------- + +2.1) Automatic startup and shutdown + +If you want to start zabbix_agent2 on system bootup, include these lines in +your /etc/rc.d/rc.local: + + # Start zabbix_agent2 + if [ -x /etc/rc.d/rc.zabbix_agent2]; then + echo "Starting zabbix agent daemon..." + /etc/rc.d/rc.zabbix_agent2 start + fi + +To guarantee a clean shutdown of zabbix_agent2, include this in +/etc/rc.d/rc.local_shutdown: + + # Stop zabbix_agent2 + if [ -x /etc/rc.d/rc.zabbix_agent2 ]; then + echo "Stopping zabbix agent daemon..." + /etc/rc.d/rc.zabbix_agent2 stop + fi + +2.2) Make /etc/rc.d/rc.zabbix_agent2 executable + +Additionally, you'll have to set the rc script to be executable just like +any other Slackware rc script: + + # chmod +x /etc/rc.d/rc.zabbix_agent2 + +3) Starting zabbix agent daemon +------------------------------- + +Now you are ready to start zabbix_agent2 by calling the startup script: + + # /etc/rc.d/rc.zabbix_agent2 start + +You can check the log file (/var/log/zabbix/zabbig_agent2.log) in case of +problems. + +Zabbix uses ports 10050 & 10051 to communicate, so make sure these aren't +blocked on your network. diff --git a/network/zabbix_agent2/doinst.sh b/network/zabbix_agent2/doinst.sh new file mode 100644 index 0000000000..21efb95b2d --- /dev/null +++ b/network/zabbix_agent2/doinst.sh @@ -0,0 +1,28 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +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 +} + +preserve_perms etc/rc.d/rc.zabbix_agent2.new +config etc/zabbix/zabbix_agent2.conf.new +config var/log/zabbix/zabbix_agent2.log.new +rm -f var/log/zabbix/zabbix_agent2.log.new diff --git a/network/zabbix_agent2/rc.zabbix_agent2 b/network/zabbix_agent2/rc.zabbix_agent2 new file mode 100644 index 0000000000..842014dfe8 --- /dev/null +++ b/network/zabbix_agent2/rc.zabbix_agent2 @@ -0,0 +1,78 @@ +#!/bin/sh + +# Usage: ./rc.zabbix_agent2 {start|stop|restart} + +PRGNAM=zabbix_agent2 +PRGDIR=/usr/sbin/ +PIDDIR=/var/run/zabbixagent/ +LOGDIR=/var/log/zabbix/ +DATE=$(date +%a\ %b\ %d\ %T\ %Y) +RETVAL=0 + +prg_start() { + echo -n "Starting $PRGNAM ... " + if [ -r ${PIDDIR}${PRGNAM}.pid ]; then + if $(! /sbin/pidof $PRGNAM > /dev/null 2>&1 ) ; then + echo "Removing an old ${PIDDIR}${PRGNAM}.pid" + rm -f ${PIDDIR}${PRGNAM}.pid + fi + fi + mkdir -p ${PIDDIR} + su -s /bin/sh -c "${PRGDIR}${PRGNAM} >> ${LOGDIR}${PRGNAM}.log 2>&1 &" @ZABBIXAGENTUSER@ + RETVAL=$? + + if [ $RETVAL -eq 0 ]; then + touch /var/lock/$PRGNAM + sleep 2 + echo "done" + else + echo "failed" + fi + return $RETVAL +} + +prg_stop() { + echo -n "Stopping $PRGNAM ... " + if [ -r ${PIDDIR}${PRGNAM}.pid ]; then + killall $PRGNAM + # Give it some time to die gracefully + for second in 0 1 2 3 4 5 6 7 8 9 10 ; do + if $(! /sbin/pidof $PRGNAM > /dev/null 2>&1 ) ; then + rm -f ${PIDDIR}${PRGNAM}.pid + break; + fi + sleep 1 + done + + if [ "$second" = "10" ]; then + echo "\nWARNING: $PRGNAM did not exit!" + sleep 10 + else + echo "$DATE EXIT: $PRGNAM stopped by user: $USER (UID: $EUID)" >> ${LOGDIR}${PRGNAM}.log + echo "done" + fi + fi + rm -f /var/lock/$PRGNAM + return $RETVAL +} + +# How were we called: +case "$1" in + start) + prg_start + ;; + stop) + prg_stop + ;; + restart|reload) + prg_stop + # Wait a few seconds before restarting + sleep 10 + prg_start + ;; + *) + echo "Usage: $(basename $0) {start|stop|restart}" + RETVAL=1 +esac + +#EOF diff --git a/network/zabbix_agent2/slack-desc b/network/zabbix_agent2/slack-desc new file mode 100644 index 0000000000..459d342ebf --- /dev/null +++ b/network/zabbix_agent2/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------------------------------------------------------| +zabbix_agent2: zabbix_agent2 (Linux GO agent for zabbix_server) +zabbix_agent2: +zabbix_agent2: Zabbix offers advanced monitoring, alerting and visualization +zabbix_agent2: features, including distributed monitoring, auto-discovery, +zabbix_agent2: notifications etc. +zabbix_agent2: +zabbix_agent2: This is the new agent2 daemon that communicates with the +zabbix_agent2: zabbix_server for local resource monitoring. +zabbix_agent2: +zabbix_agent2: https://www.zabbix.com/ +zabbix_agent2: diff --git a/network/zabbix_agent2/zabbix_agent2.SlackBuild b/network/zabbix_agent2/zabbix_agent2.SlackBuild new file mode 100644 index 0000000000..60f61016f1 --- /dev/null +++ b/network/zabbix_agent2/zabbix_agent2.SlackBuild @@ -0,0 +1,168 @@ +#!/bin/bash + +# Slackware build script for zabbix_agent2 + +# Copyright 2013-2014 Michal Bialozor, Gdansk, Pomorskie, POLAND +# 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=zabbix_agent2 +VERSION=${VERSION:-6.4.11} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i586 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +PRGSHORT=zabbix + +# ZABBIXUSER is owner of log directory, this is required for running the agent on the same host as server +ZABBIXUSER=${ZABBIXUSER:-zabbix} +ZABBIXGROUP=${ZABBIXGROUP:-zabbix} +ZABBIXUID=${ZABBIXUID:-228} +ZABBIXGID=${ZABBIXGID:-228} + +ZABBIXAGENTUSER=${ZABBIXAGENTUSER:-zabbixagent} +ZABBIXAGENTGROUP=${ZABBIXAGENTGROUP:-zabbixagent} +ZABBIXAGENTUID=${ZABBIXAGENTUID:-266} +ZABBIXAGENTGID=${ZABBIXAGENTGID:-266} + +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +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 + +# Bail out if user or group isn't valid on your system +# For slackbuilds.org, assigned zabbixagent uid/gid are 266/266 and assigned zabbix uid/gid are 228/228 +# See http://slackbuilds.org/uid_gid.txt +if [ "$(grep ^$ZABBIXAGENTUSER: /etc/passwd)" = "" -o "$(grep ^$ZABBIXAGENTUSER: /etc/passwd)" = "" -o \ + "$(grep ^$ZABBIXGROUP: /etc/group)" = "" ] ; then + echo " You must have a \"$ZABBIXGROUP\" group as well as \"$ZABBIXUSER\" and \"$ZABBIXAGENTUSER\" users to run this script." + echo " # groupadd -g $ZABBIXGID $ZABBIXGROUP" + echo " # useradd -u $ZABBIXUID -g $ZABBIXGROUP -d /dev/null -s /bin/false $ZABBIXUSER" + echo " # useradd -u $ZABBIXAGENTUID -g $ZABBIXGROUP -d /dev/null -s /bin/false $ZABBIXAGENTUSER" + exit 1 +fi + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGSHORT-$VERSION +tar xvf $CWD/$PRGSHORT-$VERSION.tar.gz +cd $PRGSHORT-$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 {} \; + +CFLAGS="$SLKCFLAGS" \ +CXXFLAGS="$SLKCFLAGS" \ +./configure \ + --prefix=/usr \ + --sysconfdir=/etc/zabbix \ + --localstatedir=/var/lib \ + --mandir=/usr/man \ + --docdir=/usr/doc/$PRGNAM-$VERSION \ + --libdir=/usr/lib${LIBDIRSUFFIX} \ + --with-libpcre2 \ + --enable-agent2 \ + --with-openssl \ + --enable-ipv6 \ + --build=$ARCH-slackware-linux + +make +make install DESTDIR=$PKG + +find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ + | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + +find $PKG/usr/man -type f -exec gzip -9 {} \; +for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done + +# Initial log file +mkdir -p $PKG/var/log/$PRGSHORT +chown $ZABBIXUSER:$ZABBIXGROUP $PKG/var/log/$PRGSHORT +chmod g+w $PKG/var/log/$PRGSHORT +#touch $PKG/var/log/$PRGSHORT/$PRGNAM.log.new +#chown $ZABBIXAGENTUSER:$ZABBIXUSER $PKG/var/log/$PRGSHORT/$PRGNAM.log.new + +# Dir for pid-file +mkdir -p $PKG/var/run/$PRGNAM +chown -R $ZABBIXAGENTUSER:$ZABBIXGROUP $PKG/var/run/$PRGNAM +chmod g+w $PKG/var/run/$PRGNAM + +# Configuration file +sed -e "s,# PidFile=/tmp/zabbix_agent2.pid,PidFile=/var/run/$PRGNAM/zabbix_agent2.pid," \ + -e "s,# LogFile=/tmp/zabbix_agent2.log,LogFile=/var/log/$PRGSHORT/$PRGNAM.log," \ + -e "s,Include=./zabbix_agent2.d/plugins.d/\*.conf,Include=/etc/$PRGSHORT/zabbix_agent2.d/plugins.d/*.conf," \ + $PKG/etc/$PRGSHORT/$PRGNAM.conf > $PKG/etc/$PRGSHORT/$PRGNAM.conf.new +# remove uneeded old agent conf +rm -rf $PKG/etc/$PRGSHORT/zabbix_agentd.* $PKG/etc/$PRGSHORT/$PRGNAM.d/ $PKG/etc/$PRGSHORT/$PRGNAM.conf + +# Init script +mkdir -p $PKG/etc/rc.d +sed "s|@ZABBIXAGENTUSER@|$ZABBIXAGENTUSER|" $CWD/rc.$PRGNAM > $PKG/etc/rc.d/rc.$PRGNAM.new + +# Documentation +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a AUTHORS COPYING ChangeLog NEWS README $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 + +# Installation scripts +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/zabbix_agent2/zabbix_agent2.info b/network/zabbix_agent2/zabbix_agent2.info new file mode 100644 index 0000000000..051d035e6d --- /dev/null +++ b/network/zabbix_agent2/zabbix_agent2.info @@ -0,0 +1,10 @@ +PRGNAM="zabbix_agent2" +VERSION="6.4.11" +HOMEPAGE="https://www.zabbix.com" +DOWNLOAD="https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.11.tar.gz" +MD5SUM="c1bac67a0d6b9d0d4376ca8176f327a9" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="google-go-lang" +MAINTAINER="zux" +EMAIL="zux@pie-dabas.net" |