Move apps-related templates to applications dir and add yggdrasil template and helpers.

This commit is contained in:
Stanislav Nikitin 2020-12-21 20:40:26 +05:00
parent dd7c04e67a
commit 63192712ed
Signed by: pztrn
GPG Key ID: 1E944A0F0568B550
15 changed files with 193 additions and 0 deletions

View File

@ -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!**

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<formatVersion>4</formatVersion>
<server>
<version>3.6.300</version>
<buildTag>3.6-300-g287f599693</buildTag>
<operatingSystem>Linux 4.19.0-13-amd64</operatingSystem>
</server>
<description></description>
<events>
</events>
<templates>
<template id="542">
<guid>cde6ca5a-ea94-4c50-a67b-432f4af86def</guid>
<name>Yggdrasil</name>
<flags>0</flags>
<comments></comments>
<path>
<element id="1">Applications</element>
</path>
<dataCollection>
<dci id="5401">
<guid>4dcbdcd8-6a16-4f28-a6cc-1e6eee90365e</guid>
<name>Yggdrasil.GetBytesReceived()</name>
<description>Yggdrasil: bytes received</description>
<dataType>8</dataType>
<samples>0</samples>
<origin>1</origin>
<scheduleType>0</scheduleType>
<interval></interval>
<retentionType>0</retentionType>
<retention></retention>
<instance></instance>
<systemTag></systemTag>
<delta>2</delta>
<flags>0</flags>
<snmpRawValueType>0</snmpRawValueType>
<snmpPort>0</snmpPort>
<snmpVersion>127</snmpVersion>
<instanceDiscoveryMethod>0</instanceDiscoveryMethod>
<instanceRetentionTime>-1</instanceRetentionTime>
<comments></comments>
<isDisabled>false</isDisabled>
<transformation></transformation>
<perfTabSettings>&lt;config&gt;&#x0A; &lt;enabled&gt;false&lt;/enabled&gt;&#x0A; &lt;autoScale&gt;true&lt;/autoScale&gt;&#x0A; &lt;logScaleEnabled&gt;false&lt;/logScaleEnabled&gt;&#x0A; &lt;stacked&gt;false&lt;/stacked&gt;&#x0A; &lt;showLegendAlways&gt;false&lt;/showLegendAlways&gt;&#x0A; &lt;extendedLegend&gt;true&lt;/extendedLegend&gt;&#x0A; &lt;minYScaleValue&gt;0.0&lt;/minYScaleValue&gt;&#x0A; &lt;maxYScaleValue&gt;100.0&lt;/maxYScaleValue&gt;&#x0A; &lt;timeRange&gt;1&lt;/timeRange&gt;&#x0A; &lt;timeUnits&gt;1&lt;/timeUnits&gt;&#x0A; &lt;type&gt;0&lt;/type&gt;&#x0A; &lt;color&gt;49152&lt;/color&gt;&#x0A; &lt;title&gt;&lt;/title&gt;&#x0A; &lt;name&gt;&lt;/name&gt;&#x0A; &lt;showThresholds&gt;false&lt;/showThresholds&gt;&#x0A; &lt;groupName&gt;&lt;/groupName&gt;&#x0A; &lt;order&gt;100&lt;/order&gt;&#x0A; &lt;parentDciId&gt;0&lt;/parentDciId&gt;&#x0A; &lt;modifyYBase&gt;false&lt;/modifyYBase&gt;&#x0A; &lt;invertedValues&gt;false&lt;/invertedValues&gt;&#x0A;&lt;/config&gt;</perfTabSettings>
<instanceDiscoveryData></instanceDiscoveryData>
<instanceFilter></instanceFilter>
</dci>
<dci id="5402">
<guid>9f2c0fb1-5d9b-440f-956e-c393b7bed211</guid>
<name>Yggdrasil.GetBytesSent()</name>
<description>Yggdrasil: bytes sent</description>
<dataType>8</dataType>
<samples>0</samples>
<origin>1</origin>
<scheduleType>0</scheduleType>
<interval></interval>
<retentionType>0</retentionType>
<retention></retention>
<instance></instance>
<systemTag></systemTag>
<delta>2</delta>
<flags>0</flags>
<snmpRawValueType>0</snmpRawValueType>
<snmpPort>0</snmpPort>
<snmpVersion>127</snmpVersion>
<instanceDiscoveryMethod>0</instanceDiscoveryMethod>
<instanceRetentionTime>-1</instanceRetentionTime>
<comments></comments>
<isDisabled>false</isDisabled>
<transformation></transformation>
<perfTabSettings>&lt;config&gt;&#x0A; &lt;enabled&gt;false&lt;/enabled&gt;&#x0A; &lt;autoScale&gt;true&lt;/autoScale&gt;&#x0A; &lt;logScaleEnabled&gt;false&lt;/logScaleEnabled&gt;&#x0A; &lt;stacked&gt;false&lt;/stacked&gt;&#x0A; &lt;showLegendAlways&gt;false&lt;/showLegendAlways&gt;&#x0A; &lt;extendedLegend&gt;true&lt;/extendedLegend&gt;&#x0A; &lt;minYScaleValue&gt;0.0&lt;/minYScaleValue&gt;&#x0A; &lt;maxYScaleValue&gt;100.0&lt;/maxYScaleValue&gt;&#x0A; &lt;timeRange&gt;1&lt;/timeRange&gt;&#x0A; &lt;timeUnits&gt;1&lt;/timeUnits&gt;&#x0A; &lt;type&gt;0&lt;/type&gt;&#x0A; &lt;color&gt;49152&lt;/color&gt;&#x0A; &lt;title&gt;&lt;/title&gt;&#x0A; &lt;name&gt;&lt;/name&gt;&#x0A; &lt;showThresholds&gt;false&lt;/showThresholds&gt;&#x0A; &lt;groupName&gt;&lt;/groupName&gt;&#x0A; &lt;order&gt;100&lt;/order&gt;&#x0A; &lt;parentDciId&gt;0&lt;/parentDciId&gt;&#x0A; &lt;modifyYBase&gt;false&lt;/modifyYBase&gt;&#x0A; &lt;invertedValues&gt;false&lt;/invertedValues&gt;&#x0A;&lt;/config&gt;</perfTabSettings>
<instanceDiscoveryData></instanceDiscoveryData>
<instanceFilter></instanceFilter>
</dci>
<dci id="5403">
<guid>dc1efc30-1a8b-4bc0-98c5-a02d0ee44311</guid>
<name>Yggdrasil.GetConnectedPeersCount()</name>
<description>Yggdrasil: connected peers</description>
<dataType>8</dataType>
<samples>0</samples>
<origin>1</origin>
<scheduleType>0</scheduleType>
<interval></interval>
<retentionType>0</retentionType>
<retention></retention>
<instance></instance>
<systemTag></systemTag>
<delta>0</delta>
<flags>0</flags>
<snmpRawValueType>0</snmpRawValueType>
<snmpPort>0</snmpPort>
<snmpVersion>127</snmpVersion>
<instanceDiscoveryMethod>0</instanceDiscoveryMethod>
<instanceRetentionTime>-1</instanceRetentionTime>
<comments></comments>
<isDisabled>false</isDisabled>
<transformation></transformation>
<perfTabSettings>&lt;config&gt;&#x0A; &lt;enabled&gt;false&lt;/enabled&gt;&#x0A; &lt;autoScale&gt;true&lt;/autoScale&gt;&#x0A; &lt;logScaleEnabled&gt;false&lt;/logScaleEnabled&gt;&#x0A; &lt;stacked&gt;false&lt;/stacked&gt;&#x0A; &lt;showLegendAlways&gt;false&lt;/showLegendAlways&gt;&#x0A; &lt;extendedLegend&gt;true&lt;/extendedLegend&gt;&#x0A; &lt;minYScaleValue&gt;0.0&lt;/minYScaleValue&gt;&#x0A; &lt;maxYScaleValue&gt;100.0&lt;/maxYScaleValue&gt;&#x0A; &lt;timeRange&gt;1&lt;/timeRange&gt;&#x0A; &lt;timeUnits&gt;1&lt;/timeUnits&gt;&#x0A; &lt;type&gt;0&lt;/type&gt;&#x0A; &lt;color&gt;49152&lt;/color&gt;&#x0A; &lt;title&gt;&lt;/title&gt;&#x0A; &lt;name&gt;&lt;/name&gt;&#x0A; &lt;showThresholds&gt;false&lt;/showThresholds&gt;&#x0A; &lt;groupName&gt;&lt;/groupName&gt;&#x0A; &lt;order&gt;100&lt;/order&gt;&#x0A; &lt;parentDciId&gt;0&lt;/parentDciId&gt;&#x0A; &lt;modifyYBase&gt;false&lt;/modifyYBase&gt;&#x0A; &lt;invertedValues&gt;false&lt;/invertedValues&gt;&#x0A;&lt;/config&gt;</perfTabSettings>
<instanceDiscoveryData></instanceDiscoveryData>
<instanceFilter></instanceFilter>
</dci>
</dataCollection>
<agentPolicies>
</agentPolicies>
<filter autoBind="0" autoUnbind="0"></filter>
</template>
</templates>
<traps>
</traps>
<rules>
</rules>
<scripts>
</scripts>
<objectTools>
</objectTools>
<dciSummaryTables>
</dciSummaryTables>
<actions>
</actions>
<webServiceDefinitions>
</webServiceDefinitions>
</configuration>

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
YGGDRASIL=$(which yggdrasilctl)
if [ "${YGGDRASIL}" == "" ]; then
exit 1
fi
echo $[ $(${YGGDRASIL} getpeers | wc -l) - 1 ]

View File

@ -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