Skip to content

Commit b886c95

Browse files
committed
DLPX-96312 Mirrored perf_playbook for influxDB
1 parent 985a3ac commit b886c95

5 files changed

Lines changed: 71 additions & 18 deletions

File tree

debian/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ override_dh_auto_install:
2626
dh_install telegraf/delphix-telegraf-service telegraf/perf_playbook /usr/bin
2727
dh_install telegraf/delphix-telegraf.service /lib/systemd/system
2828
dh_install telegraf/telegraf* telegraf/*.sh /etc/telegraf
29-
dh_install influxdb/delphix-influxdb-service influxdb/delphix-influxdb-init /usr/bin
29+
dh_install influxdb/delphix-influxdb-service influxdb/delphix-influxdb-init influxdb/perf_influxdb /usr/bin
3030
dh_install influxdb/delphix-influxdb.service /lib/systemd/system
3131
dh_install influxdb/influxdb.conf influxdb/influxdb-init.conf /etc/influxdb

influxdb/delphix-influxdb-init

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ INFLUXDB_META_FILE="$INFLUXDB_CONFIG_DIR/influxdb_meta"
1616
# State file written immediately after /api/v2/setup so the script can resume
1717
# if it is interrupted before the metadata file is fully written.
1818
INFLUXDB_SETUP_STATE_FILE="$INFLUXDB_CONFIG_DIR/influxdb_setup_state"
19-
TELEGRAF_BASE="/etc/telegraf/telegraf.base"
19+
INFLUXDB_FLAG=/etc/telegraf/INFLUXDB_ENABLED
20+
INFLUXDB_OUTPUT=/etc/telegraf/telegraf.outputs.influxdb
2021
INFLUXDB_INIT_CONF="$INFLUXDB_CONFIG_DIR/influxdb-init.conf"
2122

2223
# Load tunable configuration (org, bucket, retention, wait parameters).
@@ -156,24 +157,21 @@ READ_TOKEN_RESPONSE=$(influx_post "/api/v2/authorizations" "{
156157
READ_TOKEN=$(json_field "$READ_TOKEN_RESPONSE" "['token']") || exit 1
157158

158159
#
159-
# Append the [[outputs.influxdb_v2]] stanza to telegraf.base so Telegraf
160-
# knows where to ship metrics.
160+
# Write the [[outputs.influxdb_v2]] stanza to a dedicated telegraf output file
161+
# and enable it via the INFLUXDB_ENABLED flag. The flag is read by
162+
# delphix-telegraf-service to conditionally include this output.
161163
#
162-
if [[ ! -f "$TELEGRAF_BASE" ]]; then
163-
log "WARNING: $TELEGRAF_BASE not found, skipping Telegraf output stanza."
164-
elif ! grep -q "^[[:space:]]*#\{0,1\}\[\[outputs\.influxdb_v2\]\]" "$TELEGRAF_BASE"; then
165-
cat >>"$TELEGRAF_BASE" <<EOF
166-
164+
cat >"$INFLUXDB_OUTPUT" <<EOF
167165
[[outputs.influxdb_v2]]
168166
urls = ["http://127.0.0.1:8086"]
169167
token = "$WRITE_TOKEN"
170168
organization = "$INFLUXDB_ORG"
171169
bucket = "$INFLUXDB_BUCKET"
172170
namepass = ["cpu", "disk", "diskio", "mem", "net", "procstat", "processes", "swap", "system", "zfs"]
173171
EOF
174-
fi
175172
# Enforce restrictive permissions so the write token is not world-readable.
176-
chmod 640 "$TELEGRAF_BASE"
173+
chmod 640 "$INFLUXDB_OUTPUT"
174+
touch "$INFLUXDB_FLAG"
177175

178176
#
179177
# Persist org/bucket/admin credentials/tokens so DE APIs can expose them to DCT

influxdb/perf_influxdb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2026 by Delphix. All rights reserved.
4+
#
5+
# SPDX-License-Identifier: GPL-2.0-or-later
6+
#
7+
# Script that enables and disables InfluxDB metric output for Telegraf.
8+
#
9+
10+
INFLUXDB_FLAG=/etc/telegraf/INFLUXDB_ENABLED
11+
INFLUXDB_OUTPUT=/etc/telegraf/telegraf.outputs.influxdb
12+
13+
function die() {
14+
echo -e "$(date +%T:%N:%z): $(basename $0): $*" >&2
15+
exit 1
16+
}
17+
18+
[[ $EUID -ne 0 ]] && die "must be run as root"
19+
20+
function usage() {
21+
echo "$(basename $0): $*" >&2
22+
echo "Usage: $(basename $0) [enable|disable]"
23+
exit 2
24+
}
25+
26+
function enable_influxdb() {
27+
date
28+
[[ ! -f $INFLUXDB_OUTPUT ]] && die "$INFLUXDB_OUTPUT not found. Run delphix-influxdb-init first."
29+
echo "Enabling InfluxDB Metric Output"
30+
touch $INFLUXDB_FLAG
31+
systemctl restart delphix-telegraf
32+
}
33+
34+
function disable_influxdb() {
35+
date
36+
echo "Disabling InfluxDB Metric Output"
37+
rm -rf $INFLUXDB_FLAG
38+
systemctl restart delphix-telegraf
39+
}
40+
41+
if [[ $# -ne 1 ]]; then
42+
usage
43+
fi
44+
45+
case "$1" in
46+
enable) enable_influxdb ;;
47+
disable) disable_influxdb ;;
48+
*) usage ;;
49+
esac

telegraf/delphix-telegraf-service

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ BASE_CONFIG=/etc/telegraf/telegraf.base
33
DOSE_INPUTS=/etc/telegraf/telegraf.inputs.dose
44
DCT_INPUTS=/etc/telegraf/telegraf.inputs.dct
55
PLAYBOOK_INPUTS=/etc/telegraf/telegraf.inputs.playbook
6+
INFLUXDB_OUTPUT=/etc/telegraf/telegraf.outputs.influxdb
67
PLAYBOOK_FLAG=/etc/telegraf/PLAYBOOK_ENABLED
8+
INFLUXDB_FLAG=/etc/telegraf/INFLUXDB_ENABLED
79
TELEGRAF_CONFIG=/etc/telegraf/telegraf.conf
810

911

@@ -21,6 +23,10 @@ function playbook_is_enabled() {
2123
[[ -f $PLAYBOOK_FLAG ]]
2224
}
2325

26+
function influxdb_is_enabled() {
27+
[[ -f $INFLUXDB_FLAG ]]
28+
}
29+
2430
rm -f $TELEGRAF_CONFIG
2531

2632
if engine_is_object_based; then
@@ -43,4 +49,8 @@ else
4349
fi
4450
fi
4551

52+
if influxdb_is_enabled && [[ -f $INFLUXDB_OUTPUT ]]; then
53+
cat $INFLUXDB_OUTPUT >> $TELEGRAF_CONFIG
54+
fi
55+
4656
/usr/bin/telegraf -config $TELEGRAF_CONFIG

telegraf/telegraf.base

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,9 @@
4444
data_format = "json"
4545
namepass = ["agg_*"]
4646

47-
# Update token from /etc/influxdb/influxdb_meta (INFLUXDB_ADMIN_TOKEN), then uncomment and restart telegraf.
48-
#[[outputs.influxdb_v2]]
49-
# urls = ["http://127.0.0.1:8086"]
50-
# token = ""
51-
# organization = "delphix"
52-
# bucket = "default"
53-
# namepass = ["cpu", "disk", "diskio", "mem", "net", "procstat", "processes", "swap", "system", "zfs"]
47+
# InfluxDB output is managed via /etc/telegraf/telegraf.outputs.influxdb (written by
48+
# delphix-influxdb-init) and the /etc/telegraf/INFLUXDB_ENABLED flag.
49+
# Use 'perf_influxdb enable|disable' to toggle and restart Telegraf.
5450

5551
###############################################################################
5652
# INPUT PLUGINS #

0 commit comments

Comments
 (0)