Node Exporter - Monitor Init.D Service

1,335 views
Skip to first unread message

Emmanuel Yong

unread,
Feb 6, 2018, 12:34:58 AM2/6/18
to Prometheus Users
Dear All,

How can i monitor init.d service for Centos 6 using Node Exporter?

I am able to monitor Centos 7 systemd by enabling  --collector.systemd

Thank You


Matthias Rampke

unread,
Feb 6, 2018, 4:49:37 AM2/6/18
to Emmanuel Yong, Prometheus Users
This is not supported, and likely will never be. With SystemV Init, there is no supervisor that knows the state of each service, and no common mechanism to determine that state. The only way is to shell out to the init scripts, which we will not do in the node exporter scrape cycle.

You can work around this limitation by writing a script that, out of band, determines the state of the services that you are interested in, and writes a metric file so that the textfile collector can read it.

/MR

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/9d1d3caf-5f3b-48c2-843a-6e61e81d3d91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Emmanuel Yong

unread,
Feb 6, 2018, 11:15:47 PM2/6/18
to Prometheus Users
Dear All,

What i have attempted to do is the following:
service --status-all | grep running | grep -v 'not' | sed 's/[0-9]//g; s/is//g; s/(pid  )//g; s/[[:space:]]\+/ /g; s/...$//' | sed s/running/1/g > /var/lib/node_exporter/sys_svc_running_stats.prom.$$ && mv -f /var/lib/node_exporter/sys_svc_running_stats.prom.$$ /var/lib/node_exporter/sys_svc_running_stats.prom

Which Gives The Following Output
abrtd 1
acpid 1
atd 1
auditd 1
crond 1
hald 1
irqbalance 1
keepalived 1
messagebus 1
mysqld 1
netdata 1
node_exporter 1
ntpd 1
rsyslogd 1
openssh-daemon 1
vmtoolsd 1

Checking Node Exporter Log Getting The Following Error
time="2018-02-07T12:10:34+08:00" level=error msg="Error parsing /var/lib/node_exporter/sys_svc_running_stats.prom: text format parsing error in line 15: expected float as value, got \"-daemon\"" source="textfile.go:99"

How can i fix the above issue?

Ben Kochie

unread,
Feb 7, 2018, 5:16:51 AM2/7/18
to Emmanuel Yong, Prometheus Users
"-" is an invalid metric name character.  I would do `tr '-' '_'`

To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/c1d2521f-d4e5-4f97-8e17-c17d83e4c289%40googlegroups.com.

Emmanuel Yong

unread,
Feb 7, 2018, 7:46:05 PM2/7/18
to Prometheus Users
Dear All,

Managed to do so using the below

service --status-all | grep running |awk '{print $1$4$5}'| sed -e 's/^/system_service_status{name="/g'| sed -e 's/isrunning.../"} 1/g' | sed -e 's/:notrunning./"} 0/g'

If anyone have a better way of doing it, feel free to share

Thank You

Stuart Clark

unread,
Feb 9, 2018, 5:44:18 PM2/9/18
to Emmanuel Yong, Prometheus Users
I think the problem is because of the naming of the metrics you are
producing. Rather than creating a metric for each application, you are
probably better off having a single metric with labels.

For example adjust your script (the sed bit) to instead output something
like:

systemv_up{service="abrtd"} 1
...
systemv_up{service="vmtoolsd"} 0
>>> email to prometheus-use...@googlegroups.com <javascript:>.
>>> To post to this group, send email to promethe...@googlegroups.com
>>> <javascript:>.
>>> <https://groups.google.com/d/msgid/prometheus-users/9d1d3caf-5f3b-48c2-843a-6e61e81d3d91%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to prometheus-use...@googlegroups.com.
> To post to this group, send email to promethe...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/c1d2521f-d4e5-4f97-8e17-c17d83e4c289%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


--
Stuart Clark

Reply all
Reply to author
Forward
0 new messages