Ad Widget

Collapse

SMART by Zabbix agent 2 Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gomo
    Junior Member
    • May 2024
    • 16

    #1

    SMART by Zabbix agent 2 Issue

    Hello all,

    I have Zabbix server setup on my Ubuntu 22.04.4 LTS VM which queries other VMs and systems to gather data and alerts. This is all working fine.
    One of the machines on which I have Zabbix agent installed on is a Proxmox hypervisor (debian 12). Using "Linux by Zabbix agent" template I am getting a lot of data collected (all working well). Now, I wanted to also gather SMART values of the drives which are installed on that system. So I went ahead and added additional template for that host "SMART by Zabbix agent 2" (following the steps described here https://www.zabbix.com/integrations/smart). I am not sure why but I am getting following error:
    Code:
    Cannot fetch data.: failed to execute smartctl: failed to get combined output of stdout and stderr for smartctl process: waitid: no child processes.
    Click image for larger version

Name:	image.png
Views:	1490
Size:	34.8 KB
ID:	484481

    I have a feeling this might be related to "zabbix ALL=(ALL) NOPASSWD:/usr/sbin/smartctl" part not working properly.
    Here's how my "visudo" file looks like:
    Click image for larger version

Name:	image.png
Views:	1274
Size:	84.2 KB
ID:	484482

    Click image for larger version

Name:	image.png
Views:	1280
Size:	11.1 KB
ID:	484483

    Would appreciate if someone could point me to a right direction!
    Thank you.
  • Gomo
    Junior Member
    • May 2024
    • 16

    #2
    Anyone? can't be that I am only one with this issue :/

    Comment

    • Gomo
      Junior Member
      • May 2024
      • 16

      #3
      bump .. Anyone?

      Comment

      • Markku
        Senior Member
        Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
        • Sep 2018
        • 1782

        #4
        Works here (in a VM, just doesn't apparently return any disks).

        What does sudo smartctl -V return on the Debian host?

        Markku

        Comment

        • Gomo
          Junior Member
          • May 2024
          • 16

          #5
          Originally posted by Markku
          Works here (in a VM, just doesn't apparently return any disks).

          What does sudo smartctl -V return on the Debian host?

          Markku
          This is the output:

          Code:
          root@magnetar:~$ sudo smartctl -V
          smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.8.4-3-pve] (local build)
          Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org
          
          smartctl comes with ABSOLUTELY NO WARRANTY. This is free
          software, and you are welcome to redistribute it under
          the terms of the GNU General Public License; either
          version 2, or (at your option) any later version.
          See https://www.gnu.org for further details.
          
          smartmontools release 7.3 dated 2022-02-28 at 16:33:40 UTC
          smartmontools SVN rev 5338 dated 2022-02-28 at 16:34:26
          smartmontools build host: x86_64-pc-linux-gnu
          smartmontools build with: C++11, GCC 12.2.0
          smartmontools configure arguments: [hidden in reproducible builds]
          reproducible build SOURCE_DATE_EPOCH: 1686925941 (2023-06-16 16:32:21)
          root@magnetar:~$

          Comment

          • Markku
            Senior Member
            Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
            • Sep 2018
            • 1782

            #6
            Thanks, so at least smartctl looks like it should be executable. I found the error message "failed to execute smartctl" in here: https://github.com/zabbix/zabbix/blo.../smart.go#L166

            Do you have apparmor or something else that could prevent zabbix user from executing smartctl?

            Markku

            Comment

            • Gomo
              Junior Member
              • May 2024
              • 16

              #7
              Originally posted by Markku
              Thanks, so at least smartctl looks like it should be executable. I found the error message "failed to execute smartctl" in here: https://github.com/zabbix/zabbix/blo.../smart.go#L166

              Do you have apparmor or something else that could prevent zabbix user from executing smartctl?

              Markku
              To be honest I have never heard of "apparmor", but now that I checked, it looks like Proxmox (debian 12) is using it by default.
              Code:
              root@magnetar:~$ systemctl status apparmor
              ● apparmor.service - Load AppArmor profiles
                   Loaded: loaded (/lib/systemd/system/apparmor.service; enabled; preset: enabled)
                   Active: active (exited) since Sun 2024-05-26 18:07:15 CEST; 1 week 0 days ago
                     Docs: man:apparmor(7)
                           https://gitlab.com/apparmor/apparmor/wikis/home/
                  Process: 5444 ExecStart=/lib/apparmor/apparmor.systemd reload (code=exited, status=0/SUCCESS)
                 Main PID: 5444 (code=exited, status=0/SUCCESS)
                      CPU: 2.352s
              
              May 26 18:07:14 magnetar systemd[1]: Starting apparmor.service - Load AppArmor profiles...
              May 26 18:07:14 magnetar apparmor.systemd[5444]: Restarting AppArmor
              May 26 18:07:14 magnetar apparmor.systemd[5444]: Reloading AppArmor profiles
              May 26 18:07:15 magnetar systemd[1]: Finished apparmor.service - Load AppArmor profiles.
              root@magnetar:~$
              Any idea what needs to be done in order to grant zabbix user necessary permission?

              Comment

              • Markku
                Senior Member
                Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
                • Sep 2018
                • 1782

                #8
                Unfortunately no idea

                Markku

                Comment

                • Gomo
                  Junior Member
                  • May 2024
                  • 16

                  #9
                  I disabled "apparmor" and the issue persists, sooo, it can't be caused by that.

                  Comment

                  • Markku
                    Senior Member
                    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
                    • Sep 2018
                    • 1782

                    #10
                    Are you still receiving the exact same error message ("failed to execute smartctl") even after disabling apparmor?

                    Does "sudo -u zabbix /usr/sbin/smartctl" work?

                    Markku

                    Comment

                    • Gomo
                      Junior Member
                      • May 2024
                      • 16

                      #11
                      Originally posted by Markku
                      Are you still receiving the exact same error message ("failed to execute smartctl") even after disabling apparmor?

                      Does "sudo -u zabbix /usr/sbin/smartctl" work?

                      Markku
                      Yes, it was showing the same error with "apparmor" disabled / not running.

                      Here's the result of command you mentioned
                      Click image for larger version

Name:	image.png
Views:	1208
Size:	24.9 KB
ID:	484791

                      Comment

                      • Gomo
                        Junior Member
                        • May 2024
                        • 16

                        #12
                        Bump.... anyone?

                        Comment

                        • Markku
                          Senior Member
                          Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
                          • Sep 2018
                          • 1782

                          #13
                          How about

                          sudo -u zabbix sudo /usr/sbin/smartctl /dev/sda

                          Markku

                          Comment

                          • Gomo
                            Junior Member
                            • May 2024
                            • 16

                            #14
                            Originally posted by Markku
                            How about

                            sudo -u zabbix sudo /usr/sbin/smartctl /dev/sda

                            Markku
                            It was performed, see second command in the previous screenshot.

                            Comment


                            • Markku
                              Markku commented
                              Editing a comment
                              Note the second "sudo" in the command
                          • mdella
                            Junior Member
                            • Apr 2024
                            • 8

                            #15
                            Originally posted by Gomo
                            Yes, it was showing the same error with "apparmor" disabled / not running.

                            Here's the result of command you mentioned
                            Click image for larger version  Name:	image.png Views:	39 Size:	24.9 KB ID:	484791
                            So whats happening there is that the "zabbix" user is trying to execute the smartctl command which is a root privledged command only. The above suggestion from Markku should work for you on your machine. Typically what this means is that your zabbix system was not granted access to the /dev/sd? devices application. If his example does *not* work, then the problem is going to be in your /etc/sudoers file (either there is a hidden typo, located in the wrong order, etc.

                            Additionally, I see you used the "@includedir" function. If your sudo is 1.9.1 or earlier, that wont work and would need to be the original "#includedir" to get your zabbix entry.

                            Lastly, you have "two" zabbix entries, one in the include dir and one at the end of your /etc/sudoers file. You have to eliminate one of those or you have a conflict.

                            Marcos

                            Comment

                            Working...