Skip to content

Instantly share code, notes, and snippets.

View snghnishant's full-sized avatar
👨‍💻
Grinding

Nishant Singh snghnishant

👨‍💻
Grinding
View GitHub Profile
@tomas-chudjak
tomas-chudjak / remote_script.sh
Last active April 17, 2023 13:07
Bash utility AWS Run Command
#!/bin/bash
#================================================================
# HEADER
#================================================================
#% SYNOPSIS
#+ ${SCRIPT_NAME} --tagName "argument" --tagValue "argument" --scriptFile "argument" --command "argument" --timeout "argument" [--comment] "argument" [--help] [--version]
#%
#% DESCRIPTION
#% Helper function for running external shell scripts on multiple instances with AWS SSM.
@yekver
yekver / prom-client_pm2_cluster.js
Last active August 11, 2023 18:47
Instead of `cluster` module there is no direct access to the master process in `pm2`. To return metrics for the whole cluster you can do IPC calls from the active instance to the rest of them and wait while all their locally collected metrics will be sent. Finally you have to aggregate all received metrics.
const prom = require('prom-client');
const pm2 = require('pm2');
let pm2Bus;
const REQ_TOPIC = 'get_prom_register';
function pm2exec(cmd, ...args) {
return new Promise((resolve, reject) => {
pm2[cmd](...args, (err, resp) => (err ? reject(err) : resolve(resp)));