# core/probes/system.probe.ts

> 46 lines of code and 12 definitions.

Tree: Bane's Lab Deploy
Language: typescript
Layer: operations
Canonical: https://banes-lab.com/anatomy/deploy#file-deploy-core-probes-system-probe-ts
Source text: https://banes-lab.com/source/deploy/core/probes/system.probe.ts.txt

Listed in [core/probes](https://banes-lab.com/api/source/deploy/core/probes.md), before [core/probes/vcs.probe.ts](https://banes-lab.com/source/deploy/core/probes/vcs.probe.ts.md).

## Definitions

- `describeSystem` (lexical_declaration, line 39, exported)
- `entry` (lexical_declaration, line 35)
- `processor` (lexical_declaration, line 22)
- `cores` (lexical_declaration, line 23)
- `[first]` (lexical_declaration, line 24)
- `runningFor` (lexical_declaration, line 28)
- `seconds` (lexical_declaration, line 29)
- `days` (lexical_declaration, line 30)
- `hours` (lexical_declaration, line 31)
- `platform` (lexical_declaration, line 40, exported)
- `memory` (lexical_declaration, line 41, exported)
- `entries` (lexical_declaration, line 42, exported)

## Contained in

- [core/probes](https://banes-lab.com/anatomy/deploy/folder-deploy-core-probes.md)

## Uses

- [core/converters/markdown.converter.ts](https://banes-lab.com/source/deploy/core/converters/markdown.converter.ts.md)

## Used by

- [core/reporters/deployment.reporter.ts](https://banes-lab.com/source/deploy/core/reporters/deployment.reporter.ts.md)
- [core/reporters/nginx.reporter.ts](https://banes-lab.com/source/deploy/core/reporters/nginx.reporter.ts.md)

## Linked from

- [core/converters](https://banes-lab.com/anatomy/deploy/folder-deploy-core-converters.md)
- [core/reporters](https://banes-lab.com/anatomy/deploy/folder-deploy-core-reporters.md)

## Source

```typescript
import {
    BYTES_PER_GB,
    DECIMALS,
    SECONDS_PER_DAY,
    SECONDS_PER_HOUR,
} from "#configuration/constants/deployment.constants";
import {
    CORES_SUFFIX,
    CPU_LABEL,
    DAY_SUFFIX,
    GIGABYTE,
    HOUR_SUFFIX,
    MEMORY_LABEL,
    NODE_LABEL,
    OS_LABEL,
    UNKNOWN,
    UPTIME_LABEL,
} from "#configuration/strings/notification.strings";
import { arch, cpus, release, totalmem, type, uptime } from "node:os";
import { bullet, code, lines } from "#core/converters/markdown.converter";

const processor = function processor(): string {
    const cores = cpus();
    const [first] = cores;
    return first === undefined ? UNKNOWN : `${first.model} (${String(cores.length)}${CORES_SUFFIX}`;
};

const runningFor = function runningFor(): string {
    const seconds = uptime();
    const days = Math.floor(seconds / SECONDS_PER_DAY);
    const hours = Math.floor((seconds % SECONDS_PER_DAY) / SECONDS_PER_HOUR);
    return String(days) + DAY_SUFFIX + String(hours) + HOUR_SUFFIX;
};

const entry = function entry(label: string, value: string): string {
    return bullet(label, code(value));
};

export const describeSystem = function describeSystem(): string {
    const platform = `${type()} ${release()} ${arch()}`;
    const memory = (totalmem() / BYTES_PER_GB).toFixed(DECIMALS) + GIGABYTE;
    const entries = [
        entry(OS_LABEL, platform),
        entry(NODE_LABEL, process.version),
        entry(CPU_LABEL, processor()),
        entry(MEMORY_LABEL, memory),
        entry(UPTIME_LABEL, runningFor()),
    ];
    return lines(entries);
};
```
