summaryrefslogtreecommitdiff
path: root/qa/pmdas/slow
diff options
context:
space:
mode:
Diffstat (limited to 'qa/pmdas/slow')
-rw-r--r--qa/pmdas/slow/GNUmakefile37
-rw-r--r--qa/pmdas/slow/GNUmakefile.install5
-rwxr-xr-xqa/pmdas/slow/Install38
-rwxr-xr-xqa/pmdas/slow/Remove25
-rw-r--r--qa/pmdas/slow/pmdaslow.pl74
5 files changed, 179 insertions, 0 deletions
diff --git a/qa/pmdas/slow/GNUmakefile b/qa/pmdas/slow/GNUmakefile
new file mode 100644
index 0000000..32e93dd
--- /dev/null
+++ b/qa/pmdas/slow/GNUmakefile
@@ -0,0 +1,37 @@
+#!gmake
+#
+# Copyright (c) 2014 Ken McDonell. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+
+TOPDIR = ../../..
+include $(TOPDIR)/src/include/builddefs
+
+IAM = slow
+TESTDIR = $(PCP_VAR_DIR)/testsuite/pmdas/$(IAM)
+LSRCFILES = Install Remove pmda$(IAM).pl GNUmakefile.install
+LDIRT = domain.h root pmns *.log
+
+default default_pcp setup: check_domain
+
+include $(BUILDRULES)
+
+install: default
+ $(INSTALL) -m 755 -d $(TESTDIR)
+ $(INSTALL) -m 755 Install Remove $(TESTDIR)
+ $(INSTALL) -m 644 pmda$(IAM).pl $(TESTDIR)/pmda$(IAM).pl
+ $(INSTALL) -m 644 GNUmakefile.install $(TESTDIR)/GNUmakefile
+
+install_pcp: install
+
+check_domain: $(TOPDIR)/src/pmns/stdpmid
+ $(DOMAIN_PERLRULE)
diff --git a/qa/pmdas/slow/GNUmakefile.install b/qa/pmdas/slow/GNUmakefile.install
new file mode 100644
index 0000000..8340ba8
--- /dev/null
+++ b/qa/pmdas/slow/GNUmakefile.install
@@ -0,0 +1,5 @@
+default default_pcp setup:
+
+clobber clean:
+ rm -f domain.h domain.h.perl domain.h.save
+ rm -f pmns pmns.perl pmns.save
diff --git a/qa/pmdas/slow/Install b/qa/pmdas/slow/Install
new file mode 100755
index 0000000..6ef6ec9
--- /dev/null
+++ b/qa/pmdas/slow/Install
@@ -0,0 +1,38 @@
+#! /bin/sh
+#
+# Copyright (c) 2014 Ken McDonell. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# Install the slow PMDA
+#
+
+. $PCP_DIR/etc/pcp.env
+. $PCP_SHARE_DIR/lib/pmdaproc.sh
+
+iam=slow
+perl_opt=true
+daemon_opt=false
+forced_restart=false
+
+pmdaSetup
+$PCP_ECHO_PROG $PCP_ECHO_N "Startup delay (secs) [0]? $PCP_ECHO_C"
+read x
+[ -z "$x" ] && x=0
+$PCP_ECHO_PROG $PCP_ECHO_N "Fetch delay (secs) [0]? $PCP_ECHO_C"
+read y
+[ -z "$y" ] && y=0
+perl_args="$perl_args $x $y"
+[ "$x" -lt 0 ] && check_delay=`expr -1 \* $x + 2`
+[ "$x" -gt 0 ] && check_delay=`expr $x + 2`
+
+pmdaInstall
+exit 0
diff --git a/qa/pmdas/slow/Remove b/qa/pmdas/slow/Remove
new file mode 100755
index 0000000..5641c52
--- /dev/null
+++ b/qa/pmdas/slow/Remove
@@ -0,0 +1,25 @@
+#! /bin/sh
+#
+# Copyright (c) 2014 Ken McDonell. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# Remove the slow PMDA
+#
+
+. $PCP_DIR/etc/pcp.env
+. $PCP_SHARE_DIR/lib/pmdaproc.sh
+
+iam=slow
+
+pmdaSetup
+pmdaRemove
+exit 0
diff --git a/qa/pmdas/slow/pmdaslow.pl b/qa/pmdas/slow/pmdaslow.pl
new file mode 100644
index 0000000..7d8311f
--- /dev/null
+++ b/qa/pmdas/slow/pmdaslow.pl
@@ -0,0 +1,74 @@
+#
+# Copyright (c) 2014 Ken McDonell. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+
+use strict;
+use warnings;
+use PCP::PMDA;
+
+use vars qw( $pmda $start_delay $fetch_delay );
+
+sub slow_fetch_callback
+{
+ my ($cluster, $item, $inst) = @_;
+ my $metric_name = pmda_pmid_name($cluster, $item);
+
+ if ($fetch_delay > 0) {
+ sleep($fetch_delay);
+ }
+
+ $pmda->log("slow_fetch_callback $metric_name $cluster:$item ($inst)\n");
+
+ if ($inst != PM_IN_NULL) { return (PM_ERR_INST, 0); }
+ if (!defined($metric_name)) { return (PM_ERR_PMID, 0); }
+
+ return (17, 1);
+}
+
+# Usage: pmdaslow [startdelay [fetchdelay]]
+#
+$start_delay = 0;
+$start_delay = $ARGV[0] unless !defined($ARGV[0]);
+$fetch_delay = 0;
+$fetch_delay = $ARGV[1] unless !defined($ARGV[1]);
+
+#debug# print 'start delay: ',$start_delay,' sec\n';
+#debug# print 'fetch delay: ',$fetch_delay,' sec\n';
+
+$pmda = PCP::PMDA->new('slow', 243);
+$pmda->connect_pmcd unless $start_delay < 0;
+
+if ($start_delay < 0) {
+ sleep(-$start_delay);
+}
+if ($start_delay > 0) {
+ sleep($start_delay);
+}
+
+$pmda->add_metric(pmda_pmid(0,0), PM_TYPE_U32, PM_INDOM_NULL,
+ PM_SEM_INSTANT, pmda_units(0,0,0,0,0,0),
+ 'slow.seventeen', '', '');
+
+$pmda->set_fetch_callback(\&slow_fetch_callback);
+$pmda->set_user('pcp');
+$pmda->run;
+
+=pod
+
+=head1 NAME
+
+pmdaslow - QA PMDA
+
+=head1 DESCRIPTION
+
+DO NOT INSTALL THIS PMDA.