Is there a possibility to count the entries in a view?
So for instance to display all systems in a view with snapshots, or with version xy of os, this is quite simple in a view… but to count them and deliver them as a simple metric… not possible?
Hi @katamadone,
i guess this is not possible just out of the box. You can write a simple check to query the livestatus for a specific condition and feed this back as new service to display.
Retrieving status data via Livestatus (checkmk.com)
Hi @katamadone,
you can’t get the count into a metric from what I know but you can create your view and get the row count by default from Checkmk.
Here is an example:
I used the quicksearch to find the service Filesystem on all my hosts. (Service Search View)
You can do that with any view you like. On the top right you get the row count.
Hope that helps 
Greetings Norm
the lq way did it.
created a /usr/lib/check_mk_agent/local/omd_runner.sh
#!/bin/bash
runuser -l XYZ -c 'bash /usr/lib/check_mk_agent/local/lq_localcheck.sh'
which runs that:
#!/bin/bash
#output
#echo "0 \"My 1st service\" - This static service is always OK"
#0 "My 2nd service" count1=42|count2=21;23;27 A service with 2 graphs
#metricname=value;warn;crit;min;max
#Count acknowledged problems for simple metric
countack=$(lq "GET services\nColumns: host_name description state\nFilter: acknowledged = 1" | wc -l)
#Count snapshots excluding vcenter count himself
countsnaps=$(lq "GET services\nColumns: host_name plugin_output\nFilter: description ~~ snapshots" | grep -v -e "Count: 0" -e ***SERVERNAME*** | wc -l)
#Retrieve snapshot count on vcenter to compare and monitor snapshots from unmonitored systems
countervcenter=$(lq "GET services\nColumns: host_name plugin_output\nFilter: description ~~ snapshots" | grep -e ***SERVERNAME*** | grep -oP '(?<=Count:\ ).*?(?=,\ )')
echo "0 LocalChecks pip_count_ackproblem=$countack;2;5|pip_count_snapshots=$countsnaps;5;10|pip_count_vcentersnaphots=$countervcenter Local Checks to retrieve some metrics"
Sometimes ago i made an extension to the reporting system what does exactly this, count elements of a view. It is not public available as you needed to modify the source as i found no way to integrate own reporting elements.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.
