3. Selecting and merging available data

In this section, we look at how to select a subset of available information and merging different datatrees together. This allows us to be selective in what information to present and also to monitor different aspects of the system concurrently.

Configuration file

The following configuration will measure the available free space [1] on the / (root) and /home filesystem and store the latest values in a file /tmp/monami-filesystem.

Copy the configuration below as the /etc/monami.d/example.conf file, replacing any existing file. Remember, don't try to copy the circled numbers!

 ##  MonAMI by Example, Section 3
 # Our root filesystem
  name = root-fs
  location = /
 # Our /home filesystem
 [filesystem]  ❶
  name = home-fs
  location = /home
 # Record latest f/s stats every two seconds
  read = ❷ root-fs❸.capacity.available, home-fs.capacity.available
  write = snapshot
  interval = 2
 # The current filesystem statistics
  filename = /tmp/monami-filesystem

A few things to note:

The configuration creates two monitoring targets, called root-fs and home-fs. Both use the filesystem plugin.

The read attribute is a comma-separated list of metrics or branches.

The first element of the metric's path is the target name.

Running the example

As with the previous example, you should make sure MonAMI is running for at least two seconds to guarantee that the file /tmp/monami-filesystem has been created or updated. Depending on your filesystems this file should contain something like the following:

"root-fs.capacity.available"    "126.091797" (MiB) [every 2s]
"home-fs.capacity.available"    "11178.921875" (MiB) [every 2s]

Combining different datatrees

sample sections can combine different datatrees together by specifying them as a comma-separated list of sources. The simplest is to include all metrics from two sources, by simply specifying the two target names:

read = root-fs, home-fs

This will combine all data from the root-fs and home-fs targets, resulting in /tmp/monami-filesystem output like:

"root-fs.fragment size" "1024" (B) [every 2s]
"root-fs.blocks.size"   "1024" (B) [every 2s]
"root-fs.blocks.total"  "264445" (blocks) [every 2s]
"root-fs.blocks.free"   "142771" (blocks) [every 2s]
"root-fs.blocks.available"      "129118" (blocks) [every 2s]
"root-fs.capacity.total"        "258.24707" (MiB) [every 2s]
"root-fs.capacity.free" "139.424805" (MiB) [every 2s]
"root-fs.capacity.available"    "126.091797" (MiB) [every 2s]
"root-fs.capacity.used" "118.822266" (MiB) [every 2s]
"root-fs.files.used"    "68272" (files) [every 2s]
"root-fs.files.free"    "56294" (files) [every 2s]
"root-fs.files.available"       "56294" (files) [every 2s]
"root-fs.flag"  "0" () [every 2s]
"root-fs.namemax"       "255" () [every 2s]
"home-fs.fragment size" "4096" (B) [every 2s]
"home-fs.blocks.size"   "4096" (B) [every 2s]
"home-fs.blocks.total"  "16490546" (blocks) [every 2s]
"home-fs.blocks.free"   "3699490" (blocks) [every 2s]
"home-fs.blocks.available"      "2861802" (blocks) [every 2s]
"home-fs.capacity.total"        "64416.195312" (MiB) [every 2s]
"home-fs.capacity.free" "14451.132812" (MiB) [every 2s]
"home-fs.capacity.available"    "11178.914062" (MiB) [every 2s]
"home-fs.capacity.used" "49965.0625" (MiB) [every 2s]
"home-fs.files.used"    "8388608" (files) [every 2s]
"home-fs.files.free"    "8008120" (files) [every 2s]
"home-fs.files.available"       "8008120" (files) [every 2s]
"home-fs.flag"  "0" () [every 2s]
"home-fs.namemax"       "255" () [every 2s]

The process of combining the two datatrees is shown graphically in Figure 2.

A diagram showing combining datatrees.

Combining datatrees allows you to combine monitoring results from different targets. In the configuration at the beginning of this section, we merge two datatrees (each datatree has only one metric), but in general we can combine any number of datatrees, collecting data from any number of targets.

Selecting subsets of a datatree

In the above example, we select just one metric from within each target's datatree. From the root-fs and home-fs targets, we select only each target's capacity.available metric. This can be extended to select mulitple metrics from each datatree.

Selecting metrics

To select multiple metrics, simply list the metrics you want as a comma-separated list of datatree paths. In the following example, two metrics have been selected.

read = root-fs.blocks.available, root-fs.files.available
A diagram showing the example datatree with selected elements.

The resulting datatree will include both the blocks.available and files.available metrics.

Selecting branches

We can also specify the path of a branch to include all metrics within that branch. The following shows an example selecting the blocks branch from the root-fs target.

read = root-fs.blocks
A diagram showing the example datatree with selected elementsq

The new datatree will include the metrics root-fs.blocks.size, root-fs.blocks.total, root-fs.blocks.free and root-fs.blocks.available.

Vetoing metrics and branches

Sometimes it is easier to say what data you don't want to include. Specific metrics or branches can be excluded by listing them prefixed with an exclamation mark. The following demonstrates how to select all of the blocks metrics from the root-fs targe except for the blocks.size metric:

read = root-fs.blocks, !root-fs.blocks.free
A diagram showing the example datatree with selected element.

This is easier than listing all the metrics individually: root-fs.blocks.size, root-fs.blocks.total and root-fs.blocks.available.

The final example shows selecting all metrics except for a metric and those beneath a branch.

read = root-fs, !root-fs.blocks, !root-fs.flag
A diagram showing the datatree selected with a branch and single metric vetoed.

By selecting metrics and branches, and by vetoing selected metrics or branches of metrics, arbitrary selection of metrics is made easy.

[1] The term “available space” refers to the storage available to a non-root user whereas “free space” is the storage available to the root user. In general, the free space will be greater than the available space. More information is available in the MonAMI User Guide.