Skip to content

Conversation

@smortex
Copy link
Member

@smortex smortex commented May 13, 2020

Pull Request (PR) description

The default hostname used by collectd is system dependent as retuned by
gethostname(3) (On FreeBSD it's the FQDN, while on Linux it's the
non-FQDN). The python method socket.gethostname() always return a
non-FQDN, and the user has the ability to tune the hostname as he wish
in the collectd configuration (hostname parameter).

This change allow to use a customized hostname by using an optional
argument "hostname". When not provided, the non-FQDN and the FQDN are
tried in turn to fetch the requested metric value.

This Pull Request (PR) fixes the following issues

n/a

The default hostname used by collectd is system dependent as retuned by
gethostname(3) (On FreeBSD it's the FQDN, while on Linux it's the
non-FQDN).  The python method socket.gethostname() always return a
non-FQDN, and the user has the ability to tune the hostname as he wish
in the collectd configuration (hostname parameter).

This change allow to use a customized hostname by using an optional
argument "hostname".  When not provided, the non-FQDN and the FQDN are
tried in turn to fetch the requested metric value.
"input_method": "stdin",
"files": ["python_task_helper/files/task_helper.py"],
"parameters": {
"hostname": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi
There's example and parameters in README that could be extended with the new option.

@traylenator
Copy link
Contributor

Glad someone using this, I pretty much did it as an academic exercise

@traylenator
Copy link
Contributor

Rather than passing the hostname which will be different for every host can something be done with a fact name. Pass a factname and then that be used.
Trouble is I can't remember much how this stuff works.

@smortex
Copy link
Member Author

smortex commented May 21, 2020

Ah yes, didn't thing that passing the hostname does not scale beyond 1 node… Maybe we can just use hostname, and fallback to fqdn (so no custom values). We can also look for a setting in /etc/collectd/collectd.conf before falling back but some systems will use e.g. /usr/local/etc/collectd/collectd.conf

Not ideal… What do you think ?

@traylenator
Copy link
Contributor

Parsing collectd.conf seems a bit yuck.

We use:

FQDNLookup true

Sending a fact name of choice as a parameter then the user can specify if they
want networking.fqdn or networking.hostname

@traylenator traylenator added bug Something isn't working needs-work not ready to merge just yet labels May 26, 2020
@traylenator
Copy link
Contributor

I never realised you do a getval without the hostname.

collectdctl getval ai-catalog-diff/gauge-return_code

works perfectly well, that's the solution.

@smortex
Copy link
Member Author

smortex commented Sep 30, 2020

I never realised you do a getval without the hostname.

Interesting, I do not see this behavior and was thinking about contributing it maybe… A patch might be already available somewhere. On what system do you experience this?

@traylenator
Copy link
Contributor

rpm -q collectd
collectd-5.8.1-1.el7.cern8.x86_64

Don't think we have any patches in this area.

We do have:

FQDNLookup true

I wonder if your $(hostname) is not equaul to $(hostname -f) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working needs-tests needs-work not ready to merge just yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants