static int processAlertMessage (WVIEWD_WORK *work, EmailAlertTypes type) { char syscmnd[256]; int retVal; time_t timenow = time(NULL); struct tm bknTime; if (! work->IsAlertEmailsEnabled || ! strlen(work->alertEmailToAdrs) || ! strlen(work->alertEmailFromAdrs)) { return OK; } localtime_r(&timenow, &bknTime); sprintf(syscmnd, "sendEmail -f %s -t %s -u \"%4.4d%2.2d%2.2d %2.2d:%2.2d: %s\" -m \"%s\"", work->alertEmailFromAdrs, work->alertEmailToAdrs, bknTime.tm_year + 1900, bknTime.tm_mon + 1, bknTime.tm_mday, bknTime.tm_hour, bknTime.tm_min, emailAlertGetSubject(type), emailAlertGetBody(type)); radStartProcess (newProcessEntryPoint, syscmnd); return OK; }
int htmlmgrGenerate ( HTML_MGR_ID id ) { register HTML_IMG *img; int retVal, imgs = 0, htmls = 0; char temp[256]; struct stat fileData; GenerateTime = radTimeGetMSSinceEpoch (); #if __DEBUG_BUFFERS radMsgLog (PRI_STATUS, "DBG BFRS: HTML BEGIN: %u of %u available", buffersGetAvailable (), buffersGetTotal ()); #endif // ... compute the Barometric Pressure trend computeBPTrend (id); #if DEBUG_GENERATION radMsgLog (PRI_MEDIUM, "GENERATE: images"); #endif // ... generate the weather images for (img = (HTML_IMG *)radListGetFirst (&id->imgList); img != NULL; img = (HTML_IMG *)radListGetNext (&id->imgList, (NODE_PTR)img)) { retVal = (*img->generator) (img); if (retVal == OK) { imgs ++; } else if (retVal != ERROR_ABORT) { sprintf (temp, "%s/%s", id->imagePath, img->fname); radMsgLog (PRI_HIGH, "%s generation failed - must be local to the wview server!", temp); radMsgLog (PRI_HIGH, "Otherwise you may be including data in " "images.conf for which you do not have sensors?!?"); } } // ... clear the archiveAvailable flag (must be after generator loop) id->newArchiveMask = 0; #if DEBUG_GENERATION radMsgLog (PRI_MEDIUM, "GENERATE: pre-generate script"); #endif // If the wview pre-generation script exists, run it now sprintf (temp, "%s/%s", WVIEW_CONFIG_DIR, HTML_PRE_GEN_SCRIPT); if (stat (temp, &fileData) == 0) { // File exists, run it radStartProcess (newProcessEntryPoint, temp); } #if DEBUG_GENERATION radMsgLog (PRI_MEDIUM, "GENERATE: templates"); #endif // ... now generate the HTML if ((htmls = htmlgenOutputFiles(id, GenerateTime)) == ERROR) { return ERROR; } wvutilsLogEvent(PRI_STATUS, "Generated: %u ms: %d images, %d template files", (uint32_t)(radTimeGetMSSinceEpoch() - GenerateTime), imgs, htmls); id->imagesGenerated += imgs; id->templatesGenerated += htmls; statusUpdateStat(HTML_STATS_IMAGES_GENERATED, id->imagesGenerated); statusUpdateStat(HTML_STATS_TEMPLATES_GENERATED, id->templatesGenerated); #if __DEBUG_BUFFERS radMsgLog (PRI_STATUS, "DBG BFRS: HTML END: %u of %u available", buffersGetAvailable (), buffersGetTotal ()); #endif #if DEBUG_GENERATION radMsgLog (PRI_MEDIUM, "GENERATE: post-generate script"); #endif // Finally, if the wview post-generation script exists, run it now sprintf (temp, "%s/%s", WVIEW_CONFIG_DIR, HTML_POST_GEN_SCRIPT); if (stat (temp, &fileData) == 0) { // File exists, run it radStartProcess (newProcessEntryPoint, temp); } #if DEBUG_GENERATION radMsgLog (PRI_MEDIUM, "GENERATE: DONE"); #endif return OK; }