mirror of
https://github.com/bvanroll/_dotfiles.git
synced 2025-08-29 20:12:42 +00:00
init
This commit is contained in:
33
.config/i3blocks/gpu-load/README.md
Normal file
33
.config/i3blocks/gpu-load/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# gpu-load
|
||||
|
||||
Shows load of Nvidia or AMD GPUs.
|
||||
|
||||

|
||||
|
||||
The four values are the load of the:
|
||||
|
||||
1. The GPU it self
|
||||
2. The load of the VRAM of the Card
|
||||
3. Video buffer (NVIDIA only)
|
||||
4. PCIe bus utilization (NVIDIA only)
|
||||
|
||||
`short_text` only shows the GPU load.
|
||||
|
||||
# Dependencies
|
||||
|
||||
Choose one depends on your GPU.
|
||||
|
||||
* `nvidia-settings` Note that on Debian-based systems, you have to add `contrib` and `non-free` to your `sources.list` in order to install the package via your package manager.
|
||||
* [`radeontop`](https://github.com/clbr/radeontop)
|
||||
|
||||
# Config
|
||||
```
|
||||
[gpu-load]
|
||||
command=$SCRIPT_DIR/gpu-load
|
||||
label=GPU
|
||||
interval=10
|
||||
#min_width=GPU 100% 100% 100% 100%
|
||||
#GPU_BRAND=NVIDIA // or AMD
|
||||
#T_WARN=70
|
||||
#T_CRIT=90
|
||||
```
|
87
.config/i3blocks/gpu-load/gpu-load
Executable file
87
.config/i3blocks/gpu-load/gpu-load
Executable file
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use Getopt::Long;
|
||||
|
||||
# default values
|
||||
my $t_warn = $ENV{T_WARN} || 70;
|
||||
my $t_crit = $ENV{T_CRIT} || 90;
|
||||
my $gpu_brand = $ENV{GPU_BRAND} || "NVIDIA";
|
||||
my $gpu_usage = -1;
|
||||
my $gpu_mem = -1;
|
||||
my $gpu_video = -1;
|
||||
my $gpu_pcie = -1;
|
||||
|
||||
my $full_text = "";
|
||||
|
||||
sub help {
|
||||
print "Usage: gpu-load [-w <warning>] [-c <critical>]\n";
|
||||
print "-w <percent>: warning threshold to become amber\n";
|
||||
print "-c <percent>: critical threshold to become red\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
GetOptions("help|h" => \&help,
|
||||
"w=i" => \$t_warn,
|
||||
"c=i" => \$t_crit);
|
||||
|
||||
# Get GPU usage from nvidia-settings
|
||||
if ($gpu_brand eq "NVIDIA") {
|
||||
open (NVS, 'nvidia-settings -q GPUUtilization -t |') or die;
|
||||
while (<NVS>) {
|
||||
if (/^[a-zA-Z]*=(\d+), [a-zA-Z]*=(\d+), [a-zA-Z]*=(\d+), [a-zA-Z]*=(\d+)$/) {
|
||||
$gpu_usage = $1;
|
||||
$gpu_mem = $2;
|
||||
$gpu_video = $3;
|
||||
$gpu_pcie = $4;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close(NVS);
|
||||
$full_text = sprintf "%.0f%% %.0f%% %.0f%% %.0f%%\n", $gpu_usage, $gpu_mem, $gpu_video, $gpu_pcie;
|
||||
}
|
||||
|
||||
# For AMD, get from radeontop
|
||||
elsif ($gpu_brand eq "AMD") {
|
||||
open (AMD, 'radeontop -d - -l 1 |') or die;
|
||||
while (<AMD>) {
|
||||
if (/^.*[gpu] (\d+)\.\d+%.*.*[vram] (\d+)\.\d+%.*$/) {
|
||||
$gpu_usage = $1;
|
||||
$gpu_mem = $2;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close(AMD);
|
||||
$full_text = sprintf "%.0f%% %.0f%%\n", $gpu_usage, $gpu_mem;
|
||||
}
|
||||
|
||||
$gpu_usage eq -1 and die 'Can\'t find GPU information';
|
||||
|
||||
# Print full_text, short_text
|
||||
print $full_text;
|
||||
printf "%.0f%%\n", $gpu_usage;
|
||||
|
||||
# Print color, if needed
|
||||
if ($gpu_usage >= $t_crit || $gpu_mem >= $t_crit || $gpu_video >= $t_crit || $gpu_pcie >= $t_crit) {
|
||||
print "#FF0000\n";
|
||||
exit 33;
|
||||
} elsif ($gpu_usage >= $t_warn || $gpu_mem >= $t_warn || $gpu_video >= $t_warn || $gpu_pcie >= $t_warn) {
|
||||
print "#FFBF00\n";
|
||||
}
|
||||
|
||||
exit 0;
|
BIN
.config/i3blocks/gpu-load/gpu-load.png
Normal file
BIN
.config/i3blocks/gpu-load/gpu-load.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Reference in New Issue
Block a user