Napsty / check_smart

Monitoring Plugin to check hard drives, solid state drives and NVMe drives using SMART
https://www.claudiokuenzler.com/monitoring-plugins/check_smart.php
GNU General Public License v3.0
67 stars 20 forks source link

Escape $ so the actual variable name is printed #79

Closed RincewindsHat closed 2 years ago

Napsty commented 2 years ago

Hi and thanks for the PR. However I do not see what you are trying to achieve? The device is already in the output:

$ ./check_smart.pl -d /dev/sda
must specify an interface for /dev/sda using -i/--interface!

check_smart.pl v6.12.1
[...]
RincewindsHat commented 2 years ago

Ah, I misunderstood the intention there, I tried it with -g

./check_smart.pl  -g /dev/sd[a-z]
Use of uninitialized value $opt_d in concatenation (.) or string at ./check_smart.pl line 104.
Napsty commented 2 years ago

Oh, I didn't test with -g, I see your point now!

Napsty commented 2 years ago

May I suggest an even simpler fix:

if ($opt_d || $opt_g ) {
        unless($opt_i){
                print "must specify an interface for $opt_d using -i/--interface!\n\n" if $opt_d;
                print "must specify an interface for $opt_g using -i/--interface!\n\n" if $opt_g;
                print_help();
                exit $ERRORS{'UNKNOWN'};
        }
RincewindsHat commented 2 years ago

Ha, learned a little bit of Perl today, thank you