Am using collectd to collect the system metric and pushing into influx db.
To monitor the running process I wrote a script leveraged the collectd exec plugin to push my custo m metric into influx db... My script for exec plugin is
#!/bin/bash
tmpfile=$(mktemp)
HOSTNAME="${COLLECTD_HOSTNAME:-slave1-collectd}"
INTERVAL="${COLLECTD_INTERVAL:-6}"
while sleep "$INTERVAL"; do
sudo systemctl list-units --type service --all | grep running | awk -v OFS='\t' '{ print $1, $2, $4 }' > "$tmpfile"
done
My collectd conf file
<Plugin exec>
Exec developer "/home/developer/process.sh"
<Plugin>
If i ran the command show measurement in influxdb, it is displaying the measurement of other plugin not exec plugin:
cpu_value
df_value
disk_io_time
disk_read
disk_value
disk_weighted_io_time
disk_write
interface_rx
interface_tx
load_longterm
load_midterm
load_shortterm
memory_value
processes_majflt
processes_minflt
processes_processes
processes_read
processes_rx
processes_syst
processes_threads
processes_tx
processes_user
processes_value
processes_write
table_value
uptime_value
users_value
Can anyone please help me!
My endgoal is to monitor all the running services like below
[developer@slave1-collectd ~]$ systemctl list-units --type service --state=running
UNIT LOAD ACTIVE SUB DESCRIPTION
amazon-ssm-agent.service loaded active running amazon-ssm-agent
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
collectd.service loaded active running Collectd statistics daemon
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
getty@tty1.service loaded active running Getty on tty1
gssproxy.service loaded active running GSSAPI Proxy Daemon
httpd.service loaded active running The Apache HTTP Server
network.service loaded active running LSB: Bring up/down networking
polkit.service loaded active running Authorization Manager
postfix.service loaded active running Postfix Mail Transport Agent
rpcbind.service loaded active running RPC bind service
rsyslog.service loaded active running System Logging Service
serial-getty@ttyS0.service loaded active running Serial Getty on ttyS0
sshd.service loaded active running OpenSSH server daemon
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-udevd.service loaded active running udev Kernel Device Manager
tuned.service loaded active running Dynamic System Tuning Daemon
I wants to push all the running process along with their Unit name and status like sshd, kafka, tsdb, collectd, grafana (all these systemctl service I wants to monitor on Grafana dashboard)
#!/bin/bash
HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
INTERVAL="${COLLECTD_INTERVAL:-10}"
PORT=6379
while sleep "$INTERVAL"
do
b=$(systemctl list-units --type service --all | awk 'BEGIN{print "Service State Status"};$4 ~ /^running$/{print $1,$2,$4}' | column -t )
echo "PUTVAL $HOSTNAME/vs_processes/if_octets interval=$INTERVAL N:$b"
done
When i start the collectd am getting error:parse_value: Failed to parse string as derive: "Service".