Skip to content

Commit

Permalink
Merge branch 'master' into cache
Browse files Browse the repository at this point in the history
  • Loading branch information
pcolby committed May 10, 2014
2 parents a9f3714 + 0979fe4 commit 090ea02
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ install:
sudo apt-get install -qq
libboost-program-options-dev
libpcp3 libpcp3-dev libpcp-pmda3 libpcp-pmda3-dev
pcp
rubygems
- if [ "$CXX" = "g++" ]; then sudo apt-get install lcov; fi
- gem install lcoveralls
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
### 0.3.4 (2014-05-10)
Features:
- [API documentation](http://pcolby.github.io/pcp-pmda-cpp/api/annotated.html)
- default PMID in PMNS exports ([48a26c7](
../../commit/c4aba3608f0f699b2df6c3d61e9f7df3aca859a0))

Bug fixes:
- metrics description fallback ([#22](../../issues/22))
Expand Down
17 changes: 12 additions & 5 deletions include/pcp-cpp/pmda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,11 @@ class pmda {

void export_pmns_data(const std::string &filename) const
{
// Some basic strings we'll use a couple of times.
const std::string &pmda_name = get_pmda_name();
std::string upper_name = get_pmda_name();
std::transform(upper_name.begin(), upper_name.end(), upper_name.begin(), ::toupper);

// Open the output file.
std::ofstream file_stream;
if (filename != "-") {
Expand All @@ -1320,6 +1325,13 @@ class pmda {
}
std::ostream &stream = (filename == "-") ? std::cout : file_stream;

// Define the PMID, if not already.
stream
<< std::endl
<< "#ifndef " << upper_name << std::endl
<< "#define " << upper_name << ' ' << get_default_pmda_domain_number() << std::endl
<< "#endif" << std::endl;

// First pass to find the length of the longest metric name.
std::string::size_type max_metric_name_size = 0;
for (metrics_description::const_iterator metrics_iter = supported_metrics.begin();
Expand All @@ -1335,11 +1347,6 @@ class pmda {
}
}

// Some basic strings we'll use a couple of times.
const std::string &pmda_name = get_pmda_name();
std::string upper_name = get_pmda_name();
std::transform(upper_name.begin(), upper_name.end(), upper_name.begin(), ::toupper);

// Second pass to export the group names and ungrouped metrics.
stream << std::endl << pmda_name << " {" << std::endl;
for (metrics_description::const_iterator metrics_iter = supported_metrics.begin();
Expand Down
4 changes: 4 additions & 0 deletions test/functional/test_simple_export_pmns.expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

#ifndef SIMPLE
#define SIMPLE 253
#endif

simple {
numfetch SIMPLE:0:0
color SIMPLE:0:1
Expand Down
4 changes: 4 additions & 0 deletions test/functional/test_simplecpu_export_pmns.expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

#ifndef SIMPLECPU
#define SIMPLECPU 129
#endif

simplecpu {
ticks
}
Expand Down
9 changes: 9 additions & 0 deletions test/functional/test_simplecpu_help_text.command
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
TEMP_DIR=`mktemp -d -t test_simplecpu_help_text-XXXXXXXXXX`
./pmdasimplecpu --export-all "$TEMP_DIR"
if [ $? -ne 0 ]; then exit; fi
dbpmda -e -n "$TEMP_DIR/root" <<EOF
open pipe pmdasimplecpu
text simplecpu.ticks.total
text simplecpu.ticks.cpu0
EOF
rm -rf "$TEMP_DIR"
10 changes: 10 additions & 0 deletions test/functional/test_simplecpu_help_text.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
open pipe pmdasimplecpu
Start pmdasimplecpu PMDA: ./pmdasimplecpu
text simplecpu.ticks.total
PMID: 129.0.0
[The amount of time spent in various states]
The amount of time spent in various states
text simplecpu.ticks.cpu0
PMID: 129.0.1
[The amount of time spent in various states]
The amount of time spent in various states
4 changes: 4 additions & 0 deletions test/functional/test_trivial_export_pmns.expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

#ifndef TRIVIAL
#define TRIVIAL 250
#endif

trivial {
time TRIVIAL:0:0
}
Expand Down
8 changes: 8 additions & 0 deletions test/functional/test_trivial_help_text.command
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
TEMP_DIR=`mktemp -d -t test_trivial_text-XXXXXXXXXX`
./pmdatrivial --export-all "$TEMP_DIR"
if [ $? -ne 0 ]; then exit; fi
dbpmda -e -n "$TEMP_DIR/root" <<EOF
open pipe pmdatrivial
text trivial.time
EOF
rm -rf "$TEMP_DIR"
6 changes: 6 additions & 0 deletions test/functional/test_trivial_help_text.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
open pipe pmdatrivial
Start pmdatrivial PMDA: ./pmdatrivial
text trivial.time
PMID: 250.0.0
[The time in seconds since 1 Jan 1970]
The time in seconds since the 1st of January, 1970.

0 comments on commit 090ea02

Please sign in to comment.