void CMonitorService::WatchSystem() { time_t now; now = uptime(); if ((now-m_tmLastCheck) < 60) { // XDEBUG(ANSI_COLOR_GREEN " #######################################debug sungyeung this is not check time yet : %s : %d \n" ANSI_NORMAL, __FILE__, __LINE__); return; } if (!CheckMemory()) { UpdateLogFile(LOG_DIR, EVENT_LOG_FILE, 0, TRUE, "SYSMON::MEMORY FULL\xd\xa"); RebootSystem(); } if (!CheckFlash()) { XDEBUG(ANSI_COLOR_RED " #######################################debug sungyeung WatchSystem().!CheckFlash() : %s : %d \n", __FILE__, __LINE__); ReduceFileSystem(); UpdateLogFile(LOG_DIR, EVENT_LOG_FILE, 0, TRUE, "SYSMON::FLASH FULL\xd\xa"); RebootSystem(); } if (!CheckLauncher()) { UpdateLogFile(LOG_DIR, EVENT_LOG_FILE, 0, TRUE, "SYSMON::LAUNCHER FAIL\xd\xa"); RebootSystem(); } if (!CheckAgent()) { UpdateLogFile(LOG_DIR, EVENT_LOG_FILE, 0, TRUE, "SYSMON::AGENT FAIL\xd\xa"); RebootSystem(); } if (!CheckTelnet()) { UpdateLogFile(LOG_DIR, EVENT_LOG_FILE, 0, TRUE, "SYSMON::TELNET FAIL\xd\xa"); KillTelnet(); } m_tmLastCheck = uptime(); }
void CMonitorService::ReduceFileSystem() { DIR *dir_fdesc; dirent *dp; time_t now; struct tm when; char szTime[30]; char szFileName[128]; printf("SYSMON: Reduce FileSystem.\r\n"); system("rm -rf /app/log/*"); UpdateLogFile(LOG_DIR, EVENT_LOG_FILE, 0, TRUE, "SYSMON: Reduce FileSystem.\r\n"); time(&now); when = *localtime(&now); sprintf(szTime, "%04d%02d%02d", when.tm_year + 1900, when.tm_mon + 1, when.tm_mday); dir_fdesc = opendir("/app/data"); if (dir_fdesc != NULL) { for(; (dp=readdir(dir_fdesc));) { #if defined(_DIRENT_HAVE_D_TYPE) if (dp->d_type == DT_DIR) continue; #endif if (dp->d_name[0] == '.') continue; if(strlen(dp->d_name) <= DATE_TIME_LEN) continue; if(strncmp(szTime,dp->d_name,8)) { printf("SYSMON: Reduce Data File [%s]\r\n", dp->d_name); UpdateLogFile(LOG_DIR, EVENT_LOG_FILE, 0, TRUE, "SYSMON: Reduce Data File [%s]\r\n", dp->d_name); sprintf(szFileName, "/app/data/%s", dp->d_name); remove(szFileName); } } } RebootSystem(); }
/* DON'T RETURN -1! This causes Installer Vise to terminate! */ LONG CALLBACK ViseEntry(LONG lParam1, LPCSTR lpParam2, DWORD dwReserved) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); int rc; DebugPrintf (("ViseEntry called, lParam1= 0x%X, lpParam= %s\n",lParam1,lpParam2?lpParam2:"(null)")) switch (lParam1) { case 1: rc= CheckSigningStatus(); break; case 2: rc= DeleteJoystickType(lpParam2); break; case 3: rc= DeletePPJoyDevices50(); break; case 4: rc= CountParallelPorts(); break; case 5: rc= CountInstalledPPJoysticks(); break; case 6: rc= GetInterruptAssignment((char*)lpParam2); break; case 7: rc= GetConnectInterruptSetting((char*)lpParam2); break; case 8: rc= SetConnectInterruptSetting((char*)lpParam2,1); break; case 9: { int LPTNumber; int JoyType; int UnitNumber; int JoySubType; int VendorID; int ProductID; rc= -1; if (sscanf((char*)lpParam2,"LPT%d,%d,%d,%d,%X,%X",&LPTNumber,&JoyType,&UnitNumber,&JoySubType,&VendorID,&ProductID)==6) rc= AddNewJoystick(LPTNumber,JoyType,UnitNumber,JoySubType,VendorID,ProductID); } break; case 10: rc= GetRegistryTestsigningFlag(); break; case 11: rc= GetBCDTestsigningFlag(); break; case 12: rc= SetBCDTestsigningFlag (atoi(lpParam2)); break; case 13: rc= RebootSystem(); break; default: rc= -9999; DebugPrintf (("Unknown helper function request\n")) break; } DebugPrintf (("Return code is %d\n",rc)) /* DON'T RETURN -1! This causes Installer Vise to terminate! */ /* We will politely translater all -1 return codes to -1000 */ if (rc==-1) rc=-1000; return rc; }