Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI commands for host and service status by dimension(s) #19

Open
kobmaki opened this issue Jun 25, 2017 · 5 comments
Open

CLI commands for host and service status by dimension(s) #19

kobmaki opened this issue Jun 25, 2017 · 5 comments
Assignees
Labels
enhancement New feature or improvement

Comments

@kobmaki
Copy link

kobmaki commented Jun 25, 2017

Implement the missing cli command for the cube hoststatus.

Expected Behavior

icingacli cube hoststatus

list the cli commands for hoststatus

Current Behavior

icingacli cube
The 'cube' module does not provide any CLI commands

Possible Solution

Implement some commands for the hoststatus cube.

icingacli cube hoststatus

cube for host status
====================

Available actions:

  additional      show addtitional dimensions (doesn't work)
  columns         list the columns of the requestet cube
  dimensions      list all available dimensions
  examples        show examples
  facts           list facts for the cube
  fullqueryNoNull   show the sql query with no null values in the cube.
  info            show information
  list            fetch data from request cube, option --dimensions= required
  listSlices      list slices (doesn't work)

Show help on a specific action: icingacli help hoststatus 

The "list" command has the following options:

fetch data from request cube, option --dimensions= required
===========================================================================

USAGE

  icingacli cube hoststatus list --dimensions=[dimensions] [options]

OPTIONS

  --format=csv|json|sql

EXCEPTIONS

  MissingParameter is thrown if dimensions is not given

EXAMPLE

  icingacli cube hoststatus list --dimensions=OS

An example output with format=csv is:

icingacli cube hoststatus list --dimensions=os --format=csv

os,hosts_cnt,hosts_nok,hosts_unhandled_nok
"","214","0","0"
"","215","0","0"
"Linux","1","0","0"

The format=sql show simple the underlying query. To access the "fullquery" I had to change in interface Icinga\Module\Cube\DbCube::fullquery from protected to public.

The example with format=sql is:

icingacli cube hoststatus list --dimensions=os --format=sql

SELECT rollup.os, rollup.hosts_cnt, rollup.hosts_nok, rollup.hosts_unhandled_nok FROM (SELECT sub.os, SUM(hosts_cnt) AS hosts_cnt, SUM(hosts_nok) AS hosts_nok, SUM(hosts_unhandled_nok) AS hosts_unhandled_nok FROM (SELECT c_os.varvalue AS os, COUNT(*) AS hosts_cnt, SUM(CASE WHEN hs.current_state = 0 THEN 0 ELSE 1 END) AS hosts_nok, SUM(CASE WHEN hs.current_state != 0 AND hs.problem_has_been_acknowledged = 0 AND hs.scheduled_downtime_depth = 0 THEN 1 ELSE 0 END) AS hosts_unhandled_nok FROM icinga_objects AS o
 INNER JOIN icinga_hosts AS h ON o.object_id = h.host_object_id AND o.is_active = 1
 LEFT JOIN icinga_hoststatus AS hs ON hs.host_object_id = h.host_object_id
 LEFT JOIN icinga_customvariablestatus AS c_os ON c_os.varname = 'os' AND c_os.object_id = o.object_id GROUP BY c_os.varvalue) AS sub GROUP BY (os) WITH ROLLUP) AS rollup ORDER BY (rollup.os IS NOT NULL) ASC, rollup.os ASC, (rollup.hosts_cnt IS NOT NULL) ASC, rollup.hosts_cnt ASC, (rollup.hosts_nok IS NOT NULL) ASC, rollup.hosts_nok ASC, (rollup.hosts_unhandled_nok IS NOT NULL) ASC, rollup.hosts_unhandled_nok ASC

I fork the module and create a branch "feature-cli-command-hoststatus-WIP". This branch will be only for develop. If everything is fine I will create the final branch from which I create the pull request.

Please give some infos, if the feature will be accepted, so that I could continue with implementing the feature. Give the info if I could change the method "fullquery" like described.

@kobmaki
Copy link
Author

kobmaki commented Jan 30, 2018

Still waiting for response if the feature will be accepted.

@kobmaki
Copy link
Author

kobmaki commented Jul 5, 2018

@Thomas-Gelf @lippserd can you add a comment some thoughts about this enhancement.

@nilmerg
Copy link
Member

nilmerg commented Apr 3, 2019

Hi,

sorry for not responding earlier.

I'm not quite sure what the intention of this feature is. How is this supposed to be used?

The main motivation of this module has ever been a quick overview about one's monitoring environment. Quick in the sense that a few clicks in the UI lead to a useful result.

In which way does this feature expand/support this motivation?

@ysijason ysijason mentioned this issue Jan 27, 2017
@nilmerg nilmerg added needs-feedback We'll only proceed once we hear from you again and removed question labels May 20, 2019
@kobmaki
Copy link
Author

kobmaki commented Jun 28, 2019

It is always handy if you have an command line option.
I use the command line for quick grouping of information.

We can disguss this on the 10th Anniversary Party.

@lippserd
Copy link
Member

lippserd commented Apr 7, 2020

Hey,

Sorry that this request did not get the appropriate attention in the past.
I think a CLI command does not harm here. It is also handy for scripting.

I'll have a look at the PR and send you the feedback there.

All the best,
Eric

@lippserd lippserd changed the title feature-cli-command-hoststatus CLI commands for host and service status by dimension(s) Apr 7, 2020
@lippserd lippserd added enhancement New feature or improvement and removed needs-feedback We'll only proceed once we hear from you again labels Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

3 participants