Geneos ["Geneos"]

The end of life (EOL) date for this module is on 31 January, 2020.

Creating XPaths

Quick Start

Take the path from the previous example:

/geneos/gateway[(@name="Demo Gateway")]/directory/probe[(@name="Basic Probe")]/managedEntity[(@name="Basic Entity")]/sampler[(@name="cpu")][(@type="Basic")]/dataview[(@name="cpu")]

This is how the same path is constructed using the builder:

String query = XPathBuilder.xpath()
    .gateway("Demo Gateway")
    .probe("Basic Probe")
    .entity("Basic Entity")
    .sampler("cpu", "Basic")

Similarly, an xpath that matches a number of items can also be expressed. For example the path to match all CRITICAL entities:


can be constructed with the builder in a more succinct and readable form:

String query = XPathBuilder.xpath().entity().severity(Severity.CRITICAL).get();

Unique identities

Some methods in the API only work with xpaths that match a single item in the system, for example executing commands. In general, the rule of thumb is the path uniquely identifies an item if all the parents are named. For the case of samplers, a type must be specified as well as a name (although this can be blank).

The builder provides the isID() utility method that can be used to test if a path satisfies these criteria:

XPathBuilder.xpath().view("test").isID() == false;

XPathBuilder.xpath().gateway("gw").probe("probey").entity("woo").isID() == true;

More examples

Here’s some more examples of using the builder:
XPathBuilder.xpath().get();                          // Matches all gateways

XPathBuilder.xpath().entity().get();                 // Matches all Managed Entities
                                                     // Methods are available for all items (from gateway to cell)

XPathBuilder.xpath().view("fred").get();             // Matches all Dataviews with the name fred

XPathBuilder.probe("henry").entity("ford").get();    // Matches all Managed Entities named ford under the Probe named henry

XPathBuilder.sampler("test", "test_type").get();     // Matches all Samplers named test from the Type test_type

XPathBuilder.xpath()                                 // Matches all critical probes named barry

XPathBuilder.xpath()                                 // Matches all snoozed entities

XPathBuilder.xpath()                                 // Matches all inactive dataviews

XPathBuilder.xpath()                                 // Matches all entities where "Country" is "US"
    .attribute("Country", "US")

XPathBuilder.xpath()                                 // All samplers with a severity of warning or higher