netdata icon indicating copy to clipboard operation
netdata copied to clipboard

nut.chart.sh

Open MelkorLord opened this issue 10 years ago • 6 comments

Hi,

My NUT installation uses SSL to establish connections. When using the upsc command you'll get a warning printed to stderr

# upsc -l
Init SSL without certificate database
Connecting in SSL to 'localhost' (no certificate name specified)
Do not intend to authenticate server localhost
SSL handshake done successfully with server localhost
Connected to localhost in SSL
Certificate verification is disabled
[... list of declared UPSes ...]

This is harmless for the charts collection but these messages to stderr flood the error.log which is an inconvenience. The fix is pretty simple, just add a 2>/dev/null to nut_get_all() and nut_get() and the error.log gets clean again.

MelkorLord avatar Oct 19 '16 22:10 MelkorLord

hm... if I do this, then there will be no way to check why it is not running, to trace an issue.

We have 2 solutions here:

  1. write it like this:

    nut_get_all() {
      timeout $nut_timeout upsc -l 2>${TMP_DIR}/nut.log
      local ret=$?
      [ $ret -ne 0 ] && cat >&2 "${TMP_DIR}/nut.log"
      return $ret
    }
    

    The above will allow the log to be shown if upsc fails. ${TMP_DIR} is in /var/run so for many systems this is tmpfs.

    or

  2. You can overwrite this function in /etc/netdata/charts.d/nut.conf to eliminate these logs.

ktsaou avatar Oct 19 '16 23:10 ktsaou

Probably I can add a wrapper function in charts.d.plugin to do this for all charts.d modules...

ktsaou avatar Oct 19 '16 23:10 ktsaou

It is not in /var/run unfortunately: https://github.com/firehol/netdata/blob/cb2d5267a2176f952f19537ad7379f4f1a9469d0/plugins.d/charts.d.plugin#L480-L485

ktsaou avatar Oct 19 '16 23:10 ktsaou

Well, the written data is very low in size so this isn't an issue. If I'm not wrong, the filename /tmp/.netdata-${PROGRAM_NAME}-XXXXXXXXXX only changes upon NetData restart right?

All in all, the solution you suggest above seems perfectly acceptable.

MelkorLord avatar Oct 19 '16 23:10 MelkorLord

I implemented it https://github.com/ktsaou/netdata Can you check it?

ktsaou avatar Oct 20 '16 19:10 ktsaou

merged it. If you find any issues, let me know.

ktsaou avatar Oct 22 '16 23:10 ktsaou