Code Monkey home page Code Monkey logo

pm2-zabbix's Introduction

PM2 monitoring tool for Zabbix

What it is

This is a Node.js-powered daemon and utility that monitors a PM2 instance and sends status updates to the Zabbix server monitoring solution.

Features

  • Automatically discovers processes managed by PM2
  • Reports Node.js process status, CPU usage, memory usage and restart count
  • Monitors the PM2 God Daemon itself for status, resource usage and PID changes
  • Provides a Zabbix item template for easy installation

Architecture

pm2-zabbix operates in two ways: as a script called by the Agent used for item discovery, and by a stand-alone executable that runs in the background and periodically sends updates for data items using zabbix_sender. If all relevant items already exist on the server and no automatic discovery (LLD) is required, integration with the Agent via UserParameters is optional.

Installation

Prerequisites

This module relies on having the zabbix_sender binary installed, and on /etc/zabbix/zabbix_agentd.conf being present on the system. Both typically come with a zabbix-agent package for your Linux distribution (some repositories may split this into two separate packages - zabbix-agent and zabbix-sender). It has been tested with Zabbix 3.0.

Installing

Begin by installing the module (as root) on the server that you run PM2 on:

# npm install -g pm2-zabbix

This installs a pm2-zabbix executable in your $PATH. Alternatively, you can choose a directory to your liking and perform a local install there, or clone this repository - the relevant script is monitor.js.

Testing discovery

To see if the tool can detect your running PM2 processes, switch to the user that runs PM2 and then:

$ pm2-zabbix --discover

This should print a JSON with a familiar-looking list of processes such as this one:

{
        "data": [
                {
                        "{#PROCESS_ID}": "index-0",
                        "{#PROCESS_NAME}": "index"
                },
                {
                        "{#PROCESS_ID}": "index-1",
                        "{#PROCESS_NAME}": "index"
                }
        ]
}

(If the list is empty, inspect pm2 l and see if your processes are really there.)

The above is a JSON object compatible with the Zabbix LLD protocol. It tells us that two items (in our case, processes) have been discovered - two instances of the same index.js application launched with PM2. An appropriate template installed on the Zabbix server may use this information to automatically create items.

Testing Zabbix connectivity

The asynchronous background monitoring protocol uses zabbix_sender to send data items to the server. By default, configuration parameters are taken from /etc/zabbix/zabbix_agentd.conf, including the server address and the authentication credentials. The monitoring mode can be started using:

$ pm2-zabbix --monitor

(add --debug for additional logging)

The above launches a process that connects to the current user's PM2 instance (or launches a new one if necessary) and starts sending updates in the background.

Running the monitoring daemon

pm2-zabbix is just a Node.js script, which could be launched from pm2. However, this setup is not recommended, since the monitoring tool also monitors the status of the pm2 God Daemon itself. Instead, it is best to install a proper start-up script, specific for your distro's init system, and launch the daemon in parallel to pm2.

An example sysvinit script and a systemd unit file are provided in the install/init/ directory of this repository. These most likely need to be customized for your local install - in particular, the user name will have to be changed to match the system user that you run pm2 as.

Configuring the Zabbix Agent

For the monitoring server to know what processes exist on the PM2 host, it needs to perform Low-Level Discovery. A special data item is appointed that the Zabbix Agent will query. On the target host, the item must be defined as a UserParameter. An example configuration file that accomplishes this is provided in the install/zabbix-agent/ directory - install it as /etc/zabbix/zabbix_agentd.d/pm2-zabbix.conf.

Configuring the Zabbix Server

A template needs to be installed (and assigned to a host) that tells Zabbix of the possible items to monitor, and establishes a default set of triggers and discovery rules for dynamically finding processes.

The default template file can be found in install/zabbix-server/ - upload it via the Zabbix management web UI and assign it to the hosts that you intend to be monitoring PM2 on. Appropriate keys will be created automatically.

Logging

This program can log messages to the standard output in the bunyan JSON format. It is possible to obtain detailed diagnostic information by launching with a LOG_LEVEL variable set to one of bunyan's levels. Example:

LOG_LEVEL=info pm2-zabbix --monitor

By default, the warn level is used - only errors/warnings result in log messages. Try debug/trace for more under-the-hood insight (trace also enables execution log of the underlying zabbix_sender binary). The log can be piped through the bunyan CLI tool for prettier formatting.

Note that, in --discover mode, in order to avoid amalgamating discovery JSON output for Zabbix and the log output, all logs are sent to stderr instead.

Troubleshooting

If you run into any trouble, be sure to check the Troubleshooting guide as well the issue tracker.

License

MIT - see the LICENSE file.

pm2-zabbix's People

Contributors

abrikosovv avatar dickp avatar rkaw92 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pm2-zabbix's Issues

Help: [ ERR ] Periodic sending of PM2 status failed

CONFIGS:

1. pm2-zabbix --discover

{
"data": [
{
"{#PROCESS_ID}": "[email protected]",
"{#PROCESS_NAME}": "[email protected]"
}
]

2. /etc/zabbix/zabbix_agentd.conf

############ GENERAL PARAMETERS #################
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=1
DebugLevel=4
EnableRemoteCommands=1
LogRemoteCommands=1
Server=zabbix.internal.com
ServerActive=zabbix.internal.com
StartAgents=5
Hostname=api-test
#Include=/etc/zabbix/zabbix_agentd.d/
#UserParameter
UserParameter=pm2.processes,root /usr/local/nodejs/bin/pm2-zabbix --discover

3. /etc/sudoers

Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)

#includedir /etc/sudoers.d
zabbix ALL=(ALL) NOPASSWD: ALL
Defaults:zabbix !requiretty

4. Server

Name							Triggers	Key				Interval	History		Trends	Type			Applications	Status

Template App PM2: PM2 Daemon Status			Triggers 1	pm2.status					90d					Zabbix trapper	PM2 Daemon		Enabled	
Template App PM2: PM2 Daemon PID			Triggers 1	pm2.pid						90d			365d	Zabbix trapper	PM2 Daemon		Enabled	
Template App PM2: PM2 Daemon Memory Usage	 			pm2.memory					90d			365d	Zabbix trapper	PM2 Daemon		Enabled	
Template App PM2: PM2 Daemon CPU Usage	 				pm2.cpu						90d			365d	Zabbix trapper	PM2 Daemon		Enabled	

ERRORS:

[ ERR ] Periodic sending of PM2 status failed: { [Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -
]
killed: false,
code: 2,
signal: null,
cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -' }

TROUBLESHOOTING:

from host with zabbix-agent:

- ls /usr/bin/zabbix_sender

/usr/bin/zabbix_sender

- Has the discovery process completed successfully? Are your processes listed in the Zabbix Web UI for the host that you're sending from?

Applications from Template APP PM2

Application		Items
PM2 Daemon		Items 0
PM2 Processes        Items 4

Itens from Application PM2 Processes:

PM2 Daemon Status			Triggers 1	pm2.status		90d		Zabbix trapper	PM2 Processes	Enabled
PM2 Daemon PID				Triggers 1	pm2.pid			90d		365d	Zabbix trapper	PM2 Processes	Enabled
PM2 Daemon Memory Usage	 				pm2.memory		90d		365d	Zabbix trapper	PM2 Processes	Enabled
PM2 Daemon CPU Usage	 				pm2.cpu			90d		365d	Zabbix trapper	PM2 Processes	Enabled

- Does the hostname configured on the server match the hostname that the client is presenting itself as? In particular, compare the output of hostname with the Zabbix Server's notion of your monitored machine's hostname (if using the default HostnameItem setting).

yep, the hostnames match

- If the above does not explain the failure: can you send any data item manually, using zabbix_sender from the CLI?

Test01 --> OK

zabbix_sender -z zabbix.internal.com -s "api-test" -k pm2.cpu -o 43

info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000245"
sent: 1; skipped: 0; total: 1

Test02 --> FAIL

zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k "pm2.processes[www-0,cpu]" -s "api-test" -o 90 -vv

zabbix_sender [11909]: DEBUG: answer [{"response":"success","info":"processed: 0; failed: 1; total: 1; seconds spent: 0.000113"}]
info from server: "processed: 0; failed: 1; total: 1; seconds spent: 0.000113"
sent: 1; skipped: 0; total: 1

from zabbix-server

./usr/local/bin/zabbix_get -s 172.xx.xx.xxx -k pm2.processes
{
"data": [
{
"{#PROCESS_ID}": "[email protected]",
"{#PROCESS_NAME}": "[email protected]"
}
]
}

What/Where's wrong ?

Graph-Discrepency-LatestData vs Graph prototype

So, I have used pm2-zabbix for about 1 year, works great. Thanks for that.

It came to my attention from a developer in that the following visuals are troublesome.

If, for instance a particular application, "pm2-api_app" climbs in memory usage
pm2-zabbix does do its job, sends an alert and from "Monitoring->Latest-Data->Host-Pm2-app
it shows proper spikes/triggers in graph.

If I were to select same host and go right to graphs, bypassing "Latest Data"
The graph is not to the same scale and does not show the correct memory usage, meaning much lower
than that of "Latest Data"

I understand that graph prototype may not have the trigger lines in it, that is fine.
I just would like to know why the discrepancy happens from the graph prototype vs latest data graph
for the same application's memory check.

Thanks

[ ERR ] Periodic sending of PM2 status failed: { [Error: ENOENT: no such file or directory, open '/home/cibot//etc/pm2/pm2.pid']

Running these commands as my cibot user. I'm running pm2 as a service as the cibot user and have set the pm2 pid file to be in /etc/pm2. Below is what happens when I try to use pm2-zabbix:

pm2-zabbix --discover
{
"data": [
{
"{#PROCESS_ID}": "pm2-http-interface-0",
"{#PROCESS_NAME}": "pm2-http-interface"
},
{
"{#PROCESS_ID}": "chm-dev-api-1",
"{#PROCESS_NAME}": "chm-dev-api"
}
]
}

pm2-zabbix --monitor --debug

  • Client running (monitor mode: on)
    [ ERR ] Periodic sending of PM2 status failed: { [Error: ENOENT: no such file or directory, open '/home/cibot//etc/pm2/pm2.pid']
    errno: -2,
    code: 'ENOENT',
    syscall: 'open',
    path: '/home/cibot//etc/pm2/pm2.pid' }
    [ ERR ] Periodic sending of process list error: { [Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -
    ]
    killed: false,
    code: 2,
    signal: null,
    cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -' }

Error: The zabbix web UI can display the data from pm2 items,but still Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file

I follow the #2 to test,but the problem still existed。
Different from the above, my zabbix web UI can display the data of pm2 item value,although i got errors as i ran "pm2-zabbix monitor debug"
20181016160412

[www@web-app1 ~]$ pm2-zabbix --monitor --debug
{"name":"pm2-zabbix","hostname":"web-app1","pid":11222,"level":50,"event":"PM2ZabbixMonitor#PM2StatusSent","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send PM2 status: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2018-10-16T07:23:10.230Z","v":0}

zabbix did not collect data

root@lw-mi-aa-s-react-1:~/pm2-zabbix/install/zabbix-agent# sudo -u www-data PM2_HOME=/etc/nodejs_home/.pm2 pm2-zabbix --monitor {"name":"pm2-zabbix","hostname":"lw-mi-aa-s-react-1.appannie.org","pid":7084,"level":50,"event":"PM2ZabbixMonitor#PM2StatusSent","error":{"errno":-2,"code":"ENOENT","syscall":"open","path":"/var/www//etc/nodejs_home/.pm2/pm2.pid"},"msg":"Failed to send PM2 status: Error: ENOENT: no such file or directory, open '/var/www//etc/nodejs_home/.pm2/pm2.pid'","time":"2017-09-07T09:12:57.505Z","v":0} {"name":"pm2-zabbix","hostname":"lw-mi-aa-s-react-1.appannie.org","pid":7084,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":1,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2017-09-07T09:12:57.523Z","v":0}
root@lw-mi-aa-s-react-1:~/pm2-zabbix/install/zabbix-agent# sudo -u www-data PM2_HOME=/etc/nodejs_home/.pm2 pm2-zabbix --discover { "data": [ { "{#PROCESS_ID}": "AA React-0", "{#PROCESS_NAME}": "AA React" }, { "{#PROCESS_ID}": "AA React-1", "{#PROCESS_NAME}": "AA React" }, { "{#PROCESS_ID}": "AA React-2", "{#PROCESS_NAME}": "AA React" }

I am running the pm2 and nodejs with www-data, and a customize home dir. I can get the data by --discover; But from zabbix it did not collect anything. Can you help check where i loss configuration from the above output

Failed to send PM2 status: Error: Command failed:

Hi
i get this error...

Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-118-generic x86_64)
Zabbix Server 5.0.4
zabbix_sender (Zabbix) 5.0.4

"name":"pm2-zabbix",
"hostname":"pro-rool",
"pid":45131,
"level":50,
"event":"PM2ZabbixMonitor#PM2StatusSent",
"error":{
"killed":false,
"code":1,
"signal":null,
"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"
},
"msg":"Failed to send PM2 status: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n\n at ChildProcess.exithandler (child_process.js:308:12)\n at ChildProcess.emit (events.js:314:20)\n at maybeClose (internal/child_process.js:1047:16)\n at Socket. (internal/child_process.js:438:11)\n at Socket.emit (events.js:314:20)\n at Pipe. (net.js:672:12) {\n killed: false,\n code: 1,\n signal: null,\n cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -'\n}",
"time":"2020-10-02T00:26:24.228Z",
"v":0

Improve HOME directory handling

There are currently two issues surrounding the use of $HOME and $PM2_HOME, and both originate from lib/PM2Tracker.js:165 :

  • process.env.HOME is used, instead of os.homedir().
  • The user's home is concatenated with PM2_HOME (defaulted to .pm2) to produce the path to PM2 pidfile, even though the user may wish to override PM2_HOME completely to use an external path, for example /etc/pm2 (as demonstrated in #3 ).

This should be fixed by computing the proper path where we expect to find pm2.pid, and not using the user's home dir at all if PM2_HOME looks like an absolute path.

Failed to send PM2 status

Hi,

I installed pm2-zabbix on a fresh Ubuntu 16.04 LTS LXC container (privileged), after install I tried pm2-zabbix --monitor using user root and I receive

{"name":"pm2-zabbix","hostname":"app01","pid":26409,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2018-04-11T18:20:52.257Z","v":0}

The same error appears if I will perform the command with user zabbix.

Next error I receive is if I will start pm2-zabbix using systemd systemctl status pm2-zabbix

● pm2-zabbix.service - PM2 monitor for Zabbix
   Loaded: loaded (/etc/systemd/system/pm2-zabbix.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2018-04-11 18:29:40 UTC; 4s ago
  Process: 26966 ExecStart=/usr/local/bin/pm2-zabbix --monitor (code=exited, status=217/USER)
 Main PID: 26966 (code=exited, status=217/USER)

Apr 11 18:29:40 app01 systemd[1]: Started PM2 monitor for Zabbix.
Apr 11 18:29:40 app01 systemd[26966]: pm2-zabbix.service: Failed at step USER spawning /usr/local/bin/pm2-zabbix: No such process
Apr 11 18:29:40 app01 systemd[1]: pm2-zabbix.service: Main process exited, code=exited, status=217/USER
Apr 11 18:29:40 app01 systemd[1]: pm2-zabbix.service: Unit entered failed state.
Apr 11 18:29:40 app01 systemd[1]: pm2-zabbix.service: Failed with result 'exit-code'.

PM2 is running under user root and sudoers file is installed.

Sending with zabbix_sender works fine!

Anything else I can check?

npm install -g pm2-zabbix - Doesn't work

Hello
I've try install your package and get this error:

32 verbose Linux 3.10.0-514.26.2.el7.x86_64
33 verbose argv "/usr/bin/node" "/bin/npm" "install" "-g" "pm2-zabbix"
34 verbose node v8.4.0
35 verbose npm  v5.3.0
36 error Error while executing:
36 error /bin/git ls-remote -h -t ssh://[email protected]/greatcare/node-zabbix-sender.git
36 error
36 error fatal: failed to stat '.': Permission denied
36 error
36 error exited with error code: 128
37 verbose exit [ 1, true ]

Like you can see, this command: /bin/git ls-remote -h -t ssh://[email protected]/greatcare/node-zabbix-sender.git - cannot execute if you don't have account (with pub key) on github

npm install -g pm2-zabbix Error Install RedHat 6

When I want to install when running npm install -g pm2-zabbix gives the following log

npm WARN addRemoteGit greatcare/node-zabbix-sender#v0.3.0 resetting remote /root/.npm/_git-remotes/git-github-com-greatcare-node-zabbix-sender-git-328e4dce because of error: { [Error: not found: git] code: 'ENOGIT' }
npm ERR! git clone --template=/root/.npm/_git-remotes/_templates --mirror [email protected]:greatcare/node-zabbix-sender.git /root/.npm/_git-remotes/git-github-com-greatcare-node-zabbix-sender-git-328e4dce: undefined
npm ERR! git clone --template=/root/.npm/_git-remotes/_templates --mirror [email protected]:greatcare/node-zabbix-sender.git /root/.npm/_git-remotes/git-github-com-greatcare-node-zabbix-sender-git-328e4dce: undefined
npm ERR! Linux 2.6.32-696.18.7.el6.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "pm2-zabbix"
npm ERR! node v4.8.7
npm ERR! npm v2.15.11
npm ERR! code ENOGIT

npm ERR! not found: git
npm ERR!
npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PATH.

npm ERR! Please include the following file with any support request:
npm ERR! /etc/zabbix/zabbix_agentd.d/npm-debug.log

necesito ayuda

Warnings like (node:6980) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency

~# node -v
v14.15.4

I have Zabbix 5.0.4. Can't use pm2-zabbix due to the next problem:

~# pm2-zabbix --discover

(node:6980) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6980) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:6980) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
...

[KM] Connecting
internal/fs/utils.js:779
  throw new ERR_INVALID_ARG_TYPE(
  ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (6999)
    at Object.writeFileSync (fs.js:1460:5)
    at daemonize (/usr/local/lib/node_modules/pm2-zabbix/node_modules/pm2/lib/Interactor/InteractorDaemonizer.js:237:6)
    at /usr/local/lib/node_modules/pm2-zabbix/node_modules/pm2/lib/Interactor/InteractorDaemonizer.js:186:7
    at ReqSocket.<anonymous> (/usr/local/lib/node_modules/pm2-zabbix/node_modules/pm2/lib/Interactor/InteractorDaemonizer.js:41:12)
    at Object.onceWrapper (events.js:421:28)
    at ReqSocket.emit (events.js:315:20)
    at Timeout._onTimeout (/usr/local/lib/node_modules/pm2-zabbix/node_modules/pm2-axon/lib/sockets/sock.js:278:12)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Not installed no Linux ubuntu

npm -g install pm2-zabbix

npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b v0.3.0 git://github.com/greatcare/node-zabbix-sender.git /home/staff/user/.npm/_cacache/tmp/git-clone-9cd49948
npm ERR! /home/staff/user/.npm/_cacache/tmp/git-clone-9cd49948/.git: Permission denied

ENV:

npm -v

6.1.0

node -v

v10.2.1

Wrong pm2.pid path

Hi
the code inside the PM2Tracker.js get the wrong pm2.pid path.
Using var PM2_HOME = process.env.HOME + '/' + (process.env.PM2_HOME || '.pm2');,
the code prepend the user home directory to the PM2_HOME environment variable and according to the code on node_modules/pm2/paths.js

I think can be useful modify the code like this
if (process.env.PM2_HOME) PM2_HOME = process.env.PM2_HOME; else if (process.env.HOME && !process.env.HOMEPATH) PM2_HOME = p.resolve(process.env.HOME, '.pm2'); else if (process.env.HOME || process.env.HOMEPATH) PM2_HOME = p.resolve(process.env.HOMEDRIVE, process.env.HOME || process.env.HOMEPATH, '.pm2'); else { console.error('[PM2][Initialization] Environment variable HOME (Linux) or HOMEPATH (Windows) are not set!'); console.error('[PM2][Initialization] Defaulting to /etc/.pm2'); PM2_ROOT_PATH = p.resolve('/etc', '.pm2'); }

Problem with pm2-zabbix & varnish-zabbix

Hi
Im having the same problem, if tried everthing i can find on google but nuthing helps..

I made a replica of two of my servers (nginx + varnish and nodejs), on the original server everthing is working fine with zabbix,
however on my replicas i'm havig problems with pm2-zabbix and zabbix-varnish but no problem with system info or nginx info.

image

This is the error i get wen i run (on the node server) "sudo pm2-zabbix --monitor --debug":
{"name":"pm2-zabbix","hostname":"nodejs61replica","pid":98546,"level":50,"event":"PM2ZabbixMonitor#PM2StatusSent","error":{"kilt-file -"},"msg":"Failed to send PM2 status: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.c
{"name":"pm2-zabbix","hostname":"nodejs61replica","pid":98546,"level":50,"event":"PM2ZabbixMonitor#PM2StatusSent","error":{"killed":false,"code":1,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send PM2 status: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2020-05-03T10:10:03.944Z","v":0}

on my varnish server i run "sudo /usr/local/bin/zabbix-varnish-cache.py -i '' send -c /etc/zabbix/zabbix_agentd.conf" and it seems evrthing is OK but zabbix server dos not recive the info:
image

serHelp please!

Zabbix fails to receive discovery items

Hello!

I have the following problem, i installed and configured successfully pm2-zabbix, when i trigger --discover i can see all my node apps in the data: [ ] format. But the items are not created in zabbix, all i can see are those that are not part of the Discovery rule in Zabbix. So my suggestion is that despite i can run the discovery command successful it fails to send the data to Zabbix server. I tried to switch between trapper and agent but still no joy. Any suggestions?

error on ubuntu 22.04 ARM

906 timing command:install Completed in 1262ms
907 verbose stack Error: An unknown git error occurred
907 verbose stack at makeError (/usr/lib/node_modules/npm/node_modules/@npmcli/git/lib/make-error.js:28:13)
907 verbose stack at /usr/lib/node_modules/npm/node_modules/@npmcli/git/lib/spawn.js:37:26
907 verbose stack at processTicksAndRejections (node:internal/process/task_queues:96:5)
908 verbose cwd /
909 verbose Linux 6.5.0-1019-oracle
910 verbose node v16.20.2
911 verbose npm v8.19.4
912 error code ENOENT
913 error syscall spawn git
914 error path git
915 error errno -2
916 error enoent An unknown git error occurred
917 error enoent This is related to npm not being able to find a file.
917 error enoent
918 verbose exit -2

SELinux is preventing /usr/bin/sudo from connectto access on the unix_stream_socket /run/dbus/system_bus_socket.

Raw Audit Messages
type=AVC msg=audit(1573184726.101:864): avc: denied { connectto } for pid=17463 comm="sudo" path="/run/dbus/system_bus_socket" scontext=system_u:system_r:zabbix_agent_t:s0 tcontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tclass=unix_stream_socket permissive=0

Also related:
SELinux is preventing /usr/bin/node from write access on the sock_file rpc.sock.

Raw Audit Messages
type=AVC msg=audit(1573184726.86:862): avc: denied { write } for pid=17465 comm="node" name="rpc.sock" dev="dm-0" ino=50787429 scontext=system_u:system_r:zabbix_agent_t:s0 tcontext=unconfined_u:object_r:var_log_t:s0 tclass=sock_file permissive=0

Can this be resolved with a simple context change, or do I need to install new policy modules?

A few issues

Great module, however I've had issues getting it to work in our environment. Just fixed it and wanted to share:

  1. The sysv script is missing the "--monitor" at the end of start-stop-daemon during startup operation. Not sure if this is intended?
  2. The UserParameter had to be modified like this in order to work correctly for me:
    UserParameter=pm2.processes,sudo PM2_HOME=/home/testing/.pm2 -u testing /usr/bin/pm2-zabbix --discover

Reason being, 'zabbix' user invoking sudo would not use the correct .pm2 home directory for user 'testing', and would instead use /root/.pm2, trying to create a new instance of PM2(obviously failing) and causing "Value should be a JSON object" on Zabbix server. Invoking "sudo -u testing /usr/bin/pm2-zabbix --discover" manually as zabbix user with shell worked fine, and it would use correct PM2 instance + pull correct values. Starting "pm2-zabbix --monitor" as user 'testing' would partially fail with:

[ OK ] Periodic sending of PM2 status succeeded
[ ERR ] Periodic sending of process list error: { [Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -
]
killed: false,
code: 2,
signal: null,
cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -' }

Not sure what's going on there, but #2 fixed it for me. Used zabbix_agentd L4 logs to figure it out. Error produced in the log was:

fs.js:647
return binding.mkdir(pathModule._makeLong(path),
^
Error: EACCES, permission denied '/root/.pm2'
at Object.fs.mkdirSync (fs.js:647:18)
at Object.CLI.pm2Init (/usr/local/lib/node_modules/pm2/lib/CLI.js:37:8)
at Object. (/usr/local/lib/node_modules/pm2/bin/pm2:20:5)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3

pm2-zabbix --monitor error

i have error while run pm2-zabbix --monitor

{"name":"pm2-zabbix","hostname":"wowza","pid":32726,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":1,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2018-07-24T03:35:19.382Z","v":0}

Error Code 2

Hi, I wanted to get up-to-date data about a running process in PM2 using zabbix.
When trying to run pm2-zabbix –monitor:

"name":"pm2-zabbix","hostname":"node","pid":2440,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false ,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n\n at ChildProcess.exithandler (child_process.js: 308:12)\n at ChildProcess.emit (events.js:314:20)\n at maybeClose (internal/child_process.js:1022:16)\n at Socket.<anonymous> (internal/child_process.js:444 :11)\n at Socket.emit (events.js:314:20)\n at Pipe.<anonymous> (net.js:676:12) {\n killed: false,\n code: 2,\n signal: null,\n cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -'\n}","time":"2022-08-19T09:28 :27.553Z","v":0}

When trying to run LOG_LEVEL=trace pm2-zabbix –monitor:

{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":30,"event":"PM2ZabbixMonitor#starting","monitor":true,"msg":"Starting PM2ZabbixMonitor (monitoring enabled: true)","time":"2022-08-19T09:45:49.918Z","v":0}
{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":20,"event":"PM2ZabbixMonitor#processMapGenerated","processMap":{"hello-0":{"name":"hello","status":"online","resources":{"memory":53964800,"cpu":0},"restarts":0}},"msg":"Process map generated","time":"2022-08-19T09:45:49.955Z","v":0}
{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":30,"event":"PM2ZabbixMonitor#started","msg":"PM2ZabbixMonitor started","time":"2022-08-19T09:45:49.956Z","v":0}
{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":10,"event":"PM2ZabbixMonitor#gotProcessMap","processMap":{"hello-0":{"name":"hello","status":"online","resources":{"memory":53964800,"cpu":0},"restarts":0}},"msg":"","time":"2022-08-19T09:46:04.967Z","v":0}
{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":20,"event":"PM2ZabbixMonitor#sendProcessList","processList":{"pm2.processes[hello-0,status]":"online","pm2.processes[hello-0,cpu]":0,"pm2.processes[hello-0,memory]":53964800,"pm2.processes[hello-0,restarts]":0},"msg":"Sending process list with stats","time":"2022-08-19T09:46:04.967Z","v":0}
{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":10,"event":"ZabbixSender#send","bin":"/usr/bin/zabbix_sender","args":["--config","/etc/zabbix/zabbix_agentd.conf","--input-file","-"],"stdIn":"node pm2.processes[hello-0,status] online\nnode pm2.processes[hello-0,cpu] 0\nnode pm2.processes[hello-0,memory] 53964800\nnode pm2.processes[hello-0,restarts] 0\n","debug":false,"msg":"Executing: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -","time":"2022-08-19T09:46:04.969Z","v":0}
{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n\n    at ChildProcess.exithandler (child_process.js:308:12)\n    at ChildProcess.emit (events.js:314:20)\n    at maybeClose (internal/child_process.js:1022:16)\n    at Socket.<anonymous> (internal/child_process.js:444:11)\n    at Socket.emit (events.js:314:20)\n    at Pipe.<anonymous> (net.js:676:12) {\n  killed: false,\n  code: 2,\n  signal: null,\n  cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -'\n}","time":"2022-08-19T09:46:04.994Z","v":0}
{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":10,"event":"PM2ZabbixMonitor#gotPM2State","processState":{"name":"PM2","status":"online","resources":{"cpu":0.2371246925837011,"memory":61444096},"restarts":0,"pid":1131},"msg":"","time":"2022-08-19T09:46:05.003Z","v":0}
{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":20,"event":"PM2ZabbixMonitor#sendPM2Status","status":{"pm2.status":"online","pm2.cpu":0.2371246925837011,"pm2.memory":61444096,"pm2.pid":1131},"msg":"Sending PM2 status","time":"2022-08-19T09:46:05.004Z","v":0}
{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":10,"event":"ZabbixSender#send","bin":"/usr/bin/zabbix_sender","args":["--config","/etc/zabbix/zabbix_agentd.conf","--input-file","-"],"stdIn":"node pm2.status online\nnode pm2.cpu 0\nnode pm2.memory 61444096\nnode pm2.pid 1131\n","debug":false,"msg":"Executing: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -","time":"2022-08-19T09:46:05.005Z","v":0}
{"name":"pm2-zabbix","hostname":"node","pid":2492,"level":20,"event":"PM2ZabbixMonitor#PM2StatusSent","msg":"PM2 status sent","time":"2022-08-19T09:46:05.020Z","v":0}

i studied this https://github.com/greatcare/pm2-zabbix/blob/master/Troubleshooting.md

  1. pm2-daemon was successfully discovered in zabbix, while there is no information about the child process pm2 --discovery successfully detects running processes.
    image

  2. The hostname on the node is the same as the hostname in zabbix-agent.conf and is the same as the node on the zabbix server

  3. I can successfully send data using zabbix-sender

Resources used: Ubuntu server 22, NPM 8.5.1, PM2 5.2.0, PM2-zabbix 0.3.2.

I will appreciate any help, thanks

zabbix-server no data

hello, thanks for your document, I did with your document , but now the zabbix-server has no date , I cannot find where I'am wrong , every step is the same you said , and. my zabbix-servser is 3.2 can I use your template and could you tell me how can I test form zabbix-client to zabbix-server thanks

Installation failed on centos 6.8

Feedback a problem

Installation failed on centos 6.8
when start pm2-zabbix service:
/etc/init.d/pm2-zabbix: line 46: log_daemon_msg: command not found
/etc/init.d/pm2-zabbix: line 47: start-stop-daemon: command not found
/etc/init.d/pm2-zabbix: line 49: log_end_msg: command not found

but Successful installation on Ubuntu16.04

thanks a lot !

about check app status (request)

Hello,

I am using a Zabbix server and I am using your pm2-Zabbix. I want to check the status of applications on pm2. When any of the apps stops, I want an alarm. How can i do it, can you help me?

For example, the "logHandler" application has stopped, but it is too late for me to know. I have big problems in this regard. I'm not open to your suggestions.

│ App name │ id │ mode │ pid │ status │ ...
...
│ api │ 123 │ cluster │ 2422 │ online │ ...
│ image-proxy │ 71 │ cluster │ 25504 │ online │ ...
│ indexerIntegrityHandler │ 981 │ cluster│ 89351 │ online │ ...
│ logHandler │ 961 │ cluster │ 01 │ stopped │ ...
│ web │ 208 │ cluster │ 25192 │ online │ ...
...

pm2-zabbix --monitor wont run

hello I followed the tutorial, I've tried replacing the hostname on the monitor.js
The connection works fine this is a working zabbix agent node.
pm2-zabbix --discover works well and shows all the pm2 processes but pm2-zabbix --monitor gives the following errors

{"name":"pm2-zabbix","hostname":"CentOS-77-64-minimal","pid":25279,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n\n    at ChildProcess.exithandler (child_process.js:303:12)\n    at ChildProcess.emit (events.js:311:20)\n    at maybeClose (internal/child_process.js:1021:16)\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {\n  killed: false,\n  code: 2,\n  signal: null,\n  cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -'\n}","time":"2020-12-15T11:42:40.886Z","v":0}

{"name":"pm2-zabbix","hostname":"CentOS-77-64-minimal","pid":25279,"level":50,"event":"PM2ZabbixMonitor#PM2StatusSent","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send PM2 status: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n\n    at ChildProcess.exithandler (child_process.js:303:12)\n    at ChildProcess.emit (events.js:311:20)\n    at maybeClose (internal/child_process.js:1021:16)\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {\n  killed: false,\n  code: 2,\n  signal: null,\n  cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -'\n}","time":"2020-12-15T11:42:40.891Z","v":0}

{"name":"pm2-zabbix","hostname":"CentOS-77-64-minimal","pid":25279,"level":50,"event":"PM2ZabbixMonitor#PM2StatusSent","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send PM2 status: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n\n    at ChildProcess.exithandler (child_process.js:303:12)\n    at ChildProcess.emit (events.js:311:20)\n    at maybeClose (internal/child_process.js:1021:16)\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {\n  killed: false,\n  code: 2,\n  signal: null,\n  cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -'\n}","time":"2020-12-15T11:42:55.900Z","v":0}

{"name":"pm2-zabbix","hostname":"CentOS-77-64-minimal","pid":25279,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n\n    at ChildProcess.exithandler (child_process.js:303:12)\n    at ChildProcess.emit (events.js:311:20)\n    at maybeClose (internal/child_process.js:1021:16)\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {\n  killed: false,\n  code: 2,\n  signal: null,\n  cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -'\n}","time":"2020-12-15T11:42:55.912Z","v":0}

I can't seem to understand what could be the issues, I've tried with loglevel=trace but still doesn't show any clue.

What could be the issue?

error while running command : pm2-zabbix --monitor

Hi team,
I got below error while running
pm2-zabbix --monitor command , can anyone please help to resolve this issue.
please find error logs:

{"name":"pm2-zabbix","hostname":"Dev-210-APP","pid":70413,"level":50,"event":"PM2ZabbixMonitor#PM2StatusSent","error":{"errno":-2,"code":"ENOENT","syscall":"open","path":"/home/devops//usr/local/share/.pm2/pm2.pid"},"msg":"Failed to send PM2 status: Error: ENOENT: no such file or directory, open '/home/devops//usr/local/share/.pm2/pm2.pid'","time":"2019-03-20T14:10:06.108Z","v":0}
{"name":"pm2-zabbix","hostname":"Dev-210-APP","pid":70413,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2019-03-20T14:10:06.431Z","v":0}

pm2-zabbix --discover error

Hi All...
I've tried to get pm2-zabbix to work on CentOS 6 and 7 with Zabbix 3.2 agent, but in both cases i had the bellow error after installation using npm. I also verified if the pm2-zabbix.conf was placed in /etc/zabbix/zabbix_agentd.d/, but the file was not there. Is it done automatically?

pm2-zabbix --discover

/usr/lib/node_modules/pm2-zabbix/lib/PM2ZabbixMonitor.js:61
self._logger.error({ event: 'PM2ZabbixMonitor#processUpdateSendingError', error: error, processID: changeEvent.processID, newState: changeEvent.newState }, 'Real-time status update sending failed for process %s: %s', changeEvent.processID, );
^
SyntaxError: Unexpected token )
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/usr/lib/node_modules/pm2-zabbix/monitor.js:5:24)

pm2-zabbix only discover process_id and process_name

Version: 0.2.1

When running in discover mode, only process_id and process_name are showed up. (with a status code of 0)

/home/foo └─┬ [email protected] ├── [email protected] ├── [email protected]

I have ran --monitor --debug but it has the same result, I think the data is not picking up the data between the module and node.js and unrelated to zabbix_sender.

Any suggestion?

$ sudo PM2_HOME=/etc/data/hypernova/pm2 pm2-zabbix --discover
{
        "data": [
                {
                        "{#PROCESS_ID}": "hypernova_service-0",
                        "{#PROCESS_NAME}": "hypernova_service"
                },
                {
                        "{#PROCESS_ID}": "hypernova_service-1",
                        "{#PROCESS_NAME}": "hypernova_service"
                },
                {
                        "{#PROCESS_ID}": "hypernova_service-2",
                        "{#PROCESS_NAME}": "hypernova_service"
                }
        ]
$ sudo PM2_HOME=/etc/data/hypernova/pm2 pm2 status
┌───────────────────┬────┬─────────┬───────┬────────┬─────────┬────────┬─────┬────────────┬──────────┐
│ App name          │ id │ mode    │ pid   │ status │ restart │ uptime │ cpu │ mem        │ watching │
├───────────────────┼────┼─────────┼───────┼────────┼─────────┼────────┼─────┼────────────┼──────────┤
│ hypernova_service │ 0  │ cluster │ 17209 │ online │ 39      │ 4h     │ 0%  │ 296.7 MB   │ disabled │
│ hypernova_service │ 1  │ cluster │ 16607 │ online │ 39      │ 2h     │ 0%  │ 194.2 MB   │ disabled │
│ hypernova_service │ 2  │ cluster │ 18864 │ online │ 39      │ 3h     │ 0%  │ 264.4 MB   │ disabled │
└───────────────────┴────┴─────────┴───────┴────────┴─────────┴────────┴─────┴────────────┴──────────┘

problem import template

error when import template

Cannot read XML: (41) Specification mandate value for attribute data-pjax-transient [Line: 43 | Column: 89].

pm2-zabbix --monitor PM2ZabbixMonitor#processListSendingError

Folks, I am also facing issue while performing pm2-zabbix --monitor . Getting following result. Tried many thread to resolve this but couldnt make it work. can anyone please help !!

{"name":"pm2-zabbix","hostname":"ip-172-31-31-237","pid":3866,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2019-02-06T10:12:53.676Z","v":0}

Warning: Accessing non-existent property 'cat' of module exports inside circular dependency

$ pm2-zabbix --discover
(node:2227425) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
at emitCircularRequireWarning (node:internal/modules/cjs/loader:834:11)
at Object.get (node:internal/modules/cjs/loader:850:5)
at Object._register [as register] (/usr/lib/node_modules/pm2-zabbix/node_modules/shelljs/src/common.js:455:12)
at Object. (/usr/lib/node_modules/pm2-zabbix/node_modules/shelljs/src/cat.js:4:8)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)

Version details:
PM2 version 5.3.0
pm2-zabbix 0.3.2
Node v18.16.0
Ubuntu 20.04.1 LTS

Fix
open package.json file from pm2-zabbix folder (/usr/lib/node_modules/pm2-zabbix/)
Replace pm2 version "^2.1.0" with the installed version "^5.3.0". In my case pm2 version installed is 5.3.0.
Add shelljs with version "^0.8.5".

For eg. package.json looks like

"pm2": "^5.3.0",
"shelljs": "^0.8.5",

Update package.json file with above values to fix the issue.

Failed to send pm2 data to Zabbix server getting "code":1

Hello,

Not able to send pm2 processes to the Zabbix server using pm2-zabbix. Getting below error.
It was working fine with Ubuntu 16.04. After upgrading to Ubuntu 18.04 it stopped working.
How to fix it? Any idea?

Zabbix server: 4.0.9
Zabbix agent: 4.0.22
Ubuntu: 18.04
OPENSSL: 1.1.1g
GNUTLS: 3.5.18

Zabbix Agent Conf:

TLSConnect=psk
TLSAccept=psk
TLSPSKIdentity=PSK 001
TLSPSKFile=/etc/zabbix/zabbix_agentd.psk

zabbix-agent log

SSL_shutdown() with zabbix.server set result code to 1: file ../ssl/ssl_lib.c line 2086: error:140E0197:SSL routines:SSL_shutdown:shutdown while in init 20356:20200704:182146.522 active check configuration update from [mon.leapven.com:15001] started to fail (TLS read set result code to 1: file ../ssl/record/rec_layer_s3.c line 1544: error:1409445C:SSL routines:ssl3_read_bytes:tlsv13 alert certificate required: SSL alert number 116: TLS read fatal alert "unknown") 20356:20200704:182146.522 End of refresh_active_checks():FAIL

pm2-zabbix Error:

{"name":"pm2-zabbix","hostname":"test","pid":25087,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":1,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n\n at ChildProcess.exithandler (child_process.js:303:12)\n at ChildProcess.emit (events.js:315:20)\n at maybeClose (internal/child_process.js:1021:16)\n at Socket.<anonymous> (internal/child_process.js:443:11)\n at Socket.emit (events.js:315:20)\n at Pipe.<anonymous> (net.js:674:12) {\n killed: false,\n code: 1,\n signal: null,\n cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -'\n}","time":"2020-07-07T14:27:45.263Z","v":0}

Logging

We need some legitimate logging support. The current solution, being the --debug CLI option, has several drawbacks; the final implementation should at least:

  • Show zabbix_sender invocation parameters and results/exit codes if requested
  • Dump the initially-loaded data (process list) for manual inspection
  • Notify of inbound process events (start/stop)
  • Notify of PM2 polling attempts and results
  • Notify of PM2 daemon checks and results
  • Use a standard format for its output

"level":50, "event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":2,"signal":null, "cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"}

I have read through the 18 open and 16 closed issues, many of them related to this error.
I have read the troubleshooting guide in the readme. I have tried changing the hostname configurations, but can't seem to make it take effect.
The entire message is:
{"name":"pm2-zabbix","hostname":"puppetagenttest","pid":17431,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2019-11-07T16:10:44.327Z","v":0}

On the zabbix server, the host is called puppetagenttest. I have installed the PM2 template, and I can see the items for PM2 daemon (CPU, Memory, PID, status), but nothing for the pm2.processes.

Can anyone offer suggestions on how to further troubleshoot this issue? It seems very common.

Curious-way to get uptime-our devs want that

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 │

Feature request/improvemnt - send discovery via trapper

As you have a daemon running, why not feed in the discovery items via the trapper as well as the normal stats? I do this on a number of things and it works fine. This means you can remove the agent configuration step of the setup. Not a big deal, but maybe good to have the option.

Cannot find module 'zabbix-sender'

I installed the pm2-zabbix, but when I try to execute the command pm2-zabbix --discover returns this internal/modules/cjs/loader.js:550
throw err;
^
Error: Cannot find module 'zabbix-sender'. I'm using the version 4.4, what can i do fix this problem.
when i use this command zabbix_sender -V
return this.
Zabbix Sender v2.4.7 (revision 56694) (12 November 2015).
I need to do some change in your code, change some variables??

Not sending CPU/Memory stats; release new version?

None of the process resource usage info seems to be coming up to Zabbix.

There's a commit from Jan 26th that updates to the "new" PM2 api, but it hasn't been released as the latest version (0.1.2) is from last April (2016).

@rkaw92 could you cut a new release, please?

item_prototype name wrong

There is an error in pm2-zabbix.template.xml.
In all <item_prototype> after <name> replace $1 with {#PROCESS_NAME}

  <item_prototypes>
      <item_prototype>
          <name>$1 CPU Usage</name>

or change it her:
image

And even better change it to something like: <name>PM2 {#PROCESS_NAME} CPU Usage</name>

Spaces in keys break zabbix-sender

Here is an example. I'm simulating the parsing of the input from pm2-zabbix --monitor, which produces a key-value stream which is parsed by zabbix-sender and sent. I'm fetching just one row from this stream, and sending to zabbix:

echo "xxxxx-be-preprod01 pm2.processes[xxxxx Frontend-0,cpu] 90" | zabbix_sender -vv --config /etc/zabbix/zabbix_agentd.conf -s hostname --input-file -
zabbix_sender [25699]: DEBUG: answer [{"response":"success","info":"processed: 0; failed: 1; total: 1; seconds spent: 0.000028"}]
info from server: "processed: 0; failed: 1; total: 1; seconds spent: 0.000028"

So, if there are spaces in pm2 process, the server fails to process the monitor part. The "discover" part is working, though, because if we enclose the key with double quotes, it goes through:

echo "xxxxxx-be-preprod01 "pm2.processes[xxxxx Frontend-0,cpu]" 90" | zabbix_sender -vv --config /etc/zabbix/zabbix_agentd.conf -s hostname --input-file -
zabbix_sender [25131]: DEBUG: answer [{"response":"success","info":"processed: 1; failed: 0; total: 1; seconds spent: 0.000083"}]
info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000083"

Error sending process list

I'm having a problem sending pm2 process information to zabbix 3.0.1

pm2-zabbix --monitor --debug
* Client running (monitor mode: on)
[ OK ] Periodic sending of PM2 status succeeded
[ ERR ] Periodic sending of process list error: { [Error: Command failed: ] killed: false, code: 2, signal: null }

PM2 Status is OK in zabbix but PM2 Processes discovery rule does not trigger stating "Value should be a JSON object"

Running on CentOS 7.2.1511 (Core)

active check "pm2.processes" is not supported: Unsupported item key.

Hi there!

I've tried using this Package, but my zabbix-agent doesn't seem to like the configuration file for whatever reason.
I can't seem to figure out why and the Error it is giving me isn't helping at all.

zabbix_agentd[575]: active check "pm2.processes" is not supported: Unsupported item key.

Meanwhile pm2-zabbix is saying that it Failed to send any Information to my Zabbix Server, but I presume that is because of the zabbix-agent not understanding the config since other than the PM2 stuff, it's working fine.

My Config File contains this:

UserParameter=pm2.processes,sudo -u root pm2-zabbix --discover

Works in Zabbix 2.4.8

Fantastic daemon! 👏 I got it working with our web front ends running Ubuntu 16.04 using a Zabbix 2.4.8 server. Happy to post more details, if needed.

Error Code 1 - Zabbix agent 2

Hello, could you help me! I´m trying to make pm2-zabbix works but i can´t. I got the following error:

{"name":"pm2-zabbix","hostname":"ip-172-31-15-19","pid":3861865,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":1,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\nzabbix_sender [3861937]: ./zabbix_agent2.d/plugins.d: [2] No such file or directory\n\n at ChildProcess.exithandler (node:child_process:397:12)\n at ChildProcess.emit (node:events:390:28)\n at maybeClose (node:internal/child_process:1064:16)\n at Socket. (node:internal/child_process:450:11)\n at Socket.emit (node:events:390:28)\n at Pipe. (node:net:687:12) {\n killed: false,\n code: 1,\n signal: null,\n cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -'\n}","time":"2022-10-21T16:20:02.162Z","v":0}

this problem runs if i start the pm2-zabbix service or if i run pm2-zabbix --monitor out of /etc/zabbix directory.

The test is being doing in a ubunt 20.04 with zabbix-agent2

get help, [ ERR ] Periodic sending of PM2 status failed: { [Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -

grep -ri pm2.processes /etc/zabbix/zabbix_agentd.conf

UserParameter=pm2.processes,sudo -u root /usr/local/node/bin/pm2-zabbix --discover

[root@upelk2 ~]# pm2-zabbix --discover

{
"data": [
{
"{#PROCESS_ID}": "www-1",
"{#PROCESS_NAME}": "www"
},
{
"{#PROCESS_ID}": "pm2-http-interface-2",
"{#PROCESS_NAME}": "pm2-http-interface"
}
]
}[root@upelk2 ~]#

[root@upelk2 ~]# pm2-zabbix --monitor --debug

  • Client running (monitor mode: on)
    [ ERR ] Periodic sending of process list error: { [Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -
    ]
    killed: false,
    code: 2,
    signal: null,
    cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -' }
    [ ERR ] Periodic sending of PM2 status failed: { [Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -
    ]
    killed: false,
    code: 2,
    signal: null,
    cmd: '/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -' }

zabbix server is no pm2-zabbix graph

monitor error

hello im having a issue with pm2-zabbix. im am new to zabbix
{"name":"pm2-zabbix","hostname":"pi","pid":26920,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed:/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2019-05-10T16:42:58.057Z","v":0}
{"name":"pm2-zabbix","hostname":"pi","pid":26920,"level":50,"event":"PM2ZabbixMonitor#PM2StatusSent","error":{"killed":false,"code":2,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send PM2 status: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2019-05-10T16:42:58.112Z","v":0}

[ ERR ] Periodic sending of PM2 status failed: { Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zab

Dear greatcare

i got problem like someone in issue section found and i try to reading trubleshooting guide but cannot solve

the problem is i got code 2 from zabbix_sender but it work when i try to use manually cli i check in zabbix_agentd.conf Hostname and Hostnameitem and /etc/hosts file are same with config with Zabbixserver (ADVWSNodeAPI)

pls help me to solve this

==== CLI ====
[root@nodeapi bin]# zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k "pm2.processes[bot3bb-94,cpu]" -s 'ADVWSNodeAPI' -o 98 -vv
zabbix_sender [84361]: DEBUG: answer [{"response":"success","info":"processed: 1; failed: 0; total: 1; seconds spent: 0.000045"}]
info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000045"

screenshot 2017-06-05 16 06 29
screenshot 2017-06-05 16 10 33
screenshot 2017-06-05 16 11 58

level":50,"event":"PM2ZabbixMonitor#processListSendingError",

Hi i am facing error during running pm2-zabbix --monitor ,

{"name":"pm2-zabbix","hostname":"ip-172-31-43-89","pid":5808,"level":50,"event":"PM2ZabbixMonitor#processListSendingError","error":{"killed":false,"code":1,"signal":null,"cmd":"/usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -"},"msg":"Failed to send process list with stats to server: Error: Command failed: /usr/bin/zabbix_sender --config /etc/zabbix/zabbix_agentd.conf --input-file -\n","time":"2018-11-05T15:12:36.599Z","v":0}

i tried sending some key
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k test_key -o 0
sent: 1; skipped: 0; total: 1

image

image

i stop pm2 process but didnt receive any tirgger .

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.