collectd aggregation plugin not working? - collectd

Can't for the life of me get the aggregation plugin to produce anything. I have
LoadPlugin aggregation
...uncommented. And I have this block:
<Plugin "aggregation">
<Aggregation>
Plugin "cpu"
Type "cpu"
GroupBy "Host"
GroupBy "TypeInstance"
CalculateSum true
CalculateAverage true
</Aggregation>
</Plugin>
...which is just pulled from the wiki. The cpu plugin specification is:
<Plugin cpu>
ReportByCpu true
ReportByState false
ValuesPercentage true
</Plugin>
It reports the cpu values fine, but not the aggregate. I've tried a bunch of aggregation specifications and none work. This is on Ubuntu 16.04 (I think), default installation of collectd.

Make the type in aggregation plugin as percent instead of cpu as you have mentioned ValuesPercentage as true in Plugin cpu.
<Plugin "aggregation">
<Aggregation>
Plugin "cpu"
Type "percent"
GroupBy "Host"
GroupBy "TypeInstance"
CalculateSum true
CalculateAverage true
</Aggregation>
</Plugin>

It looks to me like "ReportByState" has to be true and "ValuesPercentage" has to be false. For no apparent reason. And not documented anywhere. :-/

Related

the execution sequence of Simulations is not controlled

For the karate running with gatling plugin, when we specify multi Simulations in the pom like following:
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling.plugin.version}</version>
<configuration>
<simulationsFolder>src/test/java</simulationsFolder>
<runMultipleSimulations>true</runMultipleSimulations>
<includes>
<include>WorkersSimulation</include>
<include>WorkersQuerySimulation</include>
</includes>
</configuration>
</plugin>
What I expect that it executes in the sequence of my sequence in the pom, WorkersSimulation first and WorkersQuerySimulation second.
But unfortunately, looks like it picks up the simulation by alphabetic sequence, WorkersQuerySimulation first and WorkersSimulation.
Sometimes we need to control the sequence of simulations, for example: create data in first simulation and test different queries in second simulation.
So is there any way to control the sequence?
I think you can use a call in your main simulation itself to set up data, like in the demo example:
MockUtils.startServer()
Otherwise this is a question about the gatling maven plugin.

Latest stable revision with ivy excluding alpha & beta releases

For our project we like to have most dependecies automaticaly up to date so we want to use the lastest strategies in IVY. However we dont want to run the bleeding edge of the dependencies ie. alpha and beta versions.
When using:
<dependency org="org.apache.httpcomponents" name="httpclient" rev="latest.revision" />
or
<dependency org="org.apache.httpcomponents" name="httpclient" rev="latest.release" />
We get revision 4.4-alpha1
This is understandable as we use the ibiblio resolver which contains the following xml in maven-metadata.xml
<metadata>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<versioning>
<latest>4.4-alpha1</latest>
<release>4.4-alpha1</release>
<versions>
<version>4.0-alpha1</version>
<!-- snip --->
<version>4.3-alpha1</version>
<version>4.3-beta1</version>
<version>4.3-beta2</version>
<version>4.3</version>
<version>4.3.1</version>
<version>4.3.2</version>
<version>4.3.3</version>
<version>4.3.4</version>
<version>4.3.5</version>
<version>4.4-alpha1</version>
</versions>
<lastUpdated>20140801101402</lastUpdated>
</versioning>
</metadata>
The meta data indicates the alpha version as both release and latest. (not sure if this is related actualy)
In this case we there is a version we would like to get in the metadata list being 4.3.5
Now ivy has a construct with and but the documentation is quite sparse, and i cant figure out how to make this strategy 'ignore' the alpha release.
I tried variation of the following to no avail (using rev="latest.test") :
`
Edit:
From the source code of org.apache.ivy.plugins.latest.LatestRevisionStrategy it appears specialmeanings wont be able to solve this since the version is first split in parts and then compared on a part by part basis.
If there is a way to forbid revisions that contain a specific string my problem would also be solved.
`
The source code of org.apache.ivy.plugins.latest.LatestRevisionStrategy indicated it's impossible to fix this with special-meaning strings in a latestStrategy element. (thanks to: this post)
we ended up using a version matcher to enforse ivy to not use -beta- or -alpha releases.
Its not an optimal solution and the regexp probably needs to be updated a few times still.
in ivysettings.xml:
<version-matchers usedefaults="true">
<pattern-vm name="lastest.nobeta">
<match revision="latest.nobeta" pattern="\.*\d+\.\d+\.?\d*(FINAL|RELEASE|STABLE)?" matcher="regexp" />
</pattern-vm>
</version-matchers>
and in ivy.xml:
<dependency org="org.apache.poi" name="poi" rev="latest.nobeta"/>
Not entirely sure if this takes the lastest version but so far that seems to be the case.

Inject property into JPA orm.xml?

