Ad Widget

Collapse

Getting SMART data without sudo?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • molnart
    Junior Member
    • Feb 2024
    • 5

    #1

    Getting SMART data without sudo?

    I am trying to get smart data from my Proxmox drives. Proxmox has no sudo installed, nor I want to install it. I have enabled the smart plugin, but the agent is showing these errors:

    Code:
    check 'smart.disk.discovery' is not supported: Cannot fetch data: Failed to scan for devices: Cannot unmarshal JSON: invalid character 's' looking for beginning of value..
    I suspect this is because the agent is trying to run smartctl as sudo.
    The issue has been already mentioned here https://www.zabbix.com/forum/zabbix-...ge4#post450246 but with no apparent solution.
  • troffasky
    Senior Member
    • Jul 2008
    • 567

    #2
    What user is the Zabbix agent running as? Does that user have permission to run smartctl? If it's simply not necessary to use sudo then remove that from the script.

    Comment

    • molnart
      Junior Member
      • Feb 2024
      • 5

      #3
      how do i remove sudo from the script? i was under the assumption that sudo is baked in into the code. zabbix agent is running under the zabbix user and is able to get data from smartctl

      Comment

      • troffasky
        Senior Member
        • Jul 2008
        • 567

        #4
        Ahh OK, I assumed this was some agent parameter with a script.
        But it looks like, as you say, it's hard-coded. Not much you can do to fix that.


        Best workaround I can think of is to create a dummy "sudo" script that just passes everything through, and setuid root on the smartctl binary [if your Zabbix user isn't able to run it].

        Comment

        • carles
          Junior Member
          • Oct 2024
          • 7

          #5
          Maybe you can do that from the API: https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/disks/smart

          You can access it through shell: pvesh get /nodes/{node}/disks/smart

          Hope it helps!

          Comment

          • wib5y
            Junior Member
            • Dec 2024
            • 2

            #6
            Not sure if this will help in your case, however this was what worked in my case (Proxmox 8.3 and Zabbix 7.0.6):

            1. Install sudo
            2. Create a new sudoers file e.g. /etc/sudoers.d/zabbix
            3. Add zabbix ALL=(ALL) NOPASSWD: /usr/sbin/smartctl to the new file
            4. Change the permissions of the file to 0440
            5. Check the config with visudo -c to make sure all is correct and that's it

            Comment

            Working...