I’m looking for a way, that doesn’t require inputs.exec scripting, to report process metrics with a CPU usage level above a certain level. While inputs.procstat has a lot of useful metrics I can’t figure out how to implement it where it forwards metrics data to Influxdb for any process with a CPU use % above some level, like 70%
I could do it in a inputs.exec script, like below, but I don’t want to keep creating one-offs if there is existing infrastructure to utilize:
IFS=$‘\n’; for i in ps -eo ppid,pid,user,comm,pcpu --sort -pcpu | head -20
; do echo $i | awk ‘$5 > 30’; done
149450 149451 root fio 63.4
61042 149450 root fio 21.7
That output could be converted into a influx input where I get user, command, PPID/PID and CPU%
It looks like inputs.procstat can give much more than that but no way to set it to conditionally send data, like for any process exceeding a CPU usage level. I don’t want all process data for every process, even the trivial stuff, cramming the database.
Is there a way to set an input like procstat to only send data for a field threshold? Like cpu_usage > 50?