@opscompass/opscompass-cli 1.0.27 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/pgpTools.js CHANGED
@@ -13,7 +13,9 @@ async function Verify(scriptDownloadInfo) {
13
13
  // Create a readable stream for the archive file
14
14
  let readableStream = undefined;
15
15
  if (fs.existsSync(scriptDownloadInfo.filePath)) {
16
- readableStream = fs.createReadStream(scriptDownloadInfo.filePath);
16
+ // This seems to break openpgp.js if the file is > 128kb
17
+ // readableStream = fs.createReadStream(scriptDownloadInfo.filePath);
18
+ readableStream = fs.readFileSync(scriptDownloadInfo.filePath);
17
19
  } else {
18
20
  console.error("Cannot read archive file:", scriptDownloadInfo.filePath);
19
21
  return false;
@@ -84,8 +86,9 @@ async function Verify(scriptDownloadInfo) {
84
86
  });
85
87
  const { verified, keyID } = verificationResult.signatures[0];
86
88
  try {
89
+ // console.log("Awaiting verify...", verified);
87
90
  await verified; // throws on invalid signature
88
- //console.log("VERIFIED: Signed by key id " + keyID.toHex());
91
+ // console.log("VERIFIED: Signed by key id " + keyID.toHex());
89
92
  } catch (e) {
90
93
  console.log("Archive file verification failed:\n" + e.message);
91
94
  return false;
@@ -401,6 +401,46 @@ async function getMetricCheckResults(args) {
401
401
  console.log(JSON.stringify(metricCheckResults, null, 2));
402
402
  }
403
403
 
404
+ async function getAggregateMetrics(args) {
405
+ for (let i = 0; i < args.length - 1; i++) {
406
+ switch (args[i].toLowerCase()) {
407
+ case "--granularity":
408
+ callParams.granularity = args[++i];
409
+ break;
410
+ case "--offset":
411
+ callParams.offset = args[++i];
412
+ break;
413
+ case "--limit":
414
+ callParams.limit = args[++i];
415
+ break;
416
+ case "--metriccheckresultid":
417
+ case "--metric-check-result-id":
418
+ callParams.metricCheckResultId = args[++i];
419
+ break;
420
+ case "--resourceid":
421
+ case "--resource-id":
422
+ callParams.resourceId = args[++i];
423
+ break;
424
+ case "--metrictype":
425
+ case "--metric-type":
426
+ callParams.metricType = args[++i];
427
+ break;
428
+ case "--calculatedatfrom":
429
+ case "--calculated-at-from":
430
+ callParams.calculatedAtFrom = args[++i];
431
+ break;
432
+ case "--calculatedatto":
433
+ case "--calculated-at-to":
434
+ callParams.calculatedAtTo = args[++i];
435
+ break;
436
+ }
437
+ }
438
+
439
+ const client = await getOpsCompassClient();
440
+ const aggregateMetrics = await client.resources.getAggregateMetrics(callParams.granularity, callParams);
441
+ console.log(JSON.stringify(aggregateMetrics, null, 2));
442
+ }
443
+
404
444
  async function printHelp() {
405
445
  console.log("Actions available for resources:");
406
446
  console.log();
@@ -512,6 +552,17 @@ async function printHelp() {
512
552
  console.log("--id [resource id]");
513
553
  console.log("--resource-id [cloud-resource-id]");
514
554
  console.log();
555
+ console.log("get-aggregate-metrics", "Gets the aggregate metrics for a resource.");
556
+ console.log("Parameters:");
557
+ console.log("--granularity ['Day' or 'Hour']");
558
+ console.log("--metric-check-result-id (optional) [metric check result id]");
559
+ console.log("--offset (optional) [number] assists in pagination of records, default is 0");
560
+ console.log("--limit (optional) [number] assists in pagination of records, default is 100, max is 250");
561
+ console.log("--resource-id (optional) [database resource id]");
562
+ console.log("--metric-type (optional) [string]");
563
+ console.log("--calculated-at-from (optional) [timestamp]");
564
+ console.log("--calculated-at-to (optional) [timestamp]");
565
+ console.log();
515
566
  }
516
567
 
517
568
  const resourcesModule = (action, ...args) => {
@@ -542,6 +593,8 @@ const resourcesModule = (action, ...args) => {
542
593
  return getOverprovisioned(args);
543
594
  case "get-metric-check-results":
544
595
  return getMetricCheckResults(args);
596
+ case "get-aggregate-metrics":
597
+ return getAggregateMetrics(args);
545
598
  case "help":
546
599
  case "":
547
600
  return printHelp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opscompass/opscompass-cli",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Calls OpsCompass's APIs",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,13 +15,13 @@
15
15
  "author": "opscompass",
16
16
  "license": "SEE LICENSE IN license.txt",
17
17
  "dependencies": {
18
- "@opscompass/opscompass-api": "^1.0.27",
18
+ "@opscompass/opscompass-api": "^1.0.29",
19
19
  "adm-zip": "^0.5.9",
20
20
  "axios": "^0.21.1",
21
21
  "fs-extra": "^10.1.0",
22
22
  "https-proxy-agent": "^5.0.1",
23
23
  "open": "^8.2.1",
24
- "openpgp": "^5.10.2",
24
+ "openpgp": "^5.11.0",
25
25
  "semver": "^7.3.7"
26
26
  },
27
27
  "bin": {