Skip to content

Commit

Permalink
pmcheck: add Redis service detection and agent recommendation
Browse files Browse the repository at this point in the history
  • Loading branch information
natoscott committed Apr 3, 2024
1 parent 0c52b50 commit d6a83f2
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
4 changes: 4 additions & 0 deletions qa/1491.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ basic stuff ...
-- no args --
pmcd OK
pmda-overhead OK
pmda-redis could be activated
pmda-sample OK
pmie OK
pmlogger OK
Expand All @@ -11,6 +12,7 @@ zeroconf OK
-- -l --
pmcd
pmda-overhead
pmda-redis
pmda-sample
pmie
pmlogger
Expand All @@ -19,6 +21,7 @@ zeroconf
-- -lv --
pmcd Performance Metrics Collection Daemon - local source of performance data
pmda-overhead overhead PMDA - ...
pmda-redis Redis PMDA - metrics from redis-server(1)
pmda-sample sample PMDA
pmie Inference Engine - rule-based monitoring
pmlogger Archive logger - record performance data for subsequent replay
Expand All @@ -27,6 +30,7 @@ zeroconf Zeroconf Package ...
-- -s --
pmcd OK
pmda-overhead OK
pmda-redis could be activated
pmda-sample OK
pmie OK
pmlogger OK
Expand Down
10 changes: 9 additions & 1 deletion qa/913
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# PCP QA Test No. 913
# Exercise the Redis PMDA and metrics.
#
# Copyright (c) 2017 Red Hat.
# Copyright (c) 2017,2024 Red Hat.
#

seq=`basename $0`
Expand Down Expand Up @@ -47,6 +47,10 @@ cd $PCP_PMDAS_DIR/redis
# get to a known starting place
$sudo ./Remove >>$here/$seq.full 2>&1

echo
echo "=== $iam check pre-install ==="
pmcheck pmda-redis

echo
echo "=== $iam agent installation ==="
$sudo ./Remove > $tmp.out 2>&1
Expand All @@ -66,6 +70,10 @@ _filter_pmda_install <$tmp.out \
}
{ print }'

echo
echo "=== $iam check post-install ==="
pmcheck pmda-redis

echo
echo "=== verify $iam metrics ==="
pminfo --verify $iam | _filter
Expand Down
6 changes: 6 additions & 0 deletions qa/913.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
QA output created by 913

=== redis check pre-install ===
pmda-redis could be activated

=== redis agent installation ===
Culling the Performance Metrics Name Space ...
redis ... not found in Name Space, this is OK
Expand All @@ -11,6 +14,9 @@ Terminate PMDA if already installed ...
Updating the PMCD control file, and notifying PMCD ...
Check redis metrics have appeared ... X metrics and Y values

=== redis check post-install ===
pmda-redis active

=== verify redis metrics ===

=== remove redis agent ===
Expand Down
4 changes: 3 additions & 1 deletion src/pmdas/redis/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ install: default
$(INSTALL) -m 755 -d $(PMDACONFIG)
$(INSTALL) -m 644 -t $(PMDATMPDIR)/redis.conf redis.conf $(PMDACONFIG)/redis.conf
@$(INSTALL_MAN)
$(INSTALL) -m 755 $(IAM).pmcheck $(PCP_SHARE_DIR)/lib/pmcheck/pmda-$(IAM)
else
build-me:
install:
install: $(TOPDIR)/src/pmcheck/pmda.na.template
$(INSTALL) -m 755 $< $(PCP_SHARE_DIR)/lib/pmcheck/pmda-$(IAM)
endif

default_pcp : default
Expand Down
45 changes: 45 additions & 0 deletions src/pmdas/redis/redis.pmcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh
#
# Redis PMDA "plugin" for pmcheck
#

. $PCP_DIR/etc/pcp.env || exit 1
. $PCP_SHARE_DIR/lib/checkproc.sh

_do_args "$@"

_check()
{
test -n "$@" && echo "$@" >> $tmp/out
[ "$verbose" -gt 0 -a -s $tmp/out ] && cat $tmp/out
[ $status -eq 0 ] || exit
}

if $lflag
then
[ "$verbose" -gt 0 ] && echo "Redis PMDA - metrics from redis-server(1)"
elif $sflag
then
status=0 # assume active until proven not to be
which redis-server >/dev/null 2>&1 || status=2
which redis-cli >/dev/null 2>&1 || status=2
_check "redis install status: $status"
_ctl_svc state redis || status=$?
_check "redis service status: $status"
pong=`redis-cli PING`
test "$pong" = "PONG" || status=2
_check "redis cli PING: $pong"
_ctl_pmda state redis || status=1
_check "redis PMDA status: $status"
elif $aflag
then
_ctl_pmda activate redis pmdaredis.pl || status=1
elif $dflag
then
_ctl_pmda deactivate redis || status=1
else
[ $verbose -gt 0 ] && echo "botch sflag=$sflag aflag=$aflag dflag=$dflag show_me=$show_me verbose=$verbose"
status=99
fi

exit

0 comments on commit d6a83f2

Please sign in to comment.