Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@dnlup/fastify-doc
Advanced tools
A Fastify plugin for sampling process metrics.
It uses the module @dnlup/doc
behind the scenes.
It decorates the Fastify
instance with a Sampler
instance that you can use to get process metrics.
A new sample of the metrics is available when the Sampler
emits a sample
event.
See @dnlup/doc
documentation for more details.
npm i @dnlup/fastify-doc
const fastify = require('fastify')()
const metrics = require('@dnlup/fastify-doc')
fastify.register(metrics)
fastify.register(function myReporter (instance, opts, next) {
instance.metrics.on('sample', () => {
// sendCpuUsage(instance.metrics.cpu.usage)
// ...send other metrics as well
})
next()
})
fastify.get('/', (request, reply) => {
reply.send({ ok: true })
})
fastify.listen(3000)
const fastify = require('fastify')()
const metrics = require('@dnlup/fastify-doc')
fastify.register(async function myReporter (instance, opts) {
await instance.register(metrics)
instance.metrics.on('sample', () => {
// sendCpuUsage(instance.metrics.cpu.usage)
// ...send other metrics as well
})
})
fastify.get('/', (request, reply) => {
reply.send({ ok: true })
})
fastify.listen(3000)
The options are the same of @dnlup/doc
(reported here for convenience):
options
<Object>
sampleInterval
<number>
: sample interval (ms) to get a sample. On each sampleInterval
ms a sample
event is emitted. Default: 500
on Node < 11.10.0, 1000
otherwise. Under the hood the package uses monitorEventLoopDelay
when available to track the event loop delay and this allows to increase the default sampleInterval
.autoStart
<boolean>
: start automatically to collect metrics. Default: true
.unref
<boolean>
: unref the timer used to schedule the sampling interval. Default: true
.gcOptions
<Object>
: Garbage collection options
aggregate
<boolean>
: Track and aggregate statistics about each garbage collection operation (see https://nodejs.org/docs/latest-v12.x/api/perf_hooks.html#perf_hooks_performanceentry_kind). Default: false
flags
<boolean>
: , Track statistics about the flags of each (aggregated) garbage collection operation (see https://nodejs.org/docs/latest-v12.x/api/perf_hooks.html#perf_hooks_performanceentry_flags). aggregate
has to be true
to enable this option. Default: true
on Node version 12.17.0
and newer.eventLoopDelayOptions
<Object>
: Options to setup monitorEventLoopDelay
. Default: { resolution: 10 }
collect
<Object>
: enable/disable the collection of specific metrics.
cpu
<boolean>
: enable cpu metric. Default: true
.resourceUsage
<boolean>
: enable resourceUsage metric. Default: false
.eventLoopDelay
<boolean>
: enable eventLoopDelay metric. Default: true
.eventLoopUtilization
<boolean>
: enable eventLoopUtilization metric. Default: true
on Node version 12.19.0
and newer.memory
<boolean>
: enable memory metric. Default: true
.gc
<boolean>
: enable garbage collection metric. Default: false
.activeHandles
<boolean>
: enable active handles collection metric. Default: false
.If options.collect.resourceUsage
is set to true
, options.collect.cpu
will be set to false because the cpu metric is already available in the resource usage metric
.
metrics
A Sampler
instance.
eventLoopUtilizationSupported
<boolean>
Whether the Node.js version in use supports the eventLoopUtilization metric.
resourceUsageSupported
<boolean>
Whether the Node.js version in use supports the resourceUsage metric.
gcFlagsSupported
<boolean>
Whether the Node.js version in use supports GC flags.
onClose
Stops the Sampler
instance when closing the server.
FAQs
A Fastify plugin for sampling process metrics.
We found that @dnlup/fastify-doc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.