Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. //---CPU---
  2. char bufferCPU[1024];
  3. unsigned int nbytesCPU;
  4. channel = ssh_channel_new(session);
  5. if (channel == NULL)
  6. {
  7. //cout << VPS[cThread].ip << VPS[cThread].user << VPS[cThread].pass << endl;
  8. free_channel(channel);
  9. free_session(session);
  10. q.push(VPS[cThread].nrThread);
  11. cout << "segf4\n";
  12. pthread_exit(NULL);
  13. return NULL;
  14. }
  15. rc = ssh_channel_open_session(channel);
  16. if (rc != SSH_OK)
  17. {
  18. //cout << VPS[cThread].ip << VPS[cThread].user << VPS[cThread].pass << endl;
  19. free_channel(channel);
  20. free_session(session);
  21. q.push(VPS[cThread].nrThread);
  22. cout << "segf5\n";
  23. return NULL;
  24. }
  25. rc = ssh_channel_request_exec(channel, "nproc");
  26. if (rc != SSH_OK) error(session);
  27.  
  28. nbytesCPU = ssh_channel_read(channel, bufferCPU, sizeof(bufferCPU), 0);
  29. free_channel(channel);
  30. //---------
  31. //---RAM---
  32. char bufferRAM[1024];
  33. unsigned int nbytesRAM;
  34. channel = ssh_channel_new(session);
  35. if (channel == NULL)
  36. {
  37. //cout << VPS[cThread].ip << VPS[cThread].user << VPS[cThread].pass << endl;
  38. free_channel(channel);
  39. free_session(session);
  40. q.push(VPS[cThread].nrThread);
  41. cout << "segf6\n";
  42. return NULL;
  43. }
  44. rc = ssh_channel_open_session(channel);
  45. if (rc != SSH_OK)
  46. {
  47. //cout << VPS[cThread].ip << VPS[cThread].user << VPS[cThread].pass << endl;
  48. free_channel(channel);
  49. free_session(session);
  50. q.push(VPS[cThread].nrThread);
  51. return NULL;
  52. }*/
  53. //rc = ssh_channel_request_exec(channel, "grep -m 1 'MemTotal' /proc/meminfo | cut -d: -f2 | sed -e 's/^ *//' | sed -e 's/$//'");
  54. if (rc != SSH_OK) error(session);
  55. nbytesRAM = ssh_channel_read(channel, bufferRAM, sizeof(bufferRAM), 0);
  56. free_channel(channel);
  57. //-------
  58. //---uname -a------
  59. char bufferUNAME[1024];
  60. unsigned int nbytesUNAME;
  61. channel = ssh_channel_new(session);
  62. if (channel == NULL)
  63. {
  64. //cout << VPS[cThread].ip << VPS[cThread].user << VPS[cThread].pass << endl;
  65. free_channel(channel);
  66. free_session(session);
  67. q.push(VPS[cThread].nrThread);
  68. return NULL;
  69. }
  70. rc = ssh_channel_open_session(channel);
  71. if (rc != SSH_OK)
  72. {
  73. //cout << VPS[cThread].ip << VPS[cThread].user << VPS[cThread].pass << endl;
  74. free_channel(channel);
  75. free_session(session);
  76. q.push(VPS[cThread].nrThread);
  77. return NULL;
  78. }
  79. rc = ssh_channel_request_exec(channel, "uname -a");
  80. if (rc != SSH_OK) error(session);
  81. nbytesUNAME = ssh_channel_read(channel, bufferUNAME, sizeof(bufferUNAME), 0);
  82. free_channel(channel);
  83. //-----------------
  84. free_session(session);
  85. cout << red << "-->Rut Hatzos: " << VPS[cThread].ip << "@" << VPS[cThread].user << ":" << VPS[cThread].pass << " port:" << VPS[cThread].port << endl;
  86. cout << "Uname: ";
  87. fwrite(bufferUNAME, 1, nbytesUNAME, stdout);
  88. cout << "Number of CPU: ";
  89. fwrite(bufferCPU, 1, nbytesCPU, stdout);
  90. cout << "RAM: ";
  91. fwrite(bufferRAM, 1, nbytesRAM, stdout);
  92. cout << yellow;
  93. gasite_fout << "-->Rut Hatzos: " << VPS[cThread].ip << "@" << VPS[cThread].user << ":" << VPS[cThread].pass << " port:" << VPS[cThread].port << " ";
  94. gasite_fout << bufferUNAME;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement