• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    Shell
  • License
    GNU Affero Genera...
  • Created almost 8 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Collection of various Zabbix templates and helper scripts created or used by Radio Bern RaBe

rabe-zabbix

Collection of various Zabbix templates and helper scripts created or used by Radio Bern RaBe.

Zabbix Templates

The Zabbix templates are located within the templates subfolder and are further subdived into the following categories:

  • Operating system (os): All operating system specific templates
    • Naming convention: Template_OS_<OPERATING-SYSTEM-NAME>_active
    • Example: Template_OS_Linux_active
  • Application (app): All application specifc templates
    • Naming convention: Template_App_[<OPERATING-SYSTEM-NAME]_<APPLICATION-NAME>_active
    • Example: Template_App_Linux_Postfix_active
  • IPMI (ipmi): All IPMI based templates
    • Naming convention: Template_IPMI_<NAME>
    • Example: Template_IPMI_Threshold_Sensors
  • SNMP (snmp): All SNMP based templates
    • Naming convention: Template_SNMP<SNMP-VERSION>_<NAME>
    • Example: Template_SNMPv2_Interfaces_HC
  • Stack (stack): Stack templates define a single system (or role) and might inherit further stack templates, or exactly one operating system template as well as multiple application or SNMP templates.
  • Naming convention: Template_Stack_<STACK-NAME>_active
  • Example: Template_Stack_MediaWiki_active

Stack templates explained

Every host within Zabbix gets a specifc stack template assigned according to its role. The stack exactly defines the setup of this host and will be re-used if there is more than one host with the same role.

As an example, a host which servers a MediaWiki instance, will get the stack template Template_Stack_MediaWiki_active assigned. The stack template might include the operating system template Template_OS_Linux_active, the application templates Template_App_Linux_Apache_HTTPD_active, Template_App_Linux_PHP-FPM_active and Template_App_Linux_MariaDB_active.

This ensures great modularity, reusability and avoids unecessary inheritance problems.

Further template conventions

  • Use active mode for zabbix agent items by default
  • Use an update interval of 300 seconds (5 minutes) by default
  • Create at least one unique application per app, ipmi and snmp template
  • Use macros whenever possible and feasible, prefix them with a unique per template prefix

App specific conventions

  • Apps may contain configuration snippets in a userparameters/ subdir.
  • SELinux policy modules for an app are in the selinux/ subdir. They are prefixed with "rabezbx" to help differentiate them from system policy.

