merged master storage areas, resolved conflicts
This commit is contained in:
commit
95eb1d3045
|
@ -22,6 +22,7 @@ db/zm_create.sql
|
|||
depcomp
|
||||
docs/_build
|
||||
install-sh
|
||||
install_manifest.txt
|
||||
misc/CMakeFiles/
|
||||
misc/apache.conf
|
||||
misc/cmake_install.cmake
|
||||
|
@ -85,11 +86,40 @@ scripts/zmupdate.pl
|
|||
scripts/zmvideo.pl
|
||||
scripts/zmwatch.pl
|
||||
scripts/zmx10.pl
|
||||
scripts/zoneminder-zmaudit.pl.8
|
||||
scripts/zoneminder-zmaudit.pl.8.gz
|
||||
scripts/zoneminder-zmcamtool.pl.8
|
||||
scripts/zoneminder-zmcamtool.pl.8.gz
|
||||
scripts/zoneminder-zmcontrol.pl.8
|
||||
scripts/zoneminder-zmcontrol.pl.8.gz
|
||||
scripts/zoneminder-zmdc.pl.8
|
||||
scripts/zoneminder-zmdc.pl.8.gz
|
||||
scripts/zoneminder-zmfilter.pl.8
|
||||
scripts/zoneminder-zmfilter.pl.8.gz
|
||||
scripts/zoneminder-zmpkg.pl.8
|
||||
scripts/zoneminder-zmpkg.pl.8.gz
|
||||
scripts/zoneminder-zmsystemctl.pl.8
|
||||
scripts/zoneminder-zmsystemctl.pl.8.gz
|
||||
scripts/zoneminder-zmtelemetry.pl.8
|
||||
scripts/zoneminder-zmtelemetry.pl.8.gz
|
||||
scripts/zoneminder-zmtrack.pl.8
|
||||
scripts/zoneminder-zmtrack.pl.8.gz
|
||||
scripts/zoneminder-zmtrigger.pl.8
|
||||
scripts/zoneminder-zmtrigger.pl.8.gz
|
||||
scripts/zoneminder-zmupdate.pl.8
|
||||
scripts/zoneminder-zmupdate.pl.8.gz
|
||||
scripts/zoneminder-zmvideo.pl.8
|
||||
scripts/zoneminder-zmvideo.pl.8.gz
|
||||
scripts/zoneminder-zmwatch.pl.8
|
||||
scripts/zoneminder-zmwatch.pl.8.gz
|
||||
scripts/zoneminder-zmx10.pl.8
|
||||
scripts/zoneminder-zmx10.pl.8.gz
|
||||
src/*.o
|
||||
src/.deps/
|
||||
src/CMakeFiles/
|
||||
src/cmake_install.cmake
|
||||
src/libzm.a
|
||||
src/nph-zms
|
||||
src/zm_config.h
|
||||
src/zm_config_defines.h
|
||||
src/zma
|
||||
|
@ -97,6 +127,16 @@ src/zmc
|
|||
src/zmf
|
||||
src/zms
|
||||
src/zmu
|
||||
src/zoneminder-zma.8
|
||||
src/zoneminder-zma.8.gz
|
||||
src/zoneminder-zmc.8
|
||||
src/zoneminder-zmc.8.gz
|
||||
src/zoneminder-zmf.8
|
||||
src/zoneminder-zmf.8.gz
|
||||
src/zoneminder-zmstreamer.8
|
||||
src/zoneminder-zmstreamer.8.gz
|
||||
src/zoneminder-zmu.8
|
||||
src/zoneminder-zmu.8.gz
|
||||
stamp-h.in
|
||||
stamp-h1
|
||||
web/CMakeFiles/
|
||||
|
@ -104,12 +144,16 @@ web/api/CMakeFiles/
|
|||
web/api/app/Config/bootstrap.php
|
||||
web/api/app/Config/core.php
|
||||
web/api/cmake_install.cmake
|
||||
web/cgi-bin/
|
||||
web/cmake_install.cmake
|
||||
web/events/
|
||||
web/images/
|
||||
web/includes/config.php
|
||||
web/tools/mootools/CMakeFiles/
|
||||
web/tools/mootools/cmake_install.cmake
|
||||
web/tools/mootools/mootools-core.js
|
||||
web/tools/mootools/mootools-more.js
|
||||
web/undef.log
|
||||
zm.conf
|
||||
zmconfgen.pl
|
||||
zmlinkcontent.sh
|
||||
|
|
|
@ -2,3 +2,6 @@
|
|||
path = web/api/app/Plugin/Crud
|
||||
url = https://github.com/FriendsOfCake/crud.git
|
||||
branch = 3.0
|
||||
[submodule "web/api/app/Plugin/CakePHP-Enum-Behavior"]
|
||||
path = web/api/app/Plugin/CakePHP-Enum-Behavior
|
||||
url = https://github.com/connortechnology/CakePHP-Enum-Behavior.git
|
||||
|
|
|
@ -58,6 +58,7 @@ if(NOT HOST_OS)
|
|||
"ZoneMinder was unable to deterimine the host OS. Please report this. Value of CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
|
||||
endif(NOT HOST_OS)
|
||||
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
# Default CLFAGS and CXXFLAGS:
|
||||
set(CMAKE_C_FLAGS_RELEASE "-Wall -D__STDC_CONSTANT_MACROS -O2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-Wall -D__STDC_CONSTANT_MACROS -O2")
|
||||
|
@ -172,7 +173,7 @@ set(ZM_PATH_ARP "" CACHE PATH
|
|||
"Full path to compatible arp binary. Leave empty for automatic detection.")
|
||||
set(ZM_CONFIG_DIR "/${CMAKE_INSTALL_SYSCONFDIR}" CACHE PATH
|
||||
"Location of ZoneMinder configuration, default system config directory")
|
||||
set(ZM_CONFIG_SUBDIR "${ZM_CONFIG_DIR}/zm/conf.d" CACHE PATH
|
||||
set(ZM_CONFIG_SUBDIR "${ZM_CONFIG_DIR}/conf.d" CACHE PATH
|
||||
"Location of ZoneMinder configuration subfolder, default: ZM_CONFIG_DIR/conf.d")
|
||||
set(ZM_EXTRA_LIBS "" CACHE STRING
|
||||
"A list of optional libraries, separated by semicolons, e.g. ssl;theora")
|
||||
|
@ -575,6 +576,7 @@ if(NOT ZM_NO_FFMPEG)
|
|||
mark_as_advanced(FORCE AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIR)
|
||||
check_include_file("libavutil/avutil.h" HAVE_LIBAVUTIL_AVUTIL_H)
|
||||
check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H)
|
||||
check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H)
|
||||
set(optlibsfound "${optlibsfound} AVUtil")
|
||||
else(AVUTIL_LIBRARIES)
|
||||
set(optlibsnotfound "${optlibsnotfound} AVUtil")
|
||||
|
@ -646,13 +648,13 @@ if(NOT ZM_NO_LIBVLC)
|
|||
endif(LIBVLC_LIBRARIES)
|
||||
endif(NOT ZM_NO_LIBVLC)
|
||||
|
||||
find_package(Boost 1.36.0)
|
||||
if(Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIRS}")
|
||||
list(APPEND ZM_BIN_LIBS "${Boost_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
#find_package(Boost 1.36.0)
|
||||
#if(Boost_FOUND)
|
||||
#include_directories(${Boost_INCLUDE_DIRS})
|
||||
##set(CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIRS}")
|
||||
#list(APPEND ZM_BIN_LIBS "${Boost_LIBRARIES}")
|
||||
#endif()
|
||||
#
|
||||
# *** END OF LIBRARY CHECKS ***
|
||||
|
||||
# Check for gnutls or crypto
|
||||
|
@ -867,7 +869,7 @@ else(zmconfgen_result EQUAL 0)
|
|||
"ZoneMinder configuration generator failed. Exit code: ${zmconfgen_result}")
|
||||
endif(zmconfgen_result EQUAL 0)
|
||||
|
||||
# Install zm.conf and conf.d subfolder
|
||||
# Install zm.conf
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zm.conf" DESTINATION "${ZM_CONFIG_DIR}")
|
||||
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/conf.d/" DESTINATION "${ZM_CONFIG_SUBDIR}" PATTERN "*.in" EXCLUDE)
|
||||
|
||||
|
@ -886,3 +888,4 @@ if(CCACHE_FOUND)
|
|||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif(CCACHE_FOUND)
|
||||
|
||||
install(DIRECTORY icons DESTINATION "${CMAKE_INSTALL_DATADIR}/zoneminder/")
|
||||
|
|
|
@ -11,3 +11,6 @@ install(FILES ${dbfileslist} DESTINATION "${CMAKE_INSTALL_DATADIR}/zoneminder/db
|
|||
|
||||
# install zm_create.sql
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zm_create.sql" DESTINATION "${CMAKE_INSTALL_DATADIR}/zoneminder/db")
|
||||
|
||||
# install triggers.sql
|
||||
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/triggers.sql" DESTINATION "${CMAKE_INSTALL_DATADIR}/zoneminder/db")
|
||||
|
|
|
@ -0,0 +1,262 @@
|
|||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Hour_delete_trigger//
|
||||
CREATE TRIGGER Events_Hour_delete_trigger BEFORE DELETE ON Events_Hour
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,1)-1,
|
||||
HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Hour_update_trigger//
|
||||
|
||||
CREATE TRIGGER Events_Hour_update_trigger AFTER UPDATE ON Events_Hour
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
DELIMITER ;
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Day_delete_trigger//
|
||||
CREATE TRIGGER Events_Day_delete_trigger BEFORE DELETE ON Events_Day
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
DayEvents = COALESCE(DayEvents,1)-1,
|
||||
DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Day_update_trigger;
|
||||
CREATE TRIGGER Events_Day_update_trigger AFTER UPDATE ON Events_Day
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Week_delete_trigger//
|
||||
CREATE TRIGGER Events_Week_delete_trigger BEFORE DELETE ON Events_Week
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
WeekEvents = COALESCE(WeekEvents,1)-1,
|
||||
WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Week_update_trigger;
|
||||
CREATE TRIGGER Events_Week_update_trigger AFTER UPDATE ON Events_Week
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Month_delete_trigger//
|
||||
CREATE TRIGGER Events_Month_delete_trigger BEFORE DELETE ON Events_Month
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
MonthEvents = COALESCE(MonthEvents,1)-1,
|
||||
MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Month_update_trigger;
|
||||
CREATE TRIGGER Events_Month_update_trigger AFTER UPDATE ON Events_Month
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+COALESCE(NEW.DiskSpace) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
drop procedure if exists update_storage_stats;
|
||||
create procedure update_storage_stats(IN StorageId smallint(5), IN space BIGINT)
|
||||
|
||||
sql security invoker
|
||||
|
||||
deterministic
|
||||
|
||||
begin
|
||||
|
||||
update Storage set DiskSpace = COALESCE(DiskSpace,0) + COALESCE(space,0) where Id = StorageId;
|
||||
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
drop trigger if exists event_update_trigger//
|
||||
|
||||
CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
||||
IF ( diff ) THEN
|
||||
call update_storage_stats(OLD.StorageId, diff);
|
||||
END IF;
|
||||
ELSE
|
||||
IF ( NEW.DiskSpace ) THEN
|
||||
call update_storage_stats(NEW.StorageId, NEW.DiskSpace);
|
||||
END IF;
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Week SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Month SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
|
||||
IF ( NEW.Archived != OLD.Archived ) THEN
|
||||
IF ( NEW.Archived ) THEN
|
||||
INSERT INTO Events_Archived (EventId,MonitorId,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.DiskSpace);
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)+1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=NEW.MonitorId;
|
||||
ELSEIF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)-1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
ELSEIF ( NEW.Archived AND diff ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
END IF;
|
||||
|
||||
IF ( diff ) THEN
|
||||
UPDATE Monitors SET TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger;
|
||||
|
||||
delimiter //
|
||||
/* The assumption is that when an Event is inserted, it has no size yet, so don't bother updating the DiskSpace, just the count.
|
||||
* The DiskSpace will get update in the Event Update Trigger
|
||||
*/
|
||||
CREATE TRIGGER event_insert_trigger AFTER INSERT ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,0)+1,
|
||||
DayEvents = COALESCE(DayEvents,0)+1,
|
||||
WeekEvents = COALESCE(WeekEvents,0)+1,
|
||||
MonthEvents = COALESCE(MonthEvents,0)+1,
|
||||
TotalEvents = COALESCE(TotalEvents,0)+1
|
||||
WHERE Id=NEW.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS event_delete_trigger//
|
||||
|
||||
CREATE TRIGGER event_delete_trigger BEFORE DELETE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Day WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Week WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Month WHERE EventId=OLD.Id;
|
||||
IF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEvents = COALESCE(ArchivedEvents,1) - 1,
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0),
|
||||
TotalEvents = COALESCE(TotalEvents,1) - 1,
|
||||
TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET
|
||||
TotalEvents = COALESCE(TotalEvents,1)-1,
|
||||
TotalEventDiskSpace=COALESCE(TotalEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Zone_Insert_Trigger//
|
||||
CREATE TRIGGER Zone_Insert_Trigger AFTER INSERT ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=NEW.MonitorId) WHERE Id=NEW.MonitorID;
|
||||
END
|
||||
//
|
||||
DROP TRIGGER IF EXISTS Zone_Delete_Trigger//
|
||||
CREATE TRIGGER Zone_Delete_Trigger AFTER DELETE ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=OLD.MonitorId) WHERE Id=OLD.MonitorID;
|
||||
END
|
||||
//
|
||||
|
||||
DELIMITER ;
|
|
@ -184,6 +184,7 @@ DROP TABLE IF EXISTS `Events`;
|
|||
CREATE TABLE `Events` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`MonitorId` int(10) unsigned NOT NULL default '0',
|
||||
`StorageId` smallint(5) unsigned default 0,
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
`Cause` varchar(32) NOT NULL default '',
|
||||
`StartTime` datetime default NULL,
|
||||
|
@ -193,7 +194,8 @@ CREATE TABLE `Events` (
|
|||
`Length` decimal(10,2) NOT NULL default '0.00',
|
||||
`Frames` int(10) unsigned default NULL,
|
||||
`AlarmFrames` int(10) unsigned default NULL,
|
||||
`DefaultVideo` VARCHAR( 64 ) NOT NULL,
|
||||
`DefaultVideo` VARCHAR( 64 ) DEFAULT '' NOT NULL,
|
||||
`SaveJPEGs` TINYINT,
|
||||
`TotScore` int(10) unsigned NOT NULL default '0',
|
||||
`AvgScore` smallint(5) unsigned default '0',
|
||||
`MaxScore` smallint(5) unsigned default '0',
|
||||
|
@ -205,11 +207,68 @@ CREATE TABLE `Events` (
|
|||
`Executed` tinyint(3) unsigned NOT NULL default '0',
|
||||
`Notes` text,
|
||||
`StateId` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`Id`,`MonitorId`),
|
||||
KEY `MonitorId` (`MonitorId`),
|
||||
KEY `StartTime` (`StartTime`),
|
||||
KEY `Frames` (`Frames`),
|
||||
KEY `Archived` (`Archived`)
|
||||
`Orientation` enum('0','90','180','270','hori','vert') NOT NULL default '0',
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
`Scheme` enum('Deep','Medium','Shallow') NOT NULL default 'Medium',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `Events_MonitorId_idx` (`MonitorId`),
|
||||
KEY `Events_StorageId_idx` (`StorageId`),
|
||||
KEY `Events_StartTime_idx` (`StartTime`),
|
||||
KEY `Events_EndTime_DiskSpace` (`EndTime`,`DiskSpace`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
DROP TABLE IF EXISTS `Events_Hour`;
|
||||
CREATE TABLE `Events_Hour` (
|
||||
`EventId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`StartTime` datetime default NULL,
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
PRIMARY KEY (`EventId`),
|
||||
KEY `Events_Hour_MonitorId_idx` (`MonitorId`),
|
||||
KEY `Events_Hour_StartTime_idx` (`StartTime`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
DROP TABLE IF EXISTS `Events_Day`;
|
||||
CREATE TABLE `Events_Day` (
|
||||
`EventId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`StartTime` datetime default NULL,
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
PRIMARY KEY (`EventId`),
|
||||
KEY `Events_Day_MonitorId_idx` (`MonitorId`),
|
||||
KEY `Events_Day_StartTime_idx` (`StartTime`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
DROP TABLE IF EXISTS `Events_Week`;
|
||||
CREATE TABLE `Events_Week` (
|
||||
`EventId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`StartTime` datetime default NULL,
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
PRIMARY KEY (`EventId`),
|
||||
KEY `Events_Week_MonitorId_idx` (`MonitorId`),
|
||||
KEY `Events_Week_StartTime_idx` (`StartTime`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
DROP TABLE IF EXISTS `Events_Month`;
|
||||
CREATE TABLE `Events_Month` (
|
||||
`EventId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`StartTime` datetime default NULL,
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
PRIMARY KEY (`EventId`),
|
||||
KEY `Events_Month_MonitorId_idx` (`MonitorId`),
|
||||
KEY `Events_Month_StartTime_idx` (`StartTime`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `Events_Archived`;
|
||||
CREATE TABLE `Events_Archived` (
|
||||
`EventId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
PRIMARY KEY (`EventId`),
|
||||
KEY `Events_Archived_MonitorId_idx` (`MonitorId`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
--
|
||||
|
@ -218,6 +277,7 @@ CREATE TABLE `Events` (
|
|||
|
||||
DROP TABLE IF EXISTS `Filters`;
|
||||
CREATE TABLE `Filters` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
`Query` text NOT NULL,
|
||||
`AutoArchive` tinyint(3) unsigned NOT NULL default '0',
|
||||
|
@ -228,8 +288,13 @@ CREATE TABLE `Filters` (
|
|||
`AutoExecute` tinyint(3) unsigned NOT NULL default '0',
|
||||
`AutoExecuteCmd` tinytext,
|
||||
`AutoDelete` tinyint(3) unsigned NOT NULL default '0',
|
||||
`AutoMove` tinyint(3) unsigned NOT NULL default '0',
|
||||
`AutoMoveTo` smallint(5) unsigned NOT NULL default 0,
|
||||
`UpdateDiskSpace` tinyint(3) unsigned NOT NULL default '0',
|
||||
`Background` tinyint(1) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`Name`)
|
||||
`Concurrent` tinyint(1) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `Name` (`Name`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
--
|
||||
|
@ -259,10 +324,25 @@ DROP TABLE IF EXISTS `Groups`;
|
|||
CREATE TABLE `Groups` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
`MonitorIds` tinytext NOT NULL,
|
||||
`ParentId` int(10) unsigned,
|
||||
PRIMARY KEY (`Id`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
--
|
||||
-- Table structure for table `Groups_Monitors`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Groups_Monitors`;
|
||||
CREATE TABLE `Groups_Monitors` (
|
||||
`Id` INT(10) unsigned NOT NULL auto_increment,
|
||||
`GroupId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`Id`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
CREATE INDEX `Groups_Monitors_GroupId_idx` ON `Groups_Monitors` (`GroupId`);
|
||||
CREATE INDEX `Groups_Monitors_MonitorId_idx` ON `Groups_Monitors` (`MonitorId`);
|
||||
|
||||
--
|
||||
-- Table structure for table `Logs`
|
||||
--
|
||||
|
@ -281,6 +361,33 @@ CREATE TABLE `Logs` (
|
|||
KEY `TimeKey` (`TimeKey`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
CREATE INDEX `Logs_TimeKey_idx` ON `Logs` (`TimeKey`);
|
||||
CREATE INDEX `Logs_Level_idx` ON `Logs` (`Level`);
|
||||
--
|
||||
-- Table structure for table `Manufacturers`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Manufacturers`;
|
||||
CREATE TABLE `Manufacturers` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` varchar(64) NOT NULL,
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY (`Name`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
--
|
||||
-- Table structure for table `Models`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Models`;
|
||||
CREATE TABLE `Models` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` varchar(64) NOT NULL,
|
||||
`ManufacturerId` int(10),
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY (`ManufacturerId`,`Name`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
--
|
||||
-- Table structure for table `MonitorPresets`
|
||||
--
|
||||
|
@ -289,7 +396,7 @@ DROP TABLE IF EXISTS `MonitorPresets`;
|
|||
CREATE TABLE `MonitorPresets` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
`Type` enum('Local','Remote','File','Ffmpeg','Libvlc','cURL') NOT NULL default 'Local',
|
||||
`Type` enum('Local','Remote','File','Ffmpeg','Libvlc','cURL','NVSocket') NOT NULL default 'Local',
|
||||
`Device` tinytext,
|
||||
`Channel` tinyint(3) unsigned default NULL,
|
||||
`Format` int(10) unsigned default NULL,
|
||||
|
@ -321,6 +428,7 @@ CREATE TABLE `Monitors` (
|
|||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
`ServerId` int(10) unsigned,
|
||||
`StorageId` smallint(5) unsigned default 0,
|
||||
`Type` enum('Local','Remote','File','Ffmpeg','Libvlc','cURL') NOT NULL default 'Local',
|
||||
`Function` enum('None','Monitor','Modect','Record','Mocord','Nodect') NOT NULL default 'Monitor',
|
||||
`Enabled` tinyint(3) unsigned NOT NULL default '1',
|
||||
|
@ -331,13 +439,13 @@ CREATE TABLE `Monitors` (
|
|||
`Format` int(10) unsigned NOT NULL default '0',
|
||||
`V4LMultiBuffer` tinyint(1) unsigned,
|
||||
`V4LCapturesPerFrame` tinyint(3) unsigned,
|
||||
`Protocol` varchar(16) default '',
|
||||
`Method` varchar(16) NOT NULL default '',
|
||||
`Protocol` varchar(16),
|
||||
`Method` varchar(16) default '',
|
||||
`Host` varchar(64),
|
||||
`Port` varchar(8) NOT NULL default '',
|
||||
`SubPath` varchar(64) NOT NULL default '',
|
||||
`Path` varchar(255),
|
||||
`Options` varchar(255) default '',
|
||||
`Options` varchar(255),
|
||||
`User` varchar(64),
|
||||
`Pass` varchar(64),
|
||||
`Width` smallint(5) unsigned NOT NULL default '0',
|
||||
|
@ -348,6 +456,8 @@ CREATE TABLE `Monitors` (
|
|||
`Deinterlacing` int(10) unsigned NOT NULL default '0',
|
||||
`SaveJPEGs` TINYINT NOT NULL DEFAULT '3' ,
|
||||
`VideoWriter` TINYINT NOT NULL DEFAULT '0',
|
||||
`OutputCodec` enum('h264','mjpeg','mpeg1','mpeg2'),
|
||||
`OutputContainer` enum('auto','mp4','mkv'),
|
||||
`EncoderParameters` TEXT,
|
||||
`RecordAudio` TINYINT NOT NULL DEFAULT '0',
|
||||
`RTSPDescribe` tinyint(1) unsigned,
|
||||
|
@ -356,7 +466,7 @@ CREATE TABLE `Monitors` (
|
|||
`Hue` mediumint(7) NOT NULL default '-1',
|
||||
`Colour` mediumint(7) NOT NULL default '-1',
|
||||
`EventPrefix` varchar(32) NOT NULL default 'Event-',
|
||||
`LabelFormat` varchar(64),
|
||||
`LabelFormat` varchar(64) default '%N - %y/%m/%d %H:%M:%S',
|
||||
`LabelX` smallint(5) unsigned NOT NULL default '0',
|
||||
`LabelY` smallint(5) unsigned NOT NULL default '0',
|
||||
`LabelSize` smallint(5) unsigned NOT NULL DEFAULT '1',
|
||||
|
@ -369,7 +479,7 @@ CREATE TABLE `Monitors` (
|
|||
`SectionLength` int(10) unsigned NOT NULL default '600',
|
||||
`FrameSkip` smallint(5) unsigned NOT NULL default '0',
|
||||
`MotionFrameSkip` smallint(5) unsigned NOT NULL default '0',
|
||||
`AnalysisFPS` decimal(5,2) default NULL,
|
||||
`AnalysisFPSLimit` decimal(5,2) default NULL,
|
||||
`AnalysisUpdateDelay` smallint(5) unsigned NOT NULL default '0',
|
||||
`MaxFPS` decimal(5,2) default NULL,
|
||||
`AlarmMaxFPS` decimal(5,2) default NULL,
|
||||
|
@ -392,9 +502,32 @@ CREATE TABLE `Monitors` (
|
|||
`WebColour` varchar(32) NOT NULL default 'red',
|
||||
`Exif` tinyint(1) unsigned NOT NULL default '0',
|
||||
`Sequence` smallint(5) unsigned default NULL,
|
||||
`TotalEvents` int(10) default NULL,
|
||||
`TotalEventDiskSpace` bigint default NULL,
|
||||
`HourEvents` int(10) default NULL,
|
||||
`HourEventDiskSpace` bigint default NULL,
|
||||
`DayEvents` int(10) default NULL,
|
||||
`DayEventDiskSpace` bigint default NULL,
|
||||
`WeekEvents` int(10) default NULL,
|
||||
`WeekEventDiskSpace` bigint default NULL,
|
||||
`MonthEvents` int(10) default NULL,
|
||||
`MonthEventDiskSpace` bigint default NULL,
|
||||
`ArchivedEvents` int(10) default NULL,
|
||||
`ArchivedEventDiskSpace` bigint default NULL,
|
||||
`ZoneCount` TINYINT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`Id`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
CREATE INDEX `Monitors_ServerId_idx` ON `Monitors` (`ServerId`);
|
||||
|
||||
DROP TABLE IF EXISTS `Monitor_Status`;
|
||||
CREATE TABLE `Monitor_Status` (
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`Status` enum('Unknown','NotRunning','Running','Connected','Signal') NOT NULL default 'Unknown',
|
||||
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||
PRIMARY KEY (`MonitorId`)
|
||||
) ENGINE=MEMORY;
|
||||
--
|
||||
-- Table structure for table `States`
|
||||
-- PP - Added IsActive to track custom run states
|
||||
|
@ -422,8 +555,20 @@ CREATE TABLE `Servers` (
|
|||
`Hostname` TEXT,
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
`State_Id` int(10) unsigned,
|
||||
`Status` enum('Unknown','NotRunning','Running') NOT NULL default 'Unknown',
|
||||
`Load` DECIMAL(5,1),
|
||||
`TotalMem` bigint unsigned default null,
|
||||
`FreeMem` bigint unsigned default null,
|
||||
`TotalSwap` bigint unsigned default null,
|
||||
`FreeSwap` bigint unsigned default null,
|
||||
`zmstats` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`zmaudit` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`zmtrigger` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY (`Id`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
CREATE INDEX `Servers_Name_idx` ON `Servers` (`Name`);
|
||||
|
||||
--
|
||||
-- Table structure for table `Stats`
|
||||
--
|
||||
|
@ -550,6 +695,24 @@ CREATE TABLE `Zones` (
|
|||
KEY `MonitorId` (`MonitorId`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
DROP TABLE IF EXISTS `Storage`;
|
||||
CREATE TABLE `Storage` (
|
||||
`Id` smallint(5) unsigned NOT NULL auto_increment,
|
||||
`Path` varchar(64) NOT NULL default '',
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
`Type` enum('local','s3fs') NOT NULL default 'local',
|
||||
`Url` varchar(255) default NULL,
|
||||
`DiskSpace` bigint default NULL,
|
||||
`Scheme` enum('Deep','Medium','Shallow') NOT NULL default 'Medium',
|
||||
`ServerId` int(10) unsigned,
|
||||
PRIMARY KEY (`Id`)
|
||||
) ENGINE=@ZM_MYSQL_ENGINE@;
|
||||
|
||||
--
|
||||
-- Create a default storage location
|
||||
--
|
||||
insert into Storage VALUES (NULL, '/var/cache/zoneminder/events', 'Default', 'local', NULL, 'Medium', 0 );
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
|
@ -570,7 +733,9 @@ insert into Users VALUES (NULL,'admin',password('admin'),'',1,'View','Edit','Edi
|
|||
--
|
||||
-- Add a sample filter to purge the oldest 100 events when the disk is 95% full
|
||||
--
|
||||
insert into Filters values ('PurgeWhenFull','{"sort_field":"Id","terms":[{"val":0,"attr":"Archived","op":"="},{"cnj":"and","val":95,"attr":"DiskPercent","op":">="}],"limit":100,"sort_asc":1}',0,0,0,0,0,0,'',1,1);
|
||||
|
||||
insert into Filters values (NULL,'PurgeWhenFull','{"sort_field":"Id","terms":[{"val":0,"attr":"Archived","op":"="},{"cnj":"and","val":95,"attr":"DiskPercent","op":">="}],"limit":100,"sort_asc":1}',0/*AutoArchive*/,0/*AutoVideo*/,0/*AutoUpload*/,0/*AutoEmail*/,0/*AutoMessage*/,0/*AutoExecute*/,'',1/*AutoDelete*/,0/*AutoMove*/,0/*MoveTo*/,0/*UpdateDiskSpace*/,1/*Background*/,0/*Concurrent*/);
|
||||
insert into Filters values (NULL,'Update DiskSpace','{"terms":[{"attr":"DiskSpace","op":"IS","val":"NULL"}]}',0,0,0,0,0,0,'',0,0,0,1,1,0);
|
||||
|
||||
--
|
||||
-- Add in some sample control protocol definitions
|
||||
|
@ -694,6 +859,36 @@ INSERT INTO ZonePresets VALUES (5,'Best, low sensitivity','Active','Percent','Bl
|
|||
INSERT INTO ZonePresets VALUES (6,'Best, medium sensitivity','Active','Percent','Blobs',40,NULL,16,NULL,5,5,12,NULL,10,NULL,1,NULL,0,0);
|
||||
INSERT INTO ZonePresets VALUES (7,'Best, high sensitivity','Active','Percent','Blobs',20,NULL,8,NULL,3,3,6,NULL,5,NULL,1,NULL,0,0);
|
||||
|
||||
DROP TABLE IF EXISTS Maps;
|
||||
|
||||
CREATE TABLE Maps (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` VARCHAR(64) NOT NULL,
|
||||
`Filename` VARCHAR(64) NOT NULL default '',
|
||||
`NumCoords` tinyint(3) unsigned NOT NULL default '0',
|
||||
`Coords` tinytext NOT NULL,
|
||||
`ParentId` int(1) unsigned,
|
||||
PRIMARY KEY (`Id`)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS MontageLayouts;
|
||||
|
||||
CREATE TABLE MontageLayouts (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` TEXT NOT NULL,
|
||||
`Positions` LONGTEXT,
|
||||
/*`Positions` JSON,*/
|
||||
PRIMARY KEY (`Id`)
|
||||
);
|
||||
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('Freeform', '{ "default":{"float":"left","left":"0px","right":"0px","top":"0px","bottom":"0px"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('2 Wide', '{ "default":{"float":"left", "width":"49%","left":"0px","right":"0px","top":"0px","bottom":"0px"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('3 Wide', '{ "default":{"float":"left", "width":"33%","left":"0px","right":"0px","top":"0px","bottom":"0px"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('4 Wide', '{ "default":{"float":"left", "width":"24.5%","left":"0px","right":"0px","top":"0px","bottom":"0px"} }' );
|
||||
INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES ('5 Wide', '{ "default":{"float":"left", "width":"19%","left":"0px","right":"0px","top":"0px","bottom":"0px"} }' );
|
||||
|
||||
-- We generally don't alter triggers, we drop and re-create them, so let's keep them in a separate file that we can just source in update scripts.
|
||||
source @ZM_PATH_DATA@/db/triggers.sql
|
||||
--
|
||||
-- Apply the initial configuration
|
||||
--
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
-- This updates a 1.28.109 database to 1.28.110
|
||||
--
|
||||
|
||||
--
|
||||
-- Update Frame table to have a PrimaryKey of ID, insetad of a Composite Primary Key
|
||||
-- Used primarially for compatibility with CakePHP
|
||||
--
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
--
|
||||
-- This updates a 1.29.0 database to 1.29.1
|
||||
--
|
||||
--
|
||||
|
||||
-- Increase the size of the Pid field for FreeBSD
|
||||
ALTER TABLE Logs MODIFY Pid int(10);
|
|
@ -1,7 +1,110 @@
|
|||
--
|
||||
-- This updates a 1.30.0 database to 1.30.1
|
||||
--
|
||||
-- Alter type of Messages column from VARCHAR(255) to TEXT
|
||||
-- This updates a 1.28.108 database to 1.28.109
|
||||
--
|
||||
|
||||
ALTER TABLE Logs MODIFY Message TEXT;
|
||||
--
|
||||
-- Add Controls definition for Vivotek ePTZ
|
||||
--
|
||||
INSERT INTO Controls
|
||||
SELECT * FROM (SELECT NULL as Id,
|
||||
'Vivotek ePTZ' as Name,
|
||||
'Remote' as Type,
|
||||
'Vivotek_ePTZ' as Protocol,
|
||||
0 as CanWake,
|
||||
0 as CanSleep,
|
||||
1 as CanReset,
|
||||
1 as CanZoom,
|
||||
0 as CanAutoZoom,
|
||||
0 as CanZoomAbs,
|
||||
0 as CanZoomRel,
|
||||
1 as CanZoomCon,
|
||||
0 as MinZoomRange,
|
||||
0 as MaxZoomRange,
|
||||
0 as MinZoomStep,
|
||||
0 as MaxZoomStep,
|
||||
1 as HasZoomSpeed,
|
||||
0 as MinZoomSpeed,
|
||||
5 as MaxZoomSpeed,
|
||||
0 as CanFocus,
|
||||
0 as CanAutoFocus,
|
||||
0 as CanFocusAbs,
|
||||
0 as CanFocusRel,
|
||||
0 as CanFocusCon,
|
||||
0 as MinFocusRange,
|
||||
0 as MaxFocusRange,
|
||||
0 as MinFocusStep,
|
||||
0 as MaxFocusStep,
|
||||
0 as HasFocusSpeed,
|
||||
0 as MinFocusSpeed,
|
||||
0 as MaxFocusSpeed,
|
||||
0 as CanIris,
|
||||
0 as CanAutoIris,
|
||||
0 as CanIrisAbs,
|
||||
0 as CanIrisRel,
|
||||
0 as CanIrisCon,
|
||||
0 as MinIrisRange,
|
||||
0 as MaxIrisRange,
|
||||
0 as MinIrisStep,
|
||||
0 as MaxIrisStep,
|
||||
0 as HasIrisSpeed,
|
||||
0 as MinIrisSpeed,
|
||||
0 as MaxIrisSpeed,
|
||||
0 as CanGain,
|
||||
0 as CanAutoGain,
|
||||
0 as CanGainAbs,
|
||||
0 as CanGainRel,
|
||||
0 as CanGainCon,
|
||||
0 as MinGainRange,
|
||||
0 as MaxGainRange,
|
||||
0 as MinGainStep,
|
||||
0 as MaxGainStep,
|
||||
0 as HasGainSpeed,
|
||||
0 as MinGainSpeed,
|
||||
0 as MaxGainSpeed,
|
||||
0 as CanWhite,
|
||||
0 as CanAutoWhite,
|
||||
0 as CanWhiteAbs,
|
||||
0 as CanWhiteRel,
|
||||
0 as CanWhiteCon,
|
||||
0 as MinWhiteRange,
|
||||
0 as MaxWhiteRange,
|
||||
0 as MinWhiteStep,
|
||||
0 as MaxWhiteStep,
|
||||
0 as HasWhiteSpeed,
|
||||
0 as MinWhiteSpeed,
|
||||
0 as MaxWhiteSpeed,
|
||||
0 as HasPresets,
|
||||
0 as NumPresets,
|
||||
0 as HasHomePreset,
|
||||
0 as CanSetPresets,
|
||||
1 as CanMove,
|
||||
0 as CanMoveDiag,
|
||||
0 as CanMoveMap,
|
||||
0 as CanMoveAbs,
|
||||
0 as CanMoveRel,
|
||||
1 as CanMoveCon,
|
||||
1 as CanPan,
|
||||
0 as MinPanRange,
|
||||
0 as MaxPanRange,
|
||||
0 as MinPanStep,
|
||||
0 as MaxPanStep,
|
||||
1 as HasPanSpeed,
|
||||
0 as MinPanSpeed,
|
||||
5 as MaxPanSpeed,
|
||||
0 as HasTurboPan,
|
||||
0 as TurboPanSpeed,
|
||||
1 as CanTilt,
|
||||
0 as MinTiltRange,
|
||||
0 as MaxTiltRange,
|
||||
0 as MinTiltStep,
|
||||
0 as MaxTiltStep,
|
||||
1 as HasTiltSpeed,
|
||||
0 as MinTiltSpeed,
|
||||
5 as MaxTiltSpeed,
|
||||
0 as HasTurboTilt,
|
||||
0 as TurboTiltSpeed,
|
||||
0 as CanAutoScan,
|
||||
0 as NumScanPaths) AS tmp
|
||||
WHERE NOT EXISTS (
|
||||
SELECT Name FROM Controls WHERE name = 'Vivotek ePTZ'
|
||||
) LIMIT 1;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--
|
||||
-- This updates a 1.29.0 database to 1.30.0
|
||||
--
|
||||
|
||||
SELECT 'Checking for SaveJPEGs in Monitors';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
|
@ -16,6 +16,7 @@ SET @s = (SELECT IF(
|
|||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SELECT 'Checking for VideoWriter in Monitors';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
|
@ -30,6 +31,7 @@ SET @s = (SELECT IF(
|
|||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SELECT 'Checking for EncoderParameters in Monitors';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
|
@ -44,6 +46,7 @@ SET @s = (SELECT IF(
|
|||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SELECT 'Checking for DefaultVideo in Events';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
|
@ -52,12 +55,13 @@ SET @s = (SELECT IF(
|
|||
AND column_name = 'DefaultVideo'
|
||||
) > 0,
|
||||
"SELECT 'Column DefaultVideo exists in Events'",
|
||||
"ALTER TABLE `Events` ADD `DefaultVideo` VARCHAR( 64 ) NOT NULL AFTER `AlarmFrames`"
|
||||
"ALTER TABLE `Events` ADD `DefaultVideo` VARCHAR( 64 ) NOT NULL default '' AFTER `AlarmFrames`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SELECT 'Checking for RecordAudio in Monitors';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
--
|
||||
-- Add StateId Column to Events.
|
||||
--
|
||||
SELECT 'Checkfor StateId IN Events';
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
--
|
||||
-- Add Type column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'Status'
|
||||
) > 0,
|
||||
"SELECT 'Column Status already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `Status` enum('Unknown','NotRunning','Running') NOT NULL default 'Unknown' AFTER `State_Id`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'CpuLoad'
|
||||
) > 0,
|
||||
"SELECT 'Column CpuLoad already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `CpuLoad` DECIMAL(5,1) default NULL AFTER `Status`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'TotalMem'
|
||||
) > 0,
|
||||
"SELECT 'Column TotalMem already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `TotalMem` bigint unsigned default null AFTER `CpuLoad`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'FreeMem'
|
||||
) > 0,
|
||||
"SELECT 'Column FreeMem already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `FreeMem` bigint unsigned default null AFTER `TotalMem`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'TotalSwap'
|
||||
) > 0,
|
||||
"SELECT 'Column TotalSwap already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `TotalSwap` bigint unsigned default null AFTER `FreeMem`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'FreeSwap'
|
||||
) > 0,
|
||||
"SELECT 'Column FreeSwap already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `FreeSwap` bigint unsigned default null AFTER `TotalSwap`"
|
||||
));
|
||||
|
||||
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 = 'Status'
|
||||
) > 0,
|
||||
"SELECT 'Column Status already exists in Monitors'",
|
||||
"ALTER TABLE Monitors ADD `Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown' AFTER `Sequence`"
|
||||
));
|
||||
|
||||
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 = 'CaptureFPS'
|
||||
) > 0,
|
||||
"SELECT 'Column CaptureFPS already exists in Monitors'",
|
||||
"ALTER TABLE Monitors ADD `CaptureFPS` DECIMAL(10,2) NOT NULL default 0 AFTER `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 = 'AnalysisFPSLimit'
|
||||
) > 0,
|
||||
"SELECT 'Column AnalysisFPSLimit already exists in Monitors'",
|
||||
"ALTER TABLE Monitors CHANGE COLUMN `AnalysisFPS` `AnalysisFPSLimit` DECIMAL(5,2) default NULL"
|
||||
));
|
||||
|
||||
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 = 'AnalysisFPS'
|
||||
) > 0,
|
||||
"SELECT 'Column AnalysisFPS already exists in Monitors'",
|
||||
"ALTER TABLE Monitors ADD `AnalysisFPS` DECIMAL(5,2) NOT NULL default 0 AFTER `CaptureFPS`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,70 @@
|
|||
--
|
||||
-- Add UpdateDiskSpace action to Filters
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Filters'
|
||||
AND column_name = 'UpdateDiskSpace'
|
||||
) > 0,
|
||||
"SELECT 'Column UpdateDiskSpace already exists in Filters'",
|
||||
"ALTER TABLE Filters ADD `UpdateDiskSpace` tinyint(3) unsigned NOT NULL default '0' AFTER `AutoDelete`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
--
|
||||
-- Update Logs table to have some Indexes
|
||||
--
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Logs'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'Logs_TimeKey_idx'
|
||||
) > 0,
|
||||
"SELECT 'Logs_TimeKey_idx already exists on Logs table'",
|
||||
"CREATE INDEX `Logs_TimeKey_idx` ON `Logs` (`TimeKey`)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Logs'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'Logs_Level_idx'
|
||||
) > 0,
|
||||
"SELECT 'Logs_Level_idx already exists on Logs table'",
|
||||
"CREATE INDEX `Logs_Level_idx` ON `Logs` (`Level`)"
|
||||
));
|
||||
|
||||
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 = 'OutputCodec'
|
||||
) > 0,
|
||||
"SELECT 'Column OutputCodec already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `OutputCodec` enum('h264','mjpeg') AFTER `VideoWriter`"
|
||||
));
|
||||
|
||||
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 = 'OutputContainer'
|
||||
) > 0,
|
||||
"SELECT 'Column OutputContainer already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `OutputContainer` enum('mp4','mkv') AFTER `OutputCodec`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
--
|
||||
-- This adds Manufacturers and Models
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name = 'MontageLayouts'
|
||||
AND table_schema = DATABASE()
|
||||
) > 0,
|
||||
"SELECT 'MontageLayouts table exists'",
|
||||
"
|
||||
CREATE TABLE MontageLayouts (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` TEXT NOT NULL,
|
||||
`Positions` LONGTEXT,
|
||||
PRIMARY KEY (`Id`)
|
||||
);
|
||||
"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
DELETE FROM MontageLayouts WHERE Name IN ('Freeform','2 Wide','3 Wide','4 Wide','5 Wide');
|
||||
|
||||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='Freeform') > 0,
|
||||
"SELECT 'Freeform already in layouts'",
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'Freeform\', \'{"default":{"float":"left","position":"relative","left":"0px","right":"0px","top":"0px","bottom":"0px"}}\');'
|
||||
) );
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='2 Wide') > 0,
|
||||
"SELECT '2 Wide already in layouts'",
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'2 Wide\', \'{"default":{"float":"left","position":"relative","width":"49%","left":"0px","right":"0px","top":"0px","bottom":"0px"}}\');'
|
||||
) );
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='3 Wide') > 0,
|
||||
"SELECT '3 Wide already in layouts'",
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'3 Wide\', \'{"default":{"float":"left","position":"relative","width":"33%","left":"0px","right":"0px","top":"0px","bottom":"0px"}}\');'
|
||||
) );
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='4 Wide') > 0,
|
||||
"SELECT '4 Wide already in layouts'",
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'4 Wide\', \'{"default":{"float":"left","position":"relative","width":"24.5%","left":"0px","right":"0px","top":"0px","bottom":"0px"}}\');'
|
||||
) );
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = ( SELECT IF(
|
||||
(SELECT COUNT(*) FROM MontageLayouts WHERE Name='5 Wide') > 0,
|
||||
"SELECT '5 Wide already in layouts'",
|
||||
'INSERT INTO MontageLayouts (`Name`,`Positions`) VALUES (\'5 Wide\', \'{"default":{"float":"left","position":"relative","width":"19%"}}\' );'
|
||||
) );
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,26 @@
|
|||
ALTER TABLE `Monitors` MODIFY `OutputCodec` enum('h264','mjpeg','mpeg1','mpeg2') default 'h264';
|
||||
ALTER TABLE `Monitors` MODIFY `OutputContainer` enum('auto','mp4','mkv') default 'auto';
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Events'
|
||||
AND column_name = 'SaveJPEGs'
|
||||
) > 0,
|
||||
"SELECT 'Column SaveJPEGs already exists in Events'",
|
||||
"ALTER TABLE `Events` ADD `SaveJPEGs` TINYINT AFTER `DefaultVideo`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Storage'
|
||||
AND column_name = 'DiskSpace'
|
||||
) > 0,
|
||||
"SELECT 'Column DiskSpace already exists in Events'",
|
||||
"ALTER TABLE `Storage` ADD `DiskSpace` bigint unsigned default NULL AFTER `Type`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,148 @@
|
|||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Monitors'
|
||||
AND column_name = 'TotalEvents'
|
||||
) > 0,
|
||||
"SELECT 'Column TotalEvents already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `TotalEvents` INT(10) AFTER `AnalysisFPS`"
|
||||
));
|
||||
|
||||
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 = 'TotalEventDiskSpace'
|
||||
) > 0,
|
||||
"SELECT 'Column TotalEventDiskSpace already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `TotalEventDiskSpace` BIGINT AFTER `TotalEvents`"
|
||||
));
|
||||
|
||||
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 = 'HourEvents'
|
||||
) > 0,
|
||||
"SELECT 'Column HourEvents already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `HourEvents` INT(10) AFTER `TotalEvents`"
|
||||
));
|
||||
|
||||
|
||||
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 = 'HourEventDiskSpace'
|
||||
) > 0,
|
||||
"SELECT 'Column HourEventDiskSpace already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `HourEventDiskSpace` BIGINT AFTER `HourEvents`"
|
||||
));
|
||||
|
||||
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 = 'DayEvents'
|
||||
) > 0,
|
||||
"SELECT 'Column DayEvents already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `DayEvents` INT(10) AFTER `HourEvents`"
|
||||
));
|
||||
|
||||
|
||||
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 = 'DayEventDiskSpace'
|
||||
) > 0,
|
||||
"SELECT 'Column DayEventDiskSpace already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `DayEventDiskSpace` BIGINT AFTER `DayEvents`"
|
||||
));
|
||||
|
||||
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 = 'WeekEvents'
|
||||
) > 0,
|
||||
"SELECT 'Column WeekEvents already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `WeekEvents` INT(10) AFTER `DayEvents`"
|
||||
));
|
||||
|
||||
|
||||
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 = 'WeekEventDiskSpace'
|
||||
) > 0,
|
||||
"SELECT 'Column WeekEventDiskSpace already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `WeekEventDiskSpace` BIGINT AFTER `WeekEvents`"
|
||||
));
|
||||
|
||||
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 = 'MonthEvents'
|
||||
) > 0,
|
||||
"SELECT 'Column MonthEvents already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `MonthEvents` INT(10) AFTER `WeekEvents`"
|
||||
));
|
||||
|
||||
|
||||
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 = 'MonthEventDiskSpace'
|
||||
) > 0,
|
||||
"SELECT 'Column MonthEventDiskSpace already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `MonthEventDiskSpace` BIGINT AFTER `MonthEvents`"
|
||||
));
|
||||
|
||||
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 = 'ArchivedEvents'
|
||||
) > 0,
|
||||
"SELECT 'Column ArchivedEvents already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `ArchivedEvents` INT(10) AFTER `MonthEvents`"
|
||||
));
|
||||
|
||||
|
||||
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 = 'ArchivedEventDiskSpace'
|
||||
) > 0,
|
||||
"SELECT 'Column ArchivedEventDiskSpace already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `ArchivedEventDiskSpace` BIGINT AFTER `ArchivedEvents`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Monitors'
|
||||
AND column_name = 'ZoneCount'
|
||||
) > 0,
|
||||
"SELECT 'Column ZoneCount already exists in Monitors'",
|
||||
"ALTER TABLE `Monitors` ADD `ZoneCount` TINYINT NOT NULL DEFAULT 0 AFTER `ArchivedEventDiskSpace`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(Id) FROM Zones WHERE MonitorId=Monitors.Id);
|
|
@ -0,0 +1,94 @@
|
|||
--
|
||||
-- Add UpdateDiskSpace action to Filters
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Filters'
|
||||
AND column_name = 'AutoMove'
|
||||
) > 0,
|
||||
"SELECT 'Column AutoMove already exists in Filters'",
|
||||
"ALTER TABLE Filters ADD `AutoMove` tinyint(3) unsigned NOT NULL default '0' AFTER `AutoDelete`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Filters'
|
||||
AND column_name = 'AutoMoveTo'
|
||||
) > 0,
|
||||
"SELECT 'Column AutoMoveTo already exists in Filters'",
|
||||
"ALTER TABLE Filters ADD `AutoMoveTo` smallint(5) unsigned NOT NULL default '0' AFTER `AutoMove`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name = 'Groups_Monitors'
|
||||
AND table_schema = DATABASE()
|
||||
) > 0,
|
||||
"SELECT 'Groups_Monitors table exists'",
|
||||
"CREATE TABLE `Groups_Monitors` (
|
||||
`Id` INT(10) unsigned NOT NULL auto_increment,
|
||||
`GroupId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`Id`)
|
||||
)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Groups_Monitors'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'Groups_Monitors_GroupId_idx'
|
||||
) > 0,
|
||||
"SELECT 'Groups_Monitors_GroupId_idx already exists on Groups table'",
|
||||
"CREATE INDEX `Groups_Monitors_GroupId_idx` ON `Groups_Monitors` (`GroupId`)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Groups_Monitors'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'Groups_Monitors_MonitorId_idx'
|
||||
) > 0,
|
||||
"SELECT 'Groups_Monitors_MonitorId_idx already exists on Groups table'",
|
||||
"CREATE INDEX `Groups_Monitors_MonitorId_idx` ON `Groups_Monitors` (`MonitorId`)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Groups'
|
||||
AND column_name = 'MonitorIds'
|
||||
) > 0,
|
||||
"REPLACE INTO Groups_Monitors (GroupId,MonitorId) SELECT Id,SUBSTRING_INDEX(SUBSTRING_INDEX(t.MonitorIds, ',', n.n), ',', -1) value FROM Groups t CROSS JOIN ( SELECT a.N + b.N * 10 + 1 n FROM (SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) a ,(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) b ORDER BY n ) n WHERE t.MonitorIds != '' AND n.n <= 1 + (LENGTH(t.MonitorIds) - LENGTH(REPLACE(t.MonitorIds, ',', ''))) ORDER BY value;",
|
||||
"SELECT 'MonitorIds has already been removed.'"
|
||||
));
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Groups'
|
||||
AND column_name = 'MonitorIds'
|
||||
) > 0,
|
||||
"ALTER TABLE Groups DROP MonitorIds",
|
||||
"SELECT 'MonitorIds has already been removed.'"
|
||||
));
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,40 @@
|
|||
alter table Events modify Id int(10) unsigned;
|
||||
alter table Events DROP Primary key;
|
||||
alter table Events Add Primary key(Id);
|
||||
alter table Events modify Id int(10) unsigned auto_increment;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Storage'
|
||||
AND column_name = 'DiskSpace'
|
||||
) > 0,
|
||||
"SELECT 'Column DiskSpace already exists in Storage'",
|
||||
"ALTER TABLE Storage ADD `DiskSpace` BIGINT default null AFTER `Type`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Storage'
|
||||
AND column_name = 'Scheme'
|
||||
) > 0,
|
||||
"SELECT 'Column Scheme already exists in Storage'",
|
||||
"ALTER TABLE Storage ADD `Scheme` enum('Deep','Medium','Shallow') NOT NULL default 'Medium' AFTER `DiskSpace`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Events'
|
||||
AND column_name = 'Scheme'
|
||||
) > 0,
|
||||
"SELECT 'Column Scheme already exists in Events'",
|
||||
"ALTER TABLE Events ADD `Scheme` enum('Deep','Medium','Shallow') NOT NULL default 'Deep' AFTER `DiskSpace`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Storage'
|
||||
AND column_name = 'ServerId'
|
||||
) > 0,
|
||||
"SELECT 'Column ServerId already exists in Storage'",
|
||||
"ALTER TABLE Storage ADD `ServerId` int(10) unsigned AFTER `Scheme`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM Filters WHERE Name = 'Update DiskSpace'
|
||||
AND Query = '{"terms":[{"attr":"DiskSpace","op":"IS","val":"NULL"}]}'
|
||||
) > 0,
|
||||
"SELECT 'Update Disk Space Filter already exists.'",
|
||||
"INSERT INTO Filters (Name,Query,UpdateDiskSpace,Background) values ('Update DiskSpace','{\"terms\":[{\"attr\":\"DiskSpace\",\"op\":\"IS\",\"val\":\"NULL\"}]}',1,1)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,123 @@
|
|||
drop procedure if exists update_storage_stats;
|
||||
|
||||
delimiter //
|
||||
|
||||
create procedure update_storage_stats(IN StorageId smallint(5), IN space BIGINT)
|
||||
|
||||
sql security invoker
|
||||
|
||||
deterministic
|
||||
|
||||
begin
|
||||
|
||||
update Storage set DiskSpace = DiskSpace + space where Id = StorageId;
|
||||
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
drop trigger if exists event_update_trigger;
|
||||
|
||||
delimiter //
|
||||
|
||||
create trigger event_update_trigger
|
||||
|
||||
after update
|
||||
|
||||
on Events
|
||||
|
||||
for each row
|
||||
|
||||
begin
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = NEW.DiskSpace - OLD.DiskSpace;
|
||||
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
||||
|
||||
IF ( diff ) THEN
|
||||
call update_storage_stats(OLD.StorageId, diff);
|
||||
END IF;
|
||||
ELSE
|
||||
IF ( NEW.DiskSpace ) THEN
|
||||
call update_storage_stats(NEW.StorageId, NEW.DiskSpace);
|
||||
END IF;
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
drop trigger if exists event_insert_trigger;
|
||||
|
||||
delimiter //
|
||||
/*
|
||||
create trigger event_insert_trigger
|
||||
|
||||
after insert
|
||||
|
||||
on Events
|
||||
|
||||
for each row
|
||||
|
||||
begin
|
||||
|
||||
call update_storage_stats(NEW.StorageId, NEW.DiskSpace);
|
||||
|
||||
end;
|
||||
*/
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
|
||||
drop trigger if exists event_delete_trigger;
|
||||
|
||||
delimiter //
|
||||
|
||||
create trigger event_delete_trigger
|
||||
|
||||
before delete
|
||||
|
||||
on Events
|
||||
|
||||
for each row
|
||||
|
||||
begin
|
||||
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events' and index_name = 'Archived' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, 'DROP INDEX Archived ON Events', "SELECT 'Archived INDEX is already removed.'");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events' and index_name = 'Frames' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, 'DROP INDEX Frames ON Events', "SELECT 'Frames INDEX is already removed.'");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events' and index_name = 'Events_StorageId_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, "SELECT 'Index Events_StorageId_idx already exists.'", 'CREATE INDEX Events_StorageId_idx on Events (StorageId)');
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events' and index_name = 'Events_EndTime_DiskSpace_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, "SELECT 'Index Events_EndTime_DiskSpace_idx already exists.'", 'CREATE INDEX Events_EndTime_DiskSpace_idx on Events (EndTime, DiskSpace)');
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
UPDATE Storage SET DiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE StorageId=Storage.Id);
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
--
|
||||
-- Update Filters table to have a Concurrent Column
|
||||
--
|
||||
|
||||
SELECT 'Checking for Concurrent in Filters';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Filters'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Concurrent'
|
||||
) > 0,
|
||||
"SELECT 'Column Concurrent already exists in Filters'",
|
||||
"ALTER TABLE Filters ADD COLUMN `Concurrent` tinyint(1) unsigned NOT NULL default '0' AFTER Background"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,275 @@
|
|||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name = 'Events_Hour'
|
||||
AND table_schema = DATABASE()
|
||||
) > 0,
|
||||
"SELECT 'Events_Hour table exists'",
|
||||
"
|
||||
CREATE TABLE `Events_Hour` (
|
||||
`EventId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`StartTime` datetime default NULL,
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
PRIMARY KEY (`EventId`),
|
||||
KEY `Events_Hour_MonitorId_StartTime_idx` (`MonitorId`,`StartTime`)
|
||||
);
|
||||
"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name = 'Events_Day'
|
||||
AND table_schema = DATABASE()
|
||||
) > 0,
|
||||
"SELECT 'Events_Day table exists'",
|
||||
"
|
||||
CREATE TABLE `Events_Day` (
|
||||
`EventId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`StartTime` datetime default NULL,
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
PRIMARY KEY (`EventId`),
|
||||
KEY `Events_Day_MonitorId_StartTime_idx` (`MonitorId`,`StartTime`)
|
||||
);
|
||||
"));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name = 'Events_Week'
|
||||
AND table_schema = DATABASE()
|
||||
) > 0,
|
||||
"SELECT 'Events_Week table exists'",
|
||||
"
|
||||
CREATE TABLE `Events_Week` (
|
||||
`EventId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`StartTime` datetime default NULL,
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
PRIMARY KEY (`EventId`),
|
||||
KEY `Events_Week_MonitorId_StartTime_idx` (`MonitorId`,`StartTime`)
|
||||
);
|
||||
"));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name = 'Events_Month'
|
||||
AND table_schema = DATABASE()
|
||||
) > 0,
|
||||
"SELECT 'Events_Month table exists'",
|
||||
"
|
||||
CREATE TABLE `Events_Month` (
|
||||
`EventId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`StartTime` datetime default NULL,
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
PRIMARY KEY (`EventId`),
|
||||
KEY `Events_Month_MonitorId_StartTime_idx` (`MonitorId`,`StartTime`)
|
||||
);
|
||||
"));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name = 'Events_Archived'
|
||||
AND table_schema = DATABASE()
|
||||
) > 0,
|
||||
"SELECT 'Events_Archived table exists'",
|
||||
"
|
||||
CREATE TABLE `Events_Archived` (
|
||||
`EventId` int(10) unsigned NOT NULL,
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`DiskSpace` bigint unsigned default NULL,
|
||||
PRIMARY KEY (`EventId`),
|
||||
KEY `Events_Month_MonitorId_idx` (`MonitorId`)
|
||||
);
|
||||
"));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
drop trigger if exists event_update_trigger;
|
||||
|
||||
delimiter //
|
||||
|
||||
CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = NEW.DiskSpace - OLD.DiskSpace;
|
||||
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
||||
IF ( diff ) THEN
|
||||
call update_storage_stats(OLD.StorageId, diff);
|
||||
END IF;
|
||||
ELSE
|
||||
IF ( NEW.DiskSpace ) THEN
|
||||
call update_storage_stats(NEW.StorageId, NEW.DiskSpace);
|
||||
END IF;
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Week SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Month SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
IF ( NEW.Archived != OLD.Archived ) THEN
|
||||
IF ( NEW.Archived ) THEN
|
||||
INSERT INTO Events_Archived (EventId,MonitorId,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.DiskSpace);
|
||||
UPDATE Monitors SET ArchivedEvents = ArchivedEvents+1, ArchivedEventDiskSpace = ArchivedEventDiskSpace + NEW.DiskSpace WHERE Id=NEW.MonitorId;
|
||||
ELSEIF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET ArchivedEvents =ArchivedEvents-1, ArchivedEventDiskSpace = ArchivedEventDiskSpace - OLD.DiskSpace WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEventDiskSpace = ArchivedEventDiskSpace - OLD.DiskSpace + NEW.DiskSpace
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Monitors SET TotalEventDiskSpace = TotalEventDiskSpace - OLD.DiskSpace + NEW.DiskSpace WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger;
|
||||
|
||||
delimiter //
|
||||
create trigger event_insert_trigger after insert on Events
|
||||
for each row
|
||||
begin
|
||||
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
end;
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
|
||||
drop trigger if exists event_delete_trigger;
|
||||
|
||||
delimiter //
|
||||
|
||||
CREATE TRIGGER event_delete_trigger BEFORE DELETe on Events
|
||||
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Day WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Week WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Month WHERE EventId=OLD.Id;
|
||||
IF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEvents = ArchivedEvents - 1,
|
||||
ArchivedEventDiskSpace = ArchivedEventDiskSpace - OLD.DiskSpace,
|
||||
TotalEvents = TotalEvents - 1,
|
||||
TotalEventDiskSpace = TotalEventDiskSpace - OLD.DiskSpace
|
||||
WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET
|
||||
TotalEvents = TotalEvents-1,
|
||||
TotalEventDiskSpace=TotalEventDiskSpace-OLD.DiskSpace
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmstats.pl'
|
||||
) > 0,
|
||||
"SELECT 'Column zmstats.pl already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `zmstats.pl` BOOLEAN NOT NULL DEFAULT FALSE AFTER `FreeSwap`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmaudit.pl'
|
||||
) > 0,
|
||||
"SELECT 'Column zmaudit.pl already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `zmaudit.pl` BOOLEAN NOT NULL DEFAULT FALSE AFTER `zmstats.pl`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmtrigger.pl'
|
||||
) > 0,
|
||||
"SELECT 'Column zmtrigger.pl already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `zmtrigger.pl` BOOLEAN NOT NULL DEFAULT FALSE AFTER `zmaudit.pl`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
UPDATE Monitors INNER JOIN (
|
||||
SELECT MonitorId,
|
||||
COUNT(Id) AS TotalEvents,
|
||||
SUM(DiskSpace) AS TotalEventDiskSpace,
|
||||
SUM(IF(Archived,1,0)) AS ArchivedEvents,
|
||||
SUM(IF(Archived,DiskSpace,0)) AS ArchivedEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),1,0)) AS HourEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),DiskSpace,0)) AS HourEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),1,0)) AS DayEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),DiskSpace,0)) AS DayEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),1,0)) AS WeekEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),DiskSpace,0)) AS WeekEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),1,0)) AS MonthEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),DiskSpace,0)) AS MonthEventDiskSpace
|
||||
FROM Events GROUP BY MonitorId
|
||||
) AS E ON E.MonitorId=Monitors.Id SET
|
||||
Monitors.TotalEvents = E.TotalEvents,
|
||||
Monitors.TotalEventDiskSpace = E.TotalEventDiskSpace,
|
||||
Monitors.ArchivedEvents = E.ArchivedEvents,
|
||||
Monitors.ArchivedEventDiskSpace = E.ArchivedEventDiskSpace,
|
||||
Monitors.HourEvents = E.HourEvents,
|
||||
Monitors.HourEventDiskSpace = E.HourEventDiskSpace,
|
||||
Monitors.DayEvents = E.DayEvents,
|
||||
Monitors.DayEventDiskSpace = E.DayEventDiskSpace,
|
||||
Monitors.WeekEvents = E.WeekEvents,
|
||||
Monitors.WeekEventDiskSpace = E.WeekEventDiskSpace,
|
||||
Monitors.MonthEvents = E.MonthEvents,
|
||||
Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace;
|
|
@ -0,0 +1,150 @@
|
|||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Zone_Insert_Trigger//
|
||||
CREATE TRIGGER Zone_Insert_Trigger AFTER INSERT ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=NEW.MonitorId) WHERE Id=NEW.MonitorID;
|
||||
END
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Zone_Delete_Trigger//
|
||||
CREATE TRIGGER Zone_Delete_Trigger AFTER DELETE ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=OLD.MonitorId) WHERE Id=OLD.MonitorID;
|
||||
END
|
||||
//
|
||||
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(Id) FROM Zones WHERE MonitorId=Monitors.Id)//
|
||||
|
||||
drop trigger if exists event_update_trigger//
|
||||
|
||||
CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = NEW.DiskSpace - OLD.DiskSpace;
|
||||
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
||||
IF ( diff ) THEN
|
||||
call update_storage_stats(OLD.StorageId, diff);
|
||||
END IF;
|
||||
ELSE
|
||||
IF ( NEW.DiskSpace ) THEN
|
||||
call update_storage_stats(NEW.StorageId, NEW.DiskSpace);
|
||||
END IF;
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Week SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Month SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
IF ( NEW.Archived != OLD.Archived ) THEN
|
||||
IF ( NEW.Archived ) THEN
|
||||
INSERT INTO Events_Archived (EventId,MonitorId,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.DiskSpace);
|
||||
UPDATE Monitors SET ArchivedEvents = ArchivedEvents+1, ArchivedEventDiskSpace = ArchivedEventDiskSpace + NEW.DiskSpace WHERE Id=NEW.MonitorId;
|
||||
ELSEIF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET ArchivedEvents =ArchivedEvents-1, ArchivedEventDiskSpace = ArchivedEventDiskSpace - OLD.DiskSpace WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEventDiskSpace = ArchivedEventDiskSpace - OLD.DiskSpace + NEW.DiskSpace
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Monitors SET TotalEventDiskSpace = TotalEventDiskSpace - OLD.DiskSpace + NEW.DiskSpace WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger;
|
||||
|
||||
delimiter //
|
||||
create trigger event_insert_trigger after insert on Events
|
||||
for each row
|
||||
begin
|
||||
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
end;
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
|
||||
drop trigger if exists event_delete_trigger;
|
||||
|
||||
delimiter //
|
||||
|
||||
CREATE TRIGGER event_delete_trigger BEFORE DELETe on Events
|
||||
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Day WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Week WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Month WHERE EventId=OLD.Id;
|
||||
IF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEvents = ArchivedEvents - 1,
|
||||
ArchivedEventDiskSpace = ArchivedEventDiskSpace - OLD.DiskSpace,
|
||||
TotalEvents = TotalEvents - 1,
|
||||
TotalEventDiskSpace = TotalEventDiskSpace - OLD.DiskSpace
|
||||
WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET
|
||||
TotalEvents = TotalEvents-1,
|
||||
TotalEventDiskSpace=TotalEventDiskSpace-OLD.DiskSpace
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
UPDATE Monitors INNER JOIN (
|
||||
SELECT MonitorId,
|
||||
COUNT(Id) AS TotalEvents,
|
||||
SUM(DiskSpace) AS TotalEventDiskSpace,
|
||||
SUM(IF(Archived,1,0)) AS ArchivedEvents,
|
||||
SUM(IF(Archived,DiskSpace,0)) AS ArchivedEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),1,0)) AS HourEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),DiskSpace,0)) AS HourEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),1,0)) AS DayEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),DiskSpace,0)) AS DayEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),1,0)) AS WeekEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),DiskSpace,0)) AS WeekEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),1,0)) AS MonthEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),DiskSpace,0)) AS MonthEventDiskSpace
|
||||
FROM Events GROUP BY MonitorId
|
||||
) AS E ON E.MonitorId=Monitors.Id SET
|
||||
Monitors.TotalEvents = E.TotalEvents,
|
||||
Monitors.TotalEventDiskSpace = E.TotalEventDiskSpace,
|
||||
Monitors.ArchivedEvents = E.ArchivedEvents,
|
||||
Monitors.ArchivedEventDiskSpace = E.ArchivedEventDiskSpace,
|
||||
Monitors.HourEvents = E.HourEvents,
|
||||
Monitors.HourEventDiskSpace = E.HourEventDiskSpace,
|
||||
Monitors.DayEvents = E.DayEvents,
|
||||
Monitors.DayEventDiskSpace = E.DayEventDiskSpace,
|
||||
Monitors.WeekEvents = E.WeekEvents,
|
||||
Monitors.WeekEventDiskSpace = E.WeekEventDiskSpace,
|
||||
Monitors.MonthEvents = E.MonthEvents,
|
||||
Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace;
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Zone_Insert_Trigger//
|
||||
CREATE TRIGGER Zone_Insert_Trigger AFTER INSERT ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=NEW.MonitorId) WHERE Id=NEW.MonitorID;
|
||||
END
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Zone_Delete_Trigger//
|
||||
CREATE TRIGGER Zone_Delete_Trigger AFTER DELETE ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=OLD.MonitorId) WHERE Id=OLD.MonitorID;
|
||||
END
|
||||
//
|
||||
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(Id) FROM Zones WHERE MonitorId=Monitors.Id)//
|
||||
UPDATE Storage SET DiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE StorageId=Storage.Id);
|
|
@ -0,0 +1,88 @@
|
|||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmstats.pl'
|
||||
) > 0 AND ( SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmstats'
|
||||
) = 0
|
||||
,
|
||||
"ALTER TABLE Servers CHANGE COLUMN `zmstats.pl` `zmstats` BOOLEAN NOT NULL DEFAULT FALSE",
|
||||
"SELECT 'zmstats.pl has already been changed to zmstats'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmstats.pl'
|
||||
) > 0,
|
||||
"ALTER TABLE Servers DROP COLUMN `zmstats.pl`",
|
||||
"SELECT 'zmstats.pl has already been removed'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmaudit.pl'
|
||||
) > 0
|
||||
AND
|
||||
( SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmaudit'
|
||||
) = 0
|
||||
,
|
||||
"ALTER TABLE Servers CHANGE COLUMN `zmaudit.pl` `zmaudit` BOOLEAN NOT NULL DEFAULT FALSE",
|
||||
"SELECT 'zmaudit.pl has already been changed to zmaudit'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmaudit.pl'
|
||||
) > 0,
|
||||
"ALTER TABLE Servers DROP COLUMN `zmaudit.pl`",
|
||||
"SELECT 'zmaudit.pl has already been removed'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmtrigger.pl'
|
||||
) > 0
|
||||
AND
|
||||
( SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmtrigger'
|
||||
) = 0
|
||||
,
|
||||
"ALTER TABLE Servers CHANGE COLUMN `zmtrigger.pl` `zmtrigger` BOOLEAN NOT NULL DEFAULT FALSE",
|
||||
"SELECT 'zmtrigger.pl has already been changed to zmtrigger'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'zmtrigger.pl'
|
||||
) > 0,
|
||||
"ALTER TABLE Servers DROP COLUMN `zmtrigger.pl`",
|
||||
"SELECT 'zmtrigger.pl has already been removed'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,61 @@
|
|||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Hour' and index_name = 'Events_Hour_MonitorId_StartTime_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, 'DROP INDEX Events_Hour_MonitorId_StartTime_idx ON Events_Hour', "SELECT 'Events_Hour_MonitorId_StartTime_idx INDEX is already removed.'");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Hour' and index_name = 'Events_Hour_MonitorId_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, "SELECT 'Events_Hour_MonitorId_idx INDEX already exists.'", "CREATE INDEX `Events_Hour_MonitorId_idx` ON `Events_Hour` (`MonitorId`)");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Hour' and index_name = 'Events_Hour_StartTime_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, "SELECT 'Events_Hour_StartTime_idx INDEX already exists.'", "CREATE INDEX `Events_Hour_StartTime_idx` ON `Events_Hour` (`StartTime`)");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Day' and index_name = 'Events_Day_MonitorId_StartTime_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, 'DROP INDEX Events_Day_MonitorId_StartTime_idx ON Events_Day', "SELECT 'Events_Day_MonitorId_StartTime_idx INDEX is already removed.'");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Day' and index_name = 'Events_Day_MonitorId_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, "SELECT 'Events_Day_MonitorId_idx INDEX already exists.'", "CREATE INDEX `Events_Day_MonitorId_idx` ON `Events_Day` (`MonitorId`)");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Day' and index_name = 'Events_Day_StartTime_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, "SELECT 'Events_Day_StartTime_idx INDEX already exists.'", "CREATE INDEX `Events_Day_StartTime_idx` ON `Events_Day` (`StartTime`)");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Week' and index_name = 'Events_Week_MonitorId_StartTime_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, 'DROP INDEX Events_Week_MonitorId_StartTime_idx ON Events_Week', "SELECT 'Events_Week_MonitorId_StartTime_idx INDEX is already removed.'");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Week' and index_name = 'Events_Week_MonitorId_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, "SELECT 'Events_Week_MonitorId_idx INDEX already exists.'", "CREATE INDEX `Events_Week_MonitorId_idx` ON `Events_Week` (`MonitorId`)");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Week' and index_name = 'Events_Week_StartTime_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, "SELECT 'Events_Week_StartTime_idx INDEX already exists.'", "CREATE INDEX `Events_Week_StartTime_idx` ON `Events_Week` (`StartTime`)");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Month' and index_name = 'Events_Month_MonitorId_StartTime_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, 'DROP INDEX Events_Month_MonitorId_StartTime_idx ON Events_Month', "SELECT 'Events_Month_MonitorId_StartTime_idx INDEX is already removed.'");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Month' and index_name = 'Events_Month_MonitorId_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, "SELECT 'Events_Month_MonitorId_idx INDEX already exists.'", "CREATE INDEX `Events_Month_MonitorId_idx` ON `Events_Month` (`MonitorId`)");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
set @exist := (select count(*) from information_schema.statistics where table_name = 'Events_Month' and index_name = 'Events_Month_StartTime_idx' and table_schema = database());
|
||||
set @sqlstmt := if( @exist > 0, "SELECT 'Events_Month_StartTime_idx INDEX already exists.'", "CREATE INDEX `Events_Month_StartTime_idx` ON `Events_Month` (`StartTime`)");
|
||||
PREPARE stmt FROM @sqlstmt;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,45 @@
|
|||
delimiter //
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger//
|
||||
|
||||
create trigger event_insert_trigger after insert on Events
|
||||
for each row
|
||||
begin
|
||||
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
UPDATE Monitors SET TotalEvents = TotalEvents+1 WHERE Id=NEW.MonitorId;
|
||||
end;
|
||||
//
|
||||
|
||||
UPDATE Monitors INNER JOIN (
|
||||
SELECT MonitorId,
|
||||
COUNT(Id) AS TotalEvents,
|
||||
SUM(DiskSpace) AS TotalEventDiskSpace,
|
||||
SUM(IF(Archived,1,0)) AS ArchivedEvents,
|
||||
SUM(IF(Archived,DiskSpace,0)) AS ArchivedEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),1,0)) AS HourEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),DiskSpace,0)) AS HourEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),1,0)) AS DayEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),DiskSpace,0)) AS DayEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),1,0)) AS WeekEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),DiskSpace,0)) AS WeekEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),1,0)) AS MonthEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),DiskSpace,0)) AS MonthEventDiskSpace
|
||||
FROM Events GROUP BY MonitorId
|
||||
) AS E ON E.MonitorId=Monitors.Id SET
|
||||
Monitors.TotalEvents = E.TotalEvents,
|
||||
Monitors.TotalEventDiskSpace = E.TotalEventDiskSpace,
|
||||
Monitors.ArchivedEvents = E.ArchivedEvents,
|
||||
Monitors.ArchivedEventDiskSpace = E.ArchivedEventDiskSpace,
|
||||
Monitors.HourEvents = E.HourEvents,
|
||||
Monitors.HourEventDiskSpace = E.HourEventDiskSpace,
|
||||
Monitors.DayEvents = E.DayEvents,
|
||||
Monitors.DayEventDiskSpace = E.DayEventDiskSpace,
|
||||
Monitors.WeekEvents = E.WeekEvents,
|
||||
Monitors.WeekEventDiskSpace = E.WeekEventDiskSpace,
|
||||
Monitors.MonthEvents = E.MonthEvents,
|
||||
Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace//
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
delimiter //
|
||||
DROP TRIGGER IF EXISTS event_update_trigger;
|
||||
|
||||
CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = NEW.DiskSpace - OLD.DiskSpace;
|
||||
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
||||
IF ( diff ) THEN
|
||||
call update_storage_stats(OLD.StorageId, diff);
|
||||
END IF;
|
||||
ELSE
|
||||
IF ( NEW.DiskSpace ) THEN
|
||||
call update_storage_stats(NEW.StorageId, NEW.DiskSpace);
|
||||
END IF;
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Week SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Month SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
IF ( NEW.Archived != OLD.Archived ) THEN
|
||||
IF ( NEW.Archived ) THEN
|
||||
INSERT INTO Events_Archived (EventId,MonitorId,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.DiskSpace);
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)+1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=NEW.MonitorId;
|
||||
ELSEIF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)-1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Monitors SET TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger;
|
||||
|
||||
create trigger event_insert_trigger after insert on Events
|
||||
for each row
|
||||
begin
|
||||
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
UPDATE Monitors SET TotalEvents = COALESCE(TotalEvents,0)+1 WHERE Id=NEW.MonitorId;
|
||||
end;
|
||||
//
|
||||
|
||||
UPDATE Monitors INNER JOIN (
|
||||
SELECT MonitorId,
|
||||
COUNT(Id) AS TotalEvents,
|
||||
SUM(DiskSpace) AS TotalEventDiskSpace,
|
||||
SUM(IF(Archived,1,0)) AS ArchivedEvents,
|
||||
SUM(IF(Archived,DiskSpace,0)) AS ArchivedEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),1,0)) AS HourEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),DiskSpace,0)) AS HourEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),1,0)) AS DayEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),DiskSpace,0)) AS DayEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),1,0)) AS WeekEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),DiskSpace,0)) AS WeekEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),1,0)) AS MonthEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),DiskSpace,0)) AS MonthEventDiskSpace
|
||||
FROM Events GROUP BY MonitorId
|
||||
) AS E ON E.MonitorId=Monitors.Id SET
|
||||
Monitors.TotalEvents = E.TotalEvents,
|
||||
Monitors.TotalEventDiskSpace = E.TotalEventDiskSpace,
|
||||
Monitors.ArchivedEvents = E.ArchivedEvents,
|
||||
Monitors.ArchivedEventDiskSpace = E.ArchivedEventDiskSpace,
|
||||
Monitors.HourEvents = E.HourEvents,
|
||||
Monitors.HourEventDiskSpace = E.HourEventDiskSpace,
|
||||
Monitors.DayEvents = E.DayEvents,
|
||||
Monitors.DayEventDiskSpace = E.DayEventDiskSpace,
|
||||
Monitors.WeekEvents = E.WeekEvents,
|
||||
Monitors.WeekEventDiskSpace = E.WeekEventDiskSpace,
|
||||
Monitors.MonthEvents = E.MonthEvents,
|
||||
Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace//
|
||||
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
delimiter //
|
||||
DROP TRIGGER IF EXISTS event_update_trigger;
|
||||
|
||||
CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = NEW.DiskSpace - OLD.DiskSpace;
|
||||
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
||||
IF ( diff ) THEN
|
||||
call update_storage_stats(OLD.StorageId, diff);
|
||||
END IF;
|
||||
ELSE
|
||||
IF ( NEW.DiskSpace ) THEN
|
||||
call update_storage_stats(NEW.StorageId, NEW.DiskSpace);
|
||||
END IF;
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Week SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Month SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
IF ( NEW.Archived != OLD.Archived ) THEN
|
||||
IF ( NEW.Archived ) THEN
|
||||
INSERT INTO Events_Archived (EventId,MonitorId,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.DiskSpace);
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)+1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=NEW.MonitorId;
|
||||
ELSEIF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)-1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF (
|
||||
( (OLD.DiskSpace IS NOT NULL) AND (NEW.DiskSpace IS NULL) )
|
||||
OR
|
||||
( (OLD.DiskSpace IS NULL) AND (NEW.DiskSpace IS NOT NULL) )
|
||||
OR ( OLD.DiskSpace != NEW.DiskSpace )
|
||||
) THEN
|
||||
UPDATE Monitors SET TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger;
|
||||
|
||||
create trigger event_insert_trigger after insert on Events
|
||||
for each row
|
||||
begin
|
||||
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
UPDATE Monitors SET TotalEvents = COALESCE(TotalEvents,0)+1 WHERE Id=NEW.MonitorId;
|
||||
end;
|
||||
//
|
||||
|
||||
UPDATE Monitors INNER JOIN (
|
||||
SELECT MonitorId,
|
||||
COUNT(Id) AS TotalEvents,
|
||||
SUM(DiskSpace) AS TotalEventDiskSpace,
|
||||
SUM(IF(Archived,1,0)) AS ArchivedEvents,
|
||||
SUM(IF(Archived,DiskSpace,0)) AS ArchivedEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),1,0)) AS HourEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),DiskSpace,0)) AS HourEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),1,0)) AS DayEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),DiskSpace,0)) AS DayEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),1,0)) AS WeekEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),DiskSpace,0)) AS WeekEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),1,0)) AS MonthEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),DiskSpace,0)) AS MonthEventDiskSpace
|
||||
FROM Events GROUP BY MonitorId
|
||||
) AS E ON E.MonitorId=Monitors.Id SET
|
||||
Monitors.TotalEvents = E.TotalEvents,
|
||||
Monitors.TotalEventDiskSpace = E.TotalEventDiskSpace,
|
||||
Monitors.ArchivedEvents = E.ArchivedEvents,
|
||||
Monitors.ArchivedEventDiskSpace = E.ArchivedEventDiskSpace,
|
||||
Monitors.HourEvents = E.HourEvents,
|
||||
Monitors.HourEventDiskSpace = E.HourEventDiskSpace,
|
||||
Monitors.DayEvents = E.DayEvents,
|
||||
Monitors.DayEventDiskSpace = E.DayEventDiskSpace,
|
||||
Monitors.WeekEvents = E.WeekEvents,
|
||||
Monitors.WeekEventDiskSpace = E.WeekEventDiskSpace,
|
||||
Monitors.MonthEvents = E.MonthEvents,
|
||||
Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace//
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Monitor_Status'
|
||||
) > 0
|
||||
,
|
||||
"SELECT 'Monitor_Status Already exists'",
|
||||
"
|
||||
CREATE TABLE `Monitor_Status` (
|
||||
`Id` int(10) unsigned NOT NULL,
|
||||
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
|
||||
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||
PRIMARY KEY (`Id`)
|
||||
) ENGINE=MEMORY"
|
||||
));
|
||||
|
||||
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 = 'Status'
|
||||
) > 0
|
||||
,
|
||||
"ALTER TABLE Monitors DROP COLUMN Status",
|
||||
"SELECT 'Monitor Status already removed.'"
|
||||
));
|
||||
|
||||
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 = 'CaptureFPS'
|
||||
) > 0
|
||||
,
|
||||
"ALTER TABLE Monitors DROP COLUMN CaptureFPS",
|
||||
"SELECT 'Monitor CaptureFPS already removed.'"
|
||||
));
|
||||
|
||||
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 = 'AnalysisFPS'
|
||||
) > 0
|
||||
,
|
||||
"ALTER TABLE Monitors DROP COLUMN AnalysisFPS",
|
||||
"SELECT 'Monitor AnalysisFPS already removed.'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,8 @@
|
|||
DROP TABLE IF EXISTS `Monitor_Status`;
|
||||
CREATE TABLE `Monitor_Status` (
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
|
||||
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||
PRIMARY KEY (`MonitorId`)
|
||||
) ENGINE=MEMORY;
|
|
@ -0,0 +1,146 @@
|
|||
--
|
||||
-- This adds StorageAreas
|
||||
--
|
||||
|
||||
SELECT 'Checking For Storage Table';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name = 'Storage'
|
||||
AND table_schema = DATABASE()
|
||||
) > 0,
|
||||
"SELECT 'Storage table exists'",
|
||||
"CREATE TABLE `Storage` (
|
||||
`Id` smallint(5) unsigned NOT NULL auto_increment,
|
||||
`Path` varchar(64) NOT NULL default '',
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
PRIMARY KEY (`Id`)
|
||||
)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Add StorageId column to Monitors
|
||||
--
|
||||
|
||||
SELECT 'Checking For StorageId in Monitors';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Monitors'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'StorageId'
|
||||
) > 0,
|
||||
"SELECT 'Column StorageId exists in Monitors'",
|
||||
"ALTER TABLE Monitors ADD `StorageId` smallint(5) unsigned NOT NULL default 0 AFTER `ServerId`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Add StorageId column to Eventss
|
||||
--
|
||||
|
||||
SELECT 'Checking For StorageId in Events';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Events'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'StorageId'
|
||||
) > 0,
|
||||
"SELECT 'Column StorageId exists in Events'",
|
||||
"ALTER TABLE Events ADD `StorageId` smallint(5) unsigned NOT NULL default 0 AFTER `MonitorId`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SELECT 'Updating Monitors SETTING StorageId to default';
|
||||
UPDATE Monitors SET StorageId = 0 WHERE StorageId IS NULL;
|
||||
ALTER TABLE Monitors MODIFY `StorageId` smallint(5) unsigned NOT NULL default 0;
|
||||
UPDATE Events SET StorageId = 0 WHERE StorageId IS NULL;
|
||||
ALTER TABLE Events MODIFY `StorageId` smallint(5) unsigned NOT NULL default 0;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Events'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Orientation'
|
||||
) > 0,
|
||||
"SELECT 'Column Orientation exists in Events'",
|
||||
"ALTER TABLE `Events` ADD `Orientation` enum('0','90','180','270','hori','vert') NOT NULL default '0' AFTER `Notes`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Update Monitors table to have an Index on ServerId
|
||||
--
|
||||
SELECT 'Create Index For ServerId on Monitors';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Monitors'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'Monitors_ServerId_idx'
|
||||
) > 0,
|
||||
"SELECT 'Monitors_ServerId Index already exists on Monitors table'",
|
||||
"CREATE INDEX `Monitors_ServerId_idx` ON `Monitors` (`ServerId`)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
|
||||
--
|
||||
-- Update Server table to have an Index on Name
|
||||
--
|
||||
SELECT 'Create Index FOR Name on Servers';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Servers'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'Servers_Name_idx'
|
||||
) > 0,
|
||||
"SELECT 'Servers_Name Index already exists on Servers table'",
|
||||
"CREATE INDEX `Servers_Name_idx` ON `Servers` (`Name`)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
|
||||
SELECT 'ALTER TABLE Logs MODIFY Message TEXT NOT NULL';
|
||||
-- ALTER TABLE Logs ALTER Message DROP DEFAULT;
|
||||
ALTER TABLE Logs MODIFY Message TEXT NOT NULL;
|
||||
|
||||
SELECT 'ALTER TABLE Config MODIFY DefaultValue TEXT';
|
||||
ALTER TABLE Config MODIFY DefaultValue TEXT;
|
||||
|
||||
|
||||
--
|
||||
-- Add an Id column and make it the primary key of the Filters table
|
||||
--
|
||||
|
||||
SELECT 'Check for Id column in Filter';
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Filters'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Id'
|
||||
) > 0,
|
||||
"SELECT 'Column Id exists in Filters'",
|
||||
"ALTER TABLE `Filters` DROP PRIMARY KEY, ADD `Id` int(10) unsigned NOT NULL auto_increment PRIMARY KEY FIRST, ADD KEY `Name` (`Name`);"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
DROP TABLE IF EXISTS `Monitor_Status`;
|
||||
CREATE TABLE `Monitor_Status` (
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`Status` enum('Unknown','NotRunning','Running','Connected','Signal') NOT NULL default 'Unknown',
|
||||
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||
PRIMARY KEY (`MonitorId`)
|
||||
) ENGINE=MEMORY;
|
||||
|
||||
SET SESSION sql_mode='NO_AUTO_VALUE_ON_ZERO';
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM Storage WHERE Name = 'Default' AND Id=0 AND Path='/var/cache/zoneminder/events'
|
||||
) > 0,
|
||||
"SELECT 'Default Storage Area already exists.'",
|
||||
"INSERT INTO Storage (Id,Name,Path,Scheme,ServerId) VALUES (0,'Default','/var/cache/zoneminder/events','Medium',NULL)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE Storage MODIFY DiskSpace BIGINT default NULL;
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE Monitors MODIFY TotalEventDiskSpace BIGINT default NULL;
|
||||
ALTER TABLE Monitors MODIFY Method VARCHAR(16) default NULL;
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
drop trigger if exists event_delete_trigger;
|
||||
|
||||
delimiter //
|
||||
|
||||
CREATE TRIGGER event_delete_trigger BEFORE DELETe on Events
|
||||
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Day WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Week WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Month WHERE EventId=OLD.Id;
|
||||
IF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEvents = ArchivedEvents - 1,
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0),
|
||||
TotalEvents = TotalEvents - 1,
|
||||
TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET
|
||||
TotalEvents = TotalEvents-1,
|
||||
TotalEventDiskSpace=COALESCE(TotalEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
//
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
delimiter //
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Hour_delete_trigger//
|
||||
CREATE TRIGGER Events_Hour_delete_trigger BEFORE DELETE ON Events_Hour
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,1)-1,
|
||||
HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Day_delete_trigger//
|
||||
CREATE TRIGGER Events_Day_delete_trigger BEFORE DELETE ON Events_Day
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
DayEvents = COALESCE(DayEvents,1)-1,
|
||||
DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Week_delete_trigger//
|
||||
CREATE TRIGGER Events_Week_delete_trigger BEFORE DELETE ON Events_Week
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
WeekEvents = COALESCE(WeekEvents,1)-1,
|
||||
WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Month_delete_trigger//
|
||||
CREATE TRIGGER Events_Month_delete_trigger BEFORE DELETE ON Events_Month
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
MonthEvents = COALESCE(MonthEvents,1)-1,
|
||||
MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger//
|
||||
|
||||
CREATE TRIGGER event_insert_trigger AFTER INSERT ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,0)+1,
|
||||
DayEvents = COALESCE(DayEvents,0)+1,
|
||||
WeekEvents = COALESCE(WeekEvents,0)+1,
|
||||
MonthEvents = COALESCE(MonthEvents,0)+1,
|
||||
TotalEvents = COALESCE(TotalEvents,0)+1
|
||||
WHERE Id=NEW.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
delimiter //
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Hour_delete_trigger//
|
||||
CREATE TRIGGER Events_Hour_delete_trigger BEFORE DELETE ON Events_Hour
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,1)-1,
|
||||
HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Hour_update_trigger;
|
||||
CREATE TRIGGER Events_Hour_update_trigger AFTER UPDATE ON Events_Hour
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)+diff WHERE Monitors.Id=MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Day_delete_trigger//
|
||||
CREATE TRIGGER Events_Day_delete_trigger BEFORE DELETE ON Events_Day
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
DayEvents = COALESCE(DayEvents,1)-1,
|
||||
DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Day_update_trigger;
|
||||
CREATE TRIGGER Events_Day_update_trigger AFTER UPDATE ON Events_Day
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+diff WHERE Monitors.Id=MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Week_delete_trigger//
|
||||
CREATE TRIGGER Events_Week_delete_trigger BEFORE DELETE ON Events_Week
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
WeekEvents = COALESCE(WeekEvents,1)-1,
|
||||
WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Week_update_trigger;
|
||||
CREATE TRIGGER Events_Week_update_trigger AFTER UPDATE ON Events_Week
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+diff WHERE Monitors.Id=MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Month_delete_trigger//
|
||||
CREATE TRIGGER Events_Month_delete_trigger BEFORE DELETE ON Events_Month
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
MonthEvents = COALESCE(MonthEvents,1)-1,
|
||||
MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Month_update_trigger;
|
||||
CREATE TRIGGER Events_Month_update_trigger AFTER UPDATE ON Events_Month
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+diff WHERE Monitors.Id=MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger//
|
||||
|
||||
CREATE TRIGGER event_insert_trigger AFTER INSERT ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,0)+1,
|
||||
DayEvents = COALESCE(DayEvents,0)+1,
|
||||
WeekEvents = COALESCE(WeekEvents,0)+1,
|
||||
MonthEvents = COALESCE(MonthEvents,0)+1,
|
||||
TotalEvents = COALESCE(TotalEvents,0)+1
|
||||
WHERE Id=NEW.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Events'
|
||||
AND column_name = 'Scheme'
|
||||
) > 0,
|
||||
"SELECT 'Column Scheme already exists in Events'",
|
||||
"ALTER TABLE Events ADD `Scheme` enum('Deep','Medium','Shallow') NOT NULL default 'Deep' AFTER `DiskSpace`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
|
||||
UPDATE Monitors SET
|
||||
TotalEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id),
|
||||
TotalEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
HourEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB( NOW(), INTERVAL 1 hour) ),
|
||||
HourEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 hour) AND DiskSpace IS NOT NULL),
|
||||
DayEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 day)),
|
||||
DayEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 day) AND DiskSpace IS NOT NULL),
|
||||
WeekEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 week)),
|
||||
WeekEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 week) AND DiskSpace IS NOT NULL),
|
||||
MonthEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB( NOW(), INTERVAL 1 month)),
|
||||
MonthEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 month) AND DiskSpace IS NOT NULL),
|
||||
ArchivedEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1),
|
||||
ArchivedEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1 AND DiskSpace IS NOT NULL)
|
|
@ -0,0 +1,148 @@
|
|||
delimiter //
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Hour_delete_trigger//
|
||||
CREATE TRIGGER Events_Hour_delete_trigger BEFORE DELETE ON Events_Hour
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,1)-1,
|
||||
HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Hour_update_trigger;
|
||||
CREATE TRIGGER Events_Hour_update_trigger AFTER UPDATE ON Events_Hour
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(DayEventDiskSpace,0)-OLD.DiskSpace WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(DayEventDiskSpace,0)+NEW.DiskSpace WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(DayEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Day_delete_trigger//
|
||||
CREATE TRIGGER Events_Day_delete_trigger BEFORE DELETE ON Events_Day
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
DayEvents = COALESCE(DayEvents,1)-1,
|
||||
DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Day_update_trigger;
|
||||
CREATE TRIGGER Events_Day_update_trigger AFTER UPDATE ON Events_Day
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-OLD.DiskSpace WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+NEW.DiskSpace WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Week_delete_trigger//
|
||||
CREATE TRIGGER Events_Week_delete_trigger BEFORE DELETE ON Events_Week
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
WeekEvents = COALESCE(WeekEvents,1)-1,
|
||||
WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Week_update_trigger;
|
||||
CREATE TRIGGER Events_Week_update_trigger AFTER UPDATE ON Events_Week
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-OLD.DiskSpace WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+NEW.DiskSpace WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Month_delete_trigger//
|
||||
CREATE TRIGGER Events_Month_delete_trigger BEFORE DELETE ON Events_Month
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
MonthEvents = COALESCE(MonthEvents,1)-1,
|
||||
MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Month_update_trigger;
|
||||
CREATE TRIGGER Events_Month_update_trigger AFTER UPDATE ON Events_Month
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-OLD.DiskSpace WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+NEW.DiskSpace WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger//
|
||||
|
||||
CREATE TRIGGER event_insert_trigger AFTER INSERT ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,0)+1,
|
||||
DayEvents = COALESCE(DayEvents,0)+1,
|
||||
WeekEvents = COALESCE(WeekEvents,0)+1,
|
||||
MonthEvents = COALESCE(MonthEvents,0)+1,
|
||||
TotalEvents = COALESCE(TotalEvents,0)+1
|
||||
WHERE Id=NEW.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
UPDATE Monitors SET
|
||||
TotalEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id),
|
||||
TotalEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
HourEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB( NOW(), INTERVAL 1 hour) ),
|
||||
HourEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 hour) AND DiskSpace IS NOT NULL),
|
||||
DayEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 day)),
|
||||
DayEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 day) AND DiskSpace IS NOT NULL),
|
||||
WeekEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 week)),
|
||||
WeekEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 week) AND DiskSpace IS NOT NULL),
|
||||
MonthEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB( NOW(), INTERVAL 1 month)),
|
||||
MonthEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 month) AND DiskSpace IS NOT NULL),
|
||||
ArchivedEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1),
|
||||
ArchivedEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1 AND DiskSpace IS NOT NULL);
|
|
@ -0,0 +1,49 @@
|
|||
DROP PROCEDURE IF EXISTS update_storage_stats;
|
||||
|
||||
DELIMITER //
|
||||
|
||||
CREATE PROCEDURE update_storage_stats(IN StorageId smallint(5), IN space BIGINT)
|
||||
|
||||
sql security invoker
|
||||
|
||||
deterministic
|
||||
|
||||
begin
|
||||
|
||||
update Storage set DiskSpace = COALESCE(DiskSpace,0) + COALESCE(space,0) where Id = StorageId;
|
||||
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS event_delete_trigger//
|
||||
|
||||
CREATE TRIGGER event_delete_trigger BEFORE DELETE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Day WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Week WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Month WHERE EventId=OLD.Id;
|
||||
IF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEvents = ArchivedEvents - 1,
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0),
|
||||
TotalEvents = TotalEvents - 1,
|
||||
TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET
|
||||
TotalEvents = TotalEvents-1,
|
||||
TotalEventDiskSpace=COALESCE(TotalEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
UPDATE Storage SET DiskSpace=(SELECT SUM(COALESCE(DiskSpace,0)) FROM Events WHERE StorageId=Storage.Id)//
|
|
@ -0,0 +1,276 @@
|
|||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Hour_delete_trigger//
|
||||
CREATE TRIGGER Events_Hour_delete_trigger BEFORE DELETE ON Events_Hour
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,1)-1,
|
||||
HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Hour_update_trigger//
|
||||
|
||||
CREATE TRIGGER Events_Hour_update_trigger AFTER UPDATE ON Events_Hour
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
DELIMITER ;
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Day_delete_trigger//
|
||||
CREATE TRIGGER Events_Day_delete_trigger BEFORE DELETE ON Events_Day
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
DayEvents = COALESCE(DayEvents,1)-1,
|
||||
DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Day_update_trigger;
|
||||
CREATE TRIGGER Events_Day_update_trigger AFTER UPDATE ON Events_Day
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Week_delete_trigger//
|
||||
CREATE TRIGGER Events_Week_delete_trigger BEFORE DELETE ON Events_Week
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
WeekEvents = COALESCE(WeekEvents,1)-1,
|
||||
WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Week_update_trigger;
|
||||
CREATE TRIGGER Events_Week_update_trigger AFTER UPDATE ON Events_Week
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Month_delete_trigger//
|
||||
CREATE TRIGGER Events_Month_delete_trigger BEFORE DELETE ON Events_Month
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
MonthEvents = COALESCE(MonthEvents,1)-1,
|
||||
MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Month_update_trigger;
|
||||
CREATE TRIGGER Events_Month_update_trigger AFTER UPDATE ON Events_Month
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+COALESCE(NEW.DiskSpace) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
drop procedure if exists update_storage_stats;
|
||||
create procedure update_storage_stats(IN StorageId smallint(5), IN space BIGINT)
|
||||
|
||||
sql security invoker
|
||||
|
||||
deterministic
|
||||
|
||||
begin
|
||||
|
||||
update Storage set DiskSpace = COALESCE(DiskSpace,0) + COALESCE(space,0) where Id = StorageId;
|
||||
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
drop trigger if exists event_update_trigger//
|
||||
|
||||
CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
||||
IF ( diff ) THEN
|
||||
call update_storage_stats(OLD.StorageId, diff);
|
||||
END IF;
|
||||
ELSE
|
||||
IF ( NEW.DiskSpace ) THEN
|
||||
call update_storage_stats(NEW.StorageId, NEW.DiskSpace);
|
||||
END IF;
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Week SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Month SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
|
||||
IF ( NEW.Archived != OLD.Archived ) THEN
|
||||
IF ( NEW.Archived ) THEN
|
||||
INSERT INTO Events_Archived (EventId,MonitorId,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.DiskSpace);
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)+1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=NEW.MonitorId;
|
||||
ELSEIF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)-1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
ELSEIF ( NEW.Archived AND diff ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
END IF;
|
||||
|
||||
IF ( diff ) THEN
|
||||
UPDATE Monitors SET TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger;
|
||||
|
||||
delimiter //
|
||||
/* The assumption is that when an Event is inserted, it has no size yet, so don't bother updating the DiskSpace, just the count.
|
||||
* The DiskSpace will get update in the Event Update Trigger
|
||||
*/
|
||||
CREATE TRIGGER event_insert_trigger AFTER INSERT ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,0)+1,
|
||||
DayEvents = COALESCE(DayEvents,0)+1,
|
||||
WeekEvents = COALESCE(WeekEvents,0)+1,
|
||||
MonthEvents = COALESCE(MonthEvents,0)+1,
|
||||
TotalEvents = COALESCE(TotalEvents,0)+1
|
||||
WHERE Id=NEW.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS event_delete_trigger//
|
||||
|
||||
CREATE TRIGGER event_delete_trigger BEFORE DELETE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Day WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Week WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Month WHERE EventId=OLD.Id;
|
||||
IF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEvents = COALESCE(ArchivedEvents,1) - 1,
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0),
|
||||
TotalEvents = COALESCE(TotalEvents,1) - 1,
|
||||
TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET
|
||||
TotalEvents = COALESCE(TotalEvents,1)-1,
|
||||
TotalEventDiskSpace=COALESCE(TotalEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Zone_Insert_Trigger//
|
||||
CREATE TRIGGER Zone_Insert_Trigger AFTER INSERT ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=NEW.MonitorId) WHERE Id=NEW.MonitorID;
|
||||
END
|
||||
//
|
||||
DROP TRIGGER IF EXISTS Zone_Delete_Trigger//
|
||||
CREATE TRIGGER Zone_Delete_Trigger AFTER DELETE ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=OLD.MonitorId) WHERE Id=OLD.MonitorID;
|
||||
END
|
||||
//
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
UPDATE Monitors SET
|
||||
TotalEvents=(SELECT COUNT(*) FROM Events WHERE MonitorId=Monitors.Id),
|
||||
TotalEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
HourEvents=(SELECT COUNT(*) FROM Events_Hour WHERE MonitorId=Monitors.Id),
|
||||
HourEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Hour WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
DayEvents=(SELECT COUNT(*) FROM Events_Day WHERE MonitorId=Monitors.Id),
|
||||
DayEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Day WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
WeekEvents=(SELECT COUNT(Id) FROM Events_Week WHERE MonitorId=Monitors.Id),
|
||||
WeekEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Week WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
MonthEvents=(SELECT COUNT(Id) FROM Events_Month WHERE MonitorId=Monitors.Id),
|
||||
MonthEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Month WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
ArchivedEvents=(SELECT COUNT(Id) FROM Events_Archived WHERE MonitorId=Monitors.Id),
|
||||
ArchivedEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Archived WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL);
|
|
@ -0,0 +1,275 @@
|
|||
|
||||
ALTER TABLE `Monitors` MODIFY `HourEvents` INT(10) DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `HourEventDiskSpace` BIGINT DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `DayEvents` INT(10) DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `DayEventDiskSpace` BIGINT DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `WeekEvents` INT(10) DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `WeekEventDiskSpace` BIGINT DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `MonthEvents` INT(10) DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `MonthEventDiskSpace` BIGINT DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `ArchivedEvents` INT(10) DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `ArchivedEventDiskSpace` BIGINT DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `TotalEvents` INT(10) DEFAULT NULL;
|
||||
ALTER TABLE `Monitors` MODIFY `TotalEventDiskSpace` BIGINT DEFAULT NULL;
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Hour_delete_trigger//
|
||||
CREATE TRIGGER Events_Hour_delete_trigger BEFORE DELETE ON Events_Hour
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,1)-1,
|
||||
HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Hour_update_trigger//
|
||||
|
||||
CREATE TRIGGER Events_Hour_update_trigger AFTER UPDATE ON Events_Hour
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
DELIMITER ;
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Day_delete_trigger//
|
||||
CREATE TRIGGER Events_Day_delete_trigger BEFORE DELETE ON Events_Day
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
DayEvents = COALESCE(DayEvents,1)-1,
|
||||
DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Day_update_trigger;
|
||||
CREATE TRIGGER Events_Day_update_trigger AFTER UPDATE ON Events_Day
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Week_delete_trigger//
|
||||
CREATE TRIGGER Events_Week_delete_trigger BEFORE DELETE ON Events_Week
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
WeekEvents = COALESCE(WeekEvents,1)-1,
|
||||
WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Week_update_trigger;
|
||||
CREATE TRIGGER Events_Week_update_trigger AFTER UPDATE ON Events_Week
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Month_delete_trigger//
|
||||
CREATE TRIGGER Events_Month_delete_trigger BEFORE DELETE ON Events_Month
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
MonthEvents = COALESCE(MonthEvents,1)-1,
|
||||
MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Month_update_trigger;
|
||||
CREATE TRIGGER Events_Month_update_trigger AFTER UPDATE ON Events_Month
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+COALESCE(NEW.DiskSpace) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
drop procedure if exists update_storage_stats;
|
||||
create procedure update_storage_stats(IN StorageId smallint(5), IN space BIGINT)
|
||||
|
||||
sql security invoker
|
||||
|
||||
deterministic
|
||||
|
||||
begin
|
||||
|
||||
update Storage set DiskSpace = COALESCE(DiskSpace,0) + COALESCE(space,0) where Id = StorageId;
|
||||
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
drop trigger if exists event_update_trigger//
|
||||
|
||||
CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
||||
IF ( diff ) THEN
|
||||
call update_storage_stats(OLD.StorageId, diff);
|
||||
END IF;
|
||||
ELSE
|
||||
IF ( NEW.DiskSpace ) THEN
|
||||
call update_storage_stats(NEW.StorageId, NEW.DiskSpace);
|
||||
END IF;
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Week SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Month SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
|
||||
IF ( NEW.Archived != OLD.Archived ) THEN
|
||||
IF ( NEW.Archived ) THEN
|
||||
INSERT INTO Events_Archived (EventId,MonitorId,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.DiskSpace);
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)+1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=NEW.MonitorId;
|
||||
ELSEIF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)-1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
ELSEIF ( NEW.Archived AND diff ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
END IF;
|
||||
|
||||
IF ( diff ) THEN
|
||||
UPDATE Monitors SET TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger;
|
||||
|
||||
delimiter //
|
||||
/* The assumption is that when an Event is inserted, it has no size yet, so don't bother updating the DiskSpace, just the count.
|
||||
* The DiskSpace will get update in the Event Update Trigger
|
||||
*/
|
||||
CREATE TRIGGER event_insert_trigger AFTER INSERT ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,0)+1,
|
||||
DayEvents = COALESCE(DayEvents,0)+1,
|
||||
WeekEvents = COALESCE(WeekEvents,0)+1,
|
||||
MonthEvents = COALESCE(MonthEvents,0)+1,
|
||||
TotalEvents = COALESCE(TotalEvents,0)+1
|
||||
WHERE Id=NEW.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS event_delete_trigger//
|
||||
|
||||
CREATE TRIGGER event_delete_trigger BEFORE DELETE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
call update_storage_stats(OLD.StorageId, -OLD.DiskSpace);
|
||||
END IF;
|
||||
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Day WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Week WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Month WHERE EventId=OLD.Id;
|
||||
IF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEvents = COALESCE(ArchivedEvents,1) - 1,
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0),
|
||||
TotalEvents = COALESCE(TotalEvents,1) - 1,
|
||||
TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET
|
||||
TotalEvents = COALESCE(TotalEvents,1)-1,
|
||||
TotalEventDiskSpace=COALESCE(TotalEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Zone_Insert_Trigger//
|
||||
CREATE TRIGGER Zone_Insert_Trigger AFTER INSERT ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=NEW.MonitorId) WHERE Id=NEW.MonitorID;
|
||||
END
|
||||
//
|
||||
DROP TRIGGER IF EXISTS Zone_Delete_Trigger//
|
||||
CREATE TRIGGER Zone_Delete_Trigger AFTER DELETE ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=OLD.MonitorId) WHERE Id=OLD.MonitorID;
|
||||
END
|
||||
//
|
||||
|
||||
DELIMITER ;
|
|
@ -0,0 +1,42 @@
|
|||
--
|
||||
-- This adds Manufacturers and Models
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name = 'Manufacturers'
|
||||
AND table_schema = DATABASE()
|
||||
) > 0,
|
||||
"SELECT 'Manufacturers table exists'",
|
||||
"
|
||||
CREATE TABLE `Manufacturers` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` varchar(64) NOT NULL,
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY (`Name`)
|
||||
)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_name = 'Models'
|
||||
AND table_schema = DATABASE()
|
||||
) > 0,
|
||||
"SELECT 'Models table exists'",
|
||||
"CREATE TABLE `Models` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Name` varchar(64) NOT NULL,
|
||||
`ManufacturerId` int(10),
|
||||
PRIMARY KEY (`Id`),
|
||||
UNIQUE KEY (`ManufacturerId`,`Name`)
|
||||
)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Storage'
|
||||
AND column_name = 'Url'
|
||||
) > 0,
|
||||
"SELECT 'Column Url already exists in Storage'",
|
||||
"ALTER TABLE `Storage` ADD `Url` VARCHAR(255) default NULL AFTER `Type`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,17 @@
|
|||
--
|
||||
-- Add StorageId column to Monitors
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Groups'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'ParentId'
|
||||
) > 0,
|
||||
"SELECT 'Column GroupId exists in Groups'",
|
||||
"ALTER TABLE Groups ADD `ParentId` int(10) unsigned AFTER `Name`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE Monitors MODIFY `Type` enum('Local','Remote','File','Ffmpeg','Libvlc','cURL','NVSocket') NOT NULL default 'Local';
|
|
@ -0,0 +1,12 @@
|
|||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Groups'
|
||||
AND column_name = 'MonitorIds'
|
||||
) > 0,
|
||||
"ALTER TABLE Groups MODIFY `MonitorIds` text NOT NULL",
|
||||
"SELECT 'Groups no longer has MonitorIds'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
--
|
||||
-- Add StorageId column to Monitors
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Events'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DiskSpace'
|
||||
) > 0,
|
||||
"SELECT 'Column DiskSpace exists in Events'",
|
||||
"ALTER TABLE Events ADD `DiskSpace` bigint unsigned default null AFTER `Orientation`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,17 @@
|
|||
--
|
||||
-- Add Type column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Storage'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Type'
|
||||
) > 0,
|
||||
"SELECT 'Column Type already exists in Storage'",
|
||||
"ALTER TABLE Storage ADD `Type` enum('local','s3fs') NOT NULL default 'local' AFTER `Name`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -44,7 +44,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
|||
, libpcre3
|
||||
, ffmpeg | libav-tools, libavdevice53 | libavdevice55 | libavdevice57
|
||||
, rsyslog | system-log-daemon
|
||||
, netpbm , libjpeg8
|
||||
, netpbm
|
||||
, zip
|
||||
, libvlccore5 | libvlccore7 | libvlccore8, libvlc5
|
||||
, libpolkit-gobject-1-0, php5-gd
|
||||
|
|
|
@ -5,6 +5,9 @@ set -e
|
|||
if [ "$1" = "configure" ]; then
|
||||
|
||||
. /etc/zm/zm.conf
|
||||
for i in /etc/zm/conf.d/*.conf; do
|
||||
. $i
|
||||
done;
|
||||
|
||||
# The logs can contain passwords, etc... so by setting group root, only www-data can read them, not people in the www-data group.
|
||||
chown www-data:root /var/log/zm
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<<<<<<< HEAD
|
||||
zoneminder (1.31.0-trusty) trusty; urgency=medium
|
||||
|
||||
* placeholder
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Fri, 13 May 2016 09:45:49 -0400
|
||||
=======
|
||||
>>>>>>> master
|
|
@ -5,6 +5,7 @@ Maintainer: Dmitry Smirnov <onlyjob@debian.org>
|
|||
Uploaders: Vagrant Cascadian <vagrant@debian.org>
|
||||
Build-Depends: debhelper (>= 9), python-sphinx | python3-sphinx, apache2-dev, dh-linktree
|
||||
,cmake
|
||||
,libx264-dev, libmp4v2-dev
|
||||
,libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libavdevice-dev
|
||||
,libbz2-dev
|
||||
,libgcrypt-dev
|
||||
|
@ -34,6 +35,7 @@ Package: zoneminder
|
|||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
||||
,javascript-common
|
||||
,libmp4v2-2, libx264-142
|
||||
,libav-tools|ffmpeg
|
||||
,libdate-manip-perl
|
||||
,libdbd-mysql-perl
|
||||
|
@ -52,6 +54,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
|||
,liburi-encode-perl
|
||||
,libwww-perl
|
||||
,libdata-uuid-perl
|
||||
,libnumber-bytes-human
|
||||
,mysql-client | virtual-mysql-client
|
||||
,perl-modules
|
||||
,php5-mysql, php5-gd, php5-apcu, php-apc
|
||||
|
|
|
@ -5,6 +5,10 @@ set -e
|
|||
if [ "$1" = "configure" ]; then
|
||||
|
||||
. /etc/zm/zm.conf
|
||||
for i in /etc/zm/conf.d/*.conf; do
|
||||
. $i
|
||||
done;
|
||||
|
||||
|
||||
# The logs can contain passwords, etc... so by setting group root, only www-data can read them, not people in the www-data group
|
||||
chown www-data:root /var/log/zm
|
||||
|
@ -31,9 +35,9 @@ if [ "$1" = "configure" ]; then
|
|||
if ! $(echo quit | mysql --defaults-file=/etc/mysql/debian.cnf zm > /dev/null 2> /dev/null) ; then
|
||||
cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/debian.cnf
|
||||
# This creates the user.
|
||||
echo "grant lock tables, alter,select,insert,update,delete,create,index on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost identified by \"${ZM_DB_PASS}\";" | mysql --defaults-file=/etc/mysql/debian.cnf mysql
|
||||
echo "grant lock tables, alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost identified by \"${ZM_DB_PASS}\";" | mysql --defaults-file=/etc/mysql/debian.cnf mysql
|
||||
else
|
||||
echo "grant lock tables, alter,select,insert,update,delete,create,index on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql
|
||||
echo "grant lock tables, alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql
|
||||
fi
|
||||
|
||||
zmupdate.pl --nointeractive
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
[Unit]
|
||||
Description=ZoneMinder CCTV recording and surveillance system
|
||||
After=network.target mysql.service
|
||||
Requires=mysql.service
|
||||
# Remarked out so that it will start ZM on machines that don't have mysql installed
|
||||
#Requires=mysql.service
|
||||
|
||||
[Service]
|
||||
#User=www-data
|
||||
|
@ -13,7 +14,10 @@ ExecStart=/usr/bin/zmpkg.pl start
|
|||
ExecReload=/usr/bin/zmpkg.pl restart
|
||||
ExecStop=/usr/bin/zmpkg.pl stop
|
||||
PIDFile=/var/run/zm/zm.pid
|
||||
Restart=on-abnormal
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
Environment=TZ=:/etc/localtime
|
||||
TimeoutSec=600
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
zoneminder for Debian
|
||||
---------------------
|
||||
|
||||
There is one manual step to get the web interface working.
|
||||
You need to link /etc/zm/apache.conf to /etc/apache2/conf.d/zoneminder.conf,
|
||||
then reload the apache config (i.e. /etc/init.d/apache2 reload)
|
||||
|
||||
Changing the location for images and events
|
||||
-------------------------------------------
|
||||
|
||||
Zoneminder, in its upstream form, stores data in /usr/share/zoneminder/. This
|
||||
package modifies that by changing /usr/share/zoneminder/images and
|
||||
/usr/share/zoneminder/events to symlinks to directories under
|
||||
/var/cache/zoneminder.
|
||||
|
||||
There are numerous places these could be put and ways to do it. But, at the
|
||||
moment, if you change this, an upgrade will fail with a warning about these
|
||||
locations having changed (the reason for this was that previously, an upgrade
|
||||
would silently revert the changes and cause event loss - refer
|
||||
bug #608793).
|
||||
|
||||
If you do want to change the location, here are a couple of suggestions.
|
||||
|
||||
These lines would mount /dev/sdX1 to /video_storage, and then 'link' /video_storage
|
||||
to the locations that ZoneMinder expects them to be at.
|
||||
|
||||
/dev/sdX1 /video_storage ext4 defaults 0 2
|
||||
/video_storage/zoneminder/images /var/cache/zoneminder/images none bind 0 2
|
||||
/video_storage/zoneminder/events /var/cache/zoneminder/events none bind 0 2
|
||||
|
||||
or if you have a separate partition for each:
|
||||
|
||||
/dev/sdX1 /var/cache/zoneminder/images ext4 defaults 0 2
|
||||
/dev/sdX2 /var/cache/zoneminder/events ext4 defaults 0 2
|
||||
|
||||
|
||||
|
||||
-- Peter Howard <pjh@northern-ridge.com.au>, Sun, 16 Jan 2010 01:35:51 +1100
|
||||
|
||||
Access to /dev/video*
|
||||
---------------------
|
||||
|
||||
For cameras which require access to /dev/video*, zoneminder may need the
|
||||
www-data user added to the video group in order to see those cameras:
|
||||
|
||||
adduser www-data video
|
||||
|
||||
Note that all web applications running on the zoneminder server will then have
|
||||
access to all video devices on the system.
|
||||
|
||||
-- Vagrant Cascadian <vagrant@debian.org> Sun, 27 Mar 2011 13:06:56 -0700
|
|
@ -0,0 +1,9 @@
|
|||
Alias /zm /usr/share/zoneminder
|
||||
|
||||
<Directory /usr/share/zoneminder>
|
||||
php_flag register_globals off
|
||||
Options Indexes FollowSymLinks
|
||||
<IfModule mod_dir.c>
|
||||
DirectoryIndex index.php
|
||||
</IfModule>
|
||||
</Directory>
|
|
@ -0,0 +1,323 @@
|
|||
zoneminder (1.30.2-trusty-2016033001) trusty; urgency=medium
|
||||
|
||||
* merge master
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Wed, 30 Mar 2016 14:09:48 -0400
|
||||
|
||||
zoneminder (1.30.2-trusty-2016032901) trusty; urgency=medium
|
||||
|
||||
* filter fixes, merge options rework by Kyle
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Tue, 29 Mar 2016 12:27:57 -0400
|
||||
|
||||
zoneminder (1.30.2-trusty-2016030702) trusty; urgency=medium
|
||||
|
||||
*
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Mon, 07 Mar 2016 22:14:03 -0500
|
||||
|
||||
zoneminder (1.30.2-trusty-2016030701) trusty; urgency=medium
|
||||
|
||||
* merge master. with telemetry
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Mon, 07 Mar 2016 21:47:53 -0500
|
||||
|
||||
zoneminder (1.30.2-trusty-2016022101) trusty; urgency=medium
|
||||
|
||||
* merge zmtrigger fix
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Mon, 22 Feb 2016 09:15:53 -0500
|
||||
|
||||
zoneminder (1.30.2-trusty-2016021901) trusty; urgency=medium
|
||||
|
||||
* zmtrigger improvements
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Fri, 19 Feb 2016 11:09:57 -0500
|
||||
|
||||
zoneminder (1.30.2-trusty-2016021701) trusty; urgency=medium
|
||||
|
||||
* printout id, and ip address when failing to connect
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Wed, 17 Feb 2016 09:40:49 -0500
|
||||
|
||||
zoneminder (1.30.2-trusty-2016021001) trusty; urgency=medium
|
||||
|
||||
*
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Wed, 10 Feb 2016 13:06:09 -0500
|
||||
|
||||
zoneminder (1.29.111-trusty-2016020101) trusty; urgency=medium
|
||||
|
||||
* Fix video download and use of Storage Areas
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Mon, 01 Feb 2016 13:42:06 -0500
|
||||
|
||||
zoneminder (1.29.111-trusty-2016011401) trusty; urgency=medium
|
||||
|
||||
* fix timeline view for storageareas
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Thu, 14 Jan 2016 14:03:41 -0500
|
||||
|
||||
zoneminder (1.29.111-trusty-2016010801) trusty; urgency=medium
|
||||
|
||||
* Add better debug and skip when event links are not just digits. Merge multi-server stuff from master.
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Fri, 08 Jan 2016 10:37:16 -0500
|
||||
|
||||
zoneminder (1.29.111-trusty-2016010401) trusty; urgency=medium
|
||||
|
||||
* include fix to rotate image dimensions when applying a rotation
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Mon, 04 Jan 2016 13:24:42 -0500
|
||||
|
||||
zoneminder (1.29.111-trusty-2016010101) trusty; urgency=medium
|
||||
|
||||
* fix logging with multi-server
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Fri, 01 Jan 2016 17:11:09 -0500
|
||||
|
||||
zoneminder (1.29.111-trusty-2015123101) trusty; urgency=medium
|
||||
|
||||
* Add log filtering from multi-server
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Thu, 31 Dec 2015 10:18:03 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015122401) trusty; urgency=medium
|
||||
|
||||
* fix delete events not in database in zmaudit.pl
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Thu, 24 Dec 2015 12:38:05 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015122301) trusty; urgency=medium
|
||||
|
||||
* todays release
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Wed, 23 Dec 2015 09:33:46 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015122202) trusty; urgency=medium
|
||||
|
||||
* more object work and zmaudit
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Tue, 22 Dec 2015 13:13:56 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015122201) trusty; urgency=medium
|
||||
|
||||
* merge multi-server, and master stuff, start work on zmaudit storage areas support
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Tue, 22 Dec 2015 11:11:44 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015122103) trusty; urgency=medium
|
||||
|
||||
* Fixes
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Mon, 21 Dec 2015 15:20:15 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015122102) trusty; urgency=medium
|
||||
|
||||
* fix deleting events
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Mon, 21 Dec 2015 14:49:12 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015122101) trusty; urgency=medium
|
||||
|
||||
* Make zmfilter work.
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Mon, 21 Dec 2015 12:32:27 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015121803) trusty; urgency=medium
|
||||
|
||||
* merge zmvideo improvements
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Fri, 18 Dec 2015 14:17:56 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015121802) trusty; urgency=medium
|
||||
|
||||
* Add some missing files to the autoconf build
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Fri, 18 Dec 2015 12:14:08 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015121801) trusty; urgency=medium
|
||||
|
||||
*
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Fri, 18 Dec 2015 11:05:58 -0500
|
||||
|
||||
zoneminder (1.29.109-trusty-2015121701) trusty; urgency=medium
|
||||
|
||||
* Merge master + better zmvideo
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Thu, 17 Dec 2015 15:11:18 -0500
|
||||
|
||||
zoneminder (1.29.0-trusty-2015112301) trusty; urgency=medium
|
||||
|
||||
* apply fix for zms crash
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Mon, 23 Nov 2015 10:47:49 -0500
|
||||
|
||||
zoneminder (1.29.0-trusty-2015110601) trusty; urgency=medium
|
||||
|
||||
* add a FIONREAD test on timeout
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Wed, 22 Jul 2015 09:55:37 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-2015072201) trusty; urgency=medium
|
||||
|
||||
* add AnalysisFPS
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Wed, 22 Jul 2015 09:55:37 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-2015071601) trusty; urgency=medium
|
||||
|
||||
* Merge master and zmtrigger
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Thu, 16 Jul 2015 13:15:58 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-38) trusty; urgency=medium
|
||||
|
||||
* Merge master
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Tue, 14 Jul 2015 10:15:00 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-37) trusty; urgency=medium
|
||||
|
||||
* merge master api stuff, set sleep after failure to capture to 5000 instead of 5000000
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Fri, 19 Jun 2015 09:59:54 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-36) trusty; urgency=medium
|
||||
|
||||
* Detect select interuption when no action on our fd
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Thu, 28 May 2015 09:35:59 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-35) trusty; urgency=medium
|
||||
|
||||
* better logging
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Fri, 22 May 2015 15:30:42 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-34) trusty; urgency=medium
|
||||
|
||||
* Faster shutdown and changes to ReadData
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Thu, 21 May 2015 15:54:47 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-33) trusty; urgency=medium
|
||||
|
||||
* update zmaudit some more
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Thu, 14 May 2015 13:44:35 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-32) trusty; urgency=medium
|
||||
|
||||
* merge zmaudit_updates1
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Wed, 13 May 2015 15:51:56 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-31) trusty; urgency=medium
|
||||
|
||||
* Merge some fixes and zmaudit improvements
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Wed, 13 May 2015 15:16:19 -0400
|
||||
|
||||
zoneminder (1.29.0-trusty-27) trusty; urgency=medium
|
||||
|
||||
* fflush logs, merge master.
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Mon, 30 Mar 2015 19:28:05 -0400
|
||||
|
||||
zoneminder (1.29.0-vivid-26) vivid; urgency=medium
|
||||
|
||||
* logging improvements, merge RedData changes
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Wed, 04 Mar 2015 16:39:19 -0500
|
||||
|
||||
zoneminder (1.29.0-vivid-25) vivid; urgency=medium
|
||||
|
||||
* some change to ReadData
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Mon, 02 Mar 2015 12:57:16 -0500
|
||||
|
||||
zoneminder (1.29.0-utopic-24) utopic; urgency=medium
|
||||
|
||||
* merge local_raw
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Mon, 23 Feb 2015 17:49:36 -0500
|
||||
|
||||
zoneminder (1.29.0-trusty-23) trusty; urgency=medium
|
||||
|
||||
* more onvif merges, fix to zmfilter
|
||||
|
||||
-- Isaac Connor <iconnor@testing.internal.point-one.com> Sat, 21 Feb 2015 16:17:01 -0500
|
||||
|
||||
zoneminder (1.29.0-trusty-22) trusty; urgency=medium
|
||||
|
||||
* updates from master: merge onvif, default to classic if skin not defined.
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Thu, 19 Feb 2015 18:14:58 -0500
|
||||
|
||||
zoneminder (1.29.0-utopic-21) utopic; urgency=medium
|
||||
|
||||
* updates from master, improve monitor probing and support TRENDnet cameras
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Tue, 17 Feb 2015 14:18:52 -0500
|
||||
|
||||
zoneminder (1.29.0-wheezy-20) wheezy; urgency=medium
|
||||
|
||||
* zmaudit.pl improvements - double check db before deleting fs event
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Wed, 04 Feb 2015 11:09:22 -0500
|
||||
|
||||
zoneminder (1.29.0-utopic-18) utopic; urgency=medium
|
||||
|
||||
* RTSP Timeout fixes
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Wed, 28 Jan 2015 13:49:16 -0500
|
||||
|
||||
zoneminder (1.29.0-utopic-17) utopic; urgency=medium
|
||||
|
||||
* Merge master, use new split-up debian build
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Mon, 26 Jan 2015 11:21:07 -0500
|
||||
|
||||
zoneminder (1.28.0+nmu1) testing; urgency=medium
|
||||
|
||||
* Non-maintainer upload
|
||||
* Split the debian package into several packages
|
||||
* Switch to native source format
|
||||
|
||||
-- Emmanuel Papin <manupap01@gmail.com> Thu, 15 Jan 2015 20:00:08 +0100
|
||||
|
||||
zoneminder (1.28.0-0.2) testing; urgency=medium
|
||||
|
||||
* Non-maintainer upload.
|
||||
* Upstream release for debian jessie
|
||||
* Package dependencies updated
|
||||
* debhelper version upgraded
|
||||
* Standards-Version upgraded
|
||||
* Use debhelper commands instead of standard commands
|
||||
* Install man pages in /usr/share/man (patch added)
|
||||
* Switch to quilt
|
||||
* Switch to systemd
|
||||
* Some lintian fixes
|
||||
|
||||
-- Emmanuel Papin <manupap01@gmail.com> Wed, 26 Nov 2014 00:26:01 +0100
|
||||
|
||||
zoneminder (1.28.0-0.1) stable; urgency=medium
|
||||
|
||||
* Release
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Fri, 17 Oct 2014 09:27:22 -0400
|
||||
|
||||
zoneminder (1.27.99+1-testing-SNAPSHOT2014072901) testing; urgency=medium
|
||||
|
||||
* improve error messages
|
||||
* Make zmupdate re-run the most recent patch so that people running the daily builds get their db updates
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Tue, 29 Jul 2014 14:50:20 -0400
|
||||
|
||||
zoneminder (1.27.0+1-testing-v4ltomonitor-1) testing; urgency=high
|
||||
|
||||
* Snapshot release -
|
||||
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Wed, 09 Jul 2014 21:35:29 -0400
|
|
@ -0,0 +1 @@
|
|||
9
|
|
@ -0,0 +1,122 @@
|
|||
Source: zoneminder
|
||||
Section: net
|
||||
Priority: optional
|
||||
Maintainer: Isaac Connor <iconnor@connortechnology.com>
|
||||
Build-Depends: debhelper (>= 9), po-debconf (>= 1.0), autoconf, automake, libphp-serialization-perl, libgnutls-dev, libmysqlclient-dev | libmariadbclient-dev, libdbd-mysql-perl, libdate-manip-perl, libwww-perl, libjpeg8-dev | libjpeg9-dev | libjpeg62-turbo-dev, libpcre3-dev, libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libv4l-dev (>= 0.8.3), libbz2-dev, libtool, libsys-mmap-perl, libavdevice-dev, libdevice-serialport-perl, libarchive-zip-perl, libmime-lite-perl, dh-autoreconf, libvlccore-dev, libvlc-dev, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libgcrypt11-dev | libgcrypt20-dev, libpolkit-gobject-1-dev, libdbi-perl, libnet-sftp-foreign-perl, libexpect-perl, libmime-tools-perl, libx264-dev, libmp4v2-dev, libpcre3-dev
|
||||
Standards-Version: 3.9.6
|
||||
|
||||
Package: zoneminder
|
||||
Section: metapackages
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends},
|
||||
libzoneminder-perl (>= ${source:Version}),
|
||||
zoneminder-database (>= ${source:Version}),
|
||||
zoneminder-core (>= ${binary:Version}),
|
||||
zoneminder-ui-base (>= ${source:Version}),
|
||||
zoneminder-ui-classic (>= ${source:Version}),
|
||||
zoneminder-ui-mobile (>= ${source:Version}),
|
||||
zoneminder-ui-xml (>= ${source:Version})
|
||||
Description: Video camera security and surveillance solution (metapackage)
|
||||
ZoneMinder is intended for use in single or multi-camera video security
|
||||
applications, including commercial or home CCTV, theft prevention and child
|
||||
or family member or home monitoring and other care scenarios. It
|
||||
supports capture, analysis, recording, and monitoring of video data coming
|
||||
from one or more video or network cameras attached to a Linux system.
|
||||
ZoneMinder also support web and semi-automatic control of Pan/Tilt/Zoom
|
||||
cameras using a variety of protocols. It is suitable for use as a home
|
||||
video security system and for commercial or professional video security
|
||||
and surveillance. It can also be integrated into a home automation system
|
||||
via X.10 or other protocols.
|
||||
|
||||
Package: libzoneminder-perl
|
||||
Section: perl
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, ${perl:Depends}, libdbi-perl,
|
||||
libdevice-serialport-perl, libimage-info-perl, libjson-any-perl,
|
||||
libsys-mmap-perl, liburi-encode-perl, libwww-perl
|
||||
Description: Perl libraries for ZoneMinder
|
||||
ZoneMinder is a video camera security and surveillance solution.
|
||||
.
|
||||
This package provides the libraries for the perl scripts, it can be used to
|
||||
write custom interfaces as well.
|
||||
|
||||
Package: zoneminder-database
|
||||
Section: database
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, debconf, dbconfig-common,
|
||||
mysql-client | mariadb-client
|
||||
Recommends: mysql-server | mariadb-server
|
||||
Description: Database management package for ZoneMinder
|
||||
ZoneMinder is a video camera security and surveillance solution.
|
||||
.
|
||||
This package provides the sql files and maintenance scripts to perform all the
|
||||
database operations (installation, upgrade or removal) on a local or a remote
|
||||
server.
|
||||
|
||||
Package: zoneminder-core
|
||||
Section: video
|
||||
Architecture: any
|
||||
Depends: libzoneminder-perl (= ${source:Version}),
|
||||
zoneminder-database (= ${source:Version}), ${shlibs:Depends}, ${misc:Depends},
|
||||
${perl:Depends}, libarchive-tar-perl, libarchive-zip-perl, libdate-manip-perl,
|
||||
libdbi-perl, libmodule-load-conditional-perl, libmime-lite-perl,
|
||||
libmime-tools-perl, libnet-sftp-foreign-perl, libphp-serialization-perl,
|
||||
debconf, ffmpeg | libav-tools, rsyslog | system-log-daemon, zip,
|
||||
policykit-1, apache2, libmp4v2-2, libpcre++0
|
||||
Description: Core binaries and perl scripts for ZoneMinder
|
||||
ZoneMinder is a video camera security and surveillance solution.
|
||||
.
|
||||
This package provides the executable compiled binaries which do the main video
|
||||
processing work and the perl scripts which perform helper and/or external
|
||||
interface tasks.
|
||||
|
||||
Package: zoneminder-core-dbg
|
||||
Priority: extra
|
||||
Section: debug
|
||||
Architecture: any
|
||||
Depends: zoneminder-core (= ${binary:Version}), ${misc:Depends}
|
||||
Description: Debugging symbols for ZoneMinder
|
||||
ZoneMinder is a video camera security and surveillance solution.
|
||||
.
|
||||
This package provides the debugging symbols for the executable compiled
|
||||
binaries.
|
||||
|
||||
Package: zoneminder-ui-base
|
||||
Section: web
|
||||
Architecture: any
|
||||
Depends: zoneminder-core (= ${binary:Version}), ${shlibs:Depends},
|
||||
${misc:Depends}, debconf, apache2, libapache2-mod-php5 | libapache2-mod-fcgid,
|
||||
php5, php5-mysql | php5-mysqlnd, php5-gd
|
||||
Description: Essential files for ZoneMinder's web user interface
|
||||
ZoneMinder is a video camera security and surveillance solution.
|
||||
.
|
||||
This package provides the essential web files and maintenance scripts to set up
|
||||
a basic web environment.
|
||||
|
||||
Package: zoneminder-ui-classic
|
||||
Section: web
|
||||
Architecture: all
|
||||
Depends: zoneminder-ui-base (>= ${source:Version}), ${misc:Depends}
|
||||
Description: Classic web user interface for ZoneMinder
|
||||
ZoneMinder is a video camera security and surveillance solution.
|
||||
.
|
||||
This package provides the classic web user interface.
|
||||
|
||||
Package: zoneminder-ui-mobile
|
||||
Section: web
|
||||
Architecture: all
|
||||
Depends: zoneminder-ui-base (>= ${source:Version}), ${misc:Depends}
|
||||
Description: Mobile web user interface for ZoneMinder
|
||||
ZoneMinder is a video camera security and surveillance solution.
|
||||
.
|
||||
This package provides the web user interface for mobile devices.
|
||||
|
||||
Package: zoneminder-ui-xml
|
||||
Section: web
|
||||
Architecture: all
|
||||
Depends: zoneminder-ui-base (>= ${source:Version}), ${misc:Depends}
|
||||
Description: XML interface for ZoneMinder
|
||||
ZoneMinder is a video camera security and surveillance solution.
|
||||
.
|
||||
This package provides a XML interface mainly intended for use with the eyeZm
|
||||
iPhone Application, but can be used with any other custom programs as well.
|
|
@ -0,0 +1,22 @@
|
|||
Copyright:
|
||||
|
||||
Copyright 2002 Philip Coombes <philip.coombes@zoneminder.com>
|
||||
|
||||
License:
|
||||
|
||||
This package is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This package is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this package; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
On Debian GNU/Linux systems, the text of the GPL can be found in
|
||||
/usr/share/common-licenses/GPL.
|
|
@ -0,0 +1 @@
|
|||
README.md
|
|
@ -0,0 +1,4 @@
|
|||
usr/share/perl5/ZoneMinder
|
||||
usr/share/perl5/ZoneMinder.pm
|
||||
debian/tmp/usr/share/man/man3/ZoneMinder.3pm
|
||||
debian/tmp/usr/share/man/man3/ZoneMinder::*
|
|
@ -0,0 +1,3 @@
|
|||
[type: gettext/rfc822deb] zoneminder-core.templates
|
||||
[type: gettext/rfc822deb] zoneminder-database.templates
|
||||
[type: gettext/rfc822deb] zoneminder-ui-base.templates
|
|
@ -0,0 +1,252 @@
|
|||
# debconf french translation file for ZoneMinder.
|
||||
# Copyright (C) 2001-2008 Philip Coombes
|
||||
# This file is distributed under the same license as the zoneminder package.
|
||||
# First author: Emmanuel Papin <manupap01@gmail.com>, 2014.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: zoneminder\n"
|
||||
"Report-Msgid-Bugs-To: zoneminder@packages.debian.org\n"
|
||||
"POT-Creation-Date: 2014-12-16 12:34+0100\n"
|
||||
"PO-Revision-Date: 2014-12-07 00:40+0100\n"
|
||||
"Last-Translator: Emmanuel Papin <manupap01@gmail.com>\n"
|
||||
"Language-Team: French <debian-l10n-french@lists.debian.org>\n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:1001
|
||||
msgid "Delete this non empty directory?"
|
||||
msgstr "Supprimer ce répertoire non vide ?"
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:1001
|
||||
msgid ""
|
||||
"A purge of the ZoneMinder package is performed but the directory '/var/cache/"
|
||||
"zoneminder' is not empty so it will not be deleted."
|
||||
msgstr ""
|
||||
"Une purge du paquet ZoneMinder est en cours mais le répertoire '/var/cache/"
|
||||
"zoneminder' n'est pas vide et sera donc conservé."
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:1001
|
||||
msgid ""
|
||||
"Please consider that this directory is designed to contain data resulting "
|
||||
"from event detection. Therefore, \"proof of evidence\" could be lost!\""
|
||||
msgstr ""
|
||||
"Veuillez considérer que ce répertoire est conçu pour contenir des données "
|
||||
"résultants de la détection d'événements. Par conséquent, des preuves "
|
||||
"pourraient être perdues !"
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:1001
|
||||
msgid ""
|
||||
"If you are not sure of your decision, please do not delete this directory "
|
||||
"but perform a manual checkup."
|
||||
msgstr ""
|
||||
"Si vous n'êtes pas sûr de votre décision, veuillez conserver ce répertoire "
|
||||
"et effectuer une vérification manuelle."
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:2001
|
||||
msgid "Deletion confirmed?"
|
||||
msgstr "Supression confirmée ?"
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:2001
|
||||
msgid ""
|
||||
"You have allowed the deletion of directory '/var/cache/zoneminder' although "
|
||||
"it may contain critical data."
|
||||
msgstr ""
|
||||
"Vous avez autorisé la suppression du répertoire '/var/cache/zoneminder' bien "
|
||||
"qu'il puisse contenir des données critiques."
|
||||
|
||||
#. Type: select
|
||||
#. Choices
|
||||
#: ../zoneminder-database.templates:1001
|
||||
msgid "local"
|
||||
msgstr "local"
|
||||
|
||||
#. Type: select
|
||||
#. Choices
|
||||
#: ../zoneminder-database.templates:1001
|
||||
msgid "remote"
|
||||
msgstr "distant"
|
||||
|
||||
#. Type: select
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:1002
|
||||
msgid "Database location:"
|
||||
msgstr "Emplacement de la base de donnée :"
|
||||
|
||||
#. Type: select
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:1002
|
||||
msgid ""
|
||||
"A database server is required to run ZoneMinder. The database can be "
|
||||
"installed either locally or remotely on a machine of your network."
|
||||
msgstr ""
|
||||
"Un serveur de base de données est requis pour ZoneMinder. La base de donnée "
|
||||
"peut être installée localement ou à distance sur une machine de votre réseau."
|
||||
|
||||
#. Type: select
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:1002
|
||||
msgid ""
|
||||
"If you choose a remote location, you will have to select the 'tcp/ip' "
|
||||
"connection method and enter the hostname or ip address of the remote machine "
|
||||
"in the next configuration screens."
|
||||
msgstr ""
|
||||
"Si vous choisissez un emplacement distant, vous devrez sélectionner la "
|
||||
"méthode de connexion 'tcp/ip' et entrer le nom réseau ou l'adresse ip de la "
|
||||
"machine distante dans les écrans de configuration suivants."
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:2001
|
||||
msgid "No local database server is available:"
|
||||
msgstr "Aucun serveur local de base de données n'est disponible :"
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:2001
|
||||
msgid ""
|
||||
"Currently ZoneMinder supports mysql or mariadb database server but none of "
|
||||
"them appears to be installed on this machine."
|
||||
msgstr ""
|
||||
"Actuellement ZoneMinder supporte les serveurs de base de données mysql et "
|
||||
"mariadb mais aucun d'entre eux n'est installé sur cette machine."
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:2001
|
||||
msgid ""
|
||||
"In order to complete ZoneMinder's installation, after ending of this "
|
||||
"assistant, please install a compatible database server and then restart the "
|
||||
"assistant by invoking:"
|
||||
msgstr ""
|
||||
"Afin de compléter l'installation de ZoneMinder, après la fermeture de cet "
|
||||
"assitant, veuillez installer un serveur de base de données compatible et "
|
||||
"ensuite redémarrez l'assistant en invoquant :"
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:2001 ../zoneminder-database.templates:3001
|
||||
msgid "$ sudo dpkg-reconfigure zoneminder"
|
||||
msgstr "$ sudo dpkg-reconfigure zoneminder"
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:3001
|
||||
msgid "Remote database servers are not allowed:"
|
||||
msgstr "Les serveurs de base de données distants ne sont pas autorisés :"
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:3001
|
||||
msgid ""
|
||||
"The current configuration of dbconfig-common does not allow installation of "
|
||||
"a database on remote servers."
|
||||
msgstr ""
|
||||
"La configuration actuelle de dbconfig-common ne permet pas l'installation de "
|
||||
"bases de données sur des serveurs distants."
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:3001
|
||||
msgid ""
|
||||
"In order to reconfigure dbconfig-common, please invoke the following command "
|
||||
"after ending of this assistant:"
|
||||
msgstr ""
|
||||
"Afin de reconfigurer dbconfig-common, veuillez invoquer la commande suivante "
|
||||
"après la fermeture de cet assitant :"
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:3001
|
||||
msgid "$ sudo dpkg-reconfigure dbconfig-common"
|
||||
msgstr "$ sudo dpkg-reconfigure dbconfig-common"
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:3001
|
||||
msgid ""
|
||||
"Then, to complete ZoneMinder's installation, please restart this assistant "
|
||||
"by invoking:"
|
||||
msgstr ""
|
||||
"Ensuite, pour compléter l'installation de ZoneMinder, veuillez redémarrer "
|
||||
"cet assistant en invoquant :"
|
||||
|
||||
#. Type: password
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:4001
|
||||
msgid "New password for the ZoneMinder 'admin' user:"
|
||||
msgstr "Nouveau mot de passe pour le compte 'admin' de ZoneMinder :"
|
||||
|
||||
#. Type: password
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:4001
|
||||
msgid "Please enter the password of the default administrative user."
|
||||
msgstr "Veuillez entrer le mot de passe du compte administrateur par défaut."
|
||||
|
||||
#. Type: password
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:4001
|
||||
msgid ""
|
||||
"While not mandatory, it is highly recommended that you set a custom password "
|
||||
"for the administrative 'admin' user."
|
||||
msgstr ""
|
||||
"Bien que cela ne soit pas obligatoire, il est fortement recommandé de "
|
||||
"fournir un mot de passe personnalisé pour le compte administrateur 'admin'."
|
||||
|
||||
#. Type: password
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:4001
|
||||
msgid "If this field is left blank, the password will not be changed."
|
||||
msgstr "Si le champ est laissé vide, le mot de passe ne sera pas changé."
|
||||
|
||||
#. Type: password
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:5001
|
||||
msgid "Repeat password for the ZoneMinder 'admin' user:"
|
||||
msgstr "Répéter le mot de passe pour le compte 'admin' de ZoneMinder :"
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:6001
|
||||
msgid "Password input error"
|
||||
msgstr "Erreur de mot de passe"
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:6001
|
||||
msgid "The two passwords you entered were not the same. Please try again."
|
||||
msgstr ""
|
||||
"Les deux mots de passe saisis ne sont pas les mêmes. Veuillez essayer à "
|
||||
"nouveau."
|
||||
|
||||
#. Type: multiselect
|
||||
#. Description
|
||||
#: ../zoneminder-ui-base.templates:1001
|
||||
msgid "Web server to reconfigure automatically:"
|
||||
msgstr "Serveur web à reconfigurer automatiquement :"
|
||||
|
||||
#. Type: multiselect
|
||||
#. Description
|
||||
#: ../zoneminder-ui-base.templates:1001
|
||||
msgid ""
|
||||
"Please choose the web server that should be automatically configured for "
|
||||
"ZoneMinder's web portal access."
|
||||
msgstr ""
|
||||
"Veuillez choisir le serveur web à reconfigurer automatiquement pour l'accès "
|
||||
"au portail web de ZoneMinder."
|
|
@ -0,0 +1,222 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: zoneminder\n"
|
||||
"Report-Msgid-Bugs-To: zoneminder@packages.debian.org\n"
|
||||
"POT-Creation-Date: 2014-12-16 12:34+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:1001
|
||||
msgid "Delete this non empty directory?"
|
||||
msgstr ""
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:1001
|
||||
msgid ""
|
||||
"A purge of the ZoneMinder package is performed but the directory '/var/cache/"
|
||||
"zoneminder' is not empty so it will not be deleted."
|
||||
msgstr ""
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:1001
|
||||
msgid ""
|
||||
"Please consider that this directory is designed to contain data resulting "
|
||||
"from event detection. Therefore, \"proof of evidence\" could be lost!\""
|
||||
msgstr ""
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:1001
|
||||
msgid ""
|
||||
"If you are not sure of your decision, please do not delete this directory "
|
||||
"but perform a manual checkup."
|
||||
msgstr ""
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:2001
|
||||
msgid "Deletion confirmed?"
|
||||
msgstr ""
|
||||
|
||||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../zoneminder-core.templates:2001
|
||||
msgid ""
|
||||
"You have allowed the deletion of directory '/var/cache/zoneminder' although "
|
||||
"it may contain critical data."
|
||||
msgstr ""
|
||||
|
||||
#. Type: select
|
||||
#. Choices
|
||||
#: ../zoneminder-database.templates:1001
|
||||
msgid "local"
|
||||
msgstr ""
|
||||
|
||||
#. Type: select
|
||||
#. Choices
|
||||
#: ../zoneminder-database.templates:1001
|
||||
msgid "remote"
|
||||
msgstr ""
|
||||
|
||||
#. Type: select
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:1002
|
||||
msgid "Database location:"
|
||||
msgstr ""
|
||||
|
||||
#. Type: select
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:1002
|
||||
msgid ""
|
||||
"A database server is required to run ZoneMinder. The database can be "
|
||||
"installed either locally or remotely on a machine of your network."
|
||||
msgstr ""
|
||||
|
||||
#. Type: select
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:1002
|
||||
msgid ""
|
||||
"If you choose a remote location, you will have to select the 'tcp/ip' "
|
||||
"connection method and enter the hostname or ip address of the remote machine "
|
||||
"in the next configuration screens."
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:2001
|
||||
msgid "No local database server is available:"
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:2001
|
||||
msgid ""
|
||||
"Currently ZoneMinder supports mysql or mariadb database server but none of "
|
||||
"them appears to be installed on this machine."
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:2001
|
||||
msgid ""
|
||||
"In order to complete ZoneMinder's installation, after ending of this "
|
||||
"assistant, please install a compatible database server and then restart the "
|
||||
"assistant by invoking:"
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:2001 ../zoneminder-database.templates:3001
|
||||
msgid "$ sudo dpkg-reconfigure zoneminder"
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:3001
|
||||
msgid "Remote database servers are not allowed:"
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:3001
|
||||
msgid ""
|
||||
"The current configuration of dbconfig-common does not allow installation of "
|
||||
"a database on remote servers."
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:3001
|
||||
msgid ""
|
||||
"In order to reconfigure dbconfig-common, please invoke the following command "
|
||||
"after ending of this assistant:"
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:3001
|
||||
msgid "$ sudo dpkg-reconfigure dbconfig-common"
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:3001
|
||||
msgid ""
|
||||
"Then, to complete ZoneMinder's installation, please restart this assistant "
|
||||
"by invoking:"
|
||||
msgstr ""
|
||||
|
||||
#. Type: password
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:4001
|
||||
msgid "New password for the ZoneMinder 'admin' user:"
|
||||
msgstr ""
|
||||
|
||||
#. Type: password
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:4001
|
||||
msgid "Please enter the password of the default administrative user."
|
||||
msgstr ""
|
||||
|
||||
#. Type: password
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:4001
|
||||
msgid ""
|
||||
"While not mandatory, it is highly recommended that you set a custom password "
|
||||
"for the administrative 'admin' user."
|
||||
msgstr ""
|
||||
|
||||
#. Type: password
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:4001
|
||||
msgid "If this field is left blank, the password will not be changed."
|
||||
msgstr ""
|
||||
|
||||
#. Type: password
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:5001
|
||||
msgid "Repeat password for the ZoneMinder 'admin' user:"
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:6001
|
||||
msgid "Password input error"
|
||||
msgstr ""
|
||||
|
||||
#. Type: error
|
||||
#. Description
|
||||
#: ../zoneminder-database.templates:6001
|
||||
msgid "The two passwords you entered were not the same. Please try again."
|
||||
msgstr ""
|
||||
|
||||
#. Type: multiselect
|
||||
#. Description
|
||||
#: ../zoneminder-ui-base.templates:1001
|
||||
msgid "Web server to reconfigure automatically:"
|
||||
msgstr ""
|
||||
|
||||
#. Type: multiselect
|
||||
#. Description
|
||||
#: ../zoneminder-ui-base.templates:1001
|
||||
msgid ""
|
||||
"Please choose the web server that should be automatically configured for "
|
||||
"ZoneMinder's web portal access."
|
||||
msgstr ""
|
|
@ -0,0 +1,154 @@
|
|||
#!/usr/bin/make -f
|
||||
# -*- makefile -*-
|
||||
# Sample debian/rules that uses debhelper.
|
||||
# This file was originally written by Joey Hess and Craig Small.
|
||||
# As a special exception, when this file is copied by dh-make into a
|
||||
# dh-make output file, you may use that output file without restriction.
|
||||
# This special exception was added by Craig Small in version 0.37 of dh-make.
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
|
||||
# These are used for cross-compiling and for saving the configure script
|
||||
# from having to guess our platform (since we know it already)
|
||||
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
||||
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
||||
|
||||
CFLAGS = -Wall
|
||||
CPPFLAGS = -D__STDC_CONSTANT_MACROS
|
||||
CXXFLAGS = -DHAVE_LIBCRYPTO
|
||||
|
||||
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
|
||||
DEBOPT = --enable-debug
|
||||
CFLAGS += -g
|
||||
CXXFLAGS += -g
|
||||
else
|
||||
DEBOPT =
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
|
||||
CFLAGS += -O0
|
||||
else
|
||||
CFLAGS += -O2
|
||||
endif
|
||||
|
||||
# These are used to get the most recent version of the original sources from github
|
||||
UURL = $(shell git config --get remote.origin.url)
|
||||
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
|
||||
HEAD = $(shell git rev-parse HEAD)
|
||||
PKD = $(abspath $(dir $(MAKEFILE_LIST)))
|
||||
PKG = $(word 2,$(shell dpkg-parsechangelog -l$(PKD)/changelog | grep ^Source))
|
||||
VER ?= $(shell dpkg-parsechangelog -l$(PKD)/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\-|\+nmu\d+.*)};')
|
||||
DTYPE =
|
||||
TARBALL = ../$(PKG)_$(VER)$(DTYPE).orig.tar.xz
|
||||
|
||||
%:
|
||||
dh $@ --with autoreconf
|
||||
|
||||
override_dh_auto_configure:
|
||||
CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" dh_auto_configure -- \
|
||||
--host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
|
||||
--sysconfdir=/etc/zm --prefix=/usr --mandir=\$${prefix}/share/man \
|
||||
--infodir=\$${prefix}/share/info --with-mysql=/usr \
|
||||
--with-mariadb=/usr --with-webdir=/usr/share/zoneminder \
|
||||
--with-ffmpeg=/usr --with-cgidir=/usr/lib/cgi-bin \
|
||||
--with-webuser=www-data --with-webgroup=www-data \
|
||||
--enable-mmap=yes $(DEBOPT)
|
||||
|
||||
override_dh_clean:
|
||||
# Add here commands to clean up after the build process.
|
||||
[ ! -f Makefile ] || $(MAKE) distclean
|
||||
dh_clean src/zm_config_defines.h
|
||||
#
|
||||
# Delete remaining auto-generated Makefile if Makefile.in exists
|
||||
find $(CURDIR)/ -type f -name "Makefile" | while read file; do \
|
||||
[ -f $$file.in ] && rm -f $$file; \
|
||||
done || true
|
||||
#
|
||||
# Delete remaining auto-generated Makefile.in if Makefile.am exists
|
||||
find $(CURDIR)/ -type f -name "Makefile.in" | while read filein; do \
|
||||
fileam=`echo $$filein | sed 's/\(.*\)\.in/\1\.am/'`; \
|
||||
[ -f $$fileam ] && rm -f $$filein; \
|
||||
done || true
|
||||
|
||||
override_dh_install:
|
||||
dh_install --fail-missing
|
||||
#
|
||||
# NOTE: This is a short-term kludge; hopefully changes in the next
|
||||
# upstream version will render this unnecessary.
|
||||
rm -rf debian/zoneminder/usr/share/zoneminder/events
|
||||
rm -rf debian/zoneminder/usr/share/zoneminder/images
|
||||
rm -rf debian/zoneminder/usr/share/zoneminder/temp
|
||||
# The link stuff for these folders has been moved to
|
||||
# zoneminder-core.links file
|
||||
#
|
||||
# This is a slightly lesser kludge; moving the cgi stuff to
|
||||
# /usr/share/zoneminder/cgi-bin breaks one set of behavior,
|
||||
# having it just in /usr/lib/cgi-bin breaks another bit of
|
||||
# behavior.
|
||||
# The link stuff for /usr/share/zoneminder/cgi-bin has been moved to
|
||||
# zoneminder-ui-base.links file
|
||||
|
||||
override_dh_installinit:
|
||||
dh_installinit --package=zoneminder-core --name=zoneminder
|
||||
|
||||
override_dh_systemd_start:
|
||||
dh_systemd_start --package=zoneminder-core --name=zoneminder \
|
||||
--restart-after-upgrade
|
||||
|
||||
override_dh_systemd_enable:
|
||||
dh_systemd_enable --package=zoneminder-core --name=zoneminder
|
||||
|
||||
override_dh_fixperms:
|
||||
dh_fixperms
|
||||
#
|
||||
# As requested by the Debian Webapps Policy Manual §3.2.1
|
||||
chown root:www-data debian/zoneminder-core/etc/zm/zm.conf
|
||||
chmod 640 debian/zoneminder-core/etc/zm/zm.conf
|
||||
|
||||
override_dh_auto_test:
|
||||
# do not run tests...
|
||||
|
||||
.PHONY: override_dh_strip
|
||||
override_dh_strip:
|
||||
dh_strip --dbg-package=zoneminder-core-dbg
|
||||
|
||||
# Inspired by https://wiki.debian.org/onlyjob/get-orig-source
|
||||
.PHONY: get-orig-source
|
||||
get-orig-source: $(TARBALL) $(info I: $(PKG)_$(VER)$(DTYPE))
|
||||
@
|
||||
|
||||
$(TARBALL):
|
||||
$(if $(wildcard $(PKG)-$(VER)),$(error folder '$(PKG)-$(VER)' exists, aborting...))
|
||||
@echo "# Cloning origin repository..."; \
|
||||
if ! git clone $(UURL) $(PKG)-$(VER); then \
|
||||
$(RM) -r $(PKG)-$(VER); \
|
||||
echo "failed to clone repository, aborting..."; \
|
||||
false; \
|
||||
fi
|
||||
@if [ $(BRANCH) != "master" ]; then \
|
||||
cd $(PKG)-$(VER); \
|
||||
echo "# Not on master branch, fetching origin branch '$(BRANCH)'..."; \
|
||||
git fetch origin $(BRANCH):$(BRANCH) || false; \
|
||||
echo "# Switching to branch '$(BRANCH)'..."; \
|
||||
git checkout $(BRANCH) || false; \
|
||||
fi
|
||||
@echo "# Checking local source..."
|
||||
@if [ $$(cd $(PKG)-$(VER) && git rev-parse HEAD) = $(HEAD) ]; then \
|
||||
echo "even with origin, ok"; \
|
||||
true; \
|
||||
else \
|
||||
echo "not even with origin, aborting..."; \
|
||||
false; \
|
||||
fi
|
||||
@echo "# Setting times..."
|
||||
@cd $(PKG)-$(VER) \
|
||||
&& for F in $$(git ls-tree -r --name-only HEAD | sed -e "s/\s/\*/g"); do \
|
||||
touch --no-dereference -d "$$(git log -1 --format="%ai" -- $$F)" "$$F"; \
|
||||
done
|
||||
@echo "# Cleaning-up..."
|
||||
cd $(PKG)-$(VER) && $(RM) -r .git
|
||||
@echo "# Packing file '$(TARBALL)'..."
|
||||
@find -L "$(PKG)-$(VER)" -xdev -type f -print | sort \
|
||||
| XZ_OPT="-6v" tar -caf "$(TARBALL)" -T- --owner=root --group=root --mode=a+rX \
|
||||
&& $(RM) -r "$(PKG)-$(VER)"
|
|
@ -0,0 +1 @@
|
|||
3.0 (native)
|
|
@ -0,0 +1 @@
|
|||
extend-diff-ignore = "(^|/)(config\.sub|config\.guess|Makefile|aclocal.m4|compile|config.h.in|configure|depcomp|install-sh|missing)$"
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
# config maintainer script for zoneminder-core package
|
||||
|
||||
set -e
|
||||
|
||||
# Source the debconf stuff
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,4 @@
|
|||
var/log/zm
|
||||
var/cache/zoneminder/events
|
||||
var/cache/zoneminder/images
|
||||
var/cache/zoneminder/temp
|
|
@ -0,0 +1,4 @@
|
|||
etc/zm
|
||||
usr/bin
|
||||
usr/share/polkit-1/actions
|
||||
usr/share/polkit-1/rules.d
|
|
@ -0,0 +1,3 @@
|
|||
var/cache/zoneminder/events usr/share/zoneminder/events
|
||||
var/cache/zoneminder/images usr/share/zoneminder/images
|
||||
var/cache/zoneminder/temp usr/share/zoneminder/temp
|
|
@ -0,0 +1,80 @@
|
|||
#! /bin/sh
|
||||
# postinst maintainer script for zoneminder-core package
|
||||
|
||||
set -e
|
||||
|
||||
# Source the debconf stuff
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
# Source the config file
|
||||
CONFIGFILE=/etc/zm/zm.conf
|
||||
. $CONFIGFILE
|
||||
|
||||
# Do this when the package is installed, upgraded or reconfigured
|
||||
if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then
|
||||
|
||||
# Retrieve data from dbconfig (inputs from user)
|
||||
. /etc/dbconfig-common/zoneminder.conf
|
||||
|
||||
# ZoneMinder config file handling
|
||||
# Inspired by: http://manpages.debian.org/cgi-bin/man.cgi?query=debconf-devel&sektion=7
|
||||
|
||||
# Backup the config file
|
||||
cp -a -f $CONFIGFILE ${CONFIGFILE}.postinst.bak
|
||||
|
||||
# Redeclare variables if missing in config file
|
||||
test -z $dbc_dbserver || grep -Eq "^ *ZM_DB_HOST=" $CONFIGFILE \
|
||||
|| echo "ZM_DB_HOST=" >> ${CONFIGFILE}.postinst.bak
|
||||
test -z $dbc_dbname || grep -Eq "^ *ZM_DB_NAME=" $CONFIGFILE \
|
||||
|| echo "ZM_DB_NAME=" >> ${CONFIGFILE}.postinst.bak
|
||||
test -z $dbc_dbuser || grep -Eq "^ *ZM_DB_USER=" $CONFIGFILE \
|
||||
|| echo "ZM_DB_USER=" >> ${CONFIGFILE}.postinst.bak
|
||||
test -z $dbc_dbpass || grep -Eq "^ *ZM_DB_PASS=" $CONFIGFILE \
|
||||
|| echo "ZM_DB_PASS=" >> ${CONFIGFILE}.postinst.bak
|
||||
|
||||
# Prevent ZM_DB_HOST to be empty if user selected the 'unix socket' method
|
||||
if test -z $dbc_dbserver; then
|
||||
dbc_dbserver_override="localhost"
|
||||
else
|
||||
dbc_dbserver_override=$dbc_dbserver
|
||||
fi
|
||||
|
||||
# Update variables in config file
|
||||
sed -i "s/^ *ZM_DB_HOST=.*/ZM_DB_HOST=$dbc_dbserver_override/" \
|
||||
${CONFIGFILE}.postinst.bak
|
||||
test -z $dbc_dbname || sed -i "s/^ *ZM_DB_NAME=.*/ZM_DB_NAME=$dbc_dbname/" \
|
||||
${CONFIGFILE}.postinst.bak
|
||||
test -z $dbc_dbuser || sed -i "s/^ *ZM_DB_USER=.*/ZM_DB_USER=$dbc_dbuser/" \
|
||||
${CONFIGFILE}.postinst.bak
|
||||
test -z $dbc_dbpass || sed -i "s/^ *ZM_DB_PASS=.*/ZM_DB_PASS=$dbc_dbpass/" \
|
||||
${CONFIGFILE}.postinst.bak
|
||||
|
||||
# Clean-up backup file
|
||||
mv -f ${CONFIGFILE}.postinst.bak $CONFIGFILE
|
||||
|
||||
|
||||
# Set some file permissions
|
||||
chown $ZM_WEB_USER:$ZM_WEB_GROUP /var/log/zm
|
||||
if [ -z "$2" ]; then
|
||||
chown $ZM_WEB_USER:$ZM_WEB_GROUP -R /var/cache/zoneminder
|
||||
fi
|
||||
# As requested by the Debian Webapps Policy Manual §3.2.1
|
||||
chown root:${ZM_WEB_GROUP} $CONFIGFILE
|
||||
chmod 640 $CONFIGFILE
|
||||
fi
|
||||
|
||||
# Do this every time the package is installed or upgraded
|
||||
# Test for database presence to avoid failure of zmupdate.pl
|
||||
if [ "$dbc_install" = "true" ] && [ "$1" = "configure" ]; then
|
||||
|
||||
# Ensure zoneminder is stopped
|
||||
deb-systemd-invoke stop zoneminder.service || exit $?
|
||||
|
||||
# Run the ZoneMinder update tool
|
||||
zmupdate.pl --nointeractive
|
||||
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,37 @@
|
|||
#! /bin/sh
|
||||
# postrm maintainer script for zoneminder-core package
|
||||
|
||||
set -e
|
||||
|
||||
# Source the debconf stuff
|
||||
if [ -f /usr/share/debconf/confmodule ]; then
|
||||
. /usr/share/debconf/confmodule
|
||||
fi
|
||||
|
||||
if [ "$1" = "purge" ]; then
|
||||
|
||||
# Ask the user if we have to remove the cache directory even if not empty
|
||||
if [ -d /var/cache/zoneminder ] \
|
||||
&& [ ! $(find /var/cache/zoneminder -maxdepth 0 -type d -empty 2>/dev/null) ]; then
|
||||
RET=""
|
||||
db_input high zoneminder/ask_delete || true
|
||||
db_go || true
|
||||
db_get zoneminder/ask_delete
|
||||
if [ "$RET" = "true" ]; then
|
||||
RET=""
|
||||
db_input high zoneminder/ask_delete_again || true
|
||||
db_go || true
|
||||
db_get zoneminder/ask_delete_again
|
||||
if [ "$RET" = "true" ]; then
|
||||
rm -rf /var/cache/zoneminder
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
# postrm rm may freeze without that
|
||||
db_stop
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
# preinst maintainer script for zoneminder-core package
|
||||
|
||||
set -e
|
||||
|
||||
abort=false
|
||||
if [ -L /usr/share/zoneminder/events ]; then
|
||||
l=$(readlink /usr/share/zoneminder/events)
|
||||
if [ "$l" != "/var/cache/zoneminder/events" ]; then
|
||||
abort=true
|
||||
fi
|
||||
fi
|
||||
if [ -L /usr/share/zoneminder/images ]; then
|
||||
l=$(readlink /usr/share/zoneminder/images )
|
||||
if [ "$l" != "/var/cache/zoneminder/images" ]; then
|
||||
abort=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$abort" = "true" ]; then
|
||||
cat >&2 << EOF
|
||||
Aborting installation of zoneminder due to non-default symlinks in
|
||||
/usr/share/zoneminder for the images and/or events directory, which could
|
||||
result in loss of data. Please move your data in each of these directories to
|
||||
/var/cache/zoneminder before installing zoneminder from the package.
|
||||
EOF
|
||||
exit 1
|
||||
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,19 @@
|
|||
Template: zoneminder/ask_delete
|
||||
Type: boolean
|
||||
Default: false
|
||||
_Description: Delete this non empty directory?
|
||||
A purge of the ZoneMinder package is performed but the directory
|
||||
'/var/cache/zoneminder' is not empty so it will not be deleted.
|
||||
.
|
||||
Please consider that this directory is designed to contain data resulting from
|
||||
event detection. Therefore, "proof of evidence" could be lost!"
|
||||
.
|
||||
If you are not sure of your decision, please do not delete this directory but
|
||||
perform a manual checkup.
|
||||
|
||||
Template: zoneminder/ask_delete_again
|
||||
Type: boolean
|
||||
Default: false
|
||||
_Description: Deletion confirmed?
|
||||
You have allowed the deletion of directory '/var/cache/zoneminder' although
|
||||
it may contain critical data.
|
|
@ -0,0 +1,90 @@
|
|||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: zoneminder
|
||||
# Required-Start: $network $remote_fs $syslog
|
||||
# Required-Stop: $network $remote_fs $syslog
|
||||
# Should-Start: mysql
|
||||
# Should-Stop: mysql
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Control ZoneMinder as a Service
|
||||
### END INIT INFO
|
||||
# description: Control ZoneMinder as a Service
|
||||
# chkconfig: 2345 20 20
|
||||
|
||||
# Source function library.
|
||||
#. /etc/rc.d/init.d/functions
|
||||
|
||||
prog=ZoneMinder
|
||||
ZM_PATH_BIN="/usr/bin"
|
||||
RUNDIR=/var/run/zm
|
||||
TMPDIR=/tmp/zm
|
||||
command="$ZM_PATH_BIN/zmpkg.pl"
|
||||
|
||||
start() {
|
||||
echo -n "Starting $prog: "
|
||||
mkdir -p $RUNDIR && chown www-data:www-data $RUNDIR
|
||||
mkdir -p $TMPDIR && chown www-data:www-data $TMPDIR
|
||||
$command start
|
||||
RETVAL=$?
|
||||
[ $RETVAL = 0 ] && echo success
|
||||
[ $RETVAL != 0 ] && echo failure
|
||||
echo
|
||||
[ $RETVAL = 0 ] && touch /var/lock/zm
|
||||
return $RETVAL
|
||||
}
|
||||
stop() {
|
||||
echo -n "Stopping $prog: "
|
||||
#
|
||||
# Why is this status check being done?
|
||||
# as $command stop returns 1 if zoneminder
|
||||
# is stopped, which will result in
|
||||
# this returning 1, which will stuff
|
||||
# dpkg when it tries to stop zoneminder before
|
||||
# uninstalling . . .
|
||||
#
|
||||
result=`$command status`
|
||||
if [ ! "$result" = "running" ]; then
|
||||
echo "Zoneminder already stopped"
|
||||
echo
|
||||
RETVAL=0
|
||||
else
|
||||
$command stop
|
||||
RETVAL=$?
|
||||
[ $RETVAL = 0 ] && echo success
|
||||
[ $RETVAL != 0 ] && echo failure
|
||||
echo
|
||||
[ $RETVAL = 0 ] && rm -f /var/lock/zm
|
||||
fi
|
||||
}
|
||||
status() {
|
||||
result=`$command status`
|
||||
if [ "$result" = "running" ]; then
|
||||
echo "ZoneMinder is running"
|
||||
RETVAL=0
|
||||
else
|
||||
echo "ZoneMinder is stopped"
|
||||
RETVAL=1
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
start
|
||||
;;
|
||||
'stop')
|
||||
stop
|
||||
;;
|
||||
'restart' | 'force-reload')
|
||||
stop
|
||||
start
|
||||
;;
|
||||
'status')
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 { start | stop | restart | status }"
|
||||
RETVAL=1
|
||||
;;
|
||||
esac
|
||||
exit $RETVAL
|
|
@ -0,0 +1,19 @@
|
|||
# ZoneMinder systemd unit file
|
||||
# This file is intended to work with debian distributions
|
||||
|
||||
[Unit]
|
||||
Description=ZoneMinder CCTV recording and security system
|
||||
After=network.target mysql.service apache2.service
|
||||
Requires=apache2.service
|
||||
Wants=mysql.service
|
||||
|
||||
[Service]
|
||||
User=www-data
|
||||
Type=forking
|
||||
ExecStart=/usr/bin/zmpkg.pl start
|
||||
ExecReload=/usr/bin/zmpkg.pl restart
|
||||
ExecStop=/usr/bin/zmpkg.pl stop
|
||||
PIDFile=/var/run/zm/zm.pid
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1 @@
|
|||
d /var/run/zm 0755 www-data www-data
|
|
@ -0,0 +1,142 @@
|
|||
#!/bin/sh
|
||||
# config maintainer script for zoneminder
|
||||
|
||||
set -e
|
||||
|
||||
# Source the debconf stuff
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
# Set the first version in which dbconfig-common was introduced in the package
|
||||
dbc_first_version="1.28.0"
|
||||
|
||||
CONFIGFILE=/etc/zm/zm.conf
|
||||
if [ -e $CONFIGFILE ]; then
|
||||
# Source the config file if exists
|
||||
. $CONFIGFILE
|
||||
elif [ -e ${CONFIGFILE}.dpkg-new ]; then
|
||||
# If no config file, source the config file which is going to be installed
|
||||
# by the core package
|
||||
. ${CONFIGFILE}.dpkg-new
|
||||
else
|
||||
# If no config file is going to be installed, set some default values
|
||||
ZM_DB_HOST=
|
||||
ZM_DB_NAME="zm"
|
||||
ZM_DB_USER="zmuser"
|
||||
fi
|
||||
|
||||
# Set some variables for the dbconfig-common stuff
|
||||
dbc_dbserver="$ZM_DB_HOST"
|
||||
dbc_dbname="$ZM_DB_NAME"
|
||||
dbc_dbuser="$ZM_DB_USER"
|
||||
|
||||
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
|
||||
|
||||
# Default use dbconfig-common
|
||||
dbc_install="true"
|
||||
|
||||
# Currently we only support mysql database
|
||||
dbc_dbtypes="mysql"
|
||||
|
||||
# Set authentication method to password
|
||||
dbc_authmethod_user="password"
|
||||
|
||||
# Source the dbconfig-common stuff
|
||||
. /usr/share/dbconfig-common/dpkg/config
|
||||
fi
|
||||
|
||||
# Do this when the package is installed, upgraded or reconfigured
|
||||
# Most of answers are cached so the questions will not be asked again
|
||||
if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then
|
||||
|
||||
# Ask the user if the database shall be installed locally or remotely
|
||||
db_input high zoneminder/debconf_dblocation || true
|
||||
db_go || true
|
||||
db_get zoneminder/debconf_dblocation
|
||||
|
||||
if [ "$RET" = "local" ]; then
|
||||
if [ ! -e "/usr/sbin/mysqld" ]; then
|
||||
# Display a message and exit if the user want a local database but
|
||||
# no database server is available
|
||||
db_input high zoneminder/debconf_dblocalmissingerror || true
|
||||
db_go || true
|
||||
exit 0
|
||||
else
|
||||
# Set the database server to localhost
|
||||
dbc_dbserver="localhost"
|
||||
fi
|
||||
else
|
||||
# Source the dbconfig main configuration file
|
||||
if [ -f /etc/dbconfig-common/config ]; then
|
||||
. /etc/dbconfig-common/config
|
||||
fi
|
||||
if [ "$dbc_remote_questions_default" = "false" ]; then
|
||||
# Display a message and exit if the dbconfig configuration does not
|
||||
# allow installation of remote databases
|
||||
# Note: To overcome this issue, we could think to override the
|
||||
# default setting by using dbc_remote_questions_default='true' in
|
||||
# maintainer scripts but unfortunately this does not work due to
|
||||
# current dbconfig design
|
||||
# More information here:
|
||||
# https://bugs.launchpad.net/ubuntu/+source/dbconfig-common/+bug/1065331
|
||||
db_input high zoneminder/debconf_dbconfigerror || true
|
||||
db_go || true
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Ask the user for all database settings
|
||||
dbc_go zoneminder $@
|
||||
|
||||
# Ask the user for the password of the database administrator if the user
|
||||
# has not yet answered to this question.
|
||||
# This situation may occur if the user skipped the database creation step
|
||||
# when reconfiguring the package.
|
||||
RET=""
|
||||
db_get zoneminder/mysql/admin-pass
|
||||
if [ -z "$RET" ]; then
|
||||
db_input high zoneminder/mysql/admin-pass || true
|
||||
db_go || true
|
||||
fi
|
||||
|
||||
# Do this only when not upgrading the package (no old version in argument)
|
||||
if [ -z "$2" ]; then
|
||||
# Ask for the password of 'admin' user
|
||||
while :; do
|
||||
RET=""
|
||||
db_input high zoneminder/admin_password || true
|
||||
db_go || true
|
||||
db_get zoneminder/admin_password
|
||||
# If password isn't empty we ask for password verification
|
||||
if [ -z "$RET" ]; then
|
||||
db_fset zoneminder/admin_password seen false
|
||||
db_fset zoneminder/admin_password_again seen false
|
||||
break
|
||||
fi
|
||||
ROOT_PW="$RET"
|
||||
db_input high zoneminder/admin_password_again || true
|
||||
db_go || true
|
||||
db_get zoneminder/admin_password_again
|
||||
if [ "$RET" = "$ROOT_PW" ]; then
|
||||
ROOT_PW=""
|
||||
break
|
||||
fi
|
||||
db_fset zoneminder/password_mismatch seen false
|
||||
db_input critical zoneminder/password_mismatch || true
|
||||
db_set zoneminder/admin_password ""
|
||||
db_set zoneminder/admin_password_again ""
|
||||
db_go || true
|
||||
done
|
||||
else
|
||||
# If we are upgrading the package, set an empty password to disable
|
||||
# password update in ZoneMinder database
|
||||
db_set zoneminder/admin_password ""
|
||||
fi
|
||||
# Set the seen flag to not ask this question again if no password is
|
||||
# provided
|
||||
db_fset zoneminder/admin_password seen true
|
||||
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,3 @@
|
|||
usr/share/zoneminder/db
|
||||
usr/share/dbconfig-common/data/zoneminder/install
|
||||
usr/share/dbconfig-common/data/zoneminder/upgrade/mysql
|
|
@ -0,0 +1 @@
|
|||
usr/share/zoneminder/db
|
|
@ -0,0 +1,79 @@
|
|||
#! /bin/sh
|
||||
# postinst maintainer script for zoneminder-db package
|
||||
|
||||
set -e
|
||||
|
||||
# Source the debconf stuff
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
mysql_update() {
|
||||
|
||||
# Source the dbconfig stuff
|
||||
. /usr/share/dbconfig-common/internal/mysql
|
||||
|
||||
# Update the password of the hard-coded default 'admin' account
|
||||
test -z $ADMIN_PASSWORD || dbc_mysql_exec_command "UPDATE Users SET Password = password('$ADMIN_PASSWORD') WHERE Username = 'admin';" || true
|
||||
|
||||
# Update the database version
|
||||
dbc_mysql_exec_command "UPDATE Config SET Value = '$DB_VERSION' WHERE Name = 'ZM_DYN_DB_VERSION';" || true
|
||||
}
|
||||
|
||||
if [ -f /usr/share/dbconfig-common/dpkg/postinst ]; then
|
||||
|
||||
# Set the first version in which dbconfig-common was introduced in the package
|
||||
dbc_first_version="1.28.0"
|
||||
|
||||
# Set the database type
|
||||
dbc_dbtypes="mysql"
|
||||
|
||||
# Source the dbconfig-common stuff
|
||||
. /usr/share/dbconfig-common/dpkg/postinst
|
||||
fi
|
||||
|
||||
# Do this when the package is installed, upgraded or reconfigured
|
||||
if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then
|
||||
|
||||
# Install sql database create file for dbconfig
|
||||
# (needed at first package installation)
|
||||
if [ ! -f /usr/share/dbconfig-common/data/zoneminder/install/mysql ]; then
|
||||
install -m 644 /usr/share/zoneminder/db/zm_create.sql \
|
||||
/usr/share/dbconfig-common/data/zoneminder/install/mysql
|
||||
# Remove unneeded sql requests
|
||||
# dbconfig will create the underlying database
|
||||
sed -i "/^ *CREATE DATABASE /d" \
|
||||
/usr/share/dbconfig-common/data/zoneminder/install/mysql
|
||||
sed -i "/^ *USE /d" \
|
||||
/usr/share/dbconfig-common/data/zoneminder/install/mysql
|
||||
fi
|
||||
|
||||
# Symlink sql update files for dbconfig (needed when upgrading the package)
|
||||
for sqlfile in /usr/share/zoneminder/db/zm_update-*.sql; do
|
||||
lnk=`echo $sqlfile | sed "s/^\/usr\/share\/zoneminder\/db\/zm_update-\(.*\)\.sql/\1/"`
|
||||
if [ ! -L /usr/share/dbconfig-common/data/zoneminder/upgrade/mysql/$lnk ]; then
|
||||
ln -sf $sqlfile \
|
||||
/usr/share/dbconfig-common/data/zoneminder/upgrade/mysql/$lnk
|
||||
fi
|
||||
done || true
|
||||
|
||||
# Create the underlying database and populate it
|
||||
# dbconfig will take care of applying any updates which are newer than the
|
||||
# previously installed version
|
||||
dbc_go zoneminder $@
|
||||
|
||||
# Get the password of ZoneMinder user 'admin' from debconf
|
||||
db_get zoneminder/admin_password
|
||||
ADMIN_PASSWORD=$RET
|
||||
|
||||
# Remove the password from debconf database
|
||||
test -z $ADMIN_PASSWORD || db_reset zoneminder/admin_password || true
|
||||
|
||||
# Get the lastest database version from dbconfig upgrade folder
|
||||
DB_VERSION=$(ls -rv /usr/share/dbconfig-common/data/zoneminder/upgrade/$dbc_dbtypes | head -1)
|
||||
|
||||
# Update the default admin account and database version
|
||||
mysql_update
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,34 @@
|
|||
#! /bin/sh
|
||||
# postrm maintainer script for zoneminder-db package
|
||||
|
||||
set -e
|
||||
|
||||
# Source the debconf stuff
|
||||
if [ -f /usr/share/debconf/confmodule ]; then
|
||||
. /usr/share/debconf/confmodule
|
||||
fi
|
||||
|
||||
# Source the dbconfig stuff
|
||||
if [ -f /usr/share/dbconfig-common/dpkg/postrm ]; then
|
||||
. /usr/share/dbconfig-common/dpkg/postrm
|
||||
# Ask the user what do to with dbconfig when removing the package
|
||||
dbc_go zoneminder $@
|
||||
fi
|
||||
|
||||
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
|
||||
# Remove dbconfig stuff added in postinst script
|
||||
rm -rf /usr/share/dbconfig-common/data/zoneminder
|
||||
# No need to manually remove the zm database, dbconfig take care of this
|
||||
fi
|
||||
|
||||
if [ "$1" = "purge" ]; then
|
||||
# Delete a potential remaining file used in postinst script
|
||||
rm -f /etc/zm/zm.conf.postinst.bak
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
# postrm rm may freeze without that
|
||||
db_stop
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
# prerm script for zoneminder-db package
|
||||
|
||||
set -e
|
||||
|
||||
# Source the debconf stuff if file exists
|
||||
if [ -f /usr/share/debconf/confmodule ]; then
|
||||
. /usr/share/debconf/confmodule
|
||||
fi
|
||||
|
||||
# If dbconfig-common is installed and has been used by zoneminder
|
||||
if [ -f /usr/share/dbconfig-common/dpkg/prerm ] \
|
||||
&& [ -f /etc/dbconfig-common/zoneminder.conf ]; then
|
||||
# Source the dbconfig stuff
|
||||
. /usr/share/dbconfig-common/dpkg/prerm
|
||||
# Ask the user what do to with dbconfig before removing the package
|
||||
dbc_go zoneminder $@
|
||||
fi
|
||||
|
||||
# #DEBHELPER#
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,58 @@
|
|||
Template: zoneminder/debconf_dblocation
|
||||
Type: select
|
||||
__Choices: local, remote
|
||||
Default: local
|
||||
_Description: Database location:
|
||||
A database server is required to run ZoneMinder. The database can be installed
|
||||
either locally or remotely on a machine of your network.
|
||||
.
|
||||
If you choose a remote location, you will have to select the 'tcp/ip'
|
||||
connection method and enter the hostname or ip address of the remote machine
|
||||
in the next configuration screens.
|
||||
|
||||
Template: zoneminder/debconf_dblocalmissingerror
|
||||
Type: error
|
||||
_Description: No local database server is available:
|
||||
Currently ZoneMinder supports mysql or mariadb database server but none of them
|
||||
appears to be installed on this machine.
|
||||
.
|
||||
In order to complete ZoneMinder's installation, after ending of this assistant,
|
||||
please install a compatible database server and then restart the assistant by
|
||||
invoking:
|
||||
.
|
||||
$ sudo dpkg-reconfigure zoneminder
|
||||
|
||||
Template: zoneminder/debconf_dbconfigerror
|
||||
Type: error
|
||||
_Description: Remote database servers are not allowed:
|
||||
The current configuration of dbconfig-common does not allow installation of
|
||||
a database on remote servers.
|
||||
.
|
||||
In order to reconfigure dbconfig-common, please invoke the following command
|
||||
after ending of this assistant:
|
||||
.
|
||||
$ sudo dpkg-reconfigure dbconfig-common
|
||||
.
|
||||
Then, to complete ZoneMinder's installation, please restart this assistant by
|
||||
invoking:
|
||||
.
|
||||
$ sudo dpkg-reconfigure zoneminder
|
||||
|
||||
Template: zoneminder/admin_password
|
||||
Type: password
|
||||
_Description: New password for the ZoneMinder 'admin' user:
|
||||
Please enter the password of the default administrative user.
|
||||
.
|
||||
While not mandatory, it is highly recommended that you set a custom password
|
||||
for the administrative 'admin' user.
|
||||
.
|
||||
If this field is left blank, the password will not be changed.
|
||||
|
||||
Template: zoneminder/admin_password_again
|
||||
Type: password
|
||||
_Description: Repeat password for the ZoneMinder 'admin' user:
|
||||
|
||||
Template: zoneminder/password_mismatch
|
||||
Type: error
|
||||
_Description: Password input error
|
||||
The two passwords you entered were not the same. Please try again.
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
# config maintainer script for zoneminder-ui-base package
|
||||
|
||||
set -e
|
||||
|
||||
# Source the debconf stuff
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
# Do this when the package is installed, upgraded or reconfigured
|
||||
# Most of answers are cached so the questions will not be asked again
|
||||
if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then
|
||||
|
||||
# Ask the user for the web server(s) to configure
|
||||
db_input high zoneminder/webserver || true
|
||||
db_go || true
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,11 @@
|
|||
debian/apache.conf etc/zm
|
||||
usr/lib/cgi-bin
|
||||
usr/share/zoneminder/ajax
|
||||
usr/share/zoneminder/css
|
||||
usr/share/zoneminder/graphics
|
||||
usr/share/zoneminder/includes
|
||||
usr/share/zoneminder/index.php
|
||||
usr/share/zoneminder/js
|
||||
usr/share/zoneminder/lang
|
||||
usr/share/zoneminder/tools
|
||||
usr/share/zoneminder/views
|
|
@ -0,0 +1 @@
|
|||
usr/lib/cgi-bin usr/share/zoneminder/cgi-bin
|
|
@ -0,0 +1,48 @@
|
|||
#! /bin/sh
|
||||
# postinst maintainer script for zoneminder-ui-base package
|
||||
|
||||
set -e
|
||||
|
||||
# Source the debconf stuff
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
apache_install() {
|
||||
|
||||
mkdir -p /etc/apache2/conf-available
|
||||
ln -sf ../../zm/apache.conf /etc/apache2/conf-available/zoneminder.conf
|
||||
|
||||
COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
|
||||
|
||||
if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
|
||||
. /usr/share/apache2/apache2-maintscript-helper
|
||||
apache2_invoke enconf zoneminder
|
||||
elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
|
||||
[ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/zoneminder.conf ] && ln -s ../conf-available/zoneminder.conf /etc/apache2/conf.d/zoneminder.conf
|
||||
fi
|
||||
|
||||
# Enable CGI script module in apache (not enabled by default on jessie)
|
||||
a2enmod cgi >/dev/null 2>&1
|
||||
|
||||
# Reload the web server
|
||||
deb-systemd-invoke reload apache2.service || true
|
||||
}
|
||||
|
||||
# Do this when the package is installed, upgraded or reconfigured
|
||||
if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then
|
||||
|
||||
# Configure the web server
|
||||
db_get zoneminder/webserver
|
||||
webservers="$RET"
|
||||
|
||||
for webserver in $webservers; do
|
||||
webserver=${webserver%,}
|
||||
# Currently we only support apache2
|
||||
if [ "$webserver" = "apache2" ] ; then
|
||||
apache_install $1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,41 @@
|
|||
#! /bin/sh
|
||||
# postrm maintainer script for zoneminder-ui-base package
|
||||
|
||||
set -e
|
||||
|
||||
# Source the debconf stuff
|
||||
if [ -f /usr/share/debconf/confmodule ]; then
|
||||
. /usr/share/debconf/confmodule
|
||||
fi
|
||||
|
||||
apache_remove() {
|
||||
COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
|
||||
if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
|
||||
. /usr/share/apache2/apache2-maintscript-helper
|
||||
apache2_invoke disconf zoneminder
|
||||
elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
|
||||
rm -f /etc/apache2/conf.d/zoneminder.conf
|
||||
fi
|
||||
rm -f /etc/apache2/conf-available/zoneminder.conf
|
||||
# Reload the web server
|
||||
deb-systemd-invoke reload apache2.service || true
|
||||
}
|
||||
|
||||
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
|
||||
# Deconfigure the web server
|
||||
db_get zoneminder/webserver
|
||||
for webserver in $RET; do
|
||||
webserver=${webserver%,}
|
||||
# Currently we only support apache2
|
||||
if [ "$webserver" = "apache2" ] ; then
|
||||
apache_remove $1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
# postrm rm may freeze without that
|
||||
db_stop
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,7 @@
|
|||
Template: zoneminder/webserver
|
||||
Type: multiselect
|
||||
Choices: apache2
|
||||
Default: apache2
|
||||
_Description: Web server to reconfigure automatically:
|
||||
Please choose the web server that should be automatically configured for
|
||||
ZoneMinder's web portal access.
|
|
@ -0,0 +1 @@
|
|||
usr/share/zoneminder/skins/classic
|
|
@ -0,0 +1 @@
|
|||
usr/share/zoneminder/skins/mobile
|
|
@ -0,0 +1 @@
|
|||
usr/share/zoneminder/skins/xml
|
|
@ -0,0 +1,3 @@
|
|||
zoneminder (1.31.39~20180223.27-stretch-1) unstable; urgency=low
|
||||
*
|
||||
-- Isaac Connor <iconnor@connortechnology.com> Fri, 23 Feb 2018 14:15:59 -0500
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue