Advertisement
Zorge_R

zPingStat

Jul 15th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.28 KB | None | 0 0
  1. // PingStat.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <conio.h>
  6. #include <windows.h>
  7. #define NULL 0
  8. /*
  9.     zPingStat
  10.     zLab - 2011
  11.     cc-by-nc-sa
  12. */
  13.  
  14.  
  15.  
  16. int _tmain()
  17. {
  18.     int ALL,GOOD_ALL,BAD_ALL,SUMM_1000,GOOD_1000,BAD_1000,SUMM_100,GOOD_100,BAD_100,REDRAW,BAD_ALL_PERCENT,BAD_1000_PERCENT;
  19.     char ping_check;
  20. //  ALL
  21. ALL=0;
  22. GOOD_ALL=0;
  23. BAD_ALL=0;
  24.  
  25. //  1000
  26. SUMM_1000=0;
  27. GOOD_1000=0;
  28. BAD_1000=0;
  29.  
  30. //  100
  31. SUMM_100=0;
  32. GOOD_100=0;
  33. BAD_100=0;
  34.  
  35. //  ZERO
  36. BAD_ALL_PERCENT=0;
  37. BAD_1000_PERCENT=0;
  38.  
  39. //printTABLE:
  40.   printTABLE:
  41. system("cls");
  42. REDRAW=0;
  43.  
  44.     printf("################\n");
  45.     printf("#  zPingStat   #\n");
  46.     printf("#--------------#\n");
  47.     printf("#     ADIP     #\n");
  48.     printf("#  66.66.66.66 #\n");
  49.     printf("################\n");
  50.     printf("ALL       = %d\n",ALL);
  51.     printf("MISS      = %d percent\n",BAD_ALL_PERCENT);
  52.     printf("ALL GOOD  = %d\n",GOOD_ALL);
  53.     printf("ALL BAD   = %d\n",BAD_ALL);
  54.     printf("################\n");
  55.     printf("SUMM      = 1000\n");
  56.     printf("MISS      = %d percent\n",BAD_1000_PERCENT);
  57.     printf("COMPLETE  = %d\n",SUMM_1000);
  58.     printf("GOOD      = %d\n",GOOD_1000);
  59.     printf("BAD       = %d\n",BAD_1000);
  60.     printf("################\n");
  61.     printf("SUMM      = 100\n");
  62.     printf("COMPLETE  = %d\n",SUMM_100);
  63.     printf("GOOD      = %d\n",GOOD_100);
  64.     printf("BAD       = %d\n",BAD_100);
  65.     printf("################\n");
  66.  
  67. //  DRAW_1000
  68. if (SUMM_1000==1000)
  69.     {
  70.         GOOD_1000=0;
  71.         BAD_1000=0;
  72.         SUMM_1000=0;
  73.     }
  74.  
  75. //  DRAW_100
  76. if (SUMM_100==100)
  77.     {
  78.         GOOD_100=0;
  79.         BAD_100=0;
  80.         SUMM_100=0;
  81.     }
  82.  
  83. //REDRAWtable:
  84.   REDRAWtable:
  85. if (REDRAW==25)
  86. goto getPercentage;
  87.  
  88. //  doPing:
  89. ping_check=system("ping -w 100 -n 1 66.66.66.66 > nul");
  90.  
  91. //  Sleep
  92. Sleep(1000);
  93.  
  94. //  Counter
  95. ALL=++ALL;
  96. SUMM_1000=++SUMM_1000;
  97. SUMM_100=++SUMM_100;
  98. REDRAW=++REDRAW;
  99.  
  100. if (ping_check == NULL)
  101.     goto SEC;
  102. else
  103.     goto unSEC;
  104.  
  105. goto printTABLE;
  106.  
  107. //SEC:
  108.   SEC:
  109. GOOD_ALL=GOOD_ALL+1;
  110. GOOD_1000=GOOD_1000+1;
  111. GOOD_100=GOOD_100+1;
  112. goto REDRAWtable;
  113.  
  114. //unSEC:
  115.   unSEC:
  116. BAD_ALL=BAD_ALL+1;
  117. BAD_1000=BAD_1000+1;
  118. BAD_100=BAD_100+1;
  119. goto REDRAWtable;
  120.  
  121. //getPercentage:
  122.   getPercentage:
  123. BAD_ALL_PERCENT=BAD_ALL*100/ALL;
  124. BAD_1000_PERCENT=BAD_1000*100/SUMM_1000;
  125. goto printTABLE;
  126.  
  127.     _getch(); // задержка, пауза
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement