I don't think this is a duplicate of this but if it is, please feel free to mark it as such.
I'm running collectd to gather metrics from my home lab, as well as my home energy usage, and feed it into influxdb to display in grafana. If I launch collectd via command line:
collectd -C /etc/collectd/collectd.conf
collectd runs, collects other metrics, and collects my home-energy usage just fine (i see values in influxdb).
If I try launching collectd via it's init script
/etc/init.d/collect start
Collectd starts, gathers metrics, however I don't see any results in influx for my energy colection script.
One thing I did notice, is that if I strace the collection script process, I see different exit statuses based on how the script is invoked:
Working command line:
root@metrics:~# strace -p 28818
Process 28818 attached
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 28825
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=28825, si_uid=65534, si_status=0, si_utime=0, si_stime=0} ---
rt_sigretu() = 28825
pipe([3, 4]) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fc0d04a29d0) = 28831
close(4) = 0
read(3, "522n", 128) = 4
read(3, "", 128) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=28831, si_uid=65534, si_status=0, si_utime=220, si_stime=6} ---
rt_sigretu() = 0
close(3) = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 28831
write(1, "PUTVAL metrics.home/eagle-http/g"..., 63) = 63
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fc0d04a29d0) = 28836
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 28836
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=28836, si_uid=65534, si_status=0, si_utime=0, si_stime=0} ---
Not working init.d
Process 28710 attached
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 28745
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=28745, si_uid=65534, si_status=0, si_utime=0, si_stime=0} ---
rt_sigretu() = 28745
pipe([3, 4]) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faf1ee989d0) = 28754
close(4) = 0
read(3, "", 128) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=28754, si_uid=65534, si_status=1, si_utime=1, si_stime=0} ---
rt_sigretu() = 0
close(3) = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 28754
write(1, "PUTVAL metrics.home/eagle-http/g"..., 60) = 60
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faf1ee989d0) = 28755
wait4(-1, ^CProcess 28710 detached
The only difference I see, is that the exit status changes based on how it's run:
command line
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 28831
init.d/collectd start:
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 28754
The script is 755, owned by root, as is collectd.conf..the script section is
<Plugin "exec">
Exec "nobody" "/usr/lib/collectd/eagle.sh"
</Plugin>
eagle.sh:
#!/bin/sh
INTERVAL=30
HOST=`hostname -f`
while true; do
output=$(python /var/tmp/test.py)
echo "PUTVAL $HOST/eagle-http/gauge-wattage interval=$INTERVAL N:$output"
sleep $INTERVAL || true
done
python script it calls:
#!/usr/bin/env python
import time
from eagle_http import *
eagle = eagle_http('email_address', 'useame', 'cloud_id')
output = eagle.get_instantaneous_demand()
#demand = eagle.InstantaneousDemand.Demand
#multiplier = eagle.InstantaneousDemand.Multiplier
#divisor = eagle.InstantaneousDemand.Divisor
#timeoffset = eagle.InstantaneousDemand.TimeStamp
demand = eagle.InstantaneousDemand.Demand
print (int(demand, 16))
Does anyone have any idea why this isn't working?
Recent Questions...
ما را در سایت Recent Questions دنبال میکنید
برچسب:
نویسنده: استخدام کار
بازدید: 330
تاريخ: يکشنبه
10 مرداد
1395 ساعت: 2:02