We are splitting our baseline (for release 1.0 and 2.0 concurrent development). Instead of maintaining two separate databases (and hardware), we are investigating other alternatives. We would like to be able to use the same instance of a database, and have duplicate copies of the tables/data in two different schemas:
1.0: SCHEMA_1
2.0: SCHEMA_2
The JPA orm.xml file has a property where the schema is specified:
<schema>SCHEMA_1</schema>
My question is whether a property can be injected instead of a hard coded schema name (and how).
For example, if we have a .properties file with the following:
schema.name=SCHEMA_1
Can we then use schema.name in the orm.xml file like this:
<SCHEMA>schema.name</SCHEMA>
Thanks for any help! Other alternatives for making the schema dynamic are also welcome.
JPA only defines this in the orm.xml.
In EclipseLink you can use a SessionCustomizer to set this on your EclipseLink Session in code,
session.getLogin().setTableQualifier("SCHEMA_1");
We ended up using the velocity-maven-plugin to replace tags for the schema at build-time.
In orm.xml template:
<schema>${schemaName}</schema>
In the pom file:
<plugin>
<groupId>net.rumati.maven.plugins</groupId>
<artifactId>velocity-maven-plugin</artifactId>
<version>0.1.1</version>
<executions>
<execution>
<id>replaceSchema</id>
<phase>generate-sources</phase>
<goals>
<goal>velocity</goal>
</goals>
</execution>
</executions>
<configuration>
<template>${basedir}/src/main/resources/hibernate/template/orm.xml</template>
<properties>
<schemaName>${r1Schema}</schemaName>
</properties>
<outputFile>${basedir}/src/main/resources/hibernate/orm.xml</outputFile>
</configuration>
</plugin>
I've been faced with the exact problem. Instead of building the orm.xml in to the project, leave it out of the artifact build. Then at runtime, put it on the classpath of the application so it's picked up:
<persistence-unit-metadata>
<persistence-unit-defaults>
<schema>MySchemaThatsBeenDeterminedAtRuntime</schema>
</persistence-unit-defaults>
</persistence-unit-metadata>
Each instance of application can have it's own orm.xml and point to a different schema.

Performing Simple Calculations with Native Ant Tasks

Using only native ANT tasks, how can I create a custom ANT task to do the following:
Calculate the the number of days since January 1, 2000 local time and store it in a property.
Calculate the number of seconds since midnight local time, divided by 2 and store it in a property.
The above property values will then be appended to others and written to a file.
ANT is not a general purpose programming language, so you need to write a custom task or alternatively use something like the groovy plugin
The following example demonstrates how a groovy task using the Joda Time library can set the properties as you've specified.
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<groovy>
import org.joda.time.*
def now = new DateTime()
def midnight = new DateMidnight()
def year2000 = new DateTime(2000,1,1,0,0,0,0)
properties["year2000.days"] = Days.daysBetween(year2000, now).days
properties["midnight.seconds"] = Seconds.secondsBetween(midnight, now).seconds
properties["midnight.seconds.halved"] = Seconds.secondsBetween(midnight, now).dividedBy(2).seconds
</groovy>
I can't recommend Joda Time highly enough, standard Date and Time manipulation in Java just sucks!
Additional notes
The groovy task above will require the following jars on your classpath:
groovy-all-1.7.4.jar
joda-time-1.6.1.jar
I'd recommend using the ivy plugin to manage these by adding a "resolve" target that downloads the jars and sets the classpath automatically:
<target name="resolve">
<ivy:resolve/>
<ivy:cachepath pathid="build.path"/>
</target>
The following is the ivy.xml that lists the dependencies to be downloaded:
<ivy-module version="2.0">
<info organisation="org.myspotontheweb" module="demo"/>
<dependencies>
<dependency org="org.codehaus.groovy" name="groovy-all" rev="1.7.4" conf="default"/>
<dependency org="joda-time" name="joda-time" rev="1.6.1" conf="default"/>
</dependencies>
</ivy-module>

Override Maven's default resource filter replacement pattern

By default maven will filter resources like this:
<properties>
<replace.me>value</replace.me>
</properties>
<some-tag>
<key>${replace.me}</key>
</some-tag>
will get you:
<some-tag>
<key>value</key>
</some-tag>
Is there a way to override the way maven selects the strings to replace? Specifically, I want to be able to use this:
<some-tag>
<key>#replace.me#</key>
</some-tag>
to get the same result as above.
Have a look at the delimiters parameter of the resources mojo. Configuring the plugin like this will do the trick:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<delimiters>
<delimiter>${*}</delimiter><!-- to keep the default behavior -->
<delimiter>#</delimiter><!-- to add Ant-like tokens style -->
</delimiters>
</configuration>
</plugin>
If you would like to use only one approach then disable default delimeters:
<useDefaultDelimiters>false</useDefaultDelimiters>
<delimiters>
<delimiter>#</delimiter>
</delimiters>