Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.7 KiB

  1. #include "..\main\mttf.h"
  2. VOID
  3. __cdecl
  4. main(
  5. int argc,
  6. char * argv[]
  7. )
  8. {
  9. HANDLE statFile;
  10. StatFileRecord statRec;
  11. DWORD numBytes;
  12. if (argc==1) {
  13. printf("Usage: mttfvwr <datafile> [/t]\n\n/t for terse (Excel text format)\n");
  14. return;
  15. }
  16. if (INVALID_HANDLE_VALUE==(statFile= CreateFile(argv[1],
  17. GENERIC_READ,
  18. FILE_SHARE_READ,
  19. NULL,
  20. OPEN_ALWAYS,
  21. FILE_ATTRIBUTE_NORMAL,
  22. NULL))) {
  23. printf("Unable to open %s: %ld\n", argv[1], GetLastError());
  24. return;
  25. }
  26. if (argc<3 || tolower(argv[2][1])!='t') {
  27. printf("Mean Time To Failure data for %s\n\n", argv[1]);
  28. printf("Build: minor version number for each set of stats.\n");
  29. printf("Busy: number of minutes with cpu usage greater than idle threshhold.\n");
  30. printf("Idle: number of minutes with cpu usage less than idle threshhold.\n");
  31. printf("Gone: minutes with cpu less than threshhold for 4 consecutive hrs.\n");
  32. printf("CpuUsage: average percentage of cpu usage for all machines on that build.\n");
  33. printf("Cold: number of cold boots due to a problem.\n");
  34. printf("Warm: number of warm boots due to a problem.\n");
  35. printf("Other: number of other problems.\n\n");
  36. printf(" Build Busy Idle Gone CpuUsg Cold Warm Other\n");
  37. printf(" ----- ---- ---- ---- ------ ---- ---- -----\n");
  38. } else {
  39. printf("Build\011Busy\011Idle\011Gone\011CpuUsg\011Cold\011Warm\011Other\n");
  40. }
  41. while (ReadFile(statFile, &statRec, sizeof(statRec), &numBytes, NULL)) {
  42. if (numBytes==0) {
  43. return;
  44. }
  45. if (argc==3 && tolower(argv[2][1])=='t') {
  46. printf("%ld\011%ld\011%ld\011%ld\011%ld\011%ld\011%ld\011%ld\n",
  47. statRec.Version>>16,
  48. statRec.Busy,
  49. statRec.Idle,
  50. statRec.IdleConsec,
  51. (statRec.Busy+statRec.Idle?statRec.PercentTotal/(statRec.Busy+statRec.Idle):0),
  52. statRec.Cold,
  53. statRec.Warm,
  54. statRec.Other);
  55. } else {
  56. printf("%6ld\t%6ld\t%6ld\t%6ld\t%6ld\t%6ld\t%6ld\t%6ld\n",
  57. statRec.Version>>16,
  58. statRec.Busy,
  59. statRec.Idle,
  60. statRec.IdleConsec,
  61. (statRec.Busy+statRec.Idle?statRec.PercentTotal/(statRec.Busy+statRec.Idle):0),
  62. statRec.Cold,
  63. statRec.Warm,
  64. statRec.Other);
  65. }
  66. }
  67. }