<commit_before>#!/usr/bin/perl
use strict;
package Resmon::Module::BSD_CHECK_TEMP;
use Resmon::Module;
use Resmon::ExtComm qw/cache_command/;
use vars qw/@ISA/;
@ISA = qw/Resmon::Module/;
my $DEBUG=1;


sub handler {
  my $arg = shift; 
  my ($sensor,$chip)=split('@', $arg->{'object'});
  print STDERR "sensor=$sensor; chip=$chip\n" if $DEBUG;
  $sensor =~s/\+/ /g;
  my $warning = $arg->{'warning'};
  my $critical = $arg->{'critical'};
  $warning = $critical if not $warning;
  my $output = cache_command("sysctl -n hw.sensors.$chip.$sensor", 30);
  print STDERR $output if $DEBUG;
  my $temp;
  my $units;
  $output =~ m/(-?\d+\.?\d*)\s+(\w+)/;
  ($temp, $units) = ($1, $2);

  return "OK", {
    message => "$temp $units $sensor\@$chip",
    temp => [$temp, "i"],
  } if ($temp && ($temp < $warning));

  return "WARNING", {
    message => "$temp $units $sensor\@$chip",
    temp => [$temp, "i"],
  } if ($temp && ($temp < $critical));

  return "BAD", {
    message => "$temp $units $sensor@$chip",
    temp => [$temp, "i"],
  };
};
1;
  <commit_msg>Fix error when the check goes bad<commit_after>#!/usr/bin/perl
use strict;
package Resmon::Module::BSD_CHECK_TEMP;
use Resmon::Module;
use Resmon::ExtComm qw/cache_command/;
use vars qw/@ISA/;
@ISA = qw/Resmon::Module/;
my $DEBUG=0;


sub handler {
  my $arg = shift; 
  my ($sensor,$chip)=split('@', $arg->{'object'});
  print STDERR "sensor=$sensor; chip=$chip\n" if $DEBUG;
  $sensor =~s/\+/ /g;
  my $warning = $arg->{'warning'};
  my $critical = $arg->{'critical'};
  $warning = $critical if not $warning;
  my $output = cache_command("sysctl -n hw.sensors.$chip.$sensor", 30);
  print STDERR $output if $DEBUG;
  my $temp;
  my $units;
  $output =~ m/(-?\d+\.?\d*)\s+(\w+)/;
  ($temp, $units) = ($1, $2);

  return "OK", {
    message => "$temp $units $sensor\@$chip",
    temp => [$temp, "i"],
  } if ($temp && ($temp < $warning));

  return "WARNING", {
    message => "$temp $units $sensor\@$chip",
    temp => [$temp, "i"],
  } if ($temp && ($temp < $critical));

  return "BAD", {
    message => "$temp $units $sensor\@$chip",
    temp => [$temp, "i"],
  };
};
1;
  
{'fraction_non_alphanumeric': 0.24425691514299108, 'fraction_numerical': 0.005625879043600563, 'mean_word_length': 3.5598290598290596, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '505669', 'n_tokens_mistral': 864, 'n_tokens_neox': 812, 'n_words': 210}