[Support] Zabbix-Agent & Zabbix-Agent2


Recommended Posts

Overview: Support for Docker template of the zabbix-agent container

Application: Zabbix-Agent - https://www.zabbix.com/

DockerHub:

Agent Version: 5.4 (newest stable)

Minimum Server Version: 5.4

 

Please use this support for unraid/docker issues/questions only. Zabbix have its own community forums, when You can find lots of information.

  • Privileged mode does need to be left as enabled. This allows the agent to see system resources
  • Adding Disks for Monitoring:
    On the docker configuration page you will preconfigured /mnt/user and /mnt/cache (as array and cache pool). You can change it on Your own, for example by disk or maybe add some other pools.
    Access Mode can be just Read Only


Note, In Zabbix WebGUI You must set disk monitoring like Container Paths.

* Please specify which version is affected by the problem (Agent or Agent2)

Link to comment
  • VRx changed the title to [Support] Zabbix-Agent & Zabbix-Agent2

Using https://hub.docker.com/r/zabbix/zabbix-agent

Fix common problems is reporting: 
Template URL for docker application zabbix-agent is not the as what the template author specified.The template URL the author specified is https://raw.githubusercontent.com/vrx-666/unraid-xml/master/my-zabbix-agent.xml. The template can be updated automatically with the correct URL.

Looking at the settings for the zabbix_agent docker I don't even seen an entry for the template url. Additionally I do not recall changing or removing it. 

Was this a new change or did the docker container possibly get damaged?

Link to comment

Have you had FCP automatically fix that error?

 

2 hours ago, VRx said:

TemplateURL is deprecated:

 

It's deprecated for maintainers entering it.  But it is still used behind the scenes.  (No one ever gave it the correct value, so the appfeed automatically fills it out)

  • Thanks 1
Link to comment
4 hours ago, Squid said:

Have you had FCP automatically fix that error?

 

 

It's deprecated for maintainers entering it.  But it is still used behind the scenes.  (No one ever gave it the correct value, so the appfeed automatically fills it out)

Ah ok. Yeah I went ahead and applied the fix via FCP. 

Link to comment
  • 2 weeks later...

Because zabbix-agent2 in this container is running by the user without permissions to docker socket.
There is a possibility to run this, but You must have basic knowledge about linux shell systems.
You must check GID of docker group on Host (Unraid Server).
Log in to zabbix-agent2 container as root user (default  running "Console" from Unraid GUI made it but as zabbix user)
Add group docker (with same gid as on host/unraid server) inside zabbix-agent2 container.
Add user zabbix to this group.
Restart zabbix-agent2 container.
Note: You must do this again after every container update.

Link to comment
6 hours ago, VRx said:

Because zabbix-agent2 in this container is running by the user without permissions to docker socket.
There is a possibility to run this, but You must have basic knowledge about linux shell systems.
You must check GID of docker group on Host (Unraid Server).
Log in to zabbix-agent2 container as root user (default  running "Console" from Unraid GUI made it but as zabbix user)
Add group docker (with same gid as on host/unraid server) inside zabbix-agent2 container.
Add user zabbix to this group.
Restart zabbix-agent2 container.
Note: You must do this again after every container update.

 

First of all great job! Thanks for the template and guidelines.

 

I'm facing the same problem with the very same solution but I can't find a way to easily add the user "zabbix" into the group "docker" due to usermod command not installed.

Am I missing something?

 

I correctly create the group with:

 

docker exec --user root zabbix-agent2 sh -c "addgroup -g 281 docker"

 

Do you have any hint?

 

Thank you!

 

Link to comment

You can do this by logging in as root:

docker exec -it --user=root zabbix-agent2 /bin/bash


Next, edit group file (/etc/group) in vim or sed. If You not familiar with vim, sed will be easier:

sed -i "s/docker:x:281:/docker:x:281:zabbix/g" /etc/group

 

Next, type "exit" to exit container shell, then You can restart container from Unraid GUI

 

BTW: Some trick could be used for things that not working from zabbix container, by setting up cron in User Scripts Plugin, this cron could monitor something, and write to file, which could be read by zabbix-agent, for example:
my script read parameters from ups tools, writing output to file on cache pool, zabbix-agent read this file and parse output to different items in zabbix.

Link to comment
1 hour ago, VRx said:

You can do this by logging in as root:

docker exec -it --user=root zabbix-agent2 /bin/bash


Next, edit group file (/etc/group) in vim or sed. If You not familiar with vim, sed will be easier:

sed -i "s/docker:x:281:/docker:x:281:zabbix/g" /etc/group

 

Next, type "exit" to exit container shell, then You can restart container from Unraid GUI

 

BTW: Some trick could be used for things that not working from zabbix container, by setting up cron in User Scripts Plugin, this cron could monitor something, and write to file, which could be read by zabbix-agent, for example:
my script read parameters from ups tools, writing output to file on cache pool, zabbix-agent read this file and parse output to different items in zabbix.

