# get_cpus_length

> Solve the problem of Not correct os.cpus().length inside the docker container with cpus limited.

Latest version **1.0.3** (published 2022-05-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install get_cpus_length
pnpm add get_cpus_length
yarn add get_cpus_length
bun add get_cpus_length
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-05-02 |
| First published | 2022-01-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | xiaoxiaojx |
| Maintainers | 15000621931 |
| Keywords | docker, container, k8s, kubernetes, cpus, automaxprocs |

## Links

- npm: https://www.npmjs.com/package/get_cpus_length
- Repository: https://github.com/xiaoxiaojx/get_cpus_length
- Issues: https://github.com/xiaoxiaojx/get_cpus_length/issues
- npm.io page: https://npm.io/package/get_cpus_length

## Recent versions

- 1.0.3 (latest) — 2022-05-02
- 1.0.2 — 2022-03-23
- 1.0.1 — 2022-01-29
- 1.0.0 — 2022-01-29

## README

# get_cpus_length

Get os.cpus().length to match Linux container CPU quota. 

```diff
const getCpusLength = require("get_cpus_length");

+ console.log("CpusLength: ", getCpusLength());
- console.log("CpusLength: ", require("os").cpus().length);
```

## Installing
<a href="https://www.npmjs.com/~get_cpus_length" target="_blank"><img src="https://img.shields.io/npm/v/get_cpus_length.svg" alt="NPM Version" /></a>
```bash
npm install get_cpus_length
```
or
```bash
yarn add get_cpus_length
```

## why
When your kubernetes is set up [Resource Management for Pods and Containers](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/), this problem occurs [Not correct os.cpus().length inside the docker container with cpus limited. #28762](https://github.com/nodejs/node/issues/28762).

---
_Source: https://npm.io/package/get_cpus_length · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
