python-diamond / Diamond

Diamond is a python daemon that collects system metrics and publishes them to Graphite (and others). It is capable of collecting cpu, memory, network, i/o, load and disk metrics. Additionally, it features an API for implementing custom collectors for gathering metrics from almost any source.
http://diamond.readthedocs.org/
MIT License
1.74k stars 600 forks source link

diamond fails to run at boot with "Name or service not known" #751

Open paulraines68 opened 4 years ago

paulraines68 commented 4 years ago

On CentOS7 using diamond-4.0.515 with the included systemd service file, diamond always fails to run at boot but starts fine by a hand later.

The error in the log is:


[2020-10-23 16:07:50,198] [MainThread] Unhandled exception: [Errno -2] Name or service not known
[2020-10-23 16:07:50,199] [MainThread] traceback: Traceback (most recent call last):
  File "/usr/local/diamond/bin/diamond", line 298, in main
    server.run()
  File "/usr/local/diamond/lib/python2.7/site-packages/diamond/server.py", line 108, in run
    self.handlers = load_handlers(self.config, handlers)
  File "/usr/local/diamond/lib/python2.7/site-packages/diamond/utils/classes.py", line 89, in load_handlers
    h = cls(handler_config)
  File "/usr/local/diamond/lib/python2.7/site-packages/diamond/handler/stats_d.py", line 66, in __init__
    self._connect()
  File "/usr/local/diamond/lib/python2.7/site-packages/diamond/handler/stats_d.py", line 161, in _connect
    port=self.port
  File "/usr/lib/python2.7/site-packages/statsd/client.py", line 139, in __init__
    host, port, fam, socket.SOCK_DGRAM)[0]
gaierror: [Errno -2] Name or service not known

I tried adding the following to [Unit] in /etc/systemd/system/diamond.service but it made no difference

After=network.target

I then changed that to the following and it did work:

After=network.target remote-fs.target nss-lookup.target

shortdudey123 commented 2 years ago

Interesting ... Can you submit a PR?

paulraines68 commented 2 years ago

Sorry, I don't know how to do a pull request