|
@@ -12054,6 +12054,15 @@ void* GetLogProcess(void* data)
|
|
|
int port=0;
|
|
|
int isSuccess = FALSE;
|
|
|
char ftpbuf[200]={0};
|
|
|
+ char cmdBuf[2048];
|
|
|
+ struct tm *tmNow;
|
|
|
+ time_t CurrentTime;
|
|
|
+ struct tm tmStart;
|
|
|
+ struct tm tmStop;
|
|
|
+ CurrentTime = time(NULL);
|
|
|
+ tmNow=localtime(&CurrentTime);
|
|
|
+ uint16_t targetYear, targetMonth;
|
|
|
+
|
|
|
json_object *GetLog;
|
|
|
|
|
|
DEBUG_INFO("GetGetProcess...\n");
|
|
@@ -12093,9 +12102,49 @@ void* GetLogProcess(void* data)
|
|
|
}
|
|
|
json_object_put(GetLog);
|
|
|
|
|
|
-
|
|
|
ShmOCPP20Data->GetLog.requestId = requestId;
|
|
|
|
|
|
+ // Pack log to compress file
|
|
|
+ if((sscanf((char*)oldestTimestamp, "%4d-%2d-%2dT%2d:%2d:%2d", &tmStart.tm_year, &tmStart.tm_mon, &tmStart.tm_mday, &tmStart.tm_hour, &tmStart.tm_min, &tmStart.tm_sec) == 6) &&
|
|
|
+ (sscanf((char*)latestTimestamp, "%4d-%2d-%2dT%2d:%2d:%2d", &tmStop.tm_year, &tmStop.tm_mon, &tmStop.tm_mday, &tmStop.tm_hour, &tmStop.tm_min, &tmStop.tm_sec) == 6))
|
|
|
+ {
|
|
|
+ sprintf(cmdBuf, "exec zip -9 --password %04d%02d%s /mnt/log.zip", tmNow->tm_year+1900, tmNow->tm_mon+1, ShmSysConfigAndInfo->SysConfig.SerialNumber);
|
|
|
+ targetYear = tmStart.tm_year;
|
|
|
+ targetMonth = tmStart.tm_mon;
|
|
|
+
|
|
|
+ do
|
|
|
+ {
|
|
|
+ sprintf(cmdBuf, "%s /Storage/EventLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
|
|
|
+ sprintf(cmdBuf, "%s /Storage/SystemLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
|
|
|
+ sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
|
|
|
+
|
|
|
+ if(targetMonth+1>=13)
|
|
|
+ {
|
|
|
+ targetYear += 1;
|
|
|
+ targetMonth = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ targetMonth += 1;
|
|
|
+ }
|
|
|
+ }while((targetYear < (tmNow->tm_year+1900)) ||
|
|
|
+ ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
|
|
|
+
|
|
|
+ sprintf(cmdBuf, "%s \t /Storage/ChargeLog/*.db", cmdBuf);
|
|
|
+ sprintf(cmdBuf, "%s \t /Storage/OCPP/*.db", cmdBuf);
|
|
|
+ sprintf(cmdBuf, "%s \t /Storage/EventLog/*.db", cmdBuf);
|
|
|
+ sprintf(cmdBuf, "%s \t /Storage/CCS*.zip", cmdBuf);
|
|
|
+
|
|
|
+ system(cmdBuf);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ system("exec /root/logPackTools 'log' 6");
|
|
|
+ }
|
|
|
+
|
|
|
+ sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", ShmOCPP20Data->GetLog.Response_filename);
|
|
|
+ system(cmdBuf);
|
|
|
+ checkUploadLog();
|
|
|
//****************location*******************/
|
|
|
if(strcmp(remoteLocation,"")==0)
|
|
|
{
|
|
@@ -12230,7 +12279,6 @@ int handleGetLogRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
mtrace();
|
|
|
int result = FAIL;
|
|
|
- char cmdBuf[512];
|
|
|
char fName[258];
|
|
|
time_t CurrentTime;
|
|
|
struct tm *tm;
|
|
@@ -12239,15 +12287,10 @@ int handleGetLogRequest(char *uuid, char *payload)
|
|
|
CurrentTime = time(NULL);
|
|
|
tm = localtime(&CurrentTime);
|
|
|
sprintf(fName ,"%s-%s-%04d%02d%02d%02d%02d%02d.zip", ShmSysConfigAndInfo->SysConfig.ModelName, ShmSysConfigAndInfo->SysConfig.SerialNumber, (tm->tm_year+1900), (tm->tm_mon+1),tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
|
|
|
-
|
|
|
sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
|
|
|
sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
|
|
|
-
|
|
|
sendGetLogConfirmation(uuid);
|
|
|
- system("exec /root/logPackTools 'log' 6");
|
|
|
- sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", fName);
|
|
|
- system(cmdBuf);
|
|
|
- checkUploadLog();
|
|
|
+
|
|
|
pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
|
|
|
|
|
|
return result;
|