gigadrive 2.12.0 → 2.13.0
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/dist/index.cjs +32 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +32 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { Effect as Effect29, Layer, LogLevel, Logger } from "effect";
|
|
|
9
9
|
// package.json
|
|
10
10
|
var package_default = {
|
|
11
11
|
name: "gigadrive",
|
|
12
|
-
version: "2.
|
|
12
|
+
version: "2.13.0",
|
|
13
13
|
repository: {
|
|
14
14
|
type: "git",
|
|
15
15
|
url: "https://github.com/Gigadrive/sdk.git",
|
|
@@ -3508,6 +3508,36 @@ var getCommand = Command12.make(
|
|
|
3508
3508
|
for (const line of describeMicroVm(vm)) yield* Console12.log(line);
|
|
3509
3509
|
}).pipe(reportErrors2("get the microVM"))
|
|
3510
3510
|
).pipe(Command12.withDescription("Show a microVM"));
|
|
3511
|
+
var formatGigabytes = (bytes) => `${(bytes / 1e9).toFixed(1)} GB`;
|
|
3512
|
+
var describeMicroVmMetrics = (metrics) => {
|
|
3513
|
+
const latest = metrics.cpu.at(-1);
|
|
3514
|
+
const peak = metrics.cpu.reduce((max, point) => Math.max(max, point.cpuPercent), 0);
|
|
3515
|
+
return [
|
|
3516
|
+
`CPU (last ${metrics.windowMinutes} min, ${metrics.vcpus} vCPU): ${latest ? `${latest.cpuPercent}% at ${latest.time}, peak ${peak}%` : "no samples"}`,
|
|
3517
|
+
metrics.current ? `Memory: ${formatGigabytes(metrics.current.memoryUsedBytes)} of ${formatGigabytes(metrics.current.memoryTotalBytes)}` : "Memory: unavailable (not running, or no answer)",
|
|
3518
|
+
metrics.current ? `Disk: ${formatGigabytes(metrics.current.diskUsedBytes)} of ${formatGigabytes(metrics.current.diskTotalBytes)}` : "Disk: unavailable (not running, or no answer)"
|
|
3519
|
+
];
|
|
3520
|
+
};
|
|
3521
|
+
var metricsCommand = Command12.make(
|
|
3522
|
+
"metrics",
|
|
3523
|
+
{
|
|
3524
|
+
microvmId: microvmIdArg,
|
|
3525
|
+
window: Options7.integer("window").pipe(
|
|
3526
|
+
Options7.withDescription("Minutes of CPU history, 1 to 1440 (default: 15)"),
|
|
3527
|
+
Options7.optional
|
|
3528
|
+
),
|
|
3529
|
+
json: jsonOption2
|
|
3530
|
+
},
|
|
3531
|
+
({ microvmId, window, json }) => Effect22.gen(function* () {
|
|
3532
|
+
const apiClient = yield* ApiClientService;
|
|
3533
|
+
const windowMinutes = Option14.getOrUndefined(window);
|
|
3534
|
+
const metrics = yield* apiClient.request(
|
|
3535
|
+
(client) => client.microvms.getMetrics(microvmId, windowMinutes === void 0 ? {} : { windowMinutes })
|
|
3536
|
+
);
|
|
3537
|
+
if (json) return yield* Console12.log(JSON.stringify(metrics, null, 2));
|
|
3538
|
+
for (const line of describeMicroVmMetrics(metrics)) yield* Console12.log(line);
|
|
3539
|
+
}).pipe(reportErrors2("read the microVM metrics"))
|
|
3540
|
+
).pipe(Command12.withDescription("Show a microVM's CPU, memory and disk use"));
|
|
3511
3541
|
var execInMicroVm = (flags, io = nodeSessionIo()) => Effect22.gen(function* () {
|
|
3512
3542
|
const env = yield* keyValues("--env", flags.env);
|
|
3513
3543
|
const timeout = yield* optionalDuration("--timeout", flags.timeout);
|
|
@@ -3909,6 +3939,7 @@ var SUBCOMMANDS = [
|
|
|
3909
3939
|
createCommand,
|
|
3910
3940
|
listCommand2,
|
|
3911
3941
|
getCommand,
|
|
3942
|
+
metricsCommand,
|
|
3912
3943
|
execCommand,
|
|
3913
3944
|
shellCommand,
|
|
3914
3945
|
copyCommand,
|