2

I am trying to write a custom plugin for Icinga2 that gets license information from a product that we provide to our customers. Its a really simple script but there are multiple lines of output and I am trying to gather the data and have it formatted under the services for a specific host.

Here is the output of the data:

Users of product1, Total issued=10, Total used=0
Users of product2, Total issued=10, Total used=0
Users of product3, Total issued=10, Total used=0
Users of product4, Total issued=10, Total used=0
Users of product5, Total issued=50, Total used=11
Users of product6, Total issued=10, Total used=0
Users of product7, Total issued=771, Total used=0
Users of product8, Total issued=771, Total used=8
Users of product9, Total issued=771, Total used=0
Users of product10, Total issued=60, Total used=0

Here is what I THINK needs to be passed to Icinga2:

COMSOL CHECK OK : Users of=product1, Total issued=10, Total used=0| UsersOf=product1;;;; TotalIssued=10;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product2, Total issued=10, Total used=0| UsersOf=product2;;;; TotalIssued=10;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product3, Total issued=10, Total used=0| UsersOf=product3;;;; TotalIssued=10;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product4, Total issued=10, Total used=0| UsersOf=product4;;;; TotalIssued=10;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product5, Total issued=50, Total used=11| UsersOf=product5;;;; TotalIssued=50;;;; TotalUsed=11;;;;
COMSOL CHECK OK : Users of=product6, Total issued=10, Total used=0| UsersOf=product6;;;; TotalIssued=10;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product7, Total issued=771, Total used=0| UsersOf=product7;;;; TotalIssued=771;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product8, Total issued=771, Total used=8| UsersOf=product8;;;; TotalIssued=771;;;; TotalUsed=8;;;;
COMSOL CHECK OK : Users of=product9, Total issued=771, Total used=0| UsersOf=product9;;;; TotalIssued=771;;;; TotalUsed=0;;;;
COMSOL CHECK OK : Users of=product10, Total issued=60, Total used=0| UsersOf=product10;;;; TotalIssued=60;;;; TotalUsed=0;;;;

Here is my script:

#!/bin/bash
license=$(/opt/licenses/comsol/lmstat -a |grep 'Users of' |sed 's/://g' |head -10| awk '{print "COMSOL CHECK OK : Users of="$3", Total issued="$6", Total used="$11 "| UsersOf="$3";;;; TotalIssued="$6";;;; TotalUsed="$11";;;;" }') 

printf "${license}\n"

As you can see it really simple, but I get the following errors in Icinga this this config...

Plugin Output
sed: couldn't write 85 items to stdout: Broken pipe
grep: write error: Broken pipe
COMSOL CHECK OK : Users of=product1, Total issued=10, Total used=0
COMSOL CHECK OK : Users of=product2, Total issued=10, Total used=0
COMSOL CHECK OK : Users of=product3, Total issued=10, Total used=0
COMSOL CHECK OK : Users of=product4, Total issued=10, Total used=0
COMSOL CHECK OK : Users of=product5, Total issued=50, Total used=10
COMSOL CHECK OK : Users of=product6, Total issued=10, Total used=0
COMSOL CHECK OK : Users of=product7, Total issued=771, Total used=0
COMSOL CHECK OK : Users of=product8, Total issued=771, Total used=8
COMSOL CHECK OK : Users of=product9, Total issued=771, Total used=0
COMSOL CHECK OK : Users of=product10, Total issued=60, Total used=0

Ive even tried to pass it all to one line so the output is like this:

COMSOL CHECK OK : Users of=product1, Total issued=10, Total used=0| UsersOf=product1;;;; TotalIssued=10;;;; TotalUsed=0;;;; Users of=product2, Total   issued=10, Total used=0| UsersOf=product2;;;; TotalIssued=10;;;; TotalUsed=0;;;; Users of=product3, Total issued=10, Total used=0| UsersOf=product3;;;; TotalIssued=10;;;; TotalUsed=0;;;; Users of=product4, Total issued=10, Total used=0| UsersOf=product4;;;; TotalIssued=10;;;; TotalUsed=0;;;; Users of=product5, Total issued=50, Total used=10| UsersOf=product5;;;; TotalIssued=50;;;; TotalUsed=10;;;; Users of=product6, Total issued=10, Total used=0| UsersOf=product6;;;; TotalIssued=10;;;; TotalUsed=0;;;; Users of=product7, Total issued=771, Total used=0| UsersOf=product7;;;; TotalIssued=771;;;; TotalUsed=0;;;; Users of=product8, Total issued=771, Total used=8| UsersOf=product8;;;; TotalIssued=771;;;; TotalUsed=8;;;; Users of=product9, Total issued=771, Total used=0| UsersOf=product9;;;; TotalIssued=771;;;; TotalUsed=0;;;; Users of=product10, Total issued=60, Total used=0| UsersOf=product10;;;; TotalIssued=60;;;; TotalUsed=0;;;;

Any ideas how to get this to work... Will it work?

Thanks! Joe

Joeg1484
  • 43
  • 3

1 Answers1

-2

Performance data values have to be an integer. See https://www.monitoring-plugins.org/doc/guidelines.html#AEN201.