Run Remote command on the Zabbix

Zabbix Host

  • To accomplish the task in which we get the details of Processes which consumes the CPU, memory and SWAP usage. For that purpose I created a script which gets the top 10 processes which consumes the memory,cpu and swap
  • To enable the remote command on the zabbix host, below are the commands
  • #cd /etc/zabbix
  • #vi zabbix_agentd.conf
  • Find the line EnableRemoteCommands, uncomment it and enable it by give the bit equal to 1
  • Restart the zabbix agent (#service zabbix-agentd restart)
  • Give the write permission to the folder where we have placed script.
  • #chmod g+w /etc/zabbix/bin (bin the dir where all the scripts placed)
  • In bin dir I placed my scripts which is being used by zabbix to run them through zabbix agent 

Zabbix GUI

  • Under the Configuration Tab Select Action tab and create the action
  • Create new condition in which trigger name like the memory trigger value

  • Create the new operation in which the remote command executes on the respective target and under the comment section mention the command which we want to run under the Zabbix host agent

The remote commands here is (script). In that script I am getting the result of top 10 processes which consuming my system memory,CPU and swap. The script ran whenever the memory trigger get fired as it is linked with the trigger name.

Below is the result which I get in the email:

Memory Usage
21568  java     58.6
29453  httpd    0.6
22364  httpd    0.6
29462  httpd    0.5
29460  httpd    0.5
24540  httpd    0.5
24538  httpd    0.5
23124  httpd    0.5
22365  httpd    0.5
CPU Usage
PID    COMMAND          %CPU
21568  java             63.4
945    ext4-dio-unwrit  0.0
943    ext4-dio-unwrit  0.0
351    ext4-dio-unwrit  0.0
266    vmw_pvscsi_wq_2  0.0
2541   gdm-session-wor  0.0
2474   gdm-simple-gree  0.0
2472   polkit-gnome-au  0.0
2471   plymouth-log-vi  0.0
Swap Usage
Xorg 8104 kB
gconfd-2 2812 kB
httpd 2336 kB
httpd 2324 kB
httpd 2308 kB
httpd 2264 kB
httpd 2264 kB
httpd 2264 kB
httpd 2264 kB
httpd 2264 kB