Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    PfSense Zabbix Agent

    Scheduled Pinned Locked Moved pfSense Packages
    13 Posts 4 Posters 7.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jrosetto
      last edited by

      I am trying to get hard drive temperatures from the Zabbix agent.  I wrote the command which locally in pfSense shell executes correctly and gives my the value I am looking for.

      Command:
      smartctl -A /dev/ada0 | grep -r "Temperature_Celsius" | cut -c 88-

      I added the command as a UserParameter in Zabbix2-Agent

      UserParameter=hdtemp,smartctl -A /dev/ada0 | grep -r "Temperature_Celsius" | cut -c 88-

      When I try to pull the values from the Zabbix server directly I get smartctl: not found.

      linux-reaf:~ # zabbix-get -s 192.168.5.1 -p 10050 -k hdtemp
      smartctl: not found

      I've attempted to run the Agent on pfsense as root with little success.

      Any thoughts or suggestions on how to get this to work?

      Thanks in advance on any help or input you can provide.

      1 Reply Last reply Reply Quote 0
      • M
        mer
        last edited by

        perhaps smartctl is not on PATH for the agent?
        "which smartctl"

        specify full path for smartctl on your UserParameter line.  I don't know where it lives, but probably something like /usr/bin, /usr/sbin, /usr/local/bin  stuff like that.

        1 Reply Last reply Reply Quote 0
        • J
          jrosetto
          last edited by

          @mer:

          perhaps smartctl is not on PATH for the agent?
          "which smartctl"

          specify full path for smartctl on your UserParameter line.  I don't know where it lives, but probably something like /usr/bin, /usr/sbin, /usr/local/bin  stuff like that.

          Thanks for the suggestion but came back with the same error with the direct path to the program.

          linux-reaf:~ # zabbix-get -s 192.168.5.1 -p 10050 -k hdtemp
          /usr/local/sbin/smartctl: not found

          Any other thoughts?

          1 Reply Last reply Reply Quote 0
          • M
            mer
            last edited by

            I'm not familiar with Zabbix, but you may need quotes in the config file. 
            When I look at this line:
            UserParameter=hdtemp,smartctl -A /dev/ada0 | grep -r "Temperature_Celsius" | cut -c 88-

            it looks like hdtemp is the internal tag, then everything else is the command you want to do.  maybe quotes in front of smartctl, and after the final "-"

            1 Reply Last reply Reply Quote 0
            • J
              jrosetto
              last edited by

              @mer:

              I'm not familiar with Zabbix, but you may need quotes in the config file. 
              When I look at this line:
              UserParameter=hdtemp,smartctl -A /dev/ada0 | grep -r "Temperature_Celsius" | cut -c 88-

              it looks like hdtemp is the internal tag, then everything else is the command you want to do.  maybe quotes in front of smartctl, and after the final "-"

              Still no dice.  The output changed slightly but still not producing the values.

              linux-reaf:~ # zabbix-get -s 192.168.5.1 -p 10050 -k hdtemp
              /usr/local/sbin/smartctl -A /dev/ada0 | grep -r Temperature_Celsius | cut -c 88-: not found

              I'm at a loss at this point because I have other user defined parameters for example

              UserParameter=cputemp0,sysctl dev.cpu.0.temperature | cut -c 24-27

              that work just fine.  ???

              1 Reply Last reply Reply Quote 0
              • DerelictD
                Derelict LAYER 8 Netgate
                last edited by

                Does zabbix-get do a chroot?

                Chattanooga, Tennessee, USA
                A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                Do Not Chat For Help! NO_WAN_EGRESS(TM)

                1 Reply Last reply Reply Quote 0
                • J
                  jrosetto
                  last edited by

                  @Derelict:

                  Does zabbix-get do a chroot?

                  I believe it does.  In normal zabbix agent installs on Linux I am able to modify a conf file and set RunAsRoot=1 which will allow full root access to the system.  The pfSense Zabbix Agent has a config file which I attempted to modify but doesn't make any difference.  Even if it did work, if I change anything in the GUI it overwrites the conf file anyway.

                  The daemon runs as the zabbix user.  Any suggestions on how to get it to run as root?

                  1 Reply Last reply Reply Quote 0
                  • DerelictD
                    Derelict LAYER 8 Netgate
                    last edited by

                    chroot has to do with the filesystem, not whether or not it runs as root.

                    If it does in fact chroot you need to make sure everything you need access to (like smartctl) is linked to inside the chroot environment.

                    Chattanooga, Tennessee, USA
                    A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                    DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                    Do Not Chat For Help! NO_WAN_EGRESS(TM)

                    1 Reply Last reply Reply Quote 0
                    • M
                      mer
                      last edited by

                      @Derelict:

                      chroot has to do with the filesystem, not whether or not it runs as root.

                      If it does in fact chroot you need to make sure everything you need access to (like smartctl) is linked to inside the chroot environment.

                      Thanks, that's where I was going next :)

                      1 Reply Last reply Reply Quote 0
                      • J
                        jrosetto
                        last edited by

                        After researching the program doesn't run in a chroot environment.  It just runs under the zabbix user.  I tried setting the permissions on the file for the zabbix user but that didn't make any difference.  I'm out of ideas.

                        1 Reply Last reply Reply Quote 0
                        • DerelictD
                          Derelict LAYER 8 Netgate
                          last edited by

                          linux-reaf:~ #

                          What is that? You are running these on pfSense right?

                          Chattanooga, Tennessee, USA
                          A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                          DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                          Do Not Chat For Help! NO_WAN_EGRESS(TM)

                          1 Reply Last reply Reply Quote 0
                          • D
                            dgcom
                            last edited by

                            So - anyone have solved this yet?

                            I really want to monitor SMART status of the HDD via Zabbix - but it agent can't execute smartctl…
                            Zabbix agent runs as zabbix user, which seems to be in its own chroot.
                            There was an advice I fount to run this:

                            chmod +s /usr/local/sbin/smartctl
                            

                            But it did not help. Interestingly, now I can execute

                            su -m zabbix -c /usr/local/sbin/smartctl
                            

                            But it still fails when run from agent itself…

                            I do not want to mess much with zabbix user permission, so any help would be appreciated.

                            DG

                            1 Reply Last reply Reply Quote 0
                            • D
                              dgcom
                              last edited by

                              Ok, so I found the solution - if anyone interested:
                              Since Zabbix Agent is running in chroot, smartctl executable has to be linked in.
                              For Zabbix 2.4 64 bit command is:

                              ln /usr/local/sbin/smartctl /usr/pbi/zabbix24-agent-amd64/local/sbin
                              

                              It probably won't survive package reinstall/updates, adding to startup script might help.

                              I used the following user parameters in advanced agent config:

                              UserParameter=system.smartctl[*],smartctl -A $1 | grep $2 | cut -c 88- | cut -f1 -d' '
                              UserParameter=system.smarthealth[*],smartctl -H $1 | grep result | cut -f2 -d':' | cut -c 2-
                              
                              First one will return value for specified S.M.A.R.T. parameter - I usually monitor temperature.
                              The second one will return one of PASSED/FAILED!/UNKNOWN! so I can set a trigger if value is not PASSED.
                              
                              More can be done to improve things, like discovery of the disks -but for pfSense it is more often than not just /dev/ata0.
                              
                              

                              DG

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.