am using the haproxy socat to get the sessions data to plot it in cacti, /var/run/socket-haproxy is owned by www-data (the user which cacti uses) but when I try to execute this command as www-data am getting permission denied, any help would be much appreciated.
sudo su - www-data echo show stat | socat unix-connect:/var/run/socket-haproxy stdio | grep inbound | cut -d, -f 5
2012/01/11 15:58:18 socat[5448] E connect(3, AF=1 "/var/run/socket-haproxy", 25): Permission denied
-su: Can't open echo
So the issue is your pipes.. What you are doing is echoing show stat as the www-data user but running socat as your own user. Need to wrap it in quotes
Also your sudo is completely wrong to run a command as a user
For example
You don't need the extra su in there since you are already root I assume anyway
If you are already root just use su. Something like this