Comments (8)
are you able to share the output of the script? what format is it? thanks!
from nri-flex.
Just a sample (all nagios checks works the same way)
root@monworker001:/var/db/newrelic-infra/custom-integrations# /usr/lib64/cmbmonit/plugins/check_load -w 0,3,2 -c 1,6,4
WARNING - load average: 0.01, 0.07, 0.08|load1=0.010;0.000;1.000;0; load5=0.070;3.000;6.000;0; load15=0.080;2.000;4.000;0;
PID USER %CPU COMMAND
1 root 0.0 /sbin/init
2 root 0.0 [kthreadd]
3 root 0.0 [ksoftirqd/0]
5 root 0.0 [kworker/0:0H]
7 root 0.0 [rcu_sched]
root@monworker001:/var/db/newrelic-infra/custom-integrations# /usr/lib64/cmbmonit/plugins/check_load -w 5,3,2 -c 6,6,4
OK - load average: 0.01, 0.07, 0.08|load1=0.010;5.000;6.000;0; load5=0.070;3.000;6.000;0; load15=0.080;2.000;4.000;0;
So I want to catch output into a variable. It can be 1 line but also multiple lines (in case of warning/critical).
Thanks.
from nri-flex.
I am not sure what metrics you are trying to get from the output.
With the following sdeedee.yml config:
name: sdeedee apis: - name: sdeedee commands: - run: cat sdeedee.abc split: horizontal row_header: 0 set_header: [ status, loadAverage1, loadAverage2, loadAverage1, load11, load12, load13, load14, load51, load52, load53, load54, load151, load152, load153, load154, ] regex_match: true split_by: '(\S+).*?(load average:)\s+(.*?),\s+(.*?),\s+(.*?)\|load1=(.*?);(.*?);(.*?);(.*?);\s+load5=(.*?);(.*?);(.*?);(.*?);\s+load15=(.*?);(.*?);(.*?);(.*?);'
I got the following result:
{ "event_type": "sdeedeeSample", "integration_name": "com.newrelic.nri-flex", "integration_version": "0.8.3-pre-3-gf5a6601-dirty", "load11": 0.08, "load12": 0.01, "load13": 5, "load14": 6, "load151": 0, "load152": 0.08, "load153": 2, "load154": 4, "load51": 0, "load52": 0.07, "load53": 3, "load54": 6, "loadAverage1": 0.07, "loadAverage2": 0.01, "status": "OK" }
Please insert a blank line before the first line in the current output for multiple line output as Flex expects the metrics starts from the 2nd line onwards currently (for multi line output).
For single line output, it should work fine.
So this above yml config should work for the OK output.
OK - load average: 0.01, 0.07, 0.08|load1=0.010;5.000;6.000;0; load5=0.070;3.000;6.000;0; load15=0.080;2.000;4.000;0;
Please let me know how you go with the yml config.
./nri-flex -config_file sdeedee.yml -pretty -verbose
from nri-flex.
In the above yml file, i am using "run: cat sdeedee.abc" to simulate your script output.
the "sdeedee.abc" has the following content:
OK - load average: 0.01, 0.07, 0.08|load1=0.010;5.000;6.000;0; load5=0.070;3.000;6.000;0; load15=0.080;2.000;4.000;0;
from nri-flex.
Hi @haihongren, thanks! I can go on with your example. The multi line output I can cover by removing newline characters so the output is always a single line.
Just two other questions related to variables.
Is it possible to use variables in de flexConfig file?
/usr/lib64/cmbmonit/plugins/check_load -w @VARIABLES_ARG_WARNING -c @VARIABLES_ARG_CRITICAL
@VARIABLES_ARG defined somewhere in the flexconfig file:
- variables:
arg.warning: 3,4,5
arg.critical: 6,7,8
Is it possible to reuse the run command and exit status of the command as variable to pass as attribute? Like in bash $? returns exit code of the command and $0 the command. To have:
custom_attributes: command.exitcode: $? command.run: $0
from nri-flex.
Please look at the following example:
- variable_store
- custom_attributes
- ${var:myfile}
name: sdeedee variable_store: myfile: sdeedee.abc myCommand: cat apis: - name: sdeedee commands: - run: ${var:myCommand} ${var:myfile} split: horizontal set_header: [ status, loadAverage1, loadAverage2, loadAverage1, load11, load12, load13, load14, load51, load52, load53, load54, load151, load152, load153, load154, ] regex_match: true # split_by: '(\S+).*?(load average:)\s+(.*?),\s+(.*?),\s+(.*?)\|load1=(.*?);(.*?);(.*?);(.*?);\s+load5=(.*?);(.*?);(.*?);(.*?);\s+load15=(.*?);(.*?);(.*?);(.*?);' split_by: '(\S+).*?(load average:)\s+(.*?),\s+(.*?),\s+(.*?)\|load1=(.*?);(.*?);(.*?);(.*?);\s+load5=(.*?);(.*?);(.*?);(.*?);\s+load15=(.*?);(.*?);(.*?);(.*?);' custom_attributes: myCommand: ${var:myCommand} myFile: ${var:myfile}
I would also recommend you to look the following wiki document:
https://github.com/newrelic/nri-flex/wiki/Functions#store_variables
https://github.com/newrelic/nri-flex/wiki/Functions#lookup_file
https://github.com/newrelic/nri-flex/wiki/Functions#store_lookups
https://github.com/newrelic/nri-flex/wiki/Functions#add_attribute
- It does not capture exit code for Command at this moment, you can raise a feature request.
- It does capture http return code if you are using url. For example:
name: nginxFlex apis: - name: nginxStub url: http://127.0.0.1/nginx_status
from nri-flex.
Thanks, that was what I needed.
from nri-flex.
I am closing out this issue for now. Thanks!
from nri-flex.
Related Issues (20)
- linux-file-count.yml does not work as-is
- Review/create e2e tests to be able to upgrade go version HOT 1
- Upgrade Go version to > 1.15
- Flex IP Discovery on Kubernetes HOT 3
- Flex not working though API call works with Curl -k HOT 1
- Impossible to use the '%' character in a db query (MySQL)
- Running Flex Serverless - Azure Function App?
- Getting Parse errors in case if docker discovery doesn't finds any suitable containers
- Add support for Oracle DB HOT 1
- null value being converted to unicode HOT 8
- [Repolinter] Open Source Policy Issues HOT 1
- Extra middle whitespace in `name: nri-flex` throws an error HOT 3
- "lookups" function fails when looking up more than one value in same command HOT 1
- [Repolinter] Open Source Policy Issues HOT 1
- Sampling rate to New Relic does not go below 15s HOT 2
- [Repolinter] Open Source Policy Issues HOT 1
- Not possible to add user/pass as global to invoke PowerShell script with specific credentials HOT 3
- Swedish characters like Γ₯Àâ is not working in Flex via PowerShell HOT 3
- Recursively get data by using the 'nextCursor' attribute in Nerdgraph API HOT 2
- Dependency Dashboard HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nri-flex.