From checks to influxdb

Again, noob but have a home lab im trying to learn on, using ubuntu and centos

I have been following the doc’s as best i can and pieced stuff together to try an accomplish collecting custom metrics that are flowing on the event bus and putting it into influx for reporting purposes but i am failing at this point, have posted some lines from syslog and my handler and check configuration bellow. is anyone aware of a complete walkthrough on how to do this? I’m pretty sure once i see what i have done wrong it will open up my eyes.

once i get checks sorted out i will start to play with some plugins, also want to do something with statd as well but just baby steps right now

(posted in yaml format, is json easier to read?)

i have also used the format graphite_plaintext and receive a similar area

Many thanks for any response
Andrew

Jul 29 11:39:52 zig sensu-agent[852]: {“asset”:“cpu-checks-plugins”,“component”:“asset-manager”,“entity”:“zig”,“level”:“info”,“msg”:“asset includes builds, using builds instead of asset”,“time”:“2020-07-29T11:39:52-04:00”}
Jul 29 11:39:52 zig sensu-agent[852]: {“asset”:“sensu-ruby-runtime”,“component”:“asset-manager”,“entity”:“zig”,“level”:“info”,“msg”:“asset includes builds, using builds instead of asset”,“time”:“2020-07-29T11:39:52-04:00”}
Jul 29 11:39:57 zig sensu-agent[852]: {“check”:“check-cpu”,“component”:“agent”,“error”:“unable to extract metric from check output”,“level”:“error”,“line”:0,“msg”:“influxdb line format requires 2 arguments with a 3rd (optional) timestamp”,“namespace”:“default”,“time”:“2020-07-29T11:39:57-04:00”}

skipper@backend:/var/log$ sensuctl handler list --format yaml
type: Handler
api_version: core/v2
metadata:
created_by: skipper
name: influx-db
namespace: default
spec:
command: sensu-influxdb-handler -d sensu
env_vars:

  • INFLUXDB_ADDR=http://192.168.1.55:8086
  • INFLUXDB_USER=sensu
  • INFLUXDB_PASS=sensu
    filters: null
    handlers: null
    runtime_assets:
  • influxdb-handler
    secrets: null
    timeout: 0
    type: pipe
    skipper@backend:/var/log$

skipper@backend:/var/log$ sensuctl check list --format yaml
type: CheckConfig
api_version: core/v2
metadata:
created_by: skipper
name: check-cpu
namespace: default
spec:
check_hooks: null
command: check-cpu.rb -w 75 -c 90
env_vars: null
handlers:
high_flap_threshold: 0
interval: 150
low_flap_threshold: 0
output_metric_format: influxdb_line
output_metric_handlers:

  • influx-db
    proxy_entity_name: “”
    publish: true
    round_robin: false
    runtime_assets:
  • cpu-checks-plugins
  • sensu-ruby-runtime
    secrets: null
    stdin: false
    subdue: null
    subscriptions:
  • Linux
    timeout: 0
    ttl: 0

Hi @ohhfine, the issue I see right off the bat is that you’re using the check-cpu script, which doesn’t provide any metric data. If you wanted the status as a metric, you’d need to use the -c flag in your handler definition. Otherwise, you’d want to use metrics-cpu as your script. Another alternative would be to use a script that outputs nagios perfdata, which gets you both status and metric data in one script. The nagios foundation collection is a good one to use in this case.

1 Like

this is very good thank you for the quick feed back, so the script i am using outputs this in event console

“CheckCPU TOTAL OK: total=0.1 user=0.0 nice=0.0 system=0.1 idle=99.9 iowait=0.0 irq=0.0 softirq=0.0 steal=0.0 guest=0.0 guest_nice=0.0”

i will read up on the -c flag for handler but will look at your other suggestions by changing the script in the check

Thanks again Aaron