PfSense Zabbix Agent
-
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 foundI'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.
-
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.
-
@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 foundAny other thoughts?
-
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 "-"
-
@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 foundI'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. ???
-
Does zabbix-get do a chroot?
-
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?
-
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.
-
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 :)
-
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.
-
linux-reaf:~ #
What is that? You are running these on pfSense right?
-
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.
-
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.