IPMI specific conventions

  • Name server or motherboard templates according to IPMI <VENDOR> <PRODUCT-NAME>, for example Template IPMI Supermicro SSG-6048R-E1CR24N
  • Try to build up a server or motherboard template from existing (or newly created) standalone sensor templates (which can be reused for the same sensor and reading type).
  • Standalone sensor templates which contain sensor-specific discrete IPMI sensors (event/reading type code 6Fh)
    • Template naming according to IPMI <SENSOR-NAME> Sensors, for example IPMI Power Supply Sensors
    • Item key naming according to ipmi.discrete-sensor[<SENSOR-TYPE>,<SENSOR-NAME>], for example ipmi.discrete-sensor[power-supply,{#IPMI_SENSOR_NAME}]
    • Create triggers according to the sensor's specific event/reading type code and offsets (see Table 42-3, Sensor Type Codes) with the help of the Zabbix band() function
  • Standalone sensor templates which contain generic discrete IPMI sensors (event/reading type code 02h - 0Ch)
    • Template naming according to IPMI <SENSOR-NAME> Generic Sensors, for example IPMI Module Board Generic Sensors
    • Item key naming according to ipmi.discrete-generic-sensor[<SENSOR-TYPE>,<SENSOR-NAME>], for example ipmi.discrete-generic-sensor[module-board,{#IPMI_SENSOR_NAME}]
    • Create triggers according to the sensor's generic event/reading type code and offsets (see Table 42-2, Generic Event/Reading Type Codes) with the help of the Zabbix band() function
  • Use the provided ipmi-sensor-discovery.sh external check script for low-level auto-discovery of multiple sensors.
  • FreeIPMI's interpret sensor configuration might be helpful for mapping sensor states to Zabbix trigger severities.
  • There should be no more need for threshold based sensor templates (event/reading type code 01h), as they are already handled by the IPMI Threshold Sensors template.

SNMP specific conventions

  • Name SNMP templates according to Template SNMPv<SNMP-VERSION> <NAME>, for example Template SNMPv2 Bridge
  • Try to reflect the MIBs name within <NAME> whenever feasible
  • Use the textual form of MIB OIDs within your SNMP items. As an example, use BRIDGE-MIB::dot1dBaseNumPorts.0 instead of .1.3.6.1.2.1.17.1.2.0
  • Include instructions on how to obtain and install the required MIBs for your template.
  • Name items according to rabe.snmp.<NAME>.<OID-NAME> to avoid clashes with other templates. Example: rabe.snmp.bridge.dot1dBaseNumPorts
  • Name low-level discovery rule keys with rabe.snmp.<NAME>.<OBJECT>.discovery Example: rabe.snmp-bridge.ports.discovery
  • Create value mappings according to the OID's syntax definition from the MIB.

Developing

Adding an app template

appName="" # app name
appURL=""  # URL to the upstream project/software

lowercaseName="${appName,,}"
uppercaseName="${appName^^}"

shortName="${lowercaseName//-/}"

templateName="Template App ${appName} active"
xmlName="${templateName// /_}.xml"

appDir="app/${appName// /_}"

gitBranchName="feature/app-${lowercaseName// /-}"


git checkout -b "${gitBranchName}"
mkdir -p "${appDir}/doc"

# Generate a minimal documentation
cat > "${appDir}/doc/README.head.md" << EOF
Monitoring of [${appName}]($appURL).
EOF

# Extend the documentation as necessary
vi "${appDir}/doc/README.head.md"

# Commit the documentation
git add "${appDir}/doc/README.head.md"
git commit -m "${appName}: Added documentation"


# Export the Zabbix template and move it to the final destination
# see fetching below if you want help exporting
mv zbx_export_templates.xml "${appDir}/${xmlName}"

# Commit the Zabbix template
git add "${appDir}/${xmlName}"
git commit -m "${appName}: Added ${templateName}"

Fetching an app from the Zabbix server

Fetching a template into a file from the server is straightforward.

./helper/rabe-zabbix --template=${templateName} ${xmlName}

You need to have a working node environment and install any dependencies beforehand.

npm install

The helper will prompt for settings should they not be configured. Please see its --help for more information.

optional usage section override

cat > "${appDir}/doc/README.Usage.md" << EOF
## Usage
1. Import the
   [\`${xmlName}\`](${xmlName})
   into your Zabbix server (click on the \`Raw\` button to download).
2. Add the template to your host (or stack template)
3. Check if new data arrives
EOF

vi "${appDir}/doc/README.Usage.md"

git add "${appDir}/doc/README.Usage.md"
git commit -m "${appName}: Added usage section"

optional selinux policy

$avcViolation="" # multiple lines from /var/log/audit/audit.log

moduleName="rabezbx${shortName// /}"

mkdir "${appDir}/selinux"

echo ${avcViolation} | audit2allow -m ${moduleName} > \
  "${appDir}/selinux/${moduleName}.te"

cat > "${appDir}/doc/README.SELinux.md" <<EOD
## SELinux Policy

The [${moduleName}](selinux/${moduleName}.te) policy does <dox>.
EOD


# Commit the SELinux policy and documentation
git add "${appDir}/selinux/${moduleName}.te"
git add "${appDir}/doc/README.SELinux.md"
git commit -e -m "${appName}: Added SELinux module and documentation"

optional userparameters

mkdir "${appDir}/userparameters"

userParameterName="rabe.${lowercaseName// /-}"

cat > "${appDir}/userparameters/${userParameterName}.conf" <<EOD
#
# dox here
#
UserParameter=${userParameterName}.<key>,<script>
EOD

cat > "${appDir}/doc/README.UserParameters.md" <<EOD
## UserParameters

| Key | Description |
| --- | ----------- |
| \`${userParameterName}.<key>\` | <dox> |
EOD


# Commit the userparameters and documentation
git add "${appDir}/userparameters/${userParameterName}.conf"
git add "${appDir}/doc/README.UserParameters.md"
git commit -e -m "${appName}: Added user parameters and docs."

optional scripts

mkdir "${appDir}/scripts"

scriptName="rabe-${lowercaseName// /-}.sh"

touch "${appDir}/scripts/${scriptName}"

cat > "${appDir}/doc/README.scripts.md" <<EOD
## Scripts

* [${scriptName}](./scripts/${scriptName}) for ${userParameterName}.<key> UserParameter

<dox below listing if needed>
EOD

# Commit the scripts and documentation
git add "${appDir}/scripts/*"
git add "${appDir}/doc/README.scripts.md"
git commit -e -m "${appName}: Added scripts and docs."

optional Sudo security policies

mkdir "${appDir}/sudoers.d"

sudoersFileName="rabezbx-${lowercaseName// /_}"
sudoersCmndAliasPrefix="RABEZBX_${uppercaseName//[ -]/_}"

cat > "${appDir}/sudoers.d/${sudoersFileName}" << EOF
##
## Defaults specification for the zabbix user
##
Defaults:zabbix !requiretty

##
## Command alias specifications for ${appName}
##
Cmnd_Alias ${sudoersCmndAliasPrefix}_MYCMD = /sbin/mycmd -a -b -c
Cmnd_Alias ${sudoersCmndAliasPrefix}_MYOTHERCMD = /sbin/myothercmd

##
## User privilege specifications for the zabbix user
##
zabbix ALL=NOPASSWD: ${sudoersCmndAliasPrefix}_MYCMD
zabbix ALL=NOPASSWD: ${sudoersCmndAliasPrefix}_MYOTHERCMD
EOF


# Commit the sudo configuration snippet
git add "${appDir}/sudoers.d/${sudoersFileName}"
git commit -e -m "${appName}: Added sudoers config."

Adapt the MYCMD and MYOTHERMCD command aliases accordingly.

Generate the template documentation and push

As a final step you have to generate the template configuration and push to GitHub afterwards.

# Generate the template documentation
make update-app-doc
git add "${appDir}/README.md"
git commit -m "${appName}: Added generated documentation"

# Push and create a PR on GitHub afterwards
git push --set-upstream origin "${gitBranchName}"

Adding an OS template

osName="" # Operating system name

lowercaseName="${osName,,}"
gitBranchName="feature/os-${lowercaseName// /-}"

git checkout -b "${gitBranchName}"

templateName="Template OS ${osName}"
xmlName="${templateName// /_}.xml"

osDir="os/${osName// /_}"


mkdir -p "${osDir}/doc"
touch "${osDir}/doc/README.head.md"

# Write the documentation for your template
vi "${osDir}/doc/README.head.md"

git add "${osDir}/doc/README.head.md"
git commit -m "${osName}: Added documentation"


# Export the Zabbix template and move it to the final destination
mv zbx_export_templates.xml "${osDir}/${xmlName}"

git add "${osDir}/${xmlName}"
git commit -m "${osName}: Added ${templateName}"


# Generate the template documentation
make update-os-doc
git add "${osDir}/README.md"
git commit -m "${osName}: Added generated documentation"


# Push and create a PR on GitHub afterwards
git push --set-upstream origin "${gitBranchName}"

optional usage section override

cat > "${osDir}/doc/README.Usage.md" << EOF
## Usage
EOF

vi "${osDir}/doc/README.Usage.md"

git add "${osDir}/doc/README.Usage.md"
git commit -m "${osName}: Added usage section"

Adding an IPMI template

ipmiName="" # IPMI sensor, board or server name

lowercaseName="${ipmiName,,}"

templateName="Template IPMI ${ipmiName}"
xmlName="${templateName// /_}.xml"

ipmiDir="ipmi/${ipmiName// /_}"

mkdir -p "${ipmiDir}/doc"
touch "${ipmiDir}/doc/README.head.md"

mv zbx_export_templates.xml "${ipmiDir}/${xmlName}"

optional usage section override

cat > "${ipmiDir}/doc/README.Usage.md" << EOF
## Usage
EOF

vi "${ipmiDir}/doc/README.Usage.md"

git add "${ipmiDir}/doc/README.Usage.md"
git commit -m "${ipmiName}: Added usage section"

optional scripts

scriptName="ipmi-${lowercaseName// /-}"

mkdir -p "${ipmiDir}/scripts"

touch "${ipmiDir}/scripts/${scriptName}.sh"

cat > "${ipmiDir}/doc/README.scripts.md" <<EOD
## Scripts

* [${scriptName}.sh](./scripts/${scriptName}.sh) <short description>

<dox below listing if needed>
EOD

Adding an SNMP template

snmpName=""       # Name, usually related to the MIB or device
snmpVersion="2"   # SNMP version, 1, 2 or 3.
snmpDeviceURL=""  # URL to the device (if any)
snmpMibURL=""     # URL to the MIB (if any)

lowercaseName="${snmpName,,}"

templateName="Template SNMPv${snmpVersion} ${snmpName}"
xmlName="${templateName// /_}.xml"

snmpDir="snmp/SNMPv${snmpVersion}_${snmpName// /_}"

gitBranchName="feature/snmp-${lowercaseName// /-}"

git checkout -b "${gitBranchName}"
mkdir -p "${snmpDir}/doc"
touch "${snmpDir}/doc/README.head.md"


# Generate a minimal documentation
cat > "${snmpDir}/doc/README.head.md" << EOF
<DEVICE-SPECIFIC-EXAMPLE>
Monitoring of [${snmpName}](${snmpDeviceURL})
devices via SNMPv${snmpVersion}
</DEVICE-SPECIFIC-EXAMPLE

<MIB-SPECIFIC-EXAMPLE>
Monitors <EXAMPLE> parameters exposed by the
[\`<EXAMPLE-MIB>\`](${snmpMibURL}) via SNMPv${snmpVersion}
</MIB-SPECIFIC-EXAMPLE>
EOF

cat > "${snmpDir}/doc/README.Usage.md" << EOF
## Usage
1. Download the [<EXAMPLE-MIB>](${snmpMibURL})
2. Place the MIB file(s) into your default MIB directory on the Zabbix server
   and/or proxy (usually \`/usr/local/share/snmp/mibs\`) and make sure that the
   Zabbix server and/or proxy loads them (see [Using and loading
   MIBs](http://www.net-snmp.org/wiki/index.php/TUT:Using_and_loading_MIBS)).
3. Import the
   [\`${xmlName}\`](${xmlName})
   into your Zabbix server (click on the \`Raw\` button to download).
4. Add an SNMP interface configuration to your host
5. Set the \`{$SNMP_COMMUNITY}\` macro to your desired community if you don't
   use \`public\`
6. Add the template to your host (or stack template)
7. Check if new data arrives

## Notes
### snmpwalk command
The following \`snmpwalk\` command might be helpful for debugging:
\`\`\`bash
# Include and adapt me for SNMP version 1 or 2c
snmpwalk -v <1|2c> -c public <HOST> <EXAMPLE-MIB::OID>

# Include and adapt me for SNMP version 3
snmpwalk -v 3 -l <noAuthNo‐Priv|authNoPriv|authPriv> \\
         [-a <MD5|SHA> -A <AUTH-PASSPHRASE> \\
         [-x <DES|AES> -X <PRIV-PASSPHRASE>]] \\
         <HOST> <EXAMPLE-MIB::OID>
\`\`\`
EOF

# Adapt and extend the documentation as necessary
vi "${snmpDir}/doc/README.head.md"
vi "${snmpDir}/doc/README.Usage.md"

# Commit the documentation
git add "${snmpDir}/doc/README.head.md"
git add "${snmpDir}/doc/README.Usage.md"
git commit -m "${snmpName}: Added documentation"


# Export the Zabbix template and move it to its final destination
mv zbx_export_templates.xml "${snmpDir}/${xmlName}"

# Commit the Zabbix template
git add "${snmpDir}/${xmlName}"
git commit -m "${snmpName}: Added ${templateName}"


# Generate the template documentation
make update-snmp-doc
git add "${snmpDir}/README.md"
git commit -m "${snmpName}: Added generated documentation"

# Push and create a PR on GitHub afterwards
git push --set-upstream origin "${gitBranchName}"

Note, that you can also use the provided template fetching helper script for downloading the template from your Zabbix server.

Debugging

The following commands might be helpful for general debugging:

  • Test a specific Zabbix agent item
    su -c 'zabbix_agentd -t <ITEM-KEY>' -s /bin/bash zabbix
  • Restart the Zabbix agent
    systemctl restart zabbix-agent
  • Restart the Zabbix server
    systemctl restart zabbix-server

The following logs might contain helpful hints:

  • Zabbix Agent related messages
    /var/log/zabbix/zabbix_agentd.log
  • Zabbix Server related messages
    /var/log/zabbix/zabbix_server.log
  • sudo related messages
    journalctl -r /usr/bin/sudo
  • SELinux related messages
    /var/log/audit/audit.log

RPM Packages

The rabe-zabbix templates come with an RPM package that helps install SELinux policies and UserParameter configs. We provide a pre-built version through the openSUSE Build Server. They are available as part of the home:radiorabe:zabbix Subproject. You can install them as follows.

curl -o /etc/yum.repos.d/home:radiorabe:zabbix.repo \
     http://download.opensuse.org/repositories/home:/radiorabe:/zabbix/CentOS_7/home:radiorabe:zabbix.repo

yum install rabe-zabbix

Releasing

  • Bump the version in the Specfile and add a new commit to master with the version bump
  • Tag this commit with the same version you used in the Specfile
  • Push master and the tag to github
  • The openSUSE Build Service should get triggered and build a new package automagically

License

This template collection is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.

Copyright

Copyright (c) 2017 - 2019 Radio Bern RaBe

More Repositories

1

raar

RAAR is a ruby application to manage and browse an audio archive.
Ruby
20
star
2

freeipa-extending-ldap-schema-and-ui

An example to extend freeipa with custom attributes which can be configured through cli or web ui by an example for Owncloud/Nextcloud.
Python
17
star
3

docker-mediawiki

Opinionated Semantic Wiki Installation for Radio Bern RaBe
PHP
11
star
4

klangbecken

Klangbecken: The RaBe Endless Music Player
Python
10
star
5

centos-rpm-liquidsoap

RaBe Liquidsoap Distribution for CentOS 8 & Fedora (RaBe-LSD)
Shell
9
star
6

axia-pathfinder-client

Python
7
star
7

raar-ui

Web client for RAAR
TypeScript
6
star
8

systemd-axia-alsa

systemd service units and udev rules for AXIA - ALSA
Makefile
5
star
9

dabplus-on-air-processing

Liquidsoap based DAB+ on air processing solution
Makefile
4
star
10

freeipa-import-script

Python
4
star
11

raar_acr_tracks_importer

Fetch tracks recognized by ACR Cloud and import them into raar
Ruby
3
star
12

motd-ansi

RaBe logos in beautiful ANSI format to use as motd
Makefile
3
star
13

klangbecken-ui

Klangbecken User Interface
Vue
3
star
14

backup

Backup process and automation scripts
Shell
3
star
15

centos-rpm-motion

CentOS 7 RPM Specfile for Motion Project
3
star
16

docker-liquidsoap

Dockerfile for liquidsoap
Dockerfile
2
star
17

wordpress-theme-rabe

Wordpress theme of Radio Bern (RaBe)
PHP
2
star
18

rabe-icecast-theme

Radio Bern RaBe Icecast theme
XSLT
2
star
19

ipxe

CentOS 7 iPXE HTTP installation via text mode over serial console
2
star
20

acr-webhook-receiver

PoC: receive data from ACRCloud webhooks at all times
Go
2
star
21

roaming-homes

Roaming homes/profiles for linux with unison
Python
2
star
22

cat-page

overengineered intranet landing page with a cat
Python
2
star
23

acr-ingest

Ingest daily ACRCloud data dumps
Python
1
star
24

centos-rpm-butt

CentOS 7 RPM Specfile for butt
Shell
1
star
25

centos-rpm-ocaml-magic

CentOS 7 RPM Specfile for ocaml-magic
Shell
1
star
26

cordova-app

cordova based mobile app prototype
Java
1
star
27

nowplaying

Songticker πŸ¦‰
Python
1
star
28

raar-admin-ui

Web client for RAAR admin area
TypeScript
1
star
29

travis-ex-docker-liquidsoap-linting

Demonstrate linting a liquidsoap script on travis-ci 𝓉𝒽𝑒 𝓇𝒾𝑔𝒽𝓉 π“Œπ’Άπ“Žβ„’οΈ
1
star
30

kanboard-theme-rabe

RaBe Theme for Kanboard
CSS
1
star
31

puppet

Ruby
1
star
32

ansible-collection-foreman

Foreman roles and playbooks
1
star
33

raar_show_descriptor

Store missing show descriptions from the rabe.ch website into archiv.rabe.ch
Ruby
1
star
34

centos-rpm-fdk-aac-dabplus-odr

CentOS 7 RPM Specfile for Opendigitalradio's fork of fdk-aac-dabplus
1
star
35

owncloud-theme-rabe

Theme for RaBe ownCloud
CSS
1
star
36

centos-rpm-bs1770gain

1
star
37

suisa_sendemeldung

ACRCloud client for SUISA reporting @ RaBe.
Python
1
star
38

raar_feed_descriptor

Store descriptions for certain shows from the rabe.ch website feed into archiv.rabe.ch.
Ruby
1
star
39

ansible-collection-rabe_foreman

GitOps our Foreman
Jinja
1
star
40

actions

Reusable Actions, like for GitHub (thanks for reading this description, here's a birb zoo for you: πŸ¦πŸ¦‰πŸ¦œπŸ€)
1
star
41

centos-rpm-unison251

CentOS 7 RPM Specfile for modern 25.1.x Unison
1
star