Command works in bash but not in nri-flex

I am executing below command from nri flex integration , It fails

Command : find /opt/test/ -type d -print0 | while read -d ‘’ -r dir; do files=("$dir"/*); printf “%5d: %s\n” “${#files[@]}” “$dir” ;done;

The same works fine in command line .

./nri-flex -verbose -pretty -config_path /etc/newrelic-infra/integrations.d/file-count-fusion.yml

DEBU[0000] Function.isAvailable: enter
DEBU[0000] Function.isAvailable: exit status: false
INFO[0000] com.newrelic.nri-flex GOARCH=amd64 GOOS=linux version=1.4.3
DEBU[0000] config: git sync configuration not set
WARN[0000] config: testing agent config, agent features will not be available
DEBU[0000] config: running async name=linuxFileCountFusion
DEBU[0000] config: processing apis apis=1 name=linuxFileCountFusion
DEBU[0000] fetch: collect data name=linuxFileCountFusion
DEBU[0000] commands: executing count=1 name=linuxFileCountFusion
DEBU[0000] command: running find /opt/test -type d -print0 | while read -d ‘’ -r dir; do files=("$dir"/*);printf “%5d :%s\n” “${#files[@]}” “$dir”; done
DEBU[0000] processor-data: running data handler name=linuxFileCountFusion
DEBU[0000] config: finished variable processing apis apis=1 name=linuxFileCountFusion
INFO[0000] flex: completed processing configs configs=1
{
“name”: “com.newrelic.nri-flex”,
“protocol_version”: “3”,
“integration_version”: “1.4.3”,
“data”: [
{
“metrics”: [
{
“Location”: “/opt/test”,
“event_type”: “TotalFileCountFusionConsSample”,
“fileCount”: " 3 ",
“integration_name”: “com.newrelic.nri-flex”,
“integration_version”: “1.4.3”
},

Error in Query Builder
ERROR EXEC
find /opt/test -type d -print0 | while read -d ‘’ -r dir; do files=("$dir"/*);printf “%5d :%s\n” "${

ERROR MSG
/bin/sh: -c: line 0: unexpected EOF while looking for matching `}’ /bin/sh: -c: line 1: syntax error: unexpected end of file

Can someone please help me with this ?

1 Like

Hello @RLobo

Thank you for posting your query here.

Starting with, Is there any environment variable you are using in the SCRIPT , If yes can you please mention all the variables in the newrelic-infra .yml. Document.

Also can you please update the agent, In case its not updated?

Please do not hesitate to contact me in case of any additional queries or issues. I will be happy to help you.Looking forward to hearing back from you

Best Regards
Yashaswi verma

2 Likes

@RLobo
On top of checking the Variables as mentioned above. You can also add time to the ./nri-flex command to check if the timeout value in the config file needs to be increased:

time ./nri-flex -verbose -pretty -config_path /etc/newrelic-infra/integrations.d/file-count-fusion.yml

Hope this helps!

2 Likes