opennms
Version:
Client API for the OpenNMS network monitoring platform
1 lines • 51.7 kB
JSON
{"remainingRequest":"/data/node_modules/babel-loader/lib/index.js!/data/node_modules/ts-loader/index.js!/data/src/CLI.ts","dependencies":[{"path":"/data/src/CLI.ts","mtime":1553611371624},{"path":"/data/node_modules/typescript-logging/dist/commonjs/typescript-logging.d.ts","mtime":1553611387808},{"path":"/data/node_modules/typescript-logging/dist/commonjs/control/LogGroupControl.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/control/CategoryServiceControl.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/MessagesToExtensionJSON.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/MessagesFromExtensionJSON.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/ExtensionMessageJSON.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/ExtensionHelper.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/AbstractCategoryLogger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/LoggerOptions.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryLogger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryService.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryConsoleLoggerImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryDelegateLoggerImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryMessageBufferImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/Logger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/LoggerFactory.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/LoggerFactoryService.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/LoggerFactoryRuntimeSettings.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/AbstractLogger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/ConsoleLoggerImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/MessageBufferLoggerImpl.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/utils/DataStructures.d.ts","mtime":1553611387936},{"path":"/data/node_modules/typescript-logging/dist/commonjs/utils/JSONHelper.d.ts","mtime":1553611387936},{"path":"/data/node_modules/typescript-logging/dist/commonjs/utils/MessageUtils.d.ts","mtime":1553611387936},{"path":"/data/node_modules/moment/moment.d.ts","mtime":1553611386704},{"path":"/data/node_modules/axios/index.d.ts","mtime":1553611386356},{"path":"/data/typings/index.d.ts","mtime":1553611371628},{"path":"/data/node_modules/@types/fs-extra/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/node/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/node/inspector.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/glob/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/minimatch/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/glob/node_modules/@types/minimatch/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/handlebars/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/highlight.js/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/jest/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/jquery/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/lodash/index.d.ts","mtime":1553611386320},{"path":"/data/node_modules/@types/lodash/common/common.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/array.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/collection.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/date.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/function.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/lang.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/math.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/number.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/object.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/seq.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/string.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/util.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/marked/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/shelljs/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/urijs/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/typescript/lib/lib.es2015.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.core.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.collection.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.generator.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.promise.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.iterable.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.symbol.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.proxy.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.reflect.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es5.d.ts","mtime":1553611387388},{"path":"/data/node_modules/typescript/lib/lib.dom.d.ts","mtime":1553611387384},{"path":"/data/node_modules/lodash.startcase/index.js","mtime":1553611386696},{"path":"/data/src/API.ts","mtime":1553611371624},{"path":"/data/src/api/Log.ts","mtime":1553611371624},{"path":"/data/node_modules/typescript-logging/dist/commonjs/typescript-logging.d.ts","mtime":1553611387808},{"path":"/data/.babelrc","mtime":1553611371556},{"path":"/data/node_modules/cache-loader/dist/cjs.js","mtime":1553611387012},{"path":"/data/node_modules/babel-loader/lib/index.js","mtime":1553611386992},{"path":"/data/node_modules/ts-loader/index.js","mtime":1553611386824}],"contextDependencies":[],"result":["\"use strict\";\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar startCase = require(\"lodash.startcase\");\nvar API_1 = require(\"./API\");\nvar Log_1 = require(\"./api/Log\");\nvar typescript_logging_1 = require(\"typescript-logging\");\n/** @hidden */\nvar CLI = function CLI() {\n var version = global.OPENNMS_JS_VERSION || require('../package.json').version || 'unknown';\n var catCLI = new typescript_logging_1.Category('cli', Log_1.catRoot);\n // tslint:disable\n var Table = require('cli-table2');\n var colors = require('colors');\n var fs = require('fs');\n var path = require('path');\n var program = require('commander');\n // tslint:enable\n var homedir = process.env[process.platform === 'win32' ? 'USERPROFILE' : 'HOME'];\n var defaultConfigFile = path.join(homedir, '.opennms-cli.config.json');\n var tableFormat = {\n /* tslint:disable:object-literal-sort-keys */\n head: [],\n colWidths: [],\n chars: {\n 'middle': ' ',\n 'top': '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n 'left': '',\n 'left-mid': '',\n 'mid': '',\n 'mid-mid': '',\n 'right': '',\n 'right-mid': '',\n 'bottom': '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': ''\n },\n style: {\n 'padding-left': 0,\n 'padding-right': 0\n },\n wordWrap: true\n };\n var readConfig = function readConfig() {\n var configfile = program.config || defaultConfigFile;\n var config = void 0;\n if (fs.existsSync(configfile)) {\n config = JSON.parse(fs.readFileSync(configfile));\n } else {\n config = {\n password: 'admin',\n url: undefined,\n username: 'admin'\n };\n }\n return config;\n };\n var handleError = function handleError(message, err) {\n var realError = new Error(message);\n if (err instanceof API_1.API.OnmsResult) {\n realError = new API_1.API.OnmsError(message + ': ' + err.message, err.code);\n } else if (err.message) {\n realError = new API_1.API.OnmsError(message + ': ' + err.message);\n } else if (Object.prototype.toString.call(err) === '[object String]') {\n realError = new API_1.API.OnmsError(message + ': ' + err);\n }\n if (program.debug) {\n Log_1.log.error(realError.message, realError, catCLI);\n } else {\n Log_1.log.error(realError.message, undefined, catCLI);\n }\n return realError;\n };\n /* tslint:disable:no-console */\n // global options\n program.option('-d, --debug', 'Enable debug output', function () {\n Log_1.setLogLevel(typescript_logging_1.LogLevel.Debug);\n }).option('-c, --config <file>', 'Specify a configuration file (default: ~/.opennms-cli.config.json)').option('-v, --version', 'Print the OpenNMS.js version and exit', function () {\n console.log(version);\n process.exit(0);\n });\n // connect (validate server and save config)\n program.command('connect [url]').description('Connect to an OpenNMS Horizon or Meridian server').option('-u, --username <username>', 'The username to authenticate as (default: admin)').option('-p, --password <password>', 'The password to authenticate with (default: admin)').action(function (url, options) {\n console.log(colors.red('WARNING: This command saves your login' + ' information to ~/.opennms-cli.config.json in clear text.'));\n var config = readConfig();\n if (url) {\n // the user is passing a URL, reset the config\n config.url = url;\n config.username = 'admin';\n config.password = 'admin';\n }\n if (options.username) {\n config.username = options.username;\n }\n if (options.password) {\n config.password = options.password;\n }\n var auth = new API_1.API.OnmsAuthConfig(config.username, config.password);\n var server = new API_1.API.OnmsServer('OpenNMS', config.url, auth);\n var http = new API_1.Rest.AxiosHTTP(server);\n return API_1.Client.checkServer(server, http).then(function () {\n console.log(colors.green('Connection succeeded.'));\n if (!program.config) {\n Log_1.log.debug('Saving configuration to ' + defaultConfigFile, catCLI);\n fs.writeFileSync(defaultConfigFile, JSON.stringify(config, undefined, 2), { mode: 384 });\n }\n return true;\n }).catch(function (err) {\n return handleError('Server check failed', err);\n });\n });\n // list server capabilities\n program.command('capabilities').description('List the API capabilities of the OpenNMS server').action(function () {\n var config = readConfig();\n var auth = new API_1.API.OnmsAuthConfig(config.username, config.password);\n var server = new API_1.API.OnmsServer('OpenNMS', config.url, auth);\n var http = new API_1.Rest.AxiosHTTP(server);\n return API_1.Client.getMetadata(server, http).then(function (res) {\n var c = colors.green;\n if (res.type === API_1.API.ServerTypes.MERIDIAN) {\n console.log(colors.blue('OpenNMS Meridian ' + res.version.displayVersion + ' Capabilities:'));\n c = colors.blue;\n } else {\n console.log(colors.green('OpenNMS Horizon ' + res.version.displayVersion + ' Capabilities:'));\n }\n console.log('');\n var caps = res.capabilities();\n var t = new Table(tableFormat);\n for (var cap in caps) {\n if (cap === 'type') {\n continue;\n }\n t.push([startCase(cap) + ':', caps[cap]]);\n }\n console.log(t.toString());\n console.log('');\n return res;\n }).catch(function (err) {\n return handleError('Capabilities check failed', err);\n });\n });\n var alarmHeaders = ['ID', 'Severity', 'Node', 'Count', 'Last', 'Log'];\n var colorify = function colorify(severity) {\n switch (severity) {\n case 'INDETERMINATE':\n return colors.grey(severity);\n case 'CLEARED':\n return colors.white(severity);\n case 'NORMAL':\n return colors.green(severity);\n case 'WARNING':\n return colors.magenta(severity);\n case 'MINOR':\n return colors.yellow(severity);\n case 'MAJOR':\n return colors.bold.yellow(severity);\n case 'CRITICAL':\n return colors.bold.red(severity);\n default:\n return severity;\n }\n };\n var getMaxWidth = function getMaxWidth(data, prop, max) {\n var filtered = data.map(function (d) {\n return ('' + d[prop]).length;\n });\n var m = Math.max.apply(Math, _toConsumableArray(filtered));\n return Math.min(m, max);\n };\n var logMessageLength = 50;\n var formatAlarms = function formatAlarms(alarms) {\n return alarms.map(function (alarm) {\n var severityLabel = alarm.severity && alarm.severity.label ? alarm.severity.label : '';\n var logMessage = '';\n if (alarm.logMessage) {\n logMessage = alarm.logMessage.replace('[\\r\\n].*$', '').replace('<p>', '').replace('</p>', '').trim();\n }\n return {\n count: alarm.count,\n id: alarm.id,\n log: logMessage,\n node: alarm.nodeLabel || '',\n severity: colorify(severityLabel),\n time: alarm.lastEventTime ? alarm.lastEventTime.format('YYYY-MM-DD HH:ss') : ''\n };\n });\n };\n // list current alarms\n program.command('alarms [filters...]').description('List current alarms with optional filters (eg: \"severity eq MAJOR\" or \"node.label like dns*\")').action(function (filters) {\n var config = readConfig();\n return new API_1.Client().connect('OpenNMS', config.url, config.username, config.password).then(function (client) {\n var dao = new API_1.DAO.AlarmDAO(client);\n var filter = new API_1.API.Filter();\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = filters[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var f = _step.value;\n\n Log_1.log.debug('filter=' + f, catCLI);\n var parsed = API_1.API.Restriction.fromString(f);\n if (parsed) {\n filter.withOrRestriction(parsed);\n } else {\n Log_1.log.warn('Unable to parse filter \"' + f + '\"', catCLI);\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return dao.find(filter).then(function (alarms) {\n var format = Object.assign({}, tableFormat);\n var formatted = formatAlarms(alarms);\n format.head = ['ID', 'Severity', 'Node', 'Count', 'Time', 'Log'];\n format.colWidths = [3, 8, getMaxWidth(formatted, 'node', 30), 5, 17];\n var existingWidths = format.colWidths.reduce(function (acc, val) {\n return acc + val;\n });\n var spacers = format.colWidths.length * 2;\n var remainder = process.stdout.columns - existingWidths - spacers;\n format.colWidths.push(remainder);\n var t = new Table(format);\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = formatted[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var alarm = _step2.value;\n\n t.push([alarm.id, alarm.severity, alarm.node, alarm.count, alarm.time, alarm.log]);\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n console.log(t.toString());\n console.log('');\n });\n }).catch(function (err) {\n return handleError('Alarm list failed', err);\n });\n });\n var createAlarmAction = function createAlarmAction(name, description) {\n for (var _len = arguments.length, aliases = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {\n aliases[_key - 2] = arguments[_key];\n }\n\n var p = program.command(name + ' <id>');\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = aliases[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var alias = _step3.value;\n\n p.alias(alias);\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n p.description(description);\n p.action(function (id) {\n id = parseInt(id, 10);\n var config = readConfig();\n return new API_1.Client().connect('OpenNMS', config.url, config.username, config.password).then(function (client) {\n return client.alarms()[name](id).then(function () {\n console.log('Success!');\n return true;\n });\n }).catch(function (err) {\n return handleError(name + ' failed', err);\n });\n });\n };\n // ack an alarm\n program.command('acknowledge <id>').alias('ack').description('Acknowledge an alarm').option('-u, --user <user>', 'Which user to acknowledge as (only administrators can do this)').action(function (id, options) {\n id = parseInt(id, 10);\n var config = readConfig();\n return new API_1.Client().connect('OpenNMS', config.url, config.username, config.password).then(function (client) {\n return client.alarms().acknowledge(id, options.user).then(function () {\n console.log('Success!');\n return true;\n });\n }).catch(function (err) {\n return handleError('Acknowledge failed', err);\n });\n });\n // save a sticky memo\n program.command('saveSticky <id>').alias('sticky').description('Create or update the sticky memo associated with the alarm').option('-u, --user <user>', 'Which user to update the memo as (only administrators can do this)').option('-b, --body <body>', 'Memo body').action(function (id, options) {\n id = parseInt(id, 10);\n var config = readConfig();\n return new API_1.Client().connect('OpenNMS', config.url, config.username, config.password).then(function (client) {\n return client.alarms().saveStickyMemo(id, options.body, options.user).then(function () {\n console.log('Success!');\n return true;\n });\n }).catch(function (err) {\n return handleError('Save failed', err);\n });\n });\n // save a journal memo\n program.command('saveJournal <id>').alias('journal').description('Create or update the journal memo associated with the alarm').option('-u, --user <user>', 'Which user to update the memo as (only administrators can do this)').option('-b, --body <body>', 'Memo body').action(function (id, options) {\n id = parseInt(id, 10);\n var config = readConfig();\n return new API_1.Client().connect('OpenNMS', config.url, config.username, config.password).then(function (client) {\n return client.alarms().saveJournalMemo(id, options.body, options.user).then(function () {\n console.log('Success!');\n return true;\n });\n }).catch(function (err) {\n return handleError('Save failed', err);\n });\n });\n createAlarmAction('unacknowledge', 'Unacknowledge an alarm', 'unack');\n createAlarmAction('escalate', 'Escalate an alarm');\n createAlarmAction('clear', 'Clear an alarm');\n createAlarmAction('createTicket', 'Create a trouble ticket for an alarm', 'create');\n createAlarmAction('triggerTicketUpdate', 'Trigger a trouble ticket update for an alarm', 'update');\n createAlarmAction('closeTicket', 'Close a trouble ticket for an alarm', 'close');\n createAlarmAction('deleteStickyMemo', 'Delete the sticky memo for an alarm', 'deleteSticky');\n createAlarmAction('deleteJournalMemo', 'Delete the journal memo for an alarm', 'deleteJournal');\n program.parse(process.argv);\n if (!process.argv.slice(2).length) {\n program.outputHelp();\n process.exit(0);\n }\n};\nprocess.on('unhandledRejection', function (reason, p) {\n console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);\n});\nCLI();",{"version":3,"file":"/data/src/CLI.ts","sourceRoot":"","sources":["/data/src/CLI.ts"],"names":[],"mappings":";;;;;AAAA,wBAA8C;AAE9C,oBAAoD;AAEpD,oBAAoD;AACpD,mCAK4B;AAE5B,AAAc;AACd,IAAM,AAAG,MAAG,AAAG,AAAE;AACf,QAAM,AAAO,UAAG,AAAM,OAAC,AAAkB,sBAAI,AAAO,QAAC,AAAiB,AAAC,mBAAC,AAAO,WAAI,AAAS,AAAC;AAC7F,QAAM,AAAM,SAAG,IAAI,qBAAQ,SAAC,AAAK,OAAE,MAAO,AAAC,AAAC;AAE5C,AAAiB;AACjB,QAAM,AAAK,QAAG,AAAO,QAAC,AAAY,AAAC,AAAC;AACpC,QAAM,AAAM,SAAG,AAAO,QAAC,AAAQ,AAAC,AAAC;AACjC,QAAM,AAAE,KAAG,AAAO,QAAC,AAAI,AAAC,AAAC;AACzB,QAAM,AAAI,OAAG,AAAO,QAAC,AAAM,AAAC,AAAC;AAC7B,QAAM,AAAO,UAAG,AAAO,QAAC,AAAW,AAAC,AAAC;AACrC,AAAgB;AAEhB,QAAM,AAAO,UAAG,AAAO,QAAC,AAAG,IAAE,AAAO,QAAC,AAAQ,aAAK,AAAO,AAAC,AAAC,AAAC,OAAhC,GAAiC,AAAa,AAAC,AAAC,gBAAC,AAAM,AAAC,AAAC;AACrF,QAAM,AAAiB,oBAAG,AAAI,KAAC,AAAI,KAAC,AAAO,SAAE,AAA0B,AAAC,AAAC;AAEzE,QAAM,AAAW;AACf,AAA6C;AAC7C,AAAI,cAAE,AAAE;AACR,AAAS,mBAAE,AAAE;AACb,AAAK;AACH,AAAQ,sBAAE,AAAI;AACd,AAAK,mBAAE,AAAE;AACT,AAAS,uBAAE,AAAE;AACb,AAAU,wBAAE,AAAE;AACd,AAAW,yBAAE,AAAE;AACf,AAAM,oBAAE,AAAE;AACV,AAAU,wBAAE,AA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AAAa,eAAE,AAAG,AAAC,AAAC,AAC3C;AAAC,AAAC,AAAC,AACP;AAAC,AAAC,AAAC;AAEP,AAAiB,sBAAC,AAAe,iBAAE,AAAwB,0BAAE,AAAO,AAAC,AAAC;AACtE,AAAiB,sBAAC,AAAU,YAAE,AAAmB,AAAC,AAAC;AACnD,AAAiB,sBAAC,AAAO,SAAE,AAAgB,AAAC,AAAC;AAE7C,AAAiB,sBAAC,AAAc,gBAAE,AAAsC,wCAAE,AAAQ,AAAC,AAAC;AACpF,AAAiB,sBAAC,AAAqB,uBAAE,AAA8C,gDAAE,AAAQ,AAAC,AAAC;AACnG,AAAiB,sBAAC,AAAa,eAAE,AAAqC,uCAAE,AAAO,AAAC,AAAC;AAEjF,AAAiB,sBAAC,AAAkB,oBAAE,AAAqC,uCAAE,AAAc,AAAC,AAAC;AAC7F,AAAiB,sBAAC,AAAmB,qBAAE,AAAsC,wCAAE,AAAe,AAAC,AAAC;AAEhG,AAAO,YAAC,AAAK,MAAC,AAAO,QAAC,AAAI,AAAC,AAAC;AAE5B,AAAE,AAAC,QAAC,CAAC,AAAO,QAAC,AAAI,KAAC,AAAK,MAAC,AAAC,AAAC,GAAC,AAAM,AAAC,QAAC,AAAC;AAClC,AAAO,gBAAC,AAAU,AAAE,AAAC;AACrB,AAAO,gBAAC,AAAI,KAAC,AAAC,AAAC,AAAC,AAClB;AAAC,AACH;AAAC,AAAC;AAEF,AAAO,QAAC,AAAE,GAAC,AAAoB,sBAAE,UAAC,AAAM,QAAE,AAAC,AAAE,AAAE;AAC7C,AAAO,YAAC,AAAG,IAAC,AAAiC,mCAAE,AAAC,GAAE,AAAS,WAAE,AAAM,AAAC,AAAC,AACvE;AAAC,AAAC,AAAC;AAEH,AAAG,AAAE,AAAC","sourcesContent":["import * as startCase from 'lodash.startcase';\n\nimport {API, Model, Rest, DAO, Client} from './API';\n\nimport {log, catRoot, setLogLevel} from './api/Log';\nimport {\n Category,\n CategoryServiceFactory,\n CategoryDefaultConfiguration,\n LogLevel,\n} from 'typescript-logging';\n\n/** @hidden */\nconst CLI = () => {\n const version = global.OPENNMS_JS_VERSION || require('../package.json').version || 'unknown';\n const catCLI = new Category('cli', catRoot);\n\n // tslint:disable\n const Table = require('cli-table2');\n const colors = require('colors');\n const fs = require('fs');\n const path = require('path');\n const program = require('commander');\n // tslint:enable\n\n const homedir = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];\n const defaultConfigFile = path.join(homedir, '.opennms-cli.config.json');\n\n const tableFormat = {\n /* tslint:disable:object-literal-sort-keys */\n head: [],\n colWidths: [],\n chars: {\n 'middle': ' ',\n 'top': '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n 'left': '',\n 'left-mid': '',\n 'mid': '',\n 'mid-mid': '',\n 'right': '',\n 'right-mid': '',\n 'bottom': '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n },\n style: {\n 'padding-left': 0,\n 'padding-right': 0,\n },\n wordWrap: true,\n };\n\n const readConfig = () => {\n const configfile = program.config || defaultConfigFile;\n let config;\n if (fs.existsSync(configfile)) {\n config = JSON.parse(fs.readFileSync(configfile));\n } else {\n config = {\n password: 'admin',\n url: undefined,\n username: 'admin',\n };\n }\n return config;\n };\n\n const handleError = (message, err) => {\n let realError: any = new Error(message);\n if (err instanceof API.OnmsResult) {\n realError = new API.OnmsError(message + ': ' + err.message, err.code);\n } else if (err.message) {\n realError = new API.OnmsError(message + ': ' + err.message);\n } else if (Object.prototype.toString.call(err) === '[object String]') {\n realError = new API.OnmsError(message + ': ' + err);\n }\n if (program.debug) {\n log.error(realError.message, realError, catCLI);\n } else {\n log.error(realError.message, undefined, catCLI);\n }\n return realError;\n };\n\n /* tslint:disable:no-console */\n\n // global options\n program\n .option('-d, --debug', 'Enable debug output', () => {\n setLogLevel(LogLevel.Debug);\n })\n .option('-c, --config <file>', 'Specify a configuration file (default: ~/.opennms-cli.config.json)')\n .option('-v, --version', 'Print the OpenNMS.js version and exit', () => {\n console.log(version);\n process.exit(0);\n });\n\n // connect (validate server and save config)\n program\n .command('connect [url]')\n .description('Connect to an OpenNMS Horizon or Meridian server')\n .option('-u, --username <username>', 'The username to authenticate as (default: admin)')\n .option('-p, --password <password>', 'The password to authenticate with (default: admin)')\n .action((url, options) => {\n console.log(colors.red('WARNING: This command saves your login'\n + ' information to ~/.opennms-cli.config.json in clear text.'));\n const config = readConfig();\n if (url) {\n // the user is passing a URL, reset the config\n config.url = url;\n config.username = 'admin';\n config.password = 'admin';\n }\n\n if (options.username) {\n config.username = options.username;\n }\n if (options.password) {\n config.password = options.password;\n }\n const auth = new API.OnmsAuthConfig(config.username, config.password);\n const server = new API.OnmsServer('OpenNMS', config.url, auth);\n const http = new Rest.AxiosHTTP(server);\n return Client.checkServer(server, http).then(() => {\n console.log(colors.green('Connection succeeded.'));\n if (!program.config) { // don't write the config if a config was passed in\n log.debug('Saving configuration to ' + defaultConfigFile, catCLI);\n fs.writeFileSync(defaultConfigFile, JSON.stringify(config, undefined, 2), { mode: 0o600 });\n }\n return true;\n }).catch((err) => {\n return handleError('Server check failed', err);\n });\n });\n\n // list server capabilities\n program\n .command('capabilities')\n .description('List the API capabilities of the OpenNMS server')\n .action(() => {\n const config = readConfig();\n const auth = new API.OnmsAuthConfig(config.username, config.password);\n const server = new API.OnmsServer('OpenNMS', config.url, auth);\n const http = new Rest.AxiosHTTP(server);\n return Client.getMetadata(server, http).then((res) => {\n let c = colors.green;\n if (res.type === API.ServerTypes.MERIDIAN) {\n console.log(colors.blue('OpenNMS Meridian ' + res.version.displayVersion + ' Capabilities:'));\n c = colors.blue;\n } else {\n console.log(colors.green('OpenNMS Horizon ' + res.version.displayVersion + ' Capabilities:'));\n }\n console.log('');\n\n const caps = res.capabilities();\n const t = new Table(tableFormat);\n for (const cap in caps) {\n if (cap === 'type') {\n continue;\n }\n t.push([startCase(cap) + ':', caps[cap]]);\n }\n console.log(t.toString());\n console.log('');\n\n return res;\n }).catch((err) => {\n return handleError('Capabilities check failed', err);\n });\n });\n\n const alarmHeaders = ['ID', 'Severity', 'Node', 'Count', 'Last', 'Log'];\n\n const colorify = (severity: string) => {\n switch (severity) {\n case 'INDETERMINATE': return colors.grey(severity);\n case 'CLEARED': return colors.white(severity);\n case 'NORMAL': return colors.green(severity);\n case 'WARNING': return colors.magenta(severity);\n case 'MINOR': return colors.yellow(severity);\n case 'MAJOR': return colors.bold.yellow(severity);\n case 'CRITICAL': return colors.bold.red(severity);\n default: return severity;\n }\n };\n\n const getMaxWidth = (data, prop, max) => {\n const filtered = data.map((d) => ('' + d[prop]).length);\n const m = Math.max(...filtered);\n return Math.min(m, max);\n };\n\n const logMessageLength = 50;\n const formatAlarms = (alarms) => {\n return alarms.map((alarm) => {\n const severityLabel = ((alarm.severity && alarm.severity.label) ? alarm.severity.label : '');\n\n let logMessage = '';\n if (alarm.logMessage) {\n logMessage = alarm.logMessage.replace('[\\r\\n].*$', '').replace('<p>', '').replace('</p>', '').trim();\n }\n\n return {\n count: alarm.count,\n id: alarm.id,\n log: logMessage,\n node: alarm.nodeLabel || '',\n severity: colorify(severityLabel),\n time: (alarm.lastEventTime ? alarm.lastEventTime.format('YYYY-MM-DD HH:ss') : ''),\n };\n });\n };\n\n // list current alarms\n program\n .command('alarms [filters...]')\n .description('List current alarms with optional filters (eg: \"severity eq MAJOR\" or \"node.label like dns*\")')\n .action((filters) => {\n const config = readConfig();\n return new Client().connect('OpenNMS', config.url, config.username, config.password).then((client) => {\n const dao = new DAO.AlarmDAO(client);\n\n const filter = new API.Filter();\n\n for (const f of filters) {\n log.debug('filter=' + f, catCLI);\n const parsed = API.Restriction.fromString(f);\n if (parsed) {\n filter.withOrRestriction(parsed);\n } else {\n log.warn('Unable to parse filter \"' + f + '\"', catCLI);\n }\n }\n\n return dao.find(filter).then((alarms) => {\n const format = Object.assign({}, tableFormat);\n const formatted = formatAlarms(alarms);\n\n format.head = [ 'ID', 'Severity', 'Node', 'Count', 'Time', 'Log' ];\n format.colWidths = [3, 8, getMaxWidth(formatted, 'node', 30), 5, 17];\n const existingWidths = format.colWidths.reduce((acc, val) => acc + val);\n const spacers = (format.colWidths.length * 2);\n const remainder = process.stdout.columns - existingWidths - spacers;\n format.colWidths.push(remainder);\n const t = new Table(format);\n for (const alarm of formatted) {\n t.push([alarm.id, alarm.severity, alarm.node, alarm.count, alarm.time, alarm.log]);\n }\n console.log(t.toString());\n console.log('');\n });\n }).catch((err) => {\n return handleError('Alarm list failed', err);\n });\n });\n\n const createAlarmAction = (name: string, description: string, ...aliases: string[]) => {\n const p = program.command(name + ' <id>');\n for (const alias of aliases) {\n p.alias(alias);\n }\n p.description(description);\n p.action((id) => {\n id = parseInt(id, 10);\n const config = readConfig();\n return new Client().connect('OpenNMS', config.url, config.username, config.password).then((client) => {\n return client.alarms()[name](id).then(() => {\n console.log('Success!');\n return true;\n });\n }).catch((err) => {\n return handleError(name + ' failed', err);\n });\n });\n };\n\n // ack an alarm\n program\n .command('acknowledge <id>')\n .alias('ack')\n .description('Acknowledge an alarm')\n .option('-u, --user <user>', 'Which user to acknowledge as (only administrators can do this)')\n .action((id, options) => {\n id = parseInt(id, 10);\n const config = readConfig();\n return new Client().connect('OpenNMS', config.url, config.username, config.password).then((client) => {\n return client.alarms().acknowledge(id, options.user).then(() => {\n console.log('Success!');\n return true;\n });\n }).catch((err) => {\n return handleError('Acknowledge failed', err);\n });\n });\n\n // save a sticky memo\n program\n .command('saveSticky <id>')\n .alias('sticky')\n .description('Create or update the sticky memo associated with the alarm')\n .option('-u, --user <user>', 'Which user to update the memo as (only administrators can do this)')\n .option('-b, --body <body>', 'Memo body')\n .action((id, options) => {\n id = parseInt(id, 10);\n const config = readConfig();\n return new Client().connect('OpenNMS', config.url, config.username, config.password).then((client) => {\n return client.alarms().saveStickyMemo(id, options.body, options.user).then(() => {\n console.log('Success!');\n return true;\n });\n }).catch((err) => {\n return handleError('Save failed', err);\n });\n });\n\n // save a journal memo\n program\n .command('saveJournal <id>')\n .alias('journal')\n .description('Create or update the journal memo associated with the alarm')\n .option('-u, --user <user>', 'Which user to update the memo as (only administrators can do this)')\n .option('-b, --body <body>', 'Memo body')\n .action((id, options) => {\n id = parseInt(id, 10);\n const config = readConfig();\n return new Client().connect('OpenNMS', config.url, config.username, config.password).then((client) => {\n return client.alarms().saveJournalMemo(id, options.body, options.user).then(() => {\n console.log('Success!');\n return true;\n });\n }).catch((err) => {\n return handleError('Save failed', err);\n });\n });\n\n createAlarmAction('unacknowledge', 'Unacknowledge an alarm', 'unack');\n createAlarmAction('escalate', 'Escalate an alarm');\n createAlarmAction('clear', 'Clear an alarm');\n\n createAlarmAction('createTicket', 'Create a trouble ticket for an alarm', 'create');\n createAlarmAction('triggerTicketUpdate', 'Trigger a trouble ticket update for an alarm', 'update');\n createAlarmAction('closeTicket', 'Close a trouble ticket for an alarm', 'close');\n\n createAlarmAction('deleteStickyMemo', 'Delete the sticky memo for an alarm', 'deleteSticky');\n createAlarmAction('deleteJournalMemo', 'Delete the journal memo for an alarm', 'deleteJournal');\n\n program.parse(process.argv);\n\n if (!process.argv.slice(2).length) {\n program.outputHelp();\n process.exit(0);\n }\n};\n\nprocess.on('unhandledRejection', (reason, p) => {\n console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);\n});\n\nCLI();\n"]}]}