[TBASE-816]
This commit is contained in:
parent
2ac3c3f04e
commit
e1b11fbb3b
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -376,7 +377,7 @@ void monitorSaveSystemInfo() {
|
||||||
|
|
||||||
int64_t ts = taosGetTimestampUs();
|
int64_t ts = taosGetTimestampUs();
|
||||||
char * sql = monitor->sql;
|
char * sql = monitor->sql;
|
||||||
int pos = snprintf(sql, SQL_LENGTH, "insert into %s.dn_%s values(%ld", tsMonitorDbName, monitor->privateIpStr, ts);
|
int pos = snprintf(sql, SQL_LENGTH, "insert into %s.dn_%s values(%" PRId64, tsMonitorDbName, monitor->privateIpStr, ts);
|
||||||
|
|
||||||
pos += monitorBuildCpuSql(sql + pos);
|
pos += monitorBuildCpuSql(sql + pos);
|
||||||
pos += monitorBuildMemorySql(sql + pos);
|
pos += monitorBuildMemorySql(sql + pos);
|
||||||
|
@ -402,16 +403,16 @@ void monitorSaveAcctLog(char *acctId, int64_t currentPointsPerSecond, int64_t ma
|
||||||
char sql[1024] = {0};
|
char sql[1024] = {0};
|
||||||
sprintf(sql,
|
sprintf(sql,
|
||||||
"insert into %s.acct_%s using %s.acct tags('%s') values(now"
|
"insert into %s.acct_%s using %s.acct tags('%s') values(now"
|
||||||
", %ld, %ld "
|
", %" PRId64, "%" PRId64
|
||||||
", %ld, %ld"
|
", %" PRId64, "%" PRId64
|
||||||
", %ld, %ld"
|
", %" PRId64, "%" PRId64
|
||||||
", %ld, %ld"
|
", %" PRId64, "%" PRId64
|
||||||
", %ld, %ld"
|
", %" PRId64, "%" PRId64
|
||||||
", %ld, %ld"
|
", %" PRId64, "%" PRId64
|
||||||
", %ld, %ld"
|
", %" PRId64, "%" PRId64
|
||||||
", %ld, %ld"
|
", %" PRId64, "%" PRId64
|
||||||
", %ld, %ld"
|
", %" PRId64, "%" PRId64
|
||||||
", %ld, %ld"
|
", %" PRId64, "%" PRId64
|
||||||
", %d)",
|
", %d)",
|
||||||
tsMonitorDbName, acctId, tsMonitorDbName, acctId, currentPointsPerSecond, maxPointsPerSecond, totalTimeSeries,
|
tsMonitorDbName, acctId, tsMonitorDbName, acctId, currentPointsPerSecond, maxPointsPerSecond, totalTimeSeries,
|
||||||
maxTimeSeries, totalStorage, maxStorage, totalQueryTime, maxQueryTime, totalInbound, maxInbound,
|
maxTimeSeries, totalStorage, maxStorage, totalQueryTime, maxQueryTime, totalInbound, maxInbound,
|
||||||
|
@ -431,7 +432,7 @@ void monitorSaveLog(int level, const char *const format, ...) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = snprintf(sql, (size_t)max_length, "import into %s.log values(%ld, %d,'", tsMonitorDbName,
|
int len = snprintf(sql, (size_t)max_length, "import into %s.log values(%\" PRId64 \", %d,'", tsMonitorDbName,
|
||||||
taosGetTimestampUs(), level);
|
taosGetTimestampUs(), level);
|
||||||
|
|
||||||
va_start(argpointer, format);
|
va_start(argpointer, format);
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include <inttypes.h>
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
@ -99,7 +99,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
|
||||||
|
|
||||||
int64_t memKB = 0;
|
int64_t memKB = 0;
|
||||||
char tmp[10];
|
char tmp[10];
|
||||||
sscanf(line, "%s %ld", tmp, &memKB);
|
sscanf(line, "%s %" PRId64, tmp, &memKB);
|
||||||
*memoryUsedMB = (float)((double)memKB / 1024);
|
*memoryUsedMB = (float)((double)memKB / 1024);
|
||||||
|
|
||||||
tfree(line);
|
tfree(line);
|
||||||
|
@ -124,7 +124,7 @@ bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char cpu[10] = {0};
|
char cpu[10] = {0};
|
||||||
sscanf(line, "%s %lu %lu %lu %lu", cpu, &cpuInfo->user, &cpuInfo->nice, &cpuInfo->system, &cpuInfo->idle);
|
sscanf(line, "%s %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, cpu, &cpuInfo->user, &cpuInfo->nice, &cpuInfo->system, &cpuInfo->idle);
|
||||||
|
|
||||||
tfree(line);
|
tfree(line);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -150,7 +150,7 @@ bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
|
||||||
for (int i = 0, blank = 0; line[i] != 0; ++i) {
|
for (int i = 0, blank = 0; line[i] != 0; ++i) {
|
||||||
if (line[i] == ' ') blank++;
|
if (line[i] == ' ') blank++;
|
||||||
if (blank == PROCESS_ITEM) {
|
if (blank == PROCESS_ITEM) {
|
||||||
sscanf(line + i + 1, "%lu %lu %lu %lu", &cpuInfo->utime, &cpuInfo->stime, &cpuInfo->cutime, &cpuInfo->cstime);
|
sscanf(line + i + 1, "%" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, &cpuInfo->utime, &cpuInfo->stime, &cpuInfo->cutime, &cpuInfo->cstime);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ bool taosGetCardInfo(int64_t *bytes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line != NULL) {
|
if (line != NULL) {
|
||||||
sscanf(line, "%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", nouse0, &rbytes, &rpackts, &nouse1, &nouse2, &nouse3,
|
sscanf(line, "%s %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64, nouse0, &rbytes, &rpackts, &nouse1, &nouse2, &nouse3,
|
||||||
&nouse4, &nouse5, &nouse6, &tbytes, &tpackets);
|
&nouse4, &nouse5, &nouse6, &tbytes, &tpackets);
|
||||||
*bytes = rbytes + tbytes;
|
*bytes = rbytes + tbytes;
|
||||||
tfree(line);
|
tfree(line);
|
||||||
|
@ -488,10 +488,10 @@ bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strstr(line, "rchar:") != NULL) {
|
if (strstr(line, "rchar:") != NULL) {
|
||||||
sscanf(line, "%s %ld", tmp, readbyte);
|
sscanf(line, "%s %" PRId64, tmp, readbyte);
|
||||||
readIndex++;
|
readIndex++;
|
||||||
} else if (strstr(line, "wchar:") != NULL) {
|
} else if (strstr(line, "wchar:") != NULL) {
|
||||||
sscanf(line, "%s %ld", tmp, writebyte);
|
sscanf(line, "%s %" PRId64, tmp, writebyte);
|
||||||
readIndex++;
|
readIndex++;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
@ -564,9 +564,9 @@ void taosGetSystemInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsPrintOsInfo() {
|
void tsPrintOsInfo() {
|
||||||
pPrint(" os pageSize: %ld(KB)", tsPageSize);
|
pPrint(" os pageSize: %" PRId64 "(KB)", tsPageSize);
|
||||||
pPrint(" os openMax: %ld", tsOpenMax);
|
pPrint(" os openMax: %" PRId64, tsOpenMax);
|
||||||
pPrint(" os streamMax: %ld", tsStreamMax);
|
pPrint(" os streamMax: %" PRId64, tsStreamMax);
|
||||||
pPrint(" os numOfCores: %d", tsNumOfCores);
|
pPrint(" os numOfCores: %d", tsNumOfCores);
|
||||||
pPrint(" os totalDisk: %f(GB)", tsTotalDataDirGB);
|
pPrint(" os totalDisk: %f(GB)", tsTotalDataDirGB);
|
||||||
pPrint(" os totalMemory: %d(MB)", tsTotalMemoryMB);
|
pPrint(" os totalMemory: %d(MB)", tsTotalMemoryMB);
|
||||||
|
|
Loading…
Reference in New Issue