pm2-webhook-monitor
Advanced tools
Comparing version 1.0.0 to 1.0.1
29
index.js
const pm2 = require( 'pm2' ); | ||
const pmx = require( 'pmx' ); | ||
const bent = require( 'bent' ); | ||
const os = require( 'os' ); | ||
@@ -18,2 +19,24 @@ const moduleConfig = pmx.initModule(); | ||
function getLocalIpAddress() { | ||
let result; | ||
const network = os.networkInterfaces(); | ||
for ( let key in network ) { | ||
const networkUnit = network[ key ]; | ||
networkUnit.map( ( item ) => { | ||
if ( item.family === 'IPv4' && !item.internal ) { | ||
result = item.address; | ||
} | ||
} ); | ||
} | ||
if ( !result ) { | ||
result = 'Unknown IP Address'; | ||
} | ||
return result; | ||
} | ||
function notify( message ) { | ||
@@ -34,3 +57,5 @@ const requestJson = bent( 'json', { | ||
const keywordList = [ | ||
`应用名称:${ message.name }`, `事件类型:${ message.event }` | ||
`IP 地址:${ getLocalIpAddress() }`, | ||
`应用名称:${ message.name }`, | ||
`事件类型:${ message.event }` | ||
]; | ||
@@ -64,3 +89,3 @@ | ||
if ( process.exec_mode === 'cluster_mode' && process.instances > 1 ) { | ||
if ( process.exec_mode === 'cluster_mode' ) { | ||
result += `[${ process.pm_id }]`; | ||
@@ -67,0 +92,0 @@ } |
{ | ||
"name": "pm2-webhook-monitor", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A pm2 monitor which sends log messages to webhook url.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4727
144