Rough in an importance setting in monitor that we can use to decrease the log level of certain events like PrimeCapture for cameras that we don't care about

This commit is contained in:
Isaac Connor 2021-04-11 12:58:05 -04:00
parent aadfa1e6e1
commit ed29021179
5 changed files with 163 additions and 4 deletions

View File

@ -538,6 +538,7 @@ CREATE TABLE `Monitors` (
`Longitude` DECIMAL(10,8),
`RTSPServer` BOOLEAN NOT NULL DEFAULT FALSE,
`RTSPStreamName` varchar(255) NOT NULL default '',
`Importance` enum('Not','Less','Normal'),
PRIMARY KEY (`Id`)
) ENGINE=@ZM_MYSQL_ENGINE@;

144
db/zm_update-1.35.25.sql Normal file
View File

@ -0,0 +1,144 @@
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'TotalEvents'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `TotalEvents`",
"SELECT 'Column TotalEvents already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'TotalEventDiskSpace'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `TotalEventDiskSpace`",
"SELECT 'Column TotalEventDiskSpace already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'HourEvents'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `HourEvents`",
"SELECT 'Column HourEvents already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'HourEventDiskSpace'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `HourEventDiskSpace`",
"SELECT 'Column HourEventDiskSpace already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'DayEvents'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `DayEvents`",
"SELECT 'Column DayEvents already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'DayEvents'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `DayEventDiskSpace`",
"SELECT 'Column DayEventDiskSpace already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'WeekEvents'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `WeekEvents`",
"SELECT 'Column WeekEvents already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'WeekEventDiskSpace'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `WeekEventDiskSpace`",
"SELECT 'Column WeekEventDiskSpace already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'MonthEvents'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `MonthEvents`",
"SELECT 'Column MonthEvents already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'MonthEventDiskSpace'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `MonthEventDiskSpace`",
"SELECT 'Column MonthEventDiskSpace already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'ArchivedEvents'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `ArchivedEvents`",
"SELECT 'Column ArchivedEvents already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
AND column_name = 'ArchivedEventDiskSpace'
) > 0,
"ALTER TABLE `Monitor_Status` DROP `ArchivedEventDiskSpace`",
"SELECT 'Column ArchivedEventDiskSpace already removed from Monitor_Status'"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitors'
AND column_name = 'Importance'
) > 0,
"SELECT 'Column Importance already exists in Monitors'",
"ALTER TABLE `Monitors` ADD `Importance` enum('Not','Less','Normal') AFTER `RTSPStreamName`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;

View File

@ -356,6 +356,7 @@ Monitor::Monitor()
embed_exif(0),
rtsp_server(0),
rtsp_streamname(""),
importance(0),
capture_max_fps(0),
purpose(QUERY),
last_camera_bytes(0),
@ -442,7 +443,7 @@ Monitor::Monitor()
"SectionLength, MinSectionLength, FrameSkip, MotionFrameSkip, "
"FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif,"
"`RTSPServer`,`RTSPStreamName`,
"SignalCheckPoints, SignalCheckColour FROM Monitors";
"SignalCheckPoints, SignalCheckColour, Importance-2 FROM Monitors";
*/
void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
@ -588,6 +589,7 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
rtsp_streamname = dbrow[col]; col++;
signal_check_points = atoi(dbrow[col]); col++;
signal_check_colour = strtol(dbrow[col][0] == '#' ? dbrow[col]+1 : dbrow[col], 0, 16); col++;
importance = atoi(dbrow[col]); col++;
// How many frames we need to have before we start analysing
ready_count = std::max(warmup_count, pre_event_count);
@ -3201,9 +3203,6 @@ int Monitor::PrimeCapture() {
} else {
analysis_thread->Start();
}
} else {
Debug(2, "Failed to prime %d", ret);
}
return ret;
} // end int Monitor::PrimeCapture()

View File

@ -319,6 +319,7 @@ protected:
bool embed_exif; // Whether to embed Exif data into each image frame or not
bool rtsp_server; // Whether to include this monitor as an rtsp server stream
std::string rtsp_streamname; // path in the rtsp url for this monitor
int importance; // Importance of this monitor, affects Connection logging errors.
int capture_max_fps;
@ -592,6 +593,7 @@ public:
double get_analysis_fps( ) const {
return shared_data ? shared_data->analysis_fps : 0.0;
}
int Importance() { return importance; }
};
#define MOD_ADD( var, delta, limit ) (((var)+(limit)+(delta))%(limit))

View File

@ -1252,6 +1252,19 @@ echo htmlSelect('newMonitor[ReturnLocation]', $return_options, $monitor->ReturnL
<td class="text-right pr-3"><?php echo translate('RTSPStreamName'); echo makeHelpLink('OPTIONS_RTSPSTREAMNAME') ?></td>
<td><input type="text" name="newMonitor[RTSPStreamName]" value="<?php echo validHtmlStr($monitor->RTSPStreamName()) ?>"/></td>
</tr>
<tr>
<td class="text-right pr-3"><?php echo translate('Importance'); echo makeHelpLink('OPTIONS_IMPORTANCE') ?></td>
<td>
<?php
echo htmlselect('newMonitor[Importance]',
array(
'Not'=>translate('Not important'),
'Less'=>translate('Less important'),
'Normal'=>translate('Normal')
), $monitor->Importance());
?>
</td>
</tr>
<?php
break;
}