Open beepbeepplop opened 8 years ago
I explain my issue here: http://stackoverflow.com/questions/39580455/exec-plugin-collectd-issue
I provided a comment, but had to edit it 3 times to get it right ;-)
Thankyou for the response. This is actually driving me a little mad. It all works from the command line, but as soon as collectd gets involved it just falls apart.
BTW ive been on irc at #collecd for the past 3-4 days. Noone has been able to help me there.
I don't use collectd, so I can provide only general help. The plugin file wants to execute /usr/local/bin/collectd_pcsensor_temper.sh
as nobody. Try running it as such on the console:
su -c /usr/local/bin/collectd_pcsensor_temper.sh nobody
I changed it from nobody to incognito. I also removed the root requirement through a udev script.
sudo -u incognito /usr/local/bin/collectd_pcsensor_temper.sh
works` fine btw. :)
I am afraid I can't follow. So the plugin works now?
No. This was one of the first avenues i investigated. :) It has never worked for me inside collectd.
So, what does su -c /usr/local/bin/collectd_pcsensor_temper.sh nobody
give you on the console run as root, or sudo su -c ...
if you are restricted user.
Well i changed it to incognito..so let's stick with that. su -c /usr/local/bin/collectd_pcsensor_temper.sh incognito
gives me no output.
No output suggests that the exit code is non-zero. Try
su -c /usr/local/bin/collectd_pcsensor_temper.sh incognito ; echo exitcode=$?
exitcode=1
Let us inspect the contents of /usr/local/bin/collectd_pcsensor_temper.sh
.
Should be identical to this file: https://github.com/petervojtek/usb-thermometer/blob/master/collectd_pcsensor_temper.sh.in
That's not what you posted on stackoverflow. And it cannot be identical. Since there's @@BIN_DIR@@
. Please cat
the file contents here.
i posted a test file on SO. Ive been working on this for days. But you're right. collectd_pcsensor_temper.sh
#!/bin/bash -e
set -euo pipefail
IFS=$'\n\t'
PCSENSOR=/usr/local/bin/pcsensor
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
INTERVAL="${COLLECTD_INTERVAL:-60}"
${PCSENSOR} -l${INTERVAL} -n | sed -e "s/^.*\$/PUTVAL $HOSTNAME\/pcsensor\/gauge-temper\ interval=$INTERVAL N:\0/"
I guess that the ${PCSENSOR} part is the culprit. But I am afraid we'll need to check it out bit by bit. Put echo
before ${PCSENSOR}
and \
directly before the | sed
, i.e. make it
echo ${PCSENSOR} -l${INTERVAL} -n \| sed -e "s/^.*\$/PUTVAL $HOSTNAME\/pc (...)
and run su -c /usr/local/bin/collectd_pcsensor_temper.sh incognito ; echo exitcode=$?
again.
Thank you for the continued assistance.
exitcode=1
Uhm, I need the full output! Oh, wait, there was no output!?
That was the full output.
If running a shell script that basically has only an echo
command fails without providing any error message then something is very wrong :-/ Of course, one can go on debugging this but that's not an issue with collectd nor usb-termometer/pcsensor. Here's what it returns on my system:
# su -c /usr/local/bin/tmp.sh incognito
/usr/local/bin/temper_pcsensor -l60 -c | sed -e s/^.*$/PUTVAL "localhost\/pc\/gauge" interval=60 N:\0/
And no matter what I do to make it fail, it always shows an error message.
running as root (sudo su) gave no ouput. Running from my user account gives
/usr/local/bin/pcsensor -l60 -n | sed -e s/^.*$/PUTVAL localhost\/pcsensor\/gauge-temper\ interval=60 N:\0/
exitcode=0
In my defence I have at least 10 screen tabs, sshing into my server and it's getting late. Plus i have tried many many things to fix this before i ever asked for assistance from anyone. :) Thanks for your continued patience and assistance.
Could this be the issue: http://stackoverflow.com/questions/39582607/decode-sed-expression?noredirect=1#comment66479338_39582607
Hmm probably not.
Well i finally got it working. It's a cock-eyed method that presumably could be bettered. But this appears to be working. It's producing a graph as expected. Comments?
#!/bin/bash
INTERVAL=10
while true
do
/usr/local/bin/pcsensor -n > /var/tmp/temperature
cat /var/tmp/temperature | sed -e 's/.$//;s/^[0-9][0-9]*\.[0-9]/PUTVAL downloads\/exec-environmental\/temperature-cpu interval=30 N:&/'
sleep $INTERVAL
done
Oh spoke to soon. It has failed after a short period of time with
Could not set configuration 1
This is in the /var/tmp/temperature file. I have no idea. :(
Last try. So i removed the pcsensor line and just fill it manually from the terminal. ie
/usr/local/bin/pcsensor -l60 -n > /usr/local/share/temperature #yes ive moved the file incase it's a permissions problem
and updated the script to
#!/bin/bash
INTERVAL=10
while true
do
cat /usr/local/share/temperature | sed -e 's/.$//;s/^[0-9][0-9]*\.[0-9]/PUTVAL downloads\/exec-environmental\/temperature-cpu interval=30 N:&/'
sleep $INTERVAL
done
Now i get this output. http://pastebin.com/eMqB2cEL If anyone could help I would appreciate it. Thank you :)
Scrap that. It works. I replaced cat with tail -1 in the script. But boy does it feel like a hack. :)
Im having a hell of a time getting collectd to get data from this thermometer. Tried a variety of different things to no avail. It's working from the command line. Could anyone assist by sharing more details of how they achieved working collectd integration? Even just configs might be better than randomly trying stuff. ty