Thanks for this, this was something I didn't do. However after doing this the docker service is still reported as down in Zabbix.

Link to comment
58 minutes ago, mattmill said:

Thanks for this, this was something I didn't do. However after doing this the docker service is still reported as down in Zabbix.

Got it working now. 

For anyone who stumbles upon this I had to install nano (my prefered editor)

apk add nano

Then run to open the groups

nano /etc/group

I then manually added to the group file. Your GID (281 below) may differ on your host machine.

docker:x:281:zabbix

Save and reboot docker container and it now works

 

Just note that your GID may differ from the one above (281). To find your docker group ID run the below on your host machine

getent group docker | awk -F: '{printf "Group %s with GID=%d\n", $1, $3}'

 

Thanks for the pointers @VRx

Edited by mattmill
Add GID instructions.
  • Like 1
Link to comment
4 hours ago, VRx said:

You can do this by logging in as root:

docker exec -it --user=root zabbix-agent2 /bin/bash


Next, edit group file (/etc/group) in vim or sed. If You not familiar with vim, sed will be easier:

sed -i "s/docker:x:281:/docker:x:281:zabbix/g" /etc/group

 

Next, type "exit" to exit container shell, then You can restart container from Unraid GUI

 

BTW: Some trick could be used for things that not working from zabbix container, by setting up cron in User Scripts Plugin, this cron could monitor something, and write to file, which could be read by zabbix-agent, for example:
my script read parameters from ups tools, writing output to file on cache pool, zabbix-agent read this file and parse output to different items in zabbix.

 

I get the job done! thanks a lot.

With [PLUGIN] CA APPLICATION AUTO UPDATE I've added a script that runs after the update at container start. It should automate the permissions fix.

Core commands are:

 

docker exec --user root zabbix-agent2 sh -c "addgroup -g 281 docker"
docker exec --user root zabbix-agent2 sh -c "sed -i "s/docker:x:281:/docker:x:281:zabbix/g" /etc/group"

 

About User Scripts I've already set up a script that populates files:

 

sensors > /mnt/user/appdata/zabbix_agent/misc/scripts/temperatures_data
apcaccess > /mnt/user/appdata/zabbix_agent/misc/scripts/ups_data

 

Adding avolume binding "/var/local/:/var/local/" I'm able to use the template of @fabianonline (thans a lot!): https://git.schle.nz/fabian/unraid-zabbix_agent/raw/branch/main/zabbix_template.xml

  • Like 1
Link to comment
  • 2 months later...

I have a userparameter config file I use on my servers to monitor the SMART info of my disks. It requires the use of an external script that has to execute on the server to collect the necessary information...

 

Here is the USERPARAMETER :

 

 

UserParameter=storage.discovery[*],sudo /opt/zabbix/smartctl-storage-discovery.sh

UserParameter=storage.get[*],sudo smartctl -i -H -A -l error -l background $1

UserParameter=smartctl.version,smartctl --version | grep -Eo "^smartctl\s[0-9\.[:space:]\r-]+" | sed -e 's/^smartctl\s//'

 

The content of the script file is a big long so I'll skip but my question is the following. I'm having a hard time to figure out how this would work since the agent is running in a container. Anyone has a clue?

 

Link to comment

Yeah but I see various issues with that... I'll have to run a service that will periodically run a script on the server, save it to a file and drop it in a place the zabbix-agent2 will see it, process it, etc. Involves a lot of changes to existing templates on top of producing new scripts and services.

 

Ideally I could install the zabbix agent baremetal which I guess would have to reside on the USB key.... Same thing if I would use Prometheus... But not sure that is ideal, especially since it doesn't come as an addon with UNRAID so with new updates it could get in the way or just be wiped.

Link to comment
  • 1 month later...

Thank you very much for the information provided here. I was able to run the zabbix-agent2 in a docker container, and monitor other containers.
The only thing I'm missing to monitor is the free space on the root directory where the zabbix agent is running. I'm sending all of my monitored data to grafana, but it's not picking up the space utilization.
In the localhost, the root directory is in /dev/xvda.
Above you mentioned "Note, In Zabbix WebGUI You must set disk monitoring like Container Paths.", can you please elaborate a little bit on this last part?

Link to comment

Sorry, I think I missed notification about reply.
 

On 1/4/2022 at 6:23 PM, capitan_lawrence said:

Above you mentioned "Note, In Zabbix WebGUI You must set disk monitoring like Container Paths.", can you please elaborate a little bit on this last part?

 

On the docker configuration page you have preconfigured /mnt/user and /mnt/cache (as array and cache pool).
You can change it on Your own, for example by disk or maybe add some other pools.
Access Mode can be just Read Only
For example:
/mnt/user on host You can bind to /mnt/array in zabbix agent container

/mnt/cache on host You can bind to /mnt/something in zabbix agent container
In Zabbix GUI You must set container paths to monitor, so:
/mnt/array
and

/mnt/something

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.