Exemplo n.º 1
0
void get_hwstats(void)
{
  getTemp(&hw.temp1, &hw.temp2, &hw.temp3);
  //printf("Temp.= %4.1f, %4.1f, %4.1f;",hw.temp1, hw.temp2, hw.temp3);
  getFanSp(&hw.rot1, &hw.rot2, &hw.rot3);
  //printf(" Rot.= %4d, %4d, %4d\n", hw.rot1, hw.rot2, hw.rot3);
  getVolt(&hw.vc0, &hw.vc1, &hw.v33, &hw.v50p, &hw.v50n, &hw.v12p, &hw.v12n);
  //printf(" Vcore = %4.2f, %4.2f; Volt. = %4.2f, %4.2f, %5.2f, %6.2f, %5.2f\n", 
  //       hw.vc0, hw.vc1, hw.v33, hw.v50p, hw.v12p, hw.v12n, hw.v50n);
}
Exemplo n.º 2
0
void
ReadCurrentValues(void) {
  double temp1 = 0.0, temp2 = 0.0, temp3 = 0.0;
  double vc0, vc1, v33, v50p, v12p, v12n, v50n;
  int rot1, rot2, rot3;
  int n;
  char message[128];
  char command[CMD_BUFsz+1];

  /* Temperature */
  getTemp(&temp1, &temp2, &temp3);
  if (debug) {
    if (tabout) {
      printf("%4.1f\t%4.1f\t%4.1f\t", temp1, temp2, temp3);
    } else {
      printf("Temp.= %4.1f, %4.1f, %4.1f;", temp1, temp2, temp3);
    }
  }
  new_value[0] = (int)(temp1 * 65536.0);
  new_value[1] = (int)(temp2 * 65536.0);
  new_value[2] = (int)(temp3 * 65536.0);

  /* Fan Speeds */
  getFanSp(&rot1, &rot2, &rot3);
  if (debug) {
    if (tabout) {
      printf("%4d\t%4d\t%4d\t", rot1, rot2, rot3);
    } else {
      printf(" Rot.= %4d, %4d, %4d\n", rot1, rot2, rot3);
    }
  }
  new_value[3] = rot1 * 65536;
  new_value[4] = rot2 * 65536;
  new_value[5] = rot3 * 65536;

  /* Voltages */
  getVolt(&vc0, &vc1, &v33, &v50p, &v50n, &v12p, &v12n);
  if (debug) {
    if (tabout) {
      printf("%4.2f\t%4.2f\t%4.2f\t%4.2f\t%5.2f\t%6.2f\t%5.2f\n", vc0, vc1, v33, v50p, v12p, v12n, v50n);
    } else {
      printf(" Vcore = %4.2f, %4.2f; Volt. = %4.2f, %4.2f, %5.2f, %6.2f, %5.2f\n", vc0, vc1, v33, v50p, v12p, v12n, v50n);
    }
  }
  new_value[6] = (int)(vc0 * 65536.0);
  new_value[7] = (int)(vc1 * 65536.0);
  new_value[8] = (int)(v33 * 65536.0);
  new_value[9] = (int)(v50p * 65536.0);
  new_value[10] = (int)(v12p * 65536.0);
  new_value[11] = (int)(v12n * 65536.0);
  new_value[12] = (int)(v50n * 65536.0);

  if (debug != 0) {
    /* If in debug mode, don't bounds check */
    return;
  }

  for (n=0; n<MAX_TYPES; n++) {
    if (active[n]) {
      if ((min_val[n] <= new_value[n]) && (new_value[n] <= max_val[n])) {
	fail_count[n] = 0;
	fail_sent[n] = 0;
	warn_sent[n] = 0;
      } else {
	sprintf(message, "A value of %.2f for %s with a range of (%.2f <= n <= %.2f)\n", (double)new_value[n]/65536.0, label[n], (double)min_val[n]/65536.0, (double)max_val[n]/65536.0);
	fail_count[n]++;
	if ((fail_count[n] >= fail_level[n]) && (fail_sent[n] == 0)) {
	  fail_sent[n] = 1;
          if (!quiet) {
            syslog(hdCRITICAL, "%s", message);
          }
	  if ((0 <= n) && (n <= 2)) {
	    if ((strlen(temp_fail) > 0) && (doFail[n])) {
	      snprintf(command, CMD_BUFsz, temp_fail, message);
	      system(command);
	    }
	  }
	  else if ((3 <= n) && (n <= 5)) {
	    if ((strlen(fan_fail) > 0) && (doFail[n])) {
	      snprintf(command, CMD_BUFsz, fan_fail, message);
	      system(command);
	    }
	  }
	  else if ((6 <= n) && (n <= 12)) {
	    if ((strlen(volt_fail) > 0) && (doFail[n])) {
	      snprintf(command, CMD_BUFsz, volt_fail, message);
	      system(command);
	    }
	  }
	}
	else if ((fail_count[n] >= warn_level[n]) && (warn_sent[n] == 0)) {
	  warn_sent[n] = 1;
          if (!quiet) {
            syslog(hdWARNING, "%s", message);
          }
	  if ((0 <= n) && (n <= 2)) {
	    if ((strlen(temp_warn) > 0) && (doWarn[n])) {
	      snprintf(command, CMD_BUFsz, temp_warn, message);
	      system(command);
	    }
	  }
	  else if ((3 <= n) && (n <= 5)) {
	    if ((strlen(fan_warn) > 0) && (doWarn[n])) {
	      snprintf(command, CMD_BUFsz, fan_warn, message);
	      system(command);
	    }
	  }
	  else if ((6 <= n) && (n <= 12)) {
	    if ((strlen(volt_warn) > 0) && (doWarn[n])) {
	      snprintf(command, CMD_BUFsz, volt_warn, message);
	      system(command);
	    }
	  }
	}
      }
    }
  }
}