Move diag_fifo pipes in SOCKS_DIR instead of assigned Storage area. Storage areas could be a fs that cannot handle sockets or fifos like NFS.

This commit is contained in:
Isaac Connor 2020-11-12 11:53:51 -05:00
parent 645dca6bc9
commit de74a15ab1
4 changed files with 24 additions and 15 deletions

View File

@ -221,7 +221,7 @@ void FifoStream::setStreamStart(int monitor_id, const char * format) {
}
snprintf(diag_path, sizeof(diag_path), "%s/%d/%s",
monitor->getStorage()->Path(), monitor->Id(), filename);
staticConfig.PATH_SOCKS.c_str(), monitor->Id(), filename);
setStreamStart(diag_path);
}

View File

@ -540,11 +540,14 @@ Monitor::Monitor(
ReloadLinkedMonitors(p_linked_monitors);
if ( config.record_diag_images ) {
diag_path_r = stringtf(config.record_diag_images_fifo ? "%s/%d/diagpipe-r.jpg" : "%s/%d/diag-r.jpg", storage->Path(), id);
diag_path_d = stringtf(config.record_diag_images_fifo ? "%s/%d/diagpipe-d.jpg" : "%s/%d/diag-d.jpg", storage->Path(), id);
if ( config.record_diag_images_fifo ) {
FifoStream::fifo_create_if_missing(diag_path_r.c_str());
FifoStream::fifo_create_if_missing(diag_path_d.c_str());
diag_path_ref = stringtf("%s/%d/diagpipe-r.jpg", staticConfig.PATH_SOCKS.c_str(), id);
diag_path_delta = stringtf("%s/%d/diagpipe-d.jpg", staticConfig.PATH_SOCKS.c_str(), id);
FifoStream::fifo_create_if_missing(diag_path_ref.c_str());
FifoStream::fifo_create_if_missing(diag_path_delta.c_str());
} else {
diag_path_ref = stringtf("%s/%d/diag-r.jpg", storage->Path(), id);
diag_path_delta = stringtf("%s/%d/diag-d.jpg", storage->Path(), id);
}
}
} // end if purpose == ANALYSIS
@ -2683,8 +2686,8 @@ unsigned int Monitor::DetectMotion(const Image &comp_image, Event::StringSet &zo
ref_image.Delta(comp_image, &delta_image);
if ( config.record_diag_images ) {
ref_image.WriteJpeg(diag_path_r.c_str(), config.record_diag_images_fifo);
delta_image.WriteJpeg(diag_path_d.c_str(), config.record_diag_images_fifo);
ref_image.WriteJpeg(diag_path_ref.c_str(), config.record_diag_images_fifo);
delta_image.WriteJpeg(diag_path_delta.c_str(), config.record_diag_images_fifo);
}
// Blank out all exclusion zones

View File

@ -313,8 +313,8 @@ protected:
Image ref_image;
Image alarm_image; // Used in creating analysis images, will be initialized in Analysis
Image write_image; // Used when creating snapshot images
std::string diag_path_r;
std::string diag_path_d;
std::string diag_path_ref;
std::string diag_path_delta;
Purpose purpose; // What this monitor has been created to do
int event_count;

View File

@ -113,11 +113,16 @@ void Zone::Setup(
}
if ( config.record_diag_images ) {
if ( config.record_diag_images_fifo ) {
snprintf(diag_path, sizeof(diag_path),
config.record_diag_images_fifo ? "%s/diagpipe-%d-poly.jpg" : "%s/diag-%d-poly.jpg",
monitor->getStorage()->Path(), id);
if ( config.record_diag_images_fifo )
"%s/diagpipe-%d-poly.jpg",
staticConfig.PATH_SOCKS.c_str(), id);
FifoStream::fifo_create_if_missing(diag_path);
} else {
snprintf(diag_path, sizeof(diag_path), "%s/diag-%d-poly.jpg",
monitor->getStorage()->Path(), id);
}
pg_image->WriteJpeg(diag_path, config.record_diag_images_fifo);
} else {
diag_path[0] = 0;
@ -139,10 +144,11 @@ void Zone::RecordStats(const Event *event) {
"INSERT INTO Stats SET MonitorId=%d, ZoneId=%d, EventId=%" PRIu64 ", FrameId=%d, PixelDiff=%d, AlarmPixels=%d, FilterPixels=%d, BlobPixels=%d, Blobs=%d, MinBlobSize=%d, MaxBlobSize=%d, MinX=%d, MinY=%d, MaxX=%d, MaxY=%d, Score=%d",
monitor->Id(), id, event->Id(), event->Frames(), pixel_diff, alarm_pixels, alarm_filter_pixels, alarm_blob_pixels, alarm_blobs, min_blob_size, max_blob_size, alarm_box.LoX(), alarm_box.LoY(), alarm_box.HiX(), alarm_box.HiY(), score
);
if ( mysql_query(&dbconn, sql) ) {
int rc = mysql_query(&dbconn, sql);
db_mutex.unlock();
if ( rc ) {
Error("Can't insert event stats: %s", mysql_error(&dbconn));
}
db_mutex.unlock();
} // end void Zone::RecordStats( const Event *event )
bool Zone::CheckOverloadCount() {