From 63192712ed2ba8b87cf7016d9e42ddc2a4f4c5a6 Mon Sep 17 00:00:00 2001 From: "Stanislav N. aka pztrn" Date: Mon, 21 Dec 2020 20:40:26 +0500 Subject: [PATCH] Move apps-related templates to applications dir and add yggdrasil template and helpers. --- .../mysql/generic/README.md | 0 .../mysql/generic/mysql-generic.xml | 0 .../{ => applications}/mysql/innodb/README.md | 0 .../mysql/innodb/mysql-innodb.xml | 0 .../{ => applications}/mysql/myisam/README.md | 0 .../mysql/myisam/mysql-myisam.xml | 0 .../{ => applications}/postgresql/README.md | 0 .../postgresql/postgresql.xml | 0 .../README.md | 0 .../helper_script.sh | 0 .../monitor-by-processestomonitor-list.xml | 0 templates/applications/yggdrasil/README.md | 27 ++++ .../applications/yggdrasil/yggdrasil.xml | 123 ++++++++++++++++++ .../applications/yggdrasil/yggdrasil_peers.sh | 9 ++ .../yggdrasil/yggdrasil_traffic.sh | 34 +++++ 15 files changed, 193 insertions(+) rename templates/{ => applications}/mysql/generic/README.md (100%) rename templates/{ => applications}/mysql/generic/mysql-generic.xml (100%) rename templates/{ => applications}/mysql/innodb/README.md (100%) rename templates/{ => applications}/mysql/innodb/mysql-innodb.xml (100%) rename templates/{ => applications}/mysql/myisam/README.md (100%) rename templates/{ => applications}/mysql/myisam/mysql-myisam.xml (100%) rename templates/{ => applications}/postgresql/README.md (100%) rename templates/{ => applications}/postgresql/postgresql.xml (100%) rename templates/{ => applications}/processes/monitor-by-processestomonitor-list/README.md (100%) rename templates/{ => applications}/processes/monitor-by-processestomonitor-list/helper_script.sh (100%) rename templates/{ => applications}/processes/monitor-by-processestomonitor-list/monitor-by-processestomonitor-list.xml (100%) create mode 100644 templates/applications/yggdrasil/README.md create mode 100644 templates/applications/yggdrasil/yggdrasil.xml create mode 100644 templates/applications/yggdrasil/yggdrasil_peers.sh create mode 100644 templates/applications/yggdrasil/yggdrasil_traffic.sh diff --git a/templates/mysql/generic/README.md b/templates/applications/mysql/generic/README.md similarity index 100% rename from templates/mysql/generic/README.md rename to templates/applications/mysql/generic/README.md diff --git a/templates/mysql/generic/mysql-generic.xml b/templates/applications/mysql/generic/mysql-generic.xml similarity index 100% rename from templates/mysql/generic/mysql-generic.xml rename to templates/applications/mysql/generic/mysql-generic.xml diff --git a/templates/mysql/innodb/README.md b/templates/applications/mysql/innodb/README.md similarity index 100% rename from templates/mysql/innodb/README.md rename to templates/applications/mysql/innodb/README.md diff --git a/templates/mysql/innodb/mysql-innodb.xml b/templates/applications/mysql/innodb/mysql-innodb.xml similarity index 100% rename from templates/mysql/innodb/mysql-innodb.xml rename to templates/applications/mysql/innodb/mysql-innodb.xml diff --git a/templates/mysql/myisam/README.md b/templates/applications/mysql/myisam/README.md similarity index 100% rename from templates/mysql/myisam/README.md rename to templates/applications/mysql/myisam/README.md diff --git a/templates/mysql/myisam/mysql-myisam.xml b/templates/applications/mysql/myisam/mysql-myisam.xml similarity index 100% rename from templates/mysql/myisam/mysql-myisam.xml rename to templates/applications/mysql/myisam/mysql-myisam.xml diff --git a/templates/postgresql/README.md b/templates/applications/postgresql/README.md similarity index 100% rename from templates/postgresql/README.md rename to templates/applications/postgresql/README.md diff --git a/templates/postgresql/postgresql.xml b/templates/applications/postgresql/postgresql.xml similarity index 100% rename from templates/postgresql/postgresql.xml rename to templates/applications/postgresql/postgresql.xml diff --git a/templates/processes/monitor-by-processestomonitor-list/README.md b/templates/applications/processes/monitor-by-processestomonitor-list/README.md similarity index 100% rename from templates/processes/monitor-by-processestomonitor-list/README.md rename to templates/applications/processes/monitor-by-processestomonitor-list/README.md diff --git a/templates/processes/monitor-by-processestomonitor-list/helper_script.sh b/templates/applications/processes/monitor-by-processestomonitor-list/helper_script.sh similarity index 100% rename from templates/processes/monitor-by-processestomonitor-list/helper_script.sh rename to templates/applications/processes/monitor-by-processestomonitor-list/helper_script.sh diff --git a/templates/processes/monitor-by-processestomonitor-list/monitor-by-processestomonitor-list.xml b/templates/applications/processes/monitor-by-processestomonitor-list/monitor-by-processestomonitor-list.xml similarity index 100% rename from templates/processes/monitor-by-processestomonitor-list/monitor-by-processestomonitor-list.xml rename to templates/applications/processes/monitor-by-processestomonitor-list/monitor-by-processestomonitor-list.xml diff --git a/templates/applications/yggdrasil/README.md b/templates/applications/yggdrasil/README.md new file mode 100644 index 0000000..8e3fe07 --- /dev/null +++ b/templates/applications/yggdrasil/README.md @@ -0,0 +1,27 @@ +# Yggdrasil monitoring things + +This directory contains everything you need to monitor status of your Yggdrasil +node. + +## Helper scripts + +There are two helper scripts that should be placed somewhere. Don't forget about +`+x`! + +* yggdrasil_peers.sh - returns number of connected peers. +* yggdrasil_traffic.sh - returns traffic calculation. Accepts `incoming` or `outgoing` +as first parameter. + +Both scripts use `yggdrasilctl` binary and parse it's output. + +## Configure nxagent + +Add this to `/etc/nxagentd.conf`: + +``` +ExternalParameterShellExec=Yggdrasil.GetBytesReceived():/usr/local/bin/yggdrasil_traffic.sh incoming +ExternalParameterShellExec=Yggdrasil.GetBytesSent():usr/local/bin/yggdrasil_traffic.sh outgoing +ExternalParameterShellExec=Yggdrasil.GetConnectedPeersCount():/usr/local/bin/yggdrasil_peers.sh +``` + +**Don't forget to restart NetXMS agent!** diff --git a/templates/applications/yggdrasil/yggdrasil.xml b/templates/applications/yggdrasil/yggdrasil.xml new file mode 100644 index 0000000..1574acb --- /dev/null +++ b/templates/applications/yggdrasil/yggdrasil.xml @@ -0,0 +1,123 @@ + + + 4 + + 3.6.300 + 3.6-300-g287f599693 + Linux 4.19.0-13-amd64 + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/applications/yggdrasil/yggdrasil_peers.sh b/templates/applications/yggdrasil/yggdrasil_peers.sh new file mode 100644 index 0000000..78600bb --- /dev/null +++ b/templates/applications/yggdrasil/yggdrasil_peers.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +YGGDRASIL=$(which yggdrasilctl) + +if [ "${YGGDRASIL}" == "" ]; then + exit 1 +fi + +echo $[ $(${YGGDRASIL} getpeers | wc -l) - 1 ] diff --git a/templates/applications/yggdrasil/yggdrasil_traffic.sh b/templates/applications/yggdrasil/yggdrasil_traffic.sh new file mode 100644 index 0000000..ed998de --- /dev/null +++ b/templates/applications/yggdrasil/yggdrasil_traffic.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +YGGDRASIL=$(which yggdrasilctl) +if [ "${YGGDRASIL}" == "" ]; then + exit 1 +fi + +incoming=0 +outgoing=0 + +KNOWN=$(${YGGDRASIL} getpeers | tail -n +2) + +export IFS=$'\n' +for line in ${KNOWN[@]}; do + if [ "$1" == "incoming" ]; then + incoming=$[ ${incoming}+$(echo ${line} | awk {' print $2 '}) ] + fi + + if [ "$1" == "outgoing" ]; then + outgoing=$[ ${outgoing}+$(echo ${line} | awk {' print $3 '}) ] + fi +done + +case $1 in + incoming) + echo $incoming + ;; + outgoing) + echo $outgoing + ;; + *) + echo "First parameter should be 'incoming' or 'outgoing'!" + ;; +esac