Am new to cacti so please forgive me if my question sounds stupid, I have tried my best to find the solution for the problem but still needs help. I want to gather number of lines in the haproxy.log file from a remote front end(FE) machine, I have added this device successfully in cacti and graphs like load average are being drawn. I followed this: http://www.cacti.net/downloads/docs/html/how_to.html to add a graph to this device using shell script, I added a Data input method selecting Script/Command as the input type and /home/ubuntu/script.sh as the input string, added a output field too. Next I added a data source with out a template and selecting FE as the host, then as mentioned in the link I added the graph and things look fine till now, problem is that nothing is being plotted in the graph, cacti log files(Debug mode) shows the following:
CMDPHP: Poller[0] Host[5] DS[29] CMD: /home/ubuntu/script.sh, output: U 12/30/2011 12:35:07 AM - CMDPHP: Poller[0] Host[5] DS[29] WARNING: Result from CMD not valid. Partial Result: U
Now I know that script should print out the output only as this is one output field, my script contains the following
temp=$(sudo ssh -i /home/ubuntu/key.pem [email protected] '/var/log/haproxy.log | wc -l') echo $temp
the script is owned by ubuntu as there is no cacti user on cacti server, someone else installed cacti server and I have now been asked to take care of it.
If I execute the script from cacti server command line it works fine and am executing it as user ubuntu only.
Please help me I dont know where am I going wrong.
Thanks
From memory, the cacti poller runs as the
www-data
user, therefore won't have permission to read your private key.SSH isn't a brilliant way for cacti to get data from remote machines. There's numerous alternatives, but the one I've had success with is using SNMP to return data from the remote host back to cacti.
The SNMP daemon on ubuntu can use the
exec
configuration to execute scripts in response to specific SNMP queries. The example given in the ubuntusnmpd.conf
is this:This will return the current
mailq
output to any client that queries.1.3.6.1.4.1.2021.53
. You should be able to set up something similar and configure cacti to use a simple SNMP query to receive the data.This is a lot easier than faffing around with custom script inputs, in my view.