📜 ⬆️ ⬇️

Zabbix on OpenShift Part 2 - Agent Connection

In this article I want to continue sharing my experience in creating a Zabbix server on Openshift hosting. I talked about basic installation and configuration in a previous article, “Installing Zabbix 2.4 on RedHat Openshift” . In this article we will discuss the installation of a zabbix-agent on a local host (which we will monitor) and setting up its connection with a zabbix-server through an ssh tunnel.



First you need to create a new key pair (for security) and place the public key in the OpenShift key store.
Check

% ssh 55e9bc400c1e66a589000029@zabbix-chinacoolhacker.rhcloud.com [zabbix-chinacoolhacker.rhcloud.com 55e9bc400c1e66a589000029]\> 

To pass through a tunnel, you need to know your local ip of the OpenShift application.
')
 [zabbix-chinacoolhacker.rhcloud.com 55e9bc400c1e66a589000029]\> export | grep OPENSHIFT_PHP_IP declare -x OPENSHIFT_PHP_IP="127.13.151.129" 


Now we will create a script that will support the ssh tunnel on the local host:

 #!/bin/sh SSH_DAEMON="/usr/bin/ssh" SSH_DAEMON_OPTS="-2 -N -f -L" LOCAL_PREF="10051:<YOUR_LOCAL_OPENSHIFT_IP>:30051" REMOTE_PREF="<USER>@<YOUR_SERVER>.rhcloud.com" CONNECT=" $SSH_DAEMON $SSH_DAEMON_OPTS $LOCAL_PREF $REMOTE_PREF" # STAT=$(ps auxww | grep "$CONNECT" | grep -v grep | wc -l) if [ $STAT == 0 ]; then $CONNECT exit 0; else exit 0; fi 

And we will place it in the crontab of an unprivileged user (for example, zabbix) to execute once a minute.
Checking:

 user@localhost:~ % telnet localhost 10051 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. ^] telnet> quit 

Install the agent on the localhost, create something like this zabbix_agentd.conf config:

 LogFile=/tmp/zabbix_agentd.log LogFileSize=1 Server=127.0.0.1 StartAgents=0 ServerActive=127.0.0.1 Hostname=localhost RefreshActiveChecks=120 Timeout=10 User=zabbix 

Now you need to add localhost as a node in zabbix



I will immediately say that the red icon will remain so - the work of the agent in the passive mode is not supposed.
We take the template you need (for example, the built-in Template OS Linux), and in the Items settings we change (the easiest way through mass update) the type to zabbix-agent (active).



If there are discovery scripts, we don’t forget to put zabbix-agent (active) there too.
After some time, the data will begin to flow to the server.



If for some reason the data is not received - look in the log for errors.

That's all, I hope someone will be useful.
I would appreciate constructive criticism.

PS I think in the same way you can screw the active proxy and merge any data you like.

Source: https://habr.com/ru/post/271843/


All Articles