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.

522 lines
19 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
2 years ago
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "serverMySQL_dataBinder.h"
  2. #define LOG( X ) m_pLog->Log( "MDBC", this, X )
  3. #ifdef DEBUG
  4. #define LOG_ERROR( X ) {\
  5. char _tBfrErrMSG2w34[256];\
  6. sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
  7. m_pLog->Log( "MDBC", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
  8. }
  9. #else
  10. #define LOG_ERROR( X ) m_pLog->Log( "MDBC", this, _LOG_ERROR, X );
  11. #endif
  12. servaMySQLDBC *servaMySQLDBC::_instance = NULL;
  13. /**
  14. * Returns the single instance of the object.
  15. */
  16. servaMySQLDBC* servaMySQLDBC::getInstance( config_setting_t * Settings ) {
  17. // check if the instance has been created yet
  18. if( 0 == _instance ){
  19. // if not, then create it
  20. _instance = new servaMySQLDBC( Settings );
  21. };
  22. // return the single instance
  23. return _instance;
  24. };
  25. servaMySQLDBC::servaMySQLDBC( config_setting_t * Settings ):serverDataBinder(){
  26. m_pLog = basicLogCollection::getInstance();
  27. m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "DBC" );
  28. m_bIsConnected = false;
  29. m_pDatabase = NULL;
  30. };
  31. servaMySQLDBC::~servaMySQLDBC(){
  32. m_bIsConnected = false;
  33. if( m_pDatabase != NULL ) delete( m_pDatabase );
  34. m_pDatabase = NULL;
  35. _instance = NULL;
  36. };
  37. uint64_t servaMySQLDBC::addMediaQueueRecord( CSTR uuid, CSTR tMD5, uint64_t src, uint32_t ts, uint16_t tsms, uint16_t width, uint16_t height, CSTR fmt ){
  38. uint64_t RetVal = 0;
  39. if(m_bIsConnected){
  40. char tQBuf[4096];
  41. LOG("Before");
  42. sprintf( tQBuf, "INSERT INTO `report_videos` SET `mojo_id`=%" PRIu64 ", `md5`='%s', `ts`=%d, `ts_ms`=%d, `recoded`=0", src, tMD5, ts, tsms );
  43. //sprintf( tQBuf, "Yenana");
  44. //#ifdef DEBUG
  45. LOG(tQBuf);
  46. //#endif
  47. uint64_t ref_id = m_pDatabase->QueryID( tQBuf );
  48. if ( ref_id ) {
  49. sprintf( tQBuf, "INSERT INTO `media_queue` SET `ts`=UNIX_TIMESTAMP(now()), `uuid`='%s', `reg_id`=%" PRIu64 ", `src`=%" PRIu64 ", `width`=%d, `height`=%d, `fmt`='%s', `status`=0, `process`=0",
  50. uuid, ref_id, src, width, height, fmt
  51. );
  52. //#ifdef DEBUG
  53. LOG(tQBuf);
  54. //#endif
  55. RetVal = m_pDatabase->QueryID( tQBuf );
  56. };
  57. };
  58. return RetVal;
  59. };
  60. bool servaMySQLDBC::connect( void ){
  61. config_setting_t * tSetting;
  62. m_bIsConnected = false;
  63. if( m_pSettings!= NULL ) {
  64. tSetting = config_setting_get_member( m_pSettings, "DATABASE_HOST" );
  65. if( tSetting == NULL ){
  66. tSetting = config_setting_add(m_pSettings, "DATABASE_HOST", CONFIG_TYPE_STRING );
  67. config_setting_set_string( tSetting, "localhost" );
  68. basicSettingsProvider::getInstance()->compromise();
  69. LOG("No DB Host Setting! Using default!");
  70. };
  71. sprintf(m_pDbHost, "%s", config_setting_get_string(tSetting));
  72. tSetting = config_setting_get_member(m_pSettings, "DATABASE_NAME");
  73. if( tSetting == NULL ){
  74. tSetting = config_setting_add(m_pSettings, "DATABASE_NAME", CONFIG_TYPE_STRING );
  75. config_setting_set_string( tSetting, "dfsl_gunter" );
  76. basicSettingsProvider::getInstance()->compromise();
  77. LOG("No DB Database Setting! Using default!");
  78. };
  79. sprintf(m_pDbDatabase, "%s", config_setting_get_string(tSetting));
  80. tSetting = config_setting_get_member( m_pSettings, "DATABASE_USER" );
  81. if( tSetting == NULL ){
  82. tSetting = config_setting_add(m_pSettings, "DATABASE_USER", CONFIG_TYPE_STRING );
  83. config_setting_set_string( tSetting, "dbroot" );
  84. basicSettingsProvider::getInstance()->compromise();
  85. LOG("No DB User Setting! Using default!");
  86. };
  87. sprintf(m_pDbUsername, "%s", config_setting_get_string(tSetting));
  88. tSetting = config_setting_get_member( m_pSettings, "DATABASE_PASSWORD" );
  89. if( tSetting == NULL ){
  90. tSetting = config_setting_add(m_pSettings, "DATABASE_PASSWORD", CONFIG_TYPE_STRING );
  91. config_setting_set_string( tSetting, "123567" );
  92. basicSettingsProvider::getInstance()->compromise();
  93. LOG("No DB Password Setting! Using default!");
  94. };
  95. sprintf(m_pDbPassword, "%s", config_setting_get_string(tSetting));
  96. basicSettingsProvider::getInstance()->validate();
  97. m_pDatabase = new MySQL_Connector();
  98. if( m_pDatabase == NULL )return false;
  99. m_bIsConnected = m_pDatabase->Connect( m_pDbDatabase, m_pDbHost, m_pDbUsername, m_pDbPassword );
  100. } else {
  101. LOG_ERROR("No Settings Provided!");
  102. };
  103. return m_bIsConnected;
  104. };
  105. char servaMySQLDBC::getMojoWM( uint64_t id ){
  106. char RetVal = 'N';
  107. if( m_bIsConnected ){
  108. char tQBuf[MAX_PATH_LEN];
  109. AAssoc *result;
  110. sprintf( tQBuf, "SELECT `status` FROM `module_nodes` WHERE `id`=%" PRIu64 "", id );
  111. result = m_pDatabase->Query( tQBuf );
  112. if( result!= NULL ) {
  113. if( result->size() > 0 ) {
  114. Assoc *cArr;
  115. Assoc::iterator it;
  116. cArr = result->at(0);
  117. it = cArr->find("status");
  118. if( it != cArr->end() ){
  119. RetVal = it->second.c_str()[0];
  120. };
  121. };
  122. deleteResult( result );
  123. };
  124. };
  125. return RetVal;
  126. };
  127. uint64_t servaMySQLDBC::getBottomLRF( uint64_t id ){
  128. uint64_t RetVal = 0;
  129. if( m_bIsConnected ){
  130. char tQBuf[MAX_PATH_LEN];
  131. AAssoc *result;
  132. sprintf( tQBuf, "SELECT `id` FROM `lrf_sensors` WHERE `role`='B' AND `mojo_id`=%d", id );
  133. result = m_pDatabase->Query( tQBuf );
  134. if( result!= NULL ) {
  135. if( result->size() > 0 ) {
  136. Assoc *cArr;
  137. Assoc::iterator it;
  138. cArr = result->at(0);
  139. it = cArr->find("id");
  140. if( it != cArr->end() ){
  141. RetVal = atoll( it->second.c_str() );
  142. };
  143. };
  144. };
  145. deleteResult( result );
  146. };
  147. return RetVal;
  148. };
  149. uint32_t servaMySQLDBC::getCloudLTS( uint8_t Obj, uint64_t id ){
  150. uint32_t RetVal = 0;
  151. if( m_bIsConnected ){
  152. char tQBuf[MAX_PATH_LEN];
  153. AAssoc *result;
  154. sprintf( tQBuf, "SELECT `ts` FROM `mem_online_cloud` WHERE `object_id`=%" PRIu64 " AND `object_type`=%d", id, Obj );
  155. LOG( tQBuf );
  156. result = m_pDatabase->Query( tQBuf );
  157. if( result!= NULL ) {
  158. if( result->size() > 0 ) {
  159. Assoc *cArr;
  160. Assoc::iterator it;
  161. cArr = result->at(0);
  162. it = cArr->find("ts");
  163. if( it != cArr->end() ){
  164. RetVal = atoi( it->second.c_str() );
  165. };
  166. };
  167. };
  168. deleteResult( result );
  169. };
  170. return RetVal;
  171. };
  172. uint8_t servaMySQLDBC::getCloudStatus( uint8_t Obj, uint64_t id ){
  173. uint8_t RetVal = 0;
  174. if( m_bIsConnected ){
  175. char tQBuf[MAX_PATH_LEN];
  176. AAssoc *result;
  177. sprintf( tQBuf, "SELECT `status` FROM `mem_online_cloud` WHERE `object_id`=%" PRIu64 " AND `object_type`=%d", id, Obj );
  178. result = m_pDatabase->Query( tQBuf );
  179. if( result!= NULL ) {
  180. if( result->size() > 0 ) {
  181. Assoc *cArr;
  182. Assoc::iterator it;
  183. cArr = result->at(0);
  184. it = cArr->find("status");
  185. if( it != cArr->end() ){
  186. RetVal = atoi( it->second.c_str() );
  187. };
  188. };
  189. };
  190. deleteResult( result );
  191. };
  192. return RetVal;
  193. };
  194. uint64_t servaMySQLDBC::getRecentMediaId(){
  195. uint64_t RetVal = 0;
  196. if( m_bIsConnected ){
  197. char tQBuf[MAX_PATH_LEN];
  198. AAssoc *result;
  199. sprintf( tQBuf, "SELECT `id` FROM `media_queue` WHERE `status`=1" );
  200. result = m_pDatabase->Query( tQBuf );
  201. if( result!= NULL ) {
  202. if( result->size() > 0 ) {
  203. Assoc *cArr;
  204. Assoc::iterator it;
  205. cArr = result->at(0);
  206. it = cArr->find("id");
  207. if( it != cArr->end() ){
  208. RetVal = atoll( it->second.c_str() );
  209. };
  210. };
  211. };
  212. deleteResult( result );
  213. };
  214. return RetVal;
  215. };
  216. DBC_RPC_MEDIA_INFO *servaMySQLDBC::getRemoteMediaInfo( uint64_t id ){
  217. DBC_RPC_MEDIA_INFO *RetVal = NULL;
  218. if( m_bIsConnected ){
  219. char tQBuf[MAX_PATH_LEN];
  220. AAssoc *result;
  221. sprintf( tQBuf, "SELECT * FROM `media_queue` WHERE `id`='%" PRIu64 "'", id );
  222. result = m_pDatabase->Query( tQBuf );
  223. if( result!= NULL ) {
  224. if (result->size() > 0) {
  225. Assoc *cArr;
  226. Assoc::iterator it;
  227. RetVal = ( DBC_RPC_MEDIA_INFO *) malloc(sizeof(DBC_RPC_MEDIA_INFO));
  228. if ( RetVal ) {
  229. cArr = result->at(0);
  230. it = cArr->find("uuid");
  231. if( it != cArr->end() ){
  232. strncpy( RetVal->uuid, it->second.c_str(), 64 );
  233. RetVal->uuid[64] = (char)0;
  234. };
  235. it = cArr->find("reg_id");
  236. if( it != cArr->end() ){
  237. RetVal->reg_id = atoll( it->second.c_str() );
  238. };
  239. it = cArr->find("src");
  240. if( it != cArr->end() ){
  241. RetVal->src = atoll( it->second.c_str() );
  242. };
  243. it = cArr->find("width");
  244. if( it != cArr->end() ){
  245. RetVal->width = atoi( it->second.c_str() );
  246. };
  247. it = cArr->find("height");
  248. if( it != cArr->end() ){
  249. RetVal->height = atoi( it->second.c_str() );
  250. };
  251. it = cArr->find("fmt");
  252. if( it != cArr->end() ){
  253. strncpy( RetVal->fmt, it->second.c_str(), 5 );
  254. RetVal->fmt[5] = (char)0;
  255. };
  256. };
  257. };
  258. };
  259. deleteResult( result );
  260. };
  261. return RetVal;
  262. };
  263. uint64_t servaMySQLDBC::getUpperLRF( uint64_t id ){
  264. uint64_t RetVal = 0;
  265. if( m_bIsConnected ){
  266. char tQBuf[MAX_PATH_LEN];
  267. AAssoc *result;
  268. sprintf( tQBuf, "SELECT `id` FROM `lrf_sensors` WHERE `role`='U' AND `mojo_id`=%d", id );
  269. result = m_pDatabase->Query( tQBuf );
  270. if( result!= NULL ) {
  271. if( result->size() > 0 ) {
  272. Assoc *cArr;
  273. Assoc::iterator it;
  274. cArr = result->at(0);
  275. it = cArr->find("id");
  276. if( it != cArr->end() ){
  277. RetVal = atoll( it->second.c_str() );
  278. };
  279. };
  280. };
  281. deleteResult( result );
  282. };
  283. return RetVal;
  284. };
  285. bool servaMySQLDBC::putIntoLog( CSTR A, CSTR B, CSTR C ){
  286. if( m_bIsConnected ){
  287. char tQBuf[MAX_PATH_LEN];
  288. sprintf( tQBuf, "INSERT INTO `server_log_messages` SET lvl = '%s', `ts`='%s', `msg`='%s'", A, B, C );
  289. m_pDatabase->SilentQuery( tQBuf );
  290. } else LOG("Not Connected!");
  291. };
  292. uint64_t servaMySQLDBC::registerMojo( CSTR A, CSTR B ){
  293. uint64_t RetVal = 0;
  294. char tQBuf[MAX_PATH_LEN];
  295. if( m_bIsConnected ){
  296. AAssoc *result;
  297. sprintf( tQBuf, "SELECT `id` FROM `module_nodes` WHERE `IP4`='%s' AND `cert_id`='%s'", A, B );
  298. result = m_pDatabase->Query( tQBuf );
  299. if( result!= NULL ) {
  300. if( result->size() > 0 ) {
  301. Assoc *cArr;
  302. Assoc::iterator it;
  303. cArr = result->at(0);
  304. it = cArr->find("id");
  305. if( it != cArr->end() ){
  306. RetVal = atoll( it->second.c_str() );
  307. };
  308. };
  309. };
  310. deleteResult( result );
  311. };
  312. if ( RetVal ) {
  313. sprintf( tQBuf, "INSERT INTO `mem_online_cloud` SET `id` FROM `module_nodes` WHERE `IP4`='%s' AND `cert_id`='%s'", A, B );
  314. };
  315. return RetVal;
  316. };
  317. bool servaMySQLDBC::registerServer( uint32_t SiteID, CSTR identity, int PID, uint32_t *ServID, uint32_t *ServNode ){
  318. if(m_bIsConnected){
  319. //m_nSiteID = SiteID;
  320. char tQBuf[MAX_PATH_LEN];
  321. sprintf( tQBuf, "INSERT INTO servers SET `site_id`=%d, `identity`='%s', `version_string`='%s', `online`=1, `ts`=UNIX_TIMESTAMP(now()), pid=%d ON DUPLICATE KEY UPDATE `version_string`='%s', `ts`=UNIX_TIMESTAMP(now()), `online`=1, pid=%d",
  322. SiteID, identity, _BUILD_STRING_, PID, _BUILD_STRING_, PID );
  323. #ifdef DEBUG
  324. LOG(tQBuf);
  325. #endif
  326. m_pDatabase->SilentQuery( tQBuf );
  327. //*ServID = getServerID( identity );
  328. //m_nServerID = *ServID;
  329. if( *ServID ) {
  330. //sprintf(tQBuf,"INSERT INTO nodes SET `site_id`=%d, `aux_id`='%d', `type`= 0, `online`=1, `name`='Server Node' ON DUPLICATE KEY UPDATE `online`=1", m_nSiteID, *ServID );
  331. #ifdef DEBUG_ALL
  332. LOG(tQBuf);
  333. #endif
  334. *ServNode = ( uint32_t ) m_pDatabase->QueryID( tQBuf );
  335. //if( *ServNode == 0 ){
  336. // *ServNode = getServerNode( *ServID );
  337. //};
  338. //m_nServerNodeID = *ServNode;
  339. // Clenup Nodes and services ...
  340. sprintf(tQBuf,"UPDATE nodes SET `online`=0 WHERE `server_id`=%d ", *ServID );
  341. #ifdef DEBUG_ALL
  342. LOG(tQBuf);
  343. #endif
  344. m_pDatabase->SilentQuery( tQBuf );
  345. sprintf(tQBuf,"UPDATE cameras SET `online`=0 WHERE `site_id`=%d ", SiteID );
  346. #ifdef DEBUG_ALL
  347. LOG(tQBuf);
  348. #endif
  349. m_pDatabase->SilentQuery( tQBuf );
  350. sprintf(tQBuf,"UPDATE media_streams SET `valid`=0 WHERE `site_id`=%d ", SiteID );
  351. #ifdef DEBUG_ALL
  352. LOG(tQBuf);
  353. #endif
  354. m_pDatabase->SilentQuery( tQBuf );
  355. sprintf(tQBuf,"UPDATE media_server_streams SET `valid`=0, `online`=0 WHERE `site_id`=%d ", SiteID );
  356. #ifdef DEBUG_ALL
  357. LOG(tQBuf);
  358. #endif
  359. m_pDatabase->SilentQuery( tQBuf );
  360. //cleanResources( tServerNodeID );
  361. return setNodeOnline( 0, 1 );//m_nServerNodeID );
  362. }
  363. };
  364. return false;
  365. };
  366. uint32_t servaMySQLDBC::registerVideoTransfer( uint32_t srcNode, CSTR uuid, uint32_t dataSize, CSTR fmt, uint32_t ts ){
  367. if(m_bIsConnected){
  368. char tQBuf[MAX_PATH_LEN];
  369. sprintf( tQBuf, "INSERT INTO `media_queue` SET `src`=%d, `uuid`='%s', `size`=%d, `fmt`='%s', `ts`=%d",
  370. srcNode, uuid, dataSize, fmt, ts );
  371. return ( uint32_t ) m_pDatabase->QueryID( tQBuf );
  372. };
  373. return 0;
  374. };
  375. bool servaMySQLDBC::unregisterServer(){
  376. if( setNodeOffline( 0 ) ) { //m_nServerNodeID ) ){
  377. char tQBuf[CTEXT];
  378. sprintf(tQBuf,"UPDATE servers SET `online`=0, `ts`=UNIX_TIMESTAMP(now()) WHERE `id`=%d", 1 );//m_nServerID );
  379. #ifdef DEBUG_ALL
  380. LOG(tQBuf);
  381. #endif
  382. m_pDatabase->SilentQuery( tQBuf );
  383. return true;
  384. };
  385. return false;
  386. };
  387. bool servaMySQLDBC::setNodeOnline( uint32_t NodeID, uint8_t status ){
  388. if(m_bIsConnected){
  389. char tQBuf[CTEXT];
  390. if( NodeID ) {
  391. sprintf(tQBuf,"UPDATE nodes SET `online`=%d WHERE `id`=%d", status, NodeID );
  392. #ifdef DEBUG_ALL
  393. LOG(tQBuf);
  394. #endif
  395. m_pDatabase->SilentQuery( tQBuf );
  396. sprintf(tQBuf,"UPDATE `resources` SET `active`=1 WHERE `node_id`=%d", NodeID );
  397. #ifdef DEBUG_ALL
  398. LOG(tQBuf);
  399. #endif
  400. m_pDatabase->SilentQuery( tQBuf );
  401. return true;
  402. };
  403. };
  404. return false;
  405. };
  406. bool servaMySQLDBC::setNodeOffline( uint32_t NodeID ){
  407. if(m_bIsConnected){
  408. char tQBuf[CTEXT];
  409. if( NodeID ) {
  410. sprintf(tQBuf,"UPDATE nodes SET `online`=0 WHERE `id` = %d", NodeID );
  411. #ifdef DEBUG_ALL
  412. LOG(tQBuf);
  413. #endif
  414. m_pDatabase->SilentQuery( tQBuf );
  415. sprintf(tQBuf,"UPDATE `resources` SET `active`=0 WHERE `node_id` = %d", NodeID );
  416. #ifdef DEBUG_ALL
  417. LOG(tQBuf);
  418. #endif
  419. m_pDatabase->SilentQuery( tQBuf );
  420. return true;
  421. };
  422. };
  423. return false;
  424. };
  425. bool servaMySQLDBC::setCloudStatus( uint8_t Obj, uint64_t id, uint32_t status, CSTR sid ){
  426. if( m_bIsConnected ){
  427. char tQBuf[CTEXT];
  428. uint32_t CTS = time( NULL );
  429. if( sid ) {
  430. sprintf(tQBuf, "INSERT INTO `mem_online_cloud` SET `object_id`=%" PRIu64 ", `object_type`=%d, `status`=%d, `ts`=%d, `SID`='%s' ON DUPLICATE KEY UPDATE `status`=%d, `ts`=%d, `SID`='%s'",
  431. id, Obj, status, CTS, sid, status, CTS, sid );
  432. } else {
  433. sprintf(tQBuf, "INSERT INTO `mem_online_cloud` SET `object_id`=%" PRIu64 ", `object_type`=%d, `status`=%d, `ts`=%d ON DUPLICATE KEY UPDATE `status`=%d, `ts`=%d",
  434. id, Obj, status, CTS, status, CTS );
  435. };
  436. #ifdef DEBUG_ALL
  437. LOG(tQBuf);
  438. #endif
  439. m_pDatabase->SilentQuery( tQBuf );
  440. return true;
  441. };
  442. return false;
  443. };
  444. bool servaMySQLDBC::updateEncodeStatus( uint64_t dbid, uint8_t status, uint8_t perc ){
  445. if( m_bIsConnected ) {
  446. char tQBuf[4096];
  447. sprintf(tQBuf, "UPDATE `media_queue` SET `ts`=UNIX_TIMESTAMP(now()), `status`=%d, `process`=%d WHERE `id`=%" PRIu64,
  448. status, perc, dbid
  449. );
  450. #ifdef DEBUG
  451. LOG(tQBuf);
  452. #endif
  453. m_pDatabase->SilentQuery( tQBuf );
  454. return true;
  455. };
  456. return false;
  457. };
  458. //bool servaMySQLDBC::updateServerUtilisation( uint32_t ServerID, uint32_t nCores, float cpu1, float cpu5, float cpu15, float mem, float disk, uint64_t dtsize, uint64_t dcsize, uint64_t mtsize, uint64_t mcsize ){
  459. bool servaMySQLDBC::updateServerUtilisation( DBC_SYS_LOAD_INFO *ptr ){
  460. if( m_bIsConnected ) {
  461. char tQBuf[MAX_PATH_LEN];
  462. sprintf( tQBuf, "UPDATE `servers` SET `ts`=UNIX_TIMESTAMP(now()), `cpu_cores`=%d, `stat_cpu1`=%0.2f, `stat_cpu5`=%0.2f, `stat_cpu15`=%0.2f, `stat_mem`=%0.2f, `stat_disk`=%0.2f, `temp0`=%0.1f, `val_mem_tottal`=%" PRIu64 ", `val_mem_current`=%" PRIu64 ", `val_disk_tottal`=%" PRIu64 ", `val_disk_current`=%" PRIu64 " WHERE `id`=%d",
  463. ptr->CPU_CORES,
  464. ptr->cpu1,
  465. ptr->cpu5,
  466. ptr->cpu15,
  467. ptr->mem,
  468. ptr->disk,
  469. ptr->temperature,
  470. ptr->T_DISK,
  471. ptr->C_DISK,
  472. ptr->T_MEM,
  473. ptr->C_MEM,
  474. 0//m_nServerID
  475. );
  476. #ifdef DEBUG_ALL
  477. LOG(tQBuf);
  478. #endif
  479. m_pDatabase->SilentQuery( tQBuf );
  480. return true;
  481. };
  482. return false;
  483. };
  484. #undef LOG
  485. #undef LOG_ERROR