PATH and LD_LIBRARY_PATH are not getting set to execute custom scripts from assets

I have a per script that I have bundled as an asset per the doc and uploaded to one of my internal repositories. However, when I execute the perl script as a part of the Check, it says

sh: 1 script not found

Per this Jef Practice: Preparing to use assets , I also printed the PATH and LD_LIBRARY_PATH and the asset path "/var/cache/sensu/sensu-agent//asset/bin/ on the agent is not present/getting appended to both of them.

Do these have to be manually set in the path for the respective assets ?

I also see this forum Script for setting path for plugin testing and I believe this is for testing and not for the actual flow.

The first things I would check are:

  1. Can you confirm that your asset is defined as a runtime_asset for the check?
  2. Can you test that the agent is able to download via the URL listed for the asset by logging onto the agent and running a curl or wget with the URL?
  3. Can you confirm that the agent is downloading the asset as defined? On an agent that has a subscription that includes your check there should be a directory in /var/cache/sensu/sensu-agent that matches the SHA-512 checksum of your asset.

Hi Todd - Thanks for your quick reply. I see the asset downloaded on the agent and SHA value does match the downloaded one too. I have also mentioned the same in the runtime_assets directive as well.
One quick question is, does the agent and the backend need to be run as sensu user ?

Typically the backend and agent run as the sensu user, yes. And therefore the /var/cache/sensu directory structure is owned by the sensu user.

Can you provide your check and asset definitions here (redact what information you may need to such as internal URLs). Please output them as yaml using sensuctl check info <check name> --format yaml and sensuctl asset info --format yaml`. And could you also post the top line (the #! one) from the script that is in the asset?

Hi Todd - I was able to figure out the problem. I bundled the asset wrongly

I did tar -zcvf asset.tar.gz <asset_folder> as opposed to tar -C <asset_folder> -zcvf asset.tar.gz .

Thanks again for your prompt response on this and really appreciated.

1 Like