greatcare / pm2-zabbix

A Node.js PM2 monitoring tool for Zabbix.
MIT License
87 stars 60 forks source link

Curious-way to get uptime-our devs want that #20

Open ang3lwitch opened 6 years ago

ang3lwitch commented 6 years ago

Example: This just works out of box, like the others. pm2.processes[{#PROCESS_ID},status]

Wondering how to get "uptime". Things i have tried for this key just fail to do nothing.

What I have tried: pm2.processes[{#PROCESS_ID},uptime]

pm2 list shows all of them. not sure how to get uptime via discovery method with out home grown key being made. ┌─────────────┬────┬──────┬──────┬────────┬─────────┬────────┬──────────────┬──────────┐ │ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │ ├─────────────┼────┼──────┼──────┼────────┼─────────┼────────┼──────────────┼──────────┤ │mystery-app │ 4 │ fork │ 8354 │ online │ 0 │ 8m │ 124.223 MB │ disabled │ │ mystery-daemon │ 5 │ fork │ 8355 │ online │ 0 │ 8m │ 45.234 MB │ disabled │

rkaw92 commented 6 years ago

Hi, It's not working as expected because pm2-zabbix only gathers pre-defined keys from pm2: status, cpu, memory, restarts. This is hard-coded in /lib/PM2ZabbixMonitor.js . If other keys are required, it is necessary to add them to the source.

Should your devs feel inclined to do it, we're happily accepting pull requests! One thing to consider is how this will integrate with existing set-ups where the key does not exist because it was not in the template when installing pm2-zabbix and the agent files. I imagine some admins might be scared if pm2-zabbix starts logging failures because some key is rejected by Zabbix. Adding new keys is definitely a great thing to do - we'll just have to provide a fair warning in the change log and an updated template file.

ang3lwitch commented 6 years ago

Ok, thanks for the kind reply.

I really do enjoy Pm2-zabbix and it is another way to not use keymetrics per say.

For the most part the updated version works dandy and i have a better grasp now on the install since the newest release.