plambe / zabbix-nvidia-smi-multi-gpu

A zabbix template using nvidia-smi. Works with multiple GPUs on Windows and Linux.
Other
99 stars 54 forks source link

Perl one-liner instead of get_gpus_info.sh #2

Closed naoh16 closed 6 years ago

naoh16 commented 6 years ago

Hi, this is great work, and I hope we can use this easier. In my environment, I can replace the get_gpus_info.sh script into the one-liners with perl as following:

nvidia-smi -L | perl -le 'while(<>){push @a,qq|{"{#GPUINDEX}":"$1", "{#GPUUUID}":"$2"}| if(/GPU (
\d+).*UUID\: (.*)\)$/);} print qq|{"data":[\n| . join(",\n", @a) . qq|\n]}|;'

So, we can replace the UserParameter:

UserParameter=gpu.discovery,nvidia-smi -L | perl -le 'while(<>){push @a,qq|{"{#GPUINDEX}":"$1", "{#GPUUUID}":"$2"}| if(/GPU (
\d+).*UUID\: (.*)\)$/);} print qq|{"data":[\n| . join(",\n", @a) . qq|\n]}|;'

Note that, we need setting of PATH environment for nvidia-smi and perl commands.

plambe commented 6 years ago

Hi,

My first thought is that I don't want any more dependencies, such as perl, however, I'll think about adding this to the main branch, or at least as an alternative in the readme file.

Thanks for sharing!

naoh16 commented 6 years ago

Hi,

I agree to your reply. I think my script should not be added main branch. It's too much for me to your consideration.

Thanks.