I had a need to monitor the cpu usage of a specific process. Actually, all processes with a specific name. I came up with the following, hopefully someone else will find this useful:
I am using the following assumptions:
1. Zabbix conf file is located in /etc/zabbix
2. The process(es) being monitored is called: openvpn
You can change openvpn to any process you want to monitor.
3. A bin directory will be created by you in /etc/zabbix/bin
4. A data directory will be created by you in /etc/zabbix/data, and the group/ownership will be changed to the Zabbix user.
There are two files attached to this message. One is a C program called clean.c. Save it, and compile it using:
cc clean.c -o clean
The second file is a shell script, save it and rename it to
getproctime.sh
The script makes the assumption that it and the C program will be installed on the client in:
/etc/zabbix/bin
On the client, add the following line to /etc/zabbix_agentd:
UserParameter=openvpn.cpu,/etc/zabbix/bin/getproctime.sh openvpn
and restart the agent. I did it this way because I was unable to get the system.run() working on Linux.
On the server, create an Item to monitor the usage. Add the following for the key:
openvpn.cpu
Set the update interval to 5, and if possible, make it an agent. If you like, you can add a percent sign to the Units field. I am using this as an active agent.
Save it, and watch the monitoring. I use this as a standard agent, I haven't had luck yet with the active agent.
I am using the following assumptions:
1. Zabbix conf file is located in /etc/zabbix
2. The process(es) being monitored is called: openvpn
You can change openvpn to any process you want to monitor.
3. A bin directory will be created by you in /etc/zabbix/bin
4. A data directory will be created by you in /etc/zabbix/data, and the group/ownership will be changed to the Zabbix user.
There are two files attached to this message. One is a C program called clean.c. Save it, and compile it using:
cc clean.c -o clean
The second file is a shell script, save it and rename it to
getproctime.sh
The script makes the assumption that it and the C program will be installed on the client in:
/etc/zabbix/bin
On the client, add the following line to /etc/zabbix_agentd:
UserParameter=openvpn.cpu,/etc/zabbix/bin/getproctime.sh openvpn
and restart the agent. I did it this way because I was unable to get the system.run() working on Linux.
On the server, create an Item to monitor the usage. Add the following for the key:
openvpn.cpu
Set the update interval to 5, and if possible, make it an agent. If you like, you can add a percent sign to the Units field. I am using this as an active agent.
Save it, and watch the monitoring. I use this as a standard agent, I haven't had luck yet with the active agent.
Comment