million12 / docker-zabbix-agent

Zabbix Agent Docker Image (CentOS 7)
MIT License
18 stars 10 forks source link

Where are the patches applied? #6

Open gcavalcante8808 opened 7 years ago

gcavalcante8808 commented 7 years ago

Hello Friend,

I cannot find the patches applied on agent to allow it to read system data from /data/proc and so on ... Can you provide the patches or the version system where they lie?

Atem18 commented 7 years ago

+1 Would be great to know how it is done.

gcavalcante8808 commented 7 years ago

O tried to sed all occurrences of /{sys, proc, dev} to the /data preffix but the agent cant see host stats as well...

Em 1 de dez de 2016 8:30 AM, "Kevin Messer" notifications@github.com escreveu:

+1 Would be great to know how it is done.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/million12/docker-zabbix-agent/issues/6#issuecomment-264136406, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnHgYmZ-v4DceWEkmvj3bc_B2vCXXUoks5rDqGpgaJpZM4KsjsY .

Atem18 commented 7 years ago

@gcavalcante8808 I did the same, and indeed, it does not work.

gcavalcante8808 commented 7 years ago

@Atem18 Hello Friend ... so much time have passed ... but the solution appeared!

Check at https://github.com/gcavalcante8808/docker-zabbix-agent.git

There is no need to patch the agentd or install packages into the host system; we can use just the docker to provide a way to monitor the host system :D

Atem18 commented 7 years ago

@gcavalcante8808 That's nice, I actually did something similar to you, by using the official Zabbix Docker image and implementing my scripts to execute commands via chroot command.

Atem18 commented 7 years ago

@gcavalcante8808 I have a question, I tried your Docker but it can only see container's processes (ex: in Docker Zabbix server, Zabbix agent find 52 processes but my host has more than 450 processes). How did you do to monitor your host's processes and get back the info into Zabbix Server?

Thanks in advance.

gcavalcante8808 commented 7 years ago

@Atem18 Just the zabbix-agent is aware of host proccesses because its is started inside a proot that use /rootfs as the root (which is your host root volume mounted) then the agent can see and verify the proccesses. Try to use the zabbix_get to get the proccess, like the following:

zabbix_get -s 127.0.0.1 -k proc.num[""]

The following example works at a computer that uses network manager applet:

docker exec -it zabbix_agentd bash zabbix_get -s 127.0.0.1 -k proc.num["nm-applet"]

Atem18 commented 7 years ago

@gcavalcante8808 Now I understand, I tried as you said and indeed it works, so I will probably use that method. I just need to be sure that I can access hosts's binaries from Zabbix container. So thanks a lot mate :)

gcavalcante8808 commented 7 years ago

@Atem18 take a look inside the docker-entrypoint.sh, the proot command mount the libs and binaries from the container to the host!, something like the following (last line of the script):

exec proot -r /rootfs -b /usr/local/sbin -m /usr/local/sbin \ -b /usr/local/bin -m /usr/local/bin \ -b /usr/lib -m /usr/lib -b /usr/local/etc -m /usr/local/etc \ sh -c "LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu /usr/local/sbin/zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf --foreground"

Atem18 commented 7 years ago

@gcavalcante8808 Yeah I saw, I tried to add -b /usr/bin -m /usr/bin but from inside the container I have no access to my hosts's binaries like /usr/bin/docker, I have an output like : zabbix@94b276c1b4a6:/$ /usr/bin/docker bash: /usr/bin/docker: No such file or directory

gcavalcante8808 commented 7 years ago

@Atem18 In your case, you're mounting the /usr/bin from the container to the host ... is it intendend? Or are you trying to use the docker client from the host?

Take a look at the link below for more information:

https://wiki.archlinux.org/index.php/Proot

Atem18 commented 7 years ago

@gcavalcante8808 No it's probably a mistake, I want to execute docker or any binary I have on my host inside my container, for my customs scripts. Thanks for the link, I will check the documentation to get it done.

gcavalcante8808 commented 7 years ago

@Atem18 you can use your host's binaries, but not when you mount the container "/usr/bin" folder over them :D A more appropriate read of the doc should help you to understand the things in the right way. Feel free to contact me if you need some help. Cya