Script que mostra a temperatura do processador
Fiz esse script para mostrar de forma simples a temperatura do processador, baseando-me na saída do comando "sensors".
Descrição
Fiz esse script para mostrar de forma simples a temperatura do processador, baseando-me na saída do comando "sensors".
#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;34m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;33m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 61) { print "high: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;31m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
}
}
33[01;34m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;34m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;33m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 61) { print "high: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;31m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
}
}
33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;34m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;33m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 61) { print "high: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;31m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
}
}
33[01;33m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;34m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;33m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 61) { print "high: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;31m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
}
}
33[m"; }
elsif ($value > 61) { print "high: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;34m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;33m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 61) { print "high: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;31m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
}
}
33[01;31m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;34m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;33m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
elsif ($value > 61) { print "high: #!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[01;31m$temp#!/usr/bin/perl
# by ru4n :-)
@cmd = (`sensors`) or die "sensors not found!\n";
foreach my $temp (@cmd) {
if ($temp =~ /temp\d:/) {
$temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/;
my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/;
if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; }
elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; }
elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; }
}
}
33[m"; }
}
}
33[m"; }
}
}
Achei muito legal o script, fui testar e me retornou a seguinte saida:
normal:
#!/usr/bin/perl # by ru4n :-) @cmd = (`sensors`) or die "sensors not found!\n"; foreach my $temp (@cmd) { if ($temp =~ /temp\d:/) { $temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/; my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/; if ($value <= 30) { print "good:33[01;33m33[m[root@xxx ~]#!/usr/bin/perl # by ru4n :-) @cmd = (`sensors`) or die "sensors not found!\n"; foreach my $temp (@cmd) { if ($temp =~ /temp\d:/) { $temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/; my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/; if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; } elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; } elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; } } }33[01;34m$temp#!/usr/bin/perl # by ru4n :-) @cmd = (`sensors`) or die "sensors not found!\n"; foreach my $temp (@cmd) { if ($temp =~ /temp\d:/) { $temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/; my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/; if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; } elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; } elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; } } }33[m"; } elsif ($value > 31 && $value <= 60) { print "normal:#!/usr/bin/perl # by ru4n :-) @cmd = (`sensors`) or die "sensors not found!\n"; foreach my $temp (@cmd) { if ($temp =~ /temp\d:/) { $temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/; my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/; if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; } elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; } elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; } } }33[01;33m$temp#!/usr/bin/perl # by ru4n :-) @cmd = (`sensors`) or die "sensors not found!\n"; foreach my $temp (@cmd) { if ($temp =~ /temp\d:/) { $temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/; my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/; if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; } elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; } elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; } } }33[m"; } elsif ($value > 61) { print "high:#!/usr/bin/perl # by ru4n :-) @cmd = (`sensors`) or die "sensors not found!\n"; foreach my $temp (@cmd) { if ($temp =~ /temp\d:/) { $temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/; my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/; if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; } elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; } elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; } } }33[01;31m$temp#!/usr/bin/perl # by ru4n :-) @cmd = (`sensors`) or die "sensors not found!\n"; foreach my $temp (@cmd) { if ($temp =~ /temp\d:/) { $temp =~ s/temp\d:\s+ (\+\d+.*) \(.*\)/\1/; my $value = $temp; $value =~ s/^\+(\d+.\d+).*$/\1/; if ($value <= 30) { print "good: {FONTE}33[01;34m$temp{FONTE}33[m"; } elsif ($value > 31 && $value <= 60) { print "normal: {FONTE}33[01;33m$temp{FONTE}33[m"; } elsif ($value > 61) { print "high: {FONTE}33[01;31m$temp{FONTE}33[m"; } } }33[m"; } } }sendo que minha versão do perl é v5.12.3.
Revisei o código que colei no arquivo que gerei e aparentemente está certo.
O que será que estou fazendo errado?