Skip to content

Commit cde5e7f

Browse files
committed
minor changes
1 parent b217150 commit cde5e7f

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

agent_based/proxmox_bs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def proxmox_bs_discovery(section):
9595
)
9696
return
9797

98+
9899
def proxmox_bs_checks(item, params, section):
99100
req_ok = True
100101
expected = []
@@ -170,7 +171,7 @@ def proxmox_bs_checks(item, params, section):
170171
stat = e["verification"]["state"]
171172
upid = e["verification"]["upid"]
172173
yield Result(state=State.UNKN, summary=(
173-
'%s (%s) unkown state %s' % (group, upid, stat)
174+
'%s (%s) unknown state %s' % (group, upid, stat)
174175
))
175176
for e in nok:
176177
group = '%s/%s' % (e["backup-type"], e["backup-id"])
@@ -180,7 +181,6 @@ def proxmox_bs_checks(item, params, section):
180181
'Verification of %s (%s) %s' % (group, upid, stat)
181182
))
182183

183-
184184
if (n == "proxmox-backup-client status") and (k == item):
185185
try:
186186
ds_status = json.loads(c)
@@ -213,7 +213,6 @@ def proxmox_bs_checks(item, params, section):
213213

214214
register.agent_section(
215215
name="proxmox_bs",
216-
#host_label_function = proxmox_bs_hostlabels,
217216
)
218217

219218
register.check_plugin(

agents/plugins/proxmox_bs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ printf "<<<proxmox_bs>>>\n"
1313

1414
printf "===requirements===\n"
1515
requirement() {
16-
inpath $1; RC=$?
17-
printf "$RC $1\n"
16+
inpath "$1"; RC=$?
17+
printf '%s %s\n' "$RC" "$1"
1818
}
1919
requirements() {
2020
RC=0
@@ -51,33 +51,35 @@ command_section() {
5151
done
5252
cmd=$1
5353
shift
54-
printf "===$cmd===$SECTION_POSTFIX\n"
55-
echo sh -c "$cmd $* $PIPE" >&2
56-
sh -c "$cmd $* $PIPE"
54+
printf '===%s===%s\n' "$cmd" "$SECTION_POSTFIX"
55+
# shellcheck disable=SC2086
56+
echo /bin/env $cmd $* $PIPE >&2
57+
# shellcheck disable=SC2086
58+
eval /bin/env $cmd $* $PIPE
5759
}
5860

59-
$(< /etc/check_mk/proxmox_bs.env)
61+
source /etc/check_mk/proxmox_bs.env
6062
PBS_REPO="${PBS_USERNAME}@localhost"
6163
proxmox-backup-client login
6264

6365
OUTPUT_FORMAT="--output-format json-pretty"
6466

6567
command_section "proxmox-backup-manager versions" $OUTPUT_FORMAT
6668
TMP_DATASTORES=$( mktemp -p /tmp/ )
67-
command_section -t $TMP_DATASTORES \
69+
command_section -t "$TMP_DATASTORES" \
6870
"proxmox-backup-manager datastore list" $OUTPUT_FORMAT
6971

7072
command_section "proxmox-backup-manager task list" $OUTPUT_FORMAT
7173

7274
TMP_UPIDS=$( mktemp -p /tmp/ )
7375

7476
TMP_GC_FILES=$( mktemp -p /tmp/ )
75-
jq -r '.[].name' $TMP_DATASTORES | while read -r name; do
77+
jq -r '.[].name' "$TMP_DATASTORES" | while read -r name; do
7678
TMP_GC=$( mktemp -p /tmp/ )
77-
printf "$TMP_GC" >> "$TMP_GC_FILES"
79+
printf '%s' "$TMP_GC" >> "$TMP_GC_FILES"
7880
command_section -t "$TMP_GC" -p "$name" \
79-
"proxmox-backup-manager garbage-collection status" $name $OUTPUT_FORMAT
80-
jq -r '.upid' "$TMP_GC" >> $TMP_UPIDS
81+
"proxmox-backup-manager garbage-collection status" "$name" $OUTPUT_FORMAT
82+
jq -r '.upid' "$TMP_GC" >> "$TMP_UPIDS"
8183
command_section -p "$name" \
8284
"proxmox-backup-client list" --repository "$PBS_REPO:$name" $OUTPUT_FORMAT
8385
command_section -p "$name" \
@@ -89,15 +91,17 @@ jq -r '.[].name' $TMP_DATASTORES | while read -r name; do
8991
proxmox-backup-client logout --repository "$PBS_REPO:$name" > /dev/null 2>&1
9092
done
9193

94+
# shellcheck disable=SC2086 disable=SC2002
9295
cat $TMP_UPIDS | while read -r upid; do
93-
command_section -P "sed -n '/^Removed garbage: /,\$p'" -p "$upid" \
96+
command_section -P "sed '/^Removed /,\$!d'" -p "$upid" \
9497
"proxmox-backup-manager task log" "$upid"
9598
done
9699

97100
export PBS_PASSWORD=
98101

99-
printf "$TMP_GC_FILES" >> $TMP_GC_FILES
102+
echo "$TMP_GC_FILES" >> "$TMP_GC_FILES"
100103

104+
# shellcheck disable=SC2086 disable=SC2046 disable=SC2002 disable=SC2153
101105
rm -vf $TMP_DATASTORE $TMP_UPIDS $(cat $TMP_GC_FILES | xargs) >&2
102106

103107
echo "===EOD==="

web/plugins/metrics/proxmox_bs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@
6060
'verify_unknown',
6161
'verify_none',
6262
],
63+
'range': ('verify_ok:min', 'total_bakups:max'),
6364
}
6465

0 commit comments

Comments
 (0)