dalen / puppetexplorer

Puppet web interface written in CoffeeScript using AngularJS
demo.puppetexplorer.io
Other
413 stars 43 forks source link

Widgets on the dashboard, where "Pending jobs" is the most crucial #54

Open elofu17 opened 8 years ago

elofu17 commented 8 years ago

In config.js(.example), please add something like this (I'm no programmer but I think you get the idea):

DASHBOARD_PANELS = [
  {"name":"Nodes with failures","type":"danger","query":"#node.latest_report_status=\"failed\""},
  {"name":"Nodes with pending jobs","type":"warning","query":"#report { latest_report?=true and noop_pending=true }"},
  {"name":"Unresponsive nodes (within last ${UNRESPONSIVE_HOURS}h)","type":"danger","query":"#node.report_timestamp < @\"now - $UNRESPONSIVE_HOURS hours\""},
  {"name":"Nodes in production env","type":"success","query":"#node.catalog_environment = production"},
  {{"name":"Nodes in non-production env",type:"warning",query:"#node.catalog_environment != production"}}
];

1) Add a dashboard for "Nodes with pending jobs".

I have cron run 'puppet agent -t --noop' every now and then on all my nodes.

Normally these noops show up as grey icons in the Nodes tab in Puppet Explorer, as there's nothing to do. The nodes are up to date. Everything is good.

However, if the noop-run show pending changes, this is indicated with a blue icon in the Node tab.

It is crucial to me to have this as a dashboard widget, as it will show how many of my nodes are NOT up to date.

Before you can add this dashboard, you need to fix the bug in https://github.com/dalen/node-puppetdbquery/issues/1, since the query contain a questionmark.

report { latest_report?=true and noop=true and status="unchanged" }

2) I almost consider the following a bug:

In the 'Unresponsive nodes' widget you're using a static query like this: '#node.report_timestamp < @"now - 2 hours"'

This forces the widget to use 2 hours, even though the user can configure the UNRESPONSIVE_HOURS variable to e.g. 24h earlier in the file.

Update to something like this: '#node.report_timestamp < @"now - $UNRESPONSIVE_HOURS hours"'

3) This is a bit overkill, but it's just a simple if-statement:

If the puppet-db only deal with one single environment, "production", I think you should hide the 'Nodes in non-production env' widget from the dashboard. Otherwise it will always show "0" and just waste screen space for users like me. :-)

if ( total number of environments > 1 ) then show the 'Nodes in non-production env' widget fi

elofu17 commented 8 years ago

Updated the text above a bit after https://github.com/dalen/node-puppetdbquery/issues/1 was updated.

elofu17 commented 8 years ago

Update: Since the latest update of the puppet agent software (and puppetdb 4.2), we now have a new keyword for finding nodes with pending jobs: noop_pending=true.

So I've modified the original text with: old: {"name":"Nodes with pending jobs","type":"warning","query":"#report { latest_report?=true and noop=true and status=\"unchanged\" }"}, new: {"name":"Nodes with pending jobs","type":"warning","query":"#report { latest_report?=true and noop_pending=true }"},

Loshea commented 7 years ago

I have tried messing around with this some, and am finding that PE apparently doesn't understand latest_report?. When I try to query on it, Chrome reports: ` app.js:58 Error: Lexical error on line 1. Unrecognized text.

...report.latest_report?=true and noop_pend -----------------------^

at Parser.parseError (https://pe.vmlapps.com/app.js:107:5439)
at Object.parseError (https://pe.vmlapps.com/app.js:107:7768)
at Object.next (https://pe.vmlapps.com/app.js:107:11776)
at Object.lex (https://pe.vmlapps.com/app.js:107:11943)
at b (https://pe.vmlapps.com/app.js:107:5515)
at Parser.parse (https://pe.vmlapps.com/app.js:107:6207)
at Object.process.undefined.require.undefined.exports.parse 

(https://pe.vmlapps.com/app.js:107:13987) at Object.exports.parse (https://pe.vmlapps.com/app.js:103:218) at PuppetDB.parse (https://pe.vmlapps.com/app.js:26:1011) at PuppetDB.parseAndQuery (https://pe.vmlapps.com/app.js:26:1447)

`

Loshea commented 7 years ago

looks like it was fixed in node-puppetdbquery https://github.com/dalen/node-puppetdbquery/blob/master/lib/parser.jison

does this project depend on node-puppetdbquery?

elofu17 commented 7 years ago

Yes, I bug-reported it in node-puppetdbquery. Yes, PuppetExplorer depend on it.