1

I am trying to add some hosts (UPSs) for monitoring battery charge, invertor status, input voltage, etc. I've been trying to get this working for hours. So, the Nagios scripts seem to work ok and at least some data is logged in influxdb. However, when trying to view the data from the Data Explorer on influx web page, it doesn't appear to keep the details of the individual hosts. I have also separate configs same as below but with just one host in each config file, but it does not appear to make a difference. All config files are storing data in the same bucket. Took a screenshot of the query and the returned data as I could not copy/paste and still be legible.

Query selections

Displayed data

This is my config:

[[inputs.exec]]
  timeout = "5s"
  commands = [
        "/usr/local/nagios/libexec/custom-plugins/check_ups_temperature -H 192.168.x.x -o 1.3.6.1.2.1.33.1.2.7.0 -v1 -C public -w 28 -c 31",
        "/usr/local/nagios/libexec/custom-plugins/check_ups_temperature -H 192.168.x.x -o 1.3.6.1.2.1.33.1.2.7.0 -v1 -C public -w 28 -c 31",
        "/usr/local/nagios/libexec/custom-plugins/check_ups_temperature -H 192.168.x.x -o 1.3.6.1.2.1.33.1.2.7.0 -v1 -C public -w 28 -c 31",
        "/usr/local/nagios/libexec/custom-plugins/check_ups_temperature -H 192.168.x.x -o 1.3.6.1.2.1.33.1.2.7.0 -v1 -C public -w 28 -c 31"
  ]
  name_suffix = "_ups_temp"
  data_format = "nagios"
 [[outputs.influxdb_v2]]
    urls = ["http://192.168.x.x:8086"]
    token = "--token--"
    organization = "--org--"
    bucket = "UPS"

Any pointers would be greatly appreciated.

1 Answers1

0

I would try making multiple [[inputs.exec]] configuration with different name_suffix = "_ups_tempXX" where XX something what could identify source device. It will put data in different measurement. Another way to go is to add tag keys in your telegraf exec configuration. List of tag names to extract from top-level of JSON server response: tag_keys = [ "my_tag_1", "my_tag_2" ]

But in this case you will need to update your exec response by sending also values of tag keys. As a tag key you may use device IP or something what will let you easily filter data from all sources. I found some old docs, It may be helpful for you: https://archive.docs.influxdata.com/telegraf/v1.3/concepts/data_formats_input/

Crashtein
  • 261
  • 2
  • 8
  • Many thanks for your input. I had tried with tags before, but was getting an error using the Nagios input. I have tried both the individual config and the JSON route with tags, and I managed to get them both working. I do have this error in the logs even though data does appear to be polled correctly: – Martin Mifsud Aug 24 '21 at 09:55
  • `[inputs.exec] Error in plugin: must be an object or an array of objects` Config and output here: https://pastebin.com/CAAXg6Hw Have tried both as an object above and as an array (adding [] at the beginning/end. I still get the error. As far as I can tell, this is valid json. Anything obvious I am missing? Thanks again! – Martin Mifsud Aug 24 '21 at 10:05
  • It suggests that you have an error in config file, to precise, In plugin inputs.exec. In this case I would try editing clean telegraf.conf file with small steps to see what is a reason of this problem. There may be even problems with white characters in your config. It was always tricky thing to me when problems appear when config is parsed. – Crashtein Aug 24 '21 at 22:54
  • As a first thing, you should use systemctl status telegraf command to se if Telegraf at least starts. If it shows status different than running, you should check conf file. Nothing to do with your code is needed in this case. – Crashtein Aug 24 '21 at 23:00
  • Thanks for all your input. Did not have time to look at this again until yesterday, but it started working a day after I looked at it last. Config and output from commands is still the same. I'm not sure what changed. Telegraf was running before. It was logging the error every time it polled. Your first answer helped a lot though and solved my original issue :) – Martin Mifsud Aug 27 '21 at 06:15