bundles/telegraf/items.py: use new bundle from isac

This commit is contained in:
CroneKorkN 2026-01-11 09:44:16 +01:00
parent 982a27739a
commit 49594610d3
Signed by: cronekorkn
SSH key fingerprint: SHA256:v0410ZKfuO1QHdgKBsdQNF64xmTxOF8osF1LIqwTcVw
12 changed files with 520 additions and 462 deletions

View file

@ -13,16 +13,14 @@ defaults = {
},
},
'telegraf': {
'config': {
'inputs': {
'exec': {
repo.libs.hashable.hashable({
'commands': ["sudo /usr/local/share/telegraf/apcupsd"],
'name_override': "apcupsd",
'data_format': "influx",
'interval': '30s',
'flush_interval': '30s',
}),
'inputs': {
'exec': {
'apcupsd': {
'commands': ["sudo /usr/local/share/telegraf/apcupsd"],
'name_override': "apcupsd",
'data_format': "influx",
'interval': '30s',
'flush_interval': '30s',
},
},
},

View file

@ -49,13 +49,13 @@ defaults = {
},
},
'telegraf': {
'config': {
'inputs': {
'bind': [{
'inputs': {
'bind': {
'default': {
'urls': ['http://localhost:8053/xml/v3'],
'gather_memory_contexts': False,
'gather_views': True,
}],
},
},
},
},

View file

@ -14,25 +14,25 @@ defaults = {
},
},
'telegraf': {
'config': {
'inputs': {
'sensors': {repo.libs.hashable.hashable({
'inputs': {
'sensors': {
'default': {
'timeout': '2s',
})},
'exec': {
repo.libs.hashable.hashable({
'commands': ["sudo /usr/local/share/telegraf/cpu_frequency"],
'name_override': "cpu_frequency",
'data_format': "influx",
}),
# repo.libs.hashable.hashable({
# 'commands': ["/bin/bash -c 'expr $(cat /sys/class/thermal/thermal_zone0/temp) / 1000'"],
# 'name_override': "cpu_temperature",
# 'data_format': "value",
# 'data_type': "integer",
# }),
},
},
'exec': {
'cpu_frequency': {
'commands': ["sudo /usr/local/share/telegraf/cpu_frequency"],
'name_override': "cpu_frequency",
'data_format': "influx",
},
# repo.libs.hashable.hashable({
# 'commands': ["/bin/bash -c 'expr $(cat /sys/class/thermal/thermal_zone0/temp) / 1000'"],
# 'name_override': "cpu_temperature",
# 'data_format': "value",
# 'data_type': "integer",
# }),
},
},
},
}

View file

@ -25,9 +25,9 @@ defaults = {
},
},
'telegraf': {
'config': {
'inputs': {
'postfix': [{}],
'inputs': {
'postfix': {
'default': {},
},
},
},

View file

@ -98,17 +98,17 @@ def zfs(metadata):
@metadata_reactor.provides(
'telegraf/config/inputs/postgresql',
'telegraf/inputs/postgresql/default',
)
def telegraf(metadata):
return {
'telegraf': {
'config': {
'inputs': {
'postgresql': [{
'inputs': {
'postgresql': {
'default': {
'address': f'postgres://root:{root_password}@localhost:5432/postgres',
'databases': sorted(list(node.metadata.get('postgresql/databases').keys())),
}],
},
},
},
},

View file

@ -8,16 +8,14 @@ defaults = {
@metadata_reactor.provides(
'telegraf/config/agent',
'telegraf/agent',
)
def telegraf(metadata):
return {
'telegraf': {
'config': {
'agent': {
'flush_interval': '30s',
'interval': '30s',
},
'agent': {
'flush_interval': '30s',
'interval': '1m',
},
},
}

View file

@ -1,344 +1,344 @@
h = repo.libs.hashable.hashable
# h = repo.libs.hashable.hashable
defaults = {
'apt': {
'packages': {
'snmp': {},
'snmp-mibs-downloader': {},
},
},
}
# defaults = {
# 'apt': {
# 'packages': {
# 'snmp': {},
# 'snmp-mibs-downloader': {},
# },
# },
# }
@metadata_reactor.provides(
'telegraf/config/inputs/snmp',
)
def routeros_monitoring_telegraf_inputs(metadata):
return {
"telegraf": {
"config": {
"processors": {
"enum": [
h({
"tagpass": {
"operating_system": ["routeros"],
},
"mapping": [
h({
"tag": "agent_host",
"dest": "host",
"default": "unknown",
"value_mappings": {
routeros_node.hostname: routeros_node.name
for routeros_node in repo.nodes_in_group("routeros")
},
})
]
})
]
},
"inputs": {
"snmp": {
h({
"agents": [
f"udp://{routeros_node.hostname}:161"
for routeros_node in repo.nodes_in_group("routeros")
],
"version": 2,
"community": "public",
"interval": "30s",
"tags": {
"operating_system": "routeros",
},
"table": [
# MikroTik Health (table)
{
"name": "hw",
"oid": "MIKROTIK-MIB::mtxrGaugeTable",
"field": [
{
"name": "sensor",
"oid": "MIKROTIK-MIB::mtxrGaugeName",
"is_tag": True,
},
{
"name": "value",
"oid": "MIKROTIK-MIB::mtxrGaugeValue",
},
{
"name": "unit",
"oid": "MIKROTIK-MIB::mtxrGaugeUnit",
"is_tag": True,
},
],
},
# Interface statistics (standard IF-MIB)
{
"name": "interface",
"oid": "IF-MIB::ifTable",
"field": [
# 6: ethernetCsmacd (physischer Ethernet-Port)
# 24: softwareLoopback
# 53: propVirtual (oft VLANs bei MikroTik)
# 131: tunnel
# 135: l2vlan
# 161: ieee8023adLag (Bonding/LACP)
# 209: bridge
{
"name": "ifType",
"oid": "IF-MIB::ifType",
"is_tag": True,
},
# @metadata_reactor.provides(
# 'telegraf/inputs/snmp',
# )
# def routeros_monitoring_telegraf_inputs(metadata):
# return {
# "telegraf": {
# "config": {
# "processors": {
# "enum": [
# h({
# "tagpass": {
# "operating_system": ["routeros"],
# },
# "mapping": [
# h({
# "tag": "agent_host",
# "dest": "host",
# "default": "unknown",
# "value_mappings": {
# routeros_node.hostname: routeros_node.name
# for routeros_node in repo.nodes_in_group("routeros")
# },
# })
# ]
# })
# ]
# },
# "inputs": {
# "snmp": {
# h({
# "agents": [
# f"udp://{routeros_node.hostname}:161"
# for routeros_node in repo.nodes_in_group("routeros")
# ],
# "version": 2,
# "community": "public",
# "interval": "30s",
# "tags": {
# "operating_system": "routeros",
# },
# "table": [
# # MikroTik Health (table)
# {
# "name": "hw",
# "oid": "MIKROTIK-MIB::mtxrGaugeTable",
# "field": [
# {
# "name": "sensor",
# "oid": "MIKROTIK-MIB::mtxrGaugeName",
# "is_tag": True,
# },
# {
# "name": "value",
# "oid": "MIKROTIK-MIB::mtxrGaugeValue",
# },
# {
# "name": "unit",
# "oid": "MIKROTIK-MIB::mtxrGaugeUnit",
# "is_tag": True,
# },
# ],
# },
# # Interface statistics (standard IF-MIB)
# {
# "name": "interface",
# "oid": "IF-MIB::ifTable",
# "field": [
# # 6: ethernetCsmacd (physischer Ethernet-Port)
# # 24: softwareLoopback
# # 53: propVirtual (oft VLANs bei MikroTik)
# # 131: tunnel
# # 135: l2vlan
# # 161: ieee8023adLag (Bonding/LACP)
# # 209: bridge
# {
# "name": "ifType",
# "oid": "IF-MIB::ifType",
# "is_tag": True,
# },
# Labels (optional but recommended)
{
"name": "ifName",
"oid": "IF-MIB::ifName",
"is_tag": True,
},
{
"name": "ifAlias",
"oid": "IF-MIB::ifAlias",
"is_tag": True,
},
# # Labels (optional but recommended)
# {
# "name": "ifName",
# "oid": "IF-MIB::ifName",
# "is_tag": True,
# },
# {
# "name": "ifAlias",
# "oid": "IF-MIB::ifAlias",
# "is_tag": True,
# },
# Bytes (64-bit)
{
"name": "in_octets",
"oid": "IF-MIB::ifHCInOctets",
},
{
"name": "out_octets",
"oid": "IF-MIB::ifHCOutOctets",
},
# # Bytes (64-bit)
# {
# "name": "in_octets",
# "oid": "IF-MIB::ifHCInOctets",
# },
# {
# "name": "out_octets",
# "oid": "IF-MIB::ifHCOutOctets",
# },
# Packets (64-bit unicast)
{
"name": "in_ucast_pkts",
"oid": "IF-MIB::ifHCInUcastPkts",
},
{
"name": "out_ucast_pkts",
"oid": "IF-MIB::ifHCOutUcastPkts",
},
{
"name": "in_mcast_pkts",
"oid": "IF-MIB::ifHCInMulticastPkts",
},
{
"name": "in_bcast_pkts",
"oid": "IF-MIB::ifHCInBroadcastPkts",
},
{
"name": "out_mcast_pkts",
"oid": "IF-MIB::ifHCOutMulticastPkts",
},
{
"name": "out_bcast_pkts",
"oid": "IF-MIB::ifHCOutBroadcastPkts",
},
# # Packets (64-bit unicast)
# {
# "name": "in_ucast_pkts",
# "oid": "IF-MIB::ifHCInUcastPkts",
# },
# {
# "name": "out_ucast_pkts",
# "oid": "IF-MIB::ifHCOutUcastPkts",
# },
# {
# "name": "in_mcast_pkts",
# "oid": "IF-MIB::ifHCInMulticastPkts",
# },
# {
# "name": "in_bcast_pkts",
# "oid": "IF-MIB::ifHCInBroadcastPkts",
# },
# {
# "name": "out_mcast_pkts",
# "oid": "IF-MIB::ifHCOutMulticastPkts",
# },
# {
# "name": "out_bcast_pkts",
# "oid": "IF-MIB::ifHCOutBroadcastPkts",
# },
# Drops / Errors
{
"name": "in_discards",
"oid": "IF-MIB::ifInDiscards",
},
{
"name": "out_discards",
"oid": "IF-MIB::ifOutDiscards",
},
{
"name": "in_errors",
"oid": "IF-MIB::ifInErrors",
},
{
"name": "out_errors",
"oid": "IF-MIB::ifOutErrors",
},
],
},
# Interface statistics (MikroTik-specific mib)
{
"name": "interface_errors",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsTable",
"field": [
# Join key / label (usually identical to IF-MIB ifName)
{
"name": "ifName",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsName",
"is_tag": True,
},
# # Drops / Errors
# {
# "name": "in_discards",
# "oid": "IF-MIB::ifInDiscards",
# },
# {
# "name": "out_discards",
# "oid": "IF-MIB::ifOutDiscards",
# },
# {
# "name": "in_errors",
# "oid": "IF-MIB::ifInErrors",
# },
# {
# "name": "out_errors",
# "oid": "IF-MIB::ifOutErrors",
# },
# ],
# },
# # Interface statistics (MikroTik-specific mib)
# {
# "name": "interface_errors",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsTable",
# "field": [
# # Join key / label (usually identical to IF-MIB ifName)
# {
# "name": "ifName",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsName",
# "is_tag": True,
# },
# join IF-MIB for better labels
{
"name": "ifAlias",
"oid": "IF-MIB::ifAlias",
"is_tag": True,
},
# # join IF-MIB for better labels
# {
# "name": "ifAlias",
# "oid": "IF-MIB::ifAlias",
# "is_tag": True,
# },
# =========================
# Physical layer (L1/L2)
# =========================
# CRC/FCS errors → very often cabling, connectors, SFPs, signal quality (EMI)
{
"name": "rx_fcs_errors",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxFCSError",
},
# Alignment errors → typically duplex mismatch or PHY problems
{
"name": "rx_align_errors",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxAlignError",
},
# Code errors → PHY encoding errors (signal/SFP/PHY)
{
"name": "rx_code_errors",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxCodeError",
},
# Carrier errors → carrier lost (copper issues, autoneg, PHY instability)
{
"name": "rx_carrier_errors",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxCarrierError",
},
# Jabber → extremely long invalid frames (faulty NIC/PHY, very severe)
{
"name": "rx_jabber",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxJabber",
},
# # =========================
# # Physical layer (L1/L2)
# # =========================
# # CRC/FCS errors → very often cabling, connectors, SFPs, signal quality (EMI)
# {
# "name": "rx_fcs_errors",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxFCSError",
# },
# # Alignment errors → typically duplex mismatch or PHY problems
# {
# "name": "rx_align_errors",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxAlignError",
# },
# # Code errors → PHY encoding errors (signal/SFP/PHY)
# {
# "name": "rx_code_errors",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxCodeError",
# },
# # Carrier errors → carrier lost (copper issues, autoneg, PHY instability)
# {
# "name": "rx_carrier_errors",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxCarrierError",
# },
# # Jabber → extremely long invalid frames (faulty NIC/PHY, very severe)
# {
# "name": "rx_jabber",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxJabber",
# },
# ==================================
# Length / framing anomalies (diagnostic)
# ==================================
# Frames shorter than minimum (noise, collisions, broken sender)
{
"name": "rx_too_short",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxTooShort",
},
# Frames longer than allowed (MTU mismatch, framing errors)
{
"name": "rx_too_long",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxTooLong",
},
# Fragments (often collision-related or duplex mismatch)
{
"name": "rx_fragment",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxFragment",
},
# Generic length errors
{
"name": "rx_length_errors",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxLengthError",
},
# # ==================================
# # Length / framing anomalies (diagnostic)
# # ==================================
# # Frames shorter than minimum (noise, collisions, broken sender)
# {
# "name": "rx_too_short",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxTooShort",
# },
# # Frames longer than allowed (MTU mismatch, framing errors)
# {
# "name": "rx_too_long",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxTooLong",
# },
# # Fragments (often collision-related or duplex mismatch)
# {
# "name": "rx_fragment",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxFragment",
# },
# # Generic length errors
# {
# "name": "rx_length_errors",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxLengthError",
# },
# ==================
# Drops (real packet loss)
# ==================
# RX drops (queue/ASIC/policy/overload) → highly alert-worthy
{
"name": "rx_drop",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxDrop",
},
# TX drops (buffer/queue exhaustion, scheduling, ASIC limits)
{
"name": "tx_drop",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxDrop",
},
# # ==================
# # Drops (real packet loss)
# # ==================
# # RX drops (queue/ASIC/policy/overload) → highly alert-worthy
# {
# "name": "rx_drop",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxDrop",
# },
# # TX drops (buffer/queue exhaustion, scheduling, ASIC limits)
# {
# "name": "tx_drop",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxDrop",
# },
# =========================================
# Duplex / collision indicators
# (should be zero on full-duplex links)
# =========================================
# Total collisions (relevant only for half-duplex or misconfigurations)
{
"name": "tx_collisions",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxCollision",
},
# Late collisions → almost always duplex mismatch / bad autoneg
{
"name": "tx_late_collisions",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxLateCollision",
},
# Aggregate collision counter (context)
{
"name": "tx_total_collisions",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxTotalCollision",
},
# Excessive collisions → persistent duplex problems
{
"name": "tx_excessive_collisions",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxExcessiveCollision",
},
# # =========================================
# # Duplex / collision indicators
# # (should be zero on full-duplex links)
# # =========================================
# # Total collisions (relevant only for half-duplex or misconfigurations)
# {
# "name": "tx_collisions",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxCollision",
# },
# # Late collisions → almost always duplex mismatch / bad autoneg
# {
# "name": "tx_late_collisions",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxLateCollision",
# },
# # Aggregate collision counter (context)
# {
# "name": "tx_total_collisions",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxTotalCollision",
# },
# # Excessive collisions → persistent duplex problems
# {
# "name": "tx_excessive_collisions",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxExcessiveCollision",
# },
# ==================
# Flow control (diagnostic)
# ==================
# Pause frames received (peer throttling you)
{
"name": "rx_pause",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxPause",
},
# Pause frames sent (you throttling the peer)
{
"name": "tx_pause",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxPause",
},
# Pause frames actually honored
{
"name": "tx_pause_honored",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxPauseHonored",
},
# # ==================
# # Flow control (diagnostic)
# # ==================
# # Pause frames received (peer throttling you)
# {
# "name": "rx_pause",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsRxPause",
# },
# # Pause frames sent (you throttling the peer)
# {
# "name": "tx_pause",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxPause",
# },
# # Pause frames actually honored
# {
# "name": "tx_pause_honored",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsTxPauseHonored",
# },
# ==========
# Stability
# ==========
# Link-down events (loose cables, bad SFPs, PoE power drops, reboots)
{
"name": "link_downs",
"oid": "MIKROTIK-MIB::mtxrInterfaceStatsLinkDowns",
},
],
},
# PoE
{
"name": "poe",
"oid": "MIKROTIK-MIB::mtxrPOETable",
"field": [
{
"name": "ifName",
"oid": "IF-MIB::ifName",
"is_tag": True,
},
{
"name": "ifAlias",
"oid": "IF-MIB::ifAlias",
"is_tag": True,
},
{
"name": "ifindex",
"oid": "MIKROTIK-MIB::mtxrPOEInterfaceIndex",
"is_tag": True,
},
{
"name": "status",
"oid": "MIKROTIK-MIB::mtxrPOEStatus",
},
{
"name": "voltage",
"oid": "MIKROTIK-MIB::mtxrPOEVoltage",
},
{
"name": "current",
"oid": "MIKROTIK-MIB::mtxrPOECurrent",
},
{
"name": "power",
"oid": "MIKROTIK-MIB::mtxrPOEPower",
},
],
},
],
})
},
},
},
},
}
# # ==========
# # Stability
# # ==========
# # Link-down events (loose cables, bad SFPs, PoE power drops, reboots)
# {
# "name": "link_downs",
# "oid": "MIKROTIK-MIB::mtxrInterfaceStatsLinkDowns",
# },
# ],
# },
# # PoE
# {
# "name": "poe",
# "oid": "MIKROTIK-MIB::mtxrPOETable",
# "field": [
# {
# "name": "ifName",
# "oid": "IF-MIB::ifName",
# "is_tag": True,
# },
# {
# "name": "ifAlias",
# "oid": "IF-MIB::ifAlias",
# "is_tag": True,
# },
# {
# "name": "ifindex",
# "oid": "MIKROTIK-MIB::mtxrPOEInterfaceIndex",
# "is_tag": True,
# },
# {
# "name": "status",
# "oid": "MIKROTIK-MIB::mtxrPOEStatus",
# },
# {
# "name": "voltage",
# "oid": "MIKROTIK-MIB::mtxrPOEVoltage",
# },
# {
# "name": "current",
# "oid": "MIKROTIK-MIB::mtxrPOECurrent",
# },
# {
# "name": "power",
# "oid": "MIKROTIK-MIB::mtxrPOEPower",
# },
# ],
# },
# ],
# })
# },
# },
# },
# },
# }

View file

@ -11,24 +11,22 @@ defaults = {
},
'smartctl': {},
'telegraf': {
'config': {
'inputs': {
'exec': {
h({
'commands': [
f'sudo /usr/local/share/telegraf/smartctl_power_mode',
],
'data_format': 'influx',
'interval': '20s',
}),
h({
'commands': [
f'sudo /usr/local/share/telegraf/smartctl_errors',
],
'data_format': 'influx',
'interval': '6h',
})
'inputs': {
'exec': {
'smartctl_power_mode': {
'commands': [
f'sudo /usr/local/share/telegraf/smartctl_power_mode',
],
'data_format': 'influx',
'interval': '20s',
},
'smartctl_errors': {
'commands': [
f'sudo /usr/local/share/telegraf/smartctl_errors',
],
'data_format': 'influx',
'interval': '6h',
}
},
},
},

View file

@ -15,7 +15,7 @@ defaults = {
@metadata_reactor.provides(
'telegraf/config/inputs/exec',
'telegraf/inputs/exec',
)
def telegraf(metadata):
return {
@ -23,11 +23,11 @@ def telegraf(metadata):
'config': {
'inputs': {
'exec': {
repo.libs.hashable.hashable({
'tasmota_charge': {
'commands': ["/usr/local/share/telegraf/tasmota_charge"],
'name_override': "tasmota_charge",
'data_format': "influx",
}),
},
},
},
},

View file

@ -1,19 +1,46 @@
import tomlkit
import json
from bundlewrap.metadata import MetadataJSONEncoder
def inner_dict_to_list(dict_of_dicts):
"""
Example:
{
'cpu': {
'default': {'something': True},
'another': {'something': False},
},
}
becomes
{
'cpu': [
{'something': True},
{'something': False},
],
}
"""
return {
key: [value for _, value in sorted(dicts.items())]
for key, dicts in sorted(dict_of_dicts.items())
}
files = {
'/etc/telegraf/telegraf.conf': {
'content': tomlkit.dumps(
json.loads(json.dumps(
node.metadata.get('telegraf/config'),
cls=MetadataJSONEncoder,
)),
sort_keys=True,
),
'triggers': [
'svc_systemd:telegraf.service:restart',
"/etc/telegraf/telegraf.conf": {
'owner': 'telegraf',
'group': 'telegraf',
'mode': '0440',
'needs': [
"pkg_apt:telegraf",
],
'content': tomlkit.dumps({
'agent': node.metadata.get('telegraf/agent'),
'inputs': inner_dict_to_list(node.metadata.get('telegraf/inputs')),
'processors': inner_dict_to_list(node.metadata.get('telegraf/processors')),
'outputs': inner_dict_to_list(node.metadata.get('telegraf/outputs')),
}),
'triggers': {
'svc_systemd:telegraf.service:restart',
},
},
'/usr/local/share/telegraf/procio': {
'content_type': 'download',
@ -27,9 +54,26 @@ files = {
},
}
svc_systemd['telegraf.service'] = {
'needs': [
'file:/etc/telegraf/telegraf.conf',
'pkg_apt:telegraf',
],
actions = {
'telegraf-test-config': {
'command': "sudo -u telegraf bash -c 'telegraf config check --config /etc/telegraf/telegraf.conf --strict-env-handling'",
'triggered': True,
'needs': [
'bundle:sudo',
'file:/etc/telegraf/telegraf.conf',
'pkg_apt:telegraf',
],
},
}
svc_systemd = {
'telegraf.service': {
'needs': ['pkg_apt:telegraf'],
'preceded_by': {
'action:telegraf-test-config',
},
'needs': {
'action:telegraf-test-config',
},
},
}

View file

@ -23,27 +23,29 @@ defaults = {
},
},
'telegraf': {
'config': {
'agent': {
'hostname': node.name,
'collection_jitter': '0s',
'flush_interval': '15s',
'flush_jitter': '0s',
'interval': '1m',
'metric_batch_size': 1000,
'metric_buffer_limit': 10000,
'omit_hostname': False,
'round_interval': True,
'skip_processors_after_aggregators': True,
},
'inputs': {
'cpu': {h({
'agent': {
'hostname': node.name,
'collection_jitter': '15s',
'flush_interval': '15s',
'flush_jitter': '0s',
'interval': '1m',
'metric_batch_size': 1000,
'metric_buffer_limit': 10000,
'omit_hostname': False,
'round_interval': True,
'skip_processors_after_aggregators': True,
},
'inputs': {
'cpu': {
'default': {
'collect_cpu_time': False,
'percpu': True,
'report_active': False,
'totalcpu': True,
})},
'disk': {h({
},
},
'disk': {
'default': {
'ignore_fs': [
'tmpfs',
'devtmpfs',
@ -53,42 +55,60 @@ defaults = {
'aufs',
'squashfs',
],
})},
'procstat': {h({
}
},
'procstat': {
'default': {
'interval': '60s',
'pattern': '.',
'fieldinclude': [
'cpu_usage',
'memory_rss',
],
})},
'diskio': {h({
},
},
'diskio': {
'default': {
'device_tags': ["ID_PART_ENTRY_NUMBER"],
})},
'kernel': {h({})},
'mem': {h({})},
'processes': {h({})},
'swap': {h({})},
'system': {h({})},
'net': {h({})},
'exec': {
# h({
# 'commands': [
# f'sudo /usr/local/share/telegraf/procio',
# ],
# 'data_format': 'influx',
# 'interval': '20s',
# }),
h({
'commands': [
f'/usr/local/share/telegraf/pressure_stall',
],
'data_format': 'influx',
'interval': '10s',
}),
}
},
'kernel': {
'default': {},
},
'mem': {
'default': {},
},
'processes': {
'default': {},
},
'swap': {
'default': {},
},
'system': {
'default': {},
},
'net': {
'default': {},
},
'exec': {
# h({
# 'commands': [
# f'sudo /usr/local/share/telegraf/procio',
# ],
# 'data_format': 'influx',
# 'interval': '20s',
# }),
'pressure_stall': {
'commands': [
f'/usr/local/share/telegraf/pressure_stall',
],
'data_format': 'influx',
'interval': '10s',
},
},
},
'processors': {},
'outputs': {},
},
'grafana_rows': {
'cpu',
@ -106,21 +126,21 @@ defaults = {
@metadata_reactor.provides(
'telegraf/config/outputs/influxdb_v2',
'telegraf/outputs/influxdb_v2/default',
)
def influxdb(metadata):
influxdb_metadata = repo.get_node(metadata.get('telegraf/influxdb_node')).metadata.get('influxdb')
return {
'telegraf': {
'config': {
'outputs': {
'influxdb_v2': [{
'outputs': {
'influxdb_v2': {
'default': {
'urls': [f"http://{influxdb_metadata['hostname']}:{influxdb_metadata['port']}"],
'token': str(influxdb_metadata['writeonly_token']),
'organization': influxdb_metadata['org'],
'bucket': influxdb_metadata['bucket'],
}]
},
},
},
},

View file

@ -59,9 +59,9 @@ defaults = {
},
},
'telegraf': {
'config': {
'inputs': {
'zfs': [{}],
'inputs': {
'zfs': {
'default': {},
},
},
},