Skip to content

Commit 5955554

Browse files
authored
Merge pull request #3 from cvmfs-contrib/first-fixes
2 parents 707db15 + 0b97324 commit 5955554

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

cvmfs-client-prometheus.sh

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cleanup_tmpfile() {
1212
trap cleanup_tmpfile EXIT
1313

1414
# CVMFS Extended Attributes and their descriptions
15-
declare -A CVMFS_EXTENDED_ATTRIBUTE_GAGUES=(
15+
declare -A CVMFS_EXTENDED_ATTRIBUTE_GAUGES=(
1616
['hitrate']='CVMFS cache hit rate (%)'
1717
['inode_max']='Shows the highest possible inode with the current set of loaded catalogs.'
1818
['maxfd']='Shows the maximum number of file descriptors available to file system clients.'
@@ -71,7 +71,7 @@ fqrn_for_cvmfs_repo() {
7171
attr -g fqrn "${repopath}" | tail -n +2
7272
}
7373

74-
get_cvmfs_repo_extended_attribute_gague_metrics() {
74+
get_cvmfs_repo_extended_attribute_gauge_metrics() {
7575
local reponame
7676
reponame="$1"
7777

@@ -82,10 +82,10 @@ get_cvmfs_repo_extended_attribute_gague_metrics() {
8282
fqrn=$(fqrn_for_cvmfs_repo "${reponame}")
8383

8484
local attribute
85-
for attribute in "${!CVMFS_EXTENDED_ATTRIBUTE_GAGUES[@]}"; do
85+
for attribute in "${!CVMFS_EXTENDED_ATTRIBUTE_GAUGES[@]}"; do
8686
local result
8787
result=$(attr -g "${attribute}" "${repomountpoint}" | tail -n +2)
88-
generate_metric "cvmfs_${attribute}" 'gague' "${CVMFS_EXTENDED_ATTRIBUTE_GAGUES[${attribute}]}" "repo=${fqrn}" "${result}"
88+
generate_metric "cvmfs_${attribute}" 'gauge' "${CVMFS_EXTENDED_ATTRIBUTE_GAUGES[${attribute}]}" "repo=\"${fqrn}\"" "${result}"
8989
done
9090
}
9191

@@ -117,7 +117,7 @@ get_cvmfs_repo_proxy_metrics() {
117117
break
118118
fi
119119
done
120-
generate_metric "cvmfs_proxy" "gague" "Shows all registered proxies for this repository." "repo=${fqrn},group=${my_proxy_group},url=${proxy}" 1
120+
generate_metric "cvmfs_proxy" "gauge" "Shows all registered proxies for this repository." "repo=\"${fqrn}\",group=\"${my_proxy_group}\",url=\"${proxy}\"" 1
121121
done
122122
}
123123

@@ -139,37 +139,37 @@ get_cvmfs_repo_metrics() {
139139

140140
local cached_bytes
141141
cached_bytes=$(cvmfs_talk -i "${reponame}" cache size | tr -d ')(' | tr -s '[:space:]' | cut -d ' ' -f 6)
142-
generate_metric 'cvmfs_cached_bytes' 'gauge' 'CVMFS currently cached bytes.' "repo=${fqrn}" "${cached_bytes}"
142+
generate_metric 'cvmfs_cached_bytes' 'gauge' 'CVMFS currently cached bytes.' "repo=\"${fqrn}\"" "${cached_bytes}"
143143

144144
local pinned_bytes
145145
pinned_bytes=$(cvmfs_talk -i "${reponame}" cache size | tr -d ')(' | tr -s '[:space:]' | cut -d ' ' -f 10)
146-
generate_metric 'cvmfs_pinned_bytes' 'gauge' 'CVMFS currently pinned bytes.' "repo=${fqrn}" "${pinned_bytes}"
146+
generate_metric 'cvmfs_pinned_bytes' 'gauge' 'CVMFS currently pinned bytes.' "repo=\"${fqrn}\"" "${pinned_bytes}"
147147

148148
local total_cache_size_mb
149149
total_cache_size_mb=$(cvmfs_talk -i "${reponame}" parameters | grep CVMFS_QUOTA_LIMIT | tr '=' ' ' | tr -s '[:space:]' | cut -d ' ' -f 2)
150150
local total_cache_size
151151
total_cache_size=$((total_cache_size_mb * 1024 * 1024))
152-
generate_metric 'cvmfs_total_cache_size_bytes' 'gague' 'CVMFS configured cache size via CVMFS_QUOTA_LIMIT.' "repo=${fqrn}" "${total_cache_size}"
152+
generate_metric 'cvmfs_total_cache_size_bytes' 'gauge' 'CVMFS configured cache size via CVMFS_QUOTA_LIMIT.' "repo=\"${fqrn}\"" "${total_cache_size}"
153153

154154
local cache_volume_max
155155
cache_volume_max=$(df -B1 "${cache_volume}" | tail -n 1 | tr -s '[:space:]' | cut -d ' ' -f 2)
156-
generate_metric 'cvmfs_physical_cache_size_bytes' 'gague' 'CVMFS cache volume physical size.' "repo=${fqrn}" "${cache_volume_max}"
156+
generate_metric 'cvmfs_physical_cache_size_bytes' 'gauge' 'CVMFS cache volume physical size.' "repo=\"${fqrn}\"" "${cache_volume_max}"
157157

158158
local cache_volume_free
159159
cache_volume_free=$(df -B1 "${cache_volume}" | tail -n 1 | tr -s '[:space:]' | cut -d ' ' -f 4)
160-
generate_metric 'cvmfs_physical_cache_avail_bytes' 'gague' 'CVMFS cache volume physical free space available.' "repo=${fqrn}" "${cache_volume_free}"
160+
generate_metric 'cvmfs_physical_cache_avail_bytes' 'gauge' 'CVMFS cache volume physical free space available.' "repo=\"${fqrn}\"" "${cache_volume_free}"
161161

162162
local cvmfs_mount_version
163163
cvmfs_mount_version=$(attr -g version "${repomountpoint}" | tail -n +2)
164164
local cvmfs_mount_revision
165165
cvmfs_mount_revision=$(attr -g revision "${repomountpoint}" | tail -n +2)
166-
generate_metric 'cvmfs_repo' 'guage' 'Shows the version of CVMFS used by this repository.' "repo=${fqrn},mountpoint=${repomountpoint},version=${cvmfs_mount_version},revision=${cvmfs_mount_revision}" 1
166+
generate_metric 'cvmfs_repo' 'gauge' 'Shows the version of CVMFS used by this repository.' "repo=\"${fqrn}\",mountpoint=\"${repomountpoint}\",version=\"${cvmfs_mount_version}\",revision=\"${cvmfs_mount_revision}\"" 1
167167

168168
local cvmfs_mount_rx_kb
169169
cvmfs_mount_rx_kb=$(attr -g rx "${repomountpoint}" | tail -n +2)
170170
local cvmfs_mount_rx
171171
cvmfs_mount_rx=$((cvmfs_mount_rx_kb * 1024))
172-
generate_metric 'cvmfs_rx_total' 'counter' 'Shows the overall amount of downloaded bytes since mounting.' "repo=${fqrn}" "${cvmfs_mount_rx}"
172+
generate_metric 'cvmfs_rx_total' 'counter' 'Shows the overall amount of downloaded bytes since mounting.' "repo=\"${fqrn}\"" "${cvmfs_mount_rx}"
173173

174174
local cvmfs_mount_uptime_minutes
175175
cvmfs_mount_uptime_minutes=$(attr -g uptime "${repomountpoint}" | tail -n +2)
@@ -181,34 +181,34 @@ get_cvmfs_repo_metrics() {
181181
rounded_now_to_minute=$((now - (now % 60)))
182182
cvmfs_mount_uptime=$((cvmfs_mount_uptime_minutes * 60))
183183
cvmfs_mount_epoch_time=$((rounded_now_to_minute - cvmfs_mount_uptime))
184-
generate_metric 'cvmfs_uptime_seconds' 'counter' 'Shows the time since the repo was mounted.' "repo=${fqrn}" "${cvmfs_mount_uptime}"
185-
generate_metric 'cvmfs_mount_epoch_timestamp' 'counter' 'Shows the epoch time the repo was mounted.' "repo=${fqrn}" "${cvmfs_mount_epoch_time}"
184+
generate_metric 'cvmfs_uptime_seconds' 'counter' 'Shows the time since the repo was mounted.' "repo=\"${fqrn}\"" "${cvmfs_mount_uptime}"
185+
generate_metric 'cvmfs_mount_epoch_timestamp' 'counter' 'Shows the epoch time the repo was mounted.' "repo=\"${fqrn}\"" "${cvmfs_mount_epoch_time}"
186186

187187
local cvmfs_repo_expires_min
188188
cvmfs_repo_expires_min=$(attr -g expires "${repomountpoint}" | tail -n +2)
189189
local cvmfs_repo_expires
190190
cvmfs_repo_expires=$((cvmfs_repo_expires_min * 60))
191-
generate_metric 'cvmfs_repo_expires_seconds' 'gague' 'Shows the remaining life time of the mounted root file catalog in seconds.' "repo=${fqrn}" "${cvmfs_repo_expires}"
191+
generate_metric 'cvmfs_repo_expires_seconds' 'gauge' 'Shows the remaining life time of the mounted root file catalog in seconds.' "repo=\"${fqrn}\"" "${cvmfs_repo_expires}"
192192

193193
local cvmfs_mount_ndownload
194194
cvmfs_mount_ndownload=$(attr -g ndownload "${repomountpoint}" | tail -n +2)
195-
generate_metric 'cvmfs_ndownload_total' 'counter' 'Shows the overall number of downloaded files since mounting.' "repo=${fqrn}" "${cvmfs_mount_ndownload}"
195+
generate_metric 'cvmfs_ndownload_total' 'counter' 'Shows the overall number of downloaded files since mounting.' "repo=\"${fqrn}\"" "${cvmfs_mount_ndownload}"
196196

197197
local cvmfs_mount_nioerr
198198
cvmfs_mount_nioerr=$(attr -g nioerr "${repomountpoint}" | tail -n +2)
199-
generate_metric 'cvmfs_nioerr_total' 'counter' 'Shows the total number of I/O errors encountered since mounting.' "repo=${fqrn}" "${cvmfs_mount_nioerr}"
199+
generate_metric 'cvmfs_nioerr_total' 'counter' 'Shows the total number of I/O errors encountered since mounting.' "repo=\"${fqrn}\"" "${cvmfs_mount_nioerr}"
200200

201201
local cvmfs_mount_timeout
202202
cvmfs_mount_timeout=$(attr -g timeout "${repomountpoint}" | tail -n +2)
203-
generate_metric 'cvmfs_timeout' 'guage' 'Shows the timeout for proxied connections in seconds.' "repo=${fqrn}" "${cvmfs_mount_timeout}"
203+
generate_metric 'cvmfs_timeout' 'gauge' 'Shows the timeout for proxied connections in seconds.' "repo=\"${fqrn}\"" "${cvmfs_mount_timeout}"
204204

205205
local cvmfs_mount_timeout_direct
206206
cvmfs_mount_timeout_direct=$(attr -g timeout_direct "${repomountpoint}" | tail -n +2)
207-
generate_metric 'cvmfs_timeout_direct' 'guage' 'Shows the timeout for direct connections in seconds.' "repo=${fqrn}" "${cvmfs_mount_timeout_direct}"
207+
generate_metric 'cvmfs_timeout_direct' 'gauge' 'Shows the timeout for direct connections in seconds.' "repo=\"${fqrn}\"" "${cvmfs_mount_timeout_direct}"
208208

209209
local cvmfs_mount_timestamp_last_ioerr
210210
cvmfs_mount_timestamp_last_ioerr=$(attr -g timestamp_last_ioerr "${repomountpoint}" | tail -n +2)
211-
generate_metric 'cvmfs_timestamp_last_ioerr' 'counter' 'Shows the timestamp of the last ioerror.' "repo=${fqrn}" "${cvmfs_mount_timestamp_last_ioerr}"
211+
generate_metric 'cvmfs_timestamp_last_ioerr' 'counter' 'Shows the timestamp of the last ioerror.' "repo=\"${fqrn}\"" "${cvmfs_mount_timestamp_last_ioerr}"
212212

213213
local cvmfs_repo_pid_statline
214214
cvmfs_repo_pid_statline=$(</proc/"${repo_pid}"/stat)
@@ -222,15 +222,15 @@ get_cvmfs_repo_metrics() {
222222
local cvmfs_system_seconds
223223
cvmfs_user_seconds=$(printf "%.2f" "$(echo "scale=4; $cvmfs_utime / $CLOCK_TICK" | bc)")
224224
cvmfs_system_seconds=$(printf "%.2f" "$(echo "scale=4; $cvmfs_stime / $CLOCK_TICK" | bc)")
225-
generate_metric 'cvmfs_cpu_user_total' 'counter' 'CPU time used in userspace by CVMFS mount in seconds.' "repo=${fqrn}" "${cvmfs_user_seconds}"
226-
generate_metric 'cvmfs_cpu_system_total' 'counter' 'CPU time used in the kernel system calls by CVMFS mount in seconds.' "repo=${fqrn}" "${cvmfs_system_seconds}"
225+
generate_metric 'cvmfs_cpu_user_total' 'counter' 'CPU time used in userspace by CVMFS mount in seconds.' "repo=\"${fqrn}\"" "${cvmfs_user_seconds}"
226+
generate_metric 'cvmfs_cpu_system_total' 'counter' 'CPU time used in the kernel system calls by CVMFS mount in seconds.' "repo=\"${fqrn}\"" "${cvmfs_system_seconds}"
227227

228228
local cvmfs_mount_active_proxy
229229
cvmfs_mount_active_proxy=$(attr -g proxy "${repomountpoint}" | tail -n +2)
230-
generate_metric 'cvmfs_active_proxy' 'gauge' 'Shows the active proxy in use for this mount.' "repo=${fqrn},proxy=${cvmfs_mount_active_proxy}" 1
230+
generate_metric 'cvmfs_active_proxy' 'gauge' 'Shows the active proxy in use for this mount.' "repo=\"${fqrn}\",proxy=\"${cvmfs_mount_active_proxy}\"" 1
231231

232232
# Pull in xattr based metrics with simple labels
233-
get_cvmfs_repo_extended_attribute_gague_metrics "${reponame}"
233+
get_cvmfs_repo_extended_attribute_gauge_metrics "${reponame}"
234234
get_cvmfs_repo_proxy_metrics "${reponame}"
235235
}
236236

0 commit comments

Comments
 (0)