Skip to content

Commit efae667

Browse files
authored
Merge branch 'master' into journal_info
2 parents 3b2c1f7 + f76b66e commit efae667

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

scripts/monitor_metrics.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,36 @@ monitor_journals () {
520520
mv "$tmpfname" "$fname"
521521
}
522522

523+
monitor_checkpoint_nosdp () {
524+
# Metric for when checkpoint last ran and how long it took.
525+
526+
[[ $UseSDP -eq 1 ]] && return # Not valid if SDP in use
527+
528+
fname="$metrics_root/p4_checkpoint-${SERVER_ID}.prom"
529+
tmpfname="$fname.$$"
530+
531+
rm -f "$tmpfname"
532+
echo "#HELP p4_checkpoint_log_time Time of last checkpoint log" >> "$tmpfname"
533+
echo "#TYPE p4_checkpoint_log_time gauge" >> "$tmpfname"
534+
535+
# Look for latest checkpoint log which has Start/End (avoids run in progress and rotate_journal logs)
536+
ckp_md5=`find -L ${P4ROOT} -maxdepth 1 -type f -name 'checkpoint.*.md5' -exec ls -t {} + |head -n1`
537+
ckp_log=`echo $ckp_md5 | sed 's/\.md5$//'`
538+
539+
ckp_starttime=`stat -c "%W" "$ckp_log"`
540+
ckp_endtime=`stat -c "%Y" "$ckp_log"`
541+
ckp_duration=$(($ckp_endtime - $ckp_starttime))
542+
543+
echo "p4_checkpoint_log_time{${serverid_label}} $ckp_starttime" >> "$tmpfname"
544+
545+
echo "#HELP p4_checkpoint_duration Time taken for last checkpoint/restore action" >> "$tmpfname"
546+
echo "#TYPE p4_checkpoint_duration gauge" >> "$tmpfname"
547+
echo "p4_checkpoint_duration{${serverid_label}} $ckp_duration" >> "$tmpfname"
548+
549+
chmod 644 "$tmpfname"
550+
mv "$tmpfname" "$fname"
551+
}
552+
523553
monitor_replicas () {
524554
# Metric for server replicas
525555
fname="$metrics_root/p4_replication${sdpinst_suffix}-${SERVER_ID}.prom"
@@ -848,4 +878,5 @@ monitor_versions
848878
monitor_ssl
849879
monitor_checkpoint
850880
monitor_journals
881+
monitor_checkpoint_nosdp
851882
monitor_errors

0 commit comments

Comments
 (0)