Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when collectd_cuda.sh is called via a symbolic link $SCRIPTDIR isn't set correctly and config file won't be found #3

Open
konzty opened this issue Nov 5, 2021 · 1 comment

Comments

@konzty
Copy link

konzty commented Nov 5, 2021

Hi,

I tried to monitor my GPU today with your script and everything works fine when I call "~/git/collectd-cuda/collectd_cuda.sh". Usually I create links to binaries or scripts in my ~/bin directory. When I call "~/bin/collectd_cuda.sh" your script exits silently with return code 1.

konstantin@majestix:~$ ~/git/collectd-cuda/collectd_cuda.sh 
PUTVAL majestix/cuda-00000000:06:00.0/cpufreq-clocks_current_sm interval=10 N:300
PUTVAL majestix/cuda-00000000:06:00.0/memory-memory_used interval=10 N:593
PUTVAL majestix/cuda-00000000:06:00.0/power-power_limit interval=10 N:125.00
PUTVAL majestix/cuda-00000000:06:00.0/temperature-temperature_memory interval=10 N:N/A
PUTVAL majestix/cuda-00000000:06:00.0/cpufreq-clocks_current_video interval=10 N:540
PUTVAL majestix/cuda-00000000:06:00.0/memory-memory_free interval=10 N:5348
PUTVAL majestix/cuda-00000000:06:00.0/cpufreq-clocks_current_memory interval=10 N:405
PUTVAL majestix/cuda-00000000:06:00.0/absolute-pstate interval=10 N:8
PUTVAL majestix/cuda-00000000:06:00.0/cpufreq-clocks_current_graphics interval=10 N:300
PUTVAL majestix/cuda-00000000:06:00.0/memory-memory_total interval=10 N:5941
PUTVAL majestix/cuda-00000000:06:00.0/percent-utilization_gpu interval=10 N:2
PUTVAL majestix/cuda-00000000:06:00.0/percent-utilization_memory interval=10 N:3
PUTVAL majestix/cuda-00000000:06:00.0/temperature-temperature_gpu interval=10 N:40
PUTVAL majestix/cuda-00000000:06:00.0/percent-fan_speed interval=10 N:29
PUTVAL majestix/cuda-00000000:06:00.0/power-power_draw interval=10 N:9.48
konstantin@majestix:~$ ln -s ~/git/collectd-cuda/collectd_cuda.sh ~/bin/collectd_cuda.sh
konstantin@majestix:~$ ~/bin/collectd_cuda.sh 
konstantin@majestix:~$ echo $?
1
konstantin@majestix:~$ 

I've added a few diagnostic echos to your script and discovered that setting $SCRIPTDIR is not reliable if the script is called via symbolic link, the variable contains the directory of the link, not the target:

konstantin@majestix:~$ ~/git/collectd-cuda/collectd_cuda.sh 
HOSTNAME = majestix
INTERVAL = 10
SCRIPTDIR = /home/konstantin/git/collectd-cuda
PUTVAL majestix/cuda-00000000:06:00.0/cpufreq-clocks_current_sm interval=10 N:300
PUTVAL majestix/cuda-00000000:06:00.0/memory-memory_used interval=10 N:615
PUTVAL majestix/cuda-00000000:06:00.0/power-power_limit interval=10 N:125.00
PUTVAL majestix/cuda-00000000:06:00.0/temperature-temperature_memory interval=10 N:N/A
PUTVAL majestix/cuda-00000000:06:00.0/cpufreq-clocks_current_video interval=10 N:540
PUTVAL majestix/cuda-00000000:06:00.0/memory-memory_free interval=10 N:5326
PUTVAL majestix/cuda-00000000:06:00.0/cpufreq-clocks_current_memory interval=10 N:405
PUTVAL majestix/cuda-00000000:06:00.0/absolute-pstate interval=10 N:8
PUTVAL majestix/cuda-00000000:06:00.0/cpufreq-clocks_current_graphics interval=10 N:300
PUTVAL majestix/cuda-00000000:06:00.0/memory-memory_total interval=10 N:5941
PUTVAL majestix/cuda-00000000:06:00.0/percent-utilization_gpu interval=10 N:6
PUTVAL majestix/cuda-00000000:06:00.0/percent-utilization_memory interval=10 N:5
PUTVAL majestix/cuda-00000000:06:00.0/temperature-temperature_gpu interval=10 N:40
PUTVAL majestix/cuda-00000000:06:00.0/percent-fan_speed interval=10 N:29
PUTVAL majestix/cuda-00000000:06:00.0/power-power_draw interval=10 N:8.68
konstantin@majestix:~$ ln -s ~/git/collectd-cuda/collectd_cuda.sh ~/bin/collectd_cuda.sh
konstantin@majestix:~$ ~/bin/collectd_cuda.sh 
HOSTNAME = majestix
INTERVAL = 10
SCRIPTDIR = /home/konstantin/bin
config file not found in /home/konstantin/bin
konstantin@majestix:~$ 

As a workaround I'm now using the actual location of the script in my collectd.conf file.

Cheers

Konzty

@umlaeute
Copy link

i think it would be great if the location of the configuration could be:

  • configurable (-c /path/to/config_file)
  • fallback to some locations outside the scripts directory (e.g. /etc/default/collectd_cuda)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants