storj_telegraf_mon icon indicating copy to clipboard operation
storj_telegraf_mon copied to clipboard

./tokens.sh not working with telegraf [UnRAID users]

Open dalekseevs opened this issue 5 years ago • 10 comments

Hi :)

I am having an issue with tokenes.sh.

When I run: telegraf --debug --config /etc/telegraf/telegraf.conf --input-filter exec --test I get: D! [inputs.exec] Error in plugin: metric parse error: expected tag at 1:7: "Error, Etherscan API returned: "

However when I run ./tokens.sh through terminal I get the correct response: e.g. StorJToken,stat=tokens,WalletAddress="0xXXXXXXXXXXXXXXXXXXXXXXXXX" BalanceSTORJ=10,BalanceUSD=1,BalanceEUR=1 1 StorJToken,stat=prices STORJPriceUSD=0.1221,STORJPriceEUR=0.1109 1

Also if I just run the query in browser I get the correct response with 'OK'

The other two plugins work as expected.

Am I missing something very obvious?

Thanks in advance guys, and thanks for doing this awesome work!

dalekseevs avatar Nov 26 '19 09:11 dalekseevs

It seems that your token.sh is not edited. (if output really says: WalletAddress="0xXXXXXXXXXXXXXXXXXXXXXXXXX" )

Please follow the README of this repo:

In order to track your wallet balance, please create an Eterscan account and API token. Edit tokens.sh with your wallet address and your Etherscan API token.

JeromeGillard avatar Nov 26 '19 10:11 JeromeGillard

I did edit it :) I just edited out my address here. As I mentioned the API string works fine in browser and the output from the tokens.sh that is triggered from terminal is as expected.

dalekseevs avatar Nov 26 '19 10:11 dalekseevs

Could you try to run it within the Telegraf container? Refer to the volume argument when running Telegraf -v "$PWD/scripts:/scripts". The script should be then located at /scripts/token.sh within the container. With standard config you should be able to:

jgi@K3:~/docker_apps/telegraf$ docker exec -i -t telegraf /bin/bash
root@K3:/# /scripts/tokens.sh
StorJToken,stat=tokens,WalletAddress="0xD71dE91105667aD9862eaddfb65CE9df3e7593a2" BalanceSTORJ=241.202,BalanceUSD=29.8608,BalanceEUR=27.1352 1574764557041666505
StorJToken,stat=prices STORJPriceUSD=0.1238,STORJPriceEUR=0.1125 1574764557042857451

The script uses curl. Could you see if this works within your Telegraf container:

curl -s 'https://api.etherscan.io/'

This should return the HTML code of their home page.

Another thing to double check: the output should come into two lines, beginning by StorJToken.

JeromeGillard avatar Nov 26 '19 11:11 JeromeGillard

Yep, its a curl issue... I don't have curl in my container. I am running under UnRaid, and docker compose is not so straightforward under this system, although I think I will try it out. Thank you for the prompt response:) I can remove the tokens.sh plugin from telegraf.conf and still run it, correct?

dalekseevs avatar Nov 26 '19 11:11 dalekseevs

Sure, you can comment out the whole [[input.exec]] block dedicated to tokens in the telegraf.conf file. The dashboard will lack data but ill be still working.

JeromeGillard avatar Nov 26 '19 12:11 JeromeGillard

Could your give a try to this fix? https://raw.githubusercontent.com/JeromeGillard/storj_telegraf_mon/avoid_curl/tokens.sh I've found a StackOverflow topic that talks about a way of doing curl, without curl...

(Do not forget to overwrite your wallet address and API key, or put them in a seperate tokens.sh.secrets)

JeromeGillard avatar Nov 26 '19 12:11 JeromeGillard

Oh cool, will try it out!

dalekseevs avatar Nov 29 '19 16:11 dalekseevs

Still cannot get it to run, still the curl error.

grep: unrecognized option: P
BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.

Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...

Search for PATTERN in FILEs (or stdin)

        -H      Add 'filename:' prefix
        -h      Do not add 'filename:' prefix
        -n      Add 'line_no:' prefix
        -l      Show only names of files that match
        -L      Show only names of files that don't match
        -c      Show only count of matching lines
        -o      Show only the matching part of line
        -q      Quiet. Return 0 if PATTERN is found, 1 otherwise
        -v      Select non-matching lines
        -s      Suppress open and read errors
        -r      Recurse
        -i      Ignore case
        -w      Match whole words only
        -x      Match whole lines only
        -F      PATTERN is a literal (not regexp)
        -E      PATTERN is an extended regexp
        -m N    Match up to N times per file
        -A N    Print N lines of trailing context
        -B N    Print N lines of leading context
        -C N    Same as '-A N -B N'
        -e PTRN Pattern to match
        -f FILE Read pattern from file
/scripts/tokens.sh: line 56: curl: command not found
Error, Cryptocompare API returned: 

dalekseevs avatar Jan 21 '20 12:01 dalekseevs

You'll have to find a way to get CURL to work on the unraid host (busybox). An alternative would be to get the docker-compose.yml working, so you can use telegraf within another container on your UnRAID. This setup is close on the github, but it's not quite ready for prime time yet.

gsxryan avatar Jan 28 '20 02:01 gsxryan

In unraid, change the repository from telegraf:alpine to telegraf:latest. Fixed the issues I was having.

0x1CED avatar Apr 25 '20 22:04 0x1CED