I've already written a few things to help me get access to my reporting data (for example, see My Own OpenWhisk Stat Tool) and while debugging something today I ran into an issue with how the wsk CLI reports activations. Currently it just shows a name and ID. Consider this input: wsk activation list dotweet.

Activation list

To get details about the activation, you then need to copy the ID and get details for just that particular activation. There is already an open enhancement request for making this report a bit deeper, but in the meantime, I've wrote a quick utility I could run to get more information. Here is an example of the output:

Activation list enterprise style

All I did was use the OpenWhisk npm package to fetch details and then add them to the result. I didn't build this as a "real" CLI, but I can run ./utils/activations.js for a default dump matching the wsk command line or supply a name and limit (currently you can't do a limit without a name) like so: ./utils/activation.js dotweet 50.

The code is rather simple:

#!/usr/bin/env node

// 2 args supported, either pass <<name>> or <<name> <<limit>>. Limit defaults to 30.

const openwhisk = require('openwhisk');
const chalk = require('chalk');

const api_key = process.env['__OW_API_KEY'];
if(!api_key) {
	console.error('Environment variable __OW_API_KEY not present.');
	process.exit();
}

let options = {apihost: 'openwhisk.ng.bluemix.net', api_key: api_key};
let ow = openwhisk(options);

let activationOptions = {
	docs:true,
	limit:30
}

if(process.argv.length >= 3) activationOptions.name = process.argv[2];
if(process.argv.length >= 4) activationOptions.limit = process.argv[3];

console.log('ID'.padEnd(32)+' '+'Name'.padEnd(32)+' '+'Date'.padEnd(15)+' Result');

ow.activations.list(activationOptions).then(result => {
	result.forEach(act => {
		let id = act.activationId;
		let name = act.name;
		let start = dtFormat(new Date(act.start));
		let result = act.response.success;
		let resultStr = chalk.green('true');
		if(!result) {
			resultStr = chalk.red('false');
		}
		console.log(`${id} ${name.padEnd(32)} ${start.padEnd(15)} ${resultStr}`);
	});
});

function dtFormat(d) {
	let result = '';
	result += d.getMonth()+1;
	result += '/';
	result += d.getDate();
	result += '/';
	result += d.getFullYear().toString().substr(2,2);
	result += ' ';
	result += zpad(d.getHours()) + ':' + zpad(d.getMinutes());
	return result;
}

function zpad(s) {
	if(s.toString().length === 1) return '0'+s;
	return s;
}

And if you want to use this yourself, you can grab the bits here: https://github.com/cfjedimaster/Serverless-Examples/tree/master/util. I'm going to try to add more utilities under this folder as they come to mind. There are similar tools as well, like WITT, but unfortunately that isn't working for me right now. (And yep, I filed a bug report.)

And as one more aside, I'm really tempted to build my own web UI like WITT just so I can play with Vue!