Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/local/lib/node_modules/pm2/lib/templates/sample-apps/pm2-plus-metrics-actions/ drwxr-xr-x | |
| Viewing file: Select action/file-type:
const io = require('@pm2/io')
// Straight Metric
var user_count = 10
const users = io.metric({
name: 'CM: Realtime user',
value: () => {
return user_count
}
})
// or users.set(user_count)
// Counter (.inc() .dec())
const currentReq = io.counter({
name: 'CM: Current Processing',
type: 'counter'
})
setInterval(() => {
currentReq.inc()
}, 1000)
// Meter
const reqsec = io.meter({
name: 'CM: req/sec'
})
setInterval(() => {
reqsec.mark()
}, 100)
// Histogram
const latency = io.histogram({
name: 'CM: latency'
});
var latencyValue = 0;
setInterval(() => {
latencyValue = Math.round(Math.random() * 100);
latency.update(latencyValue);
}, 100)
////////////////////
// Custom Actions //
////////////////////
io.action('add user', (done) => {
user_count++
done({success:true})
})
io.action('remove user', (done) => {
user_count++
done({success:true})
})
io.action('with params', (arg, done) => {
console.log(arg)
done({success:arg})
})
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0116 ]-- |