Merge branch 'master' of github.com:ZoneMinder/zoneminder
This commit is contained in:
commit
9f6a603d59
|
@ -556,7 +556,11 @@ INSERT INTO States (Name,Definition,IsActive) VALUES ('default','','1');
|
|||
DROP TABLE IF EXISTS `Servers`;
|
||||
CREATE TABLE `Servers` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Protocol` TEXT,
|
||||
`Hostname` TEXT,
|
||||
`Port` INTEGER UNSIGNED,
|
||||
`PathToIndex` TEXT,
|
||||
`PathToZMS` TEXT,
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
`State_Id` int(10) unsigned,
|
||||
`Status` enum('Unknown','NotRunning','Running') NOT NULL default 'Unknown',
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
ALTER TABLE Frames MODIFY COLUMN EventId bigint unsigned NOT NULL;
|
||||
|
||||
|
|
|
@ -2,8 +2,345 @@
|
|||
-- This updates a 1.32.2 database to 1.32.3
|
||||
--
|
||||
|
||||
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;
|
||||
//
|
||||
|
||||
|
||||
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;
|
||||
//
|
||||
|
||||
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//
|
||||
|
||||
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
|
||||
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) + diff WHERE Id = OLD.StorageId;
|
||||
END IF;
|
||||
ELSE
|
||||
IF ( NEW.DiskSpace ) THEN
|
||||
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) + NEW.DiskSpace WHERE Id = NEW.StorageId;
|
||||
END IF;
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) - OLD.DiskSpace WHERE Id = OLD.StorageId;
|
||||
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
|
||||
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) - CAST(OLD.DiskSpace AS SIGNED) WHERE Id = OLD.StorageId;
|
||||
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 ;
|
||||
|
||||
REPLACE INTO Events_Day SELECT Id,MonitorId,StartTime,DiskSpace FROM Events WHERE StartTime > DATE_SUB(NOW(), INTERVAL 1 day);
|
||||
REPLACE INTO Events_Week SELECT Id,MonitorId,StartTime,DiskSpace FROM Events WHERE StartTime > DATE_SUB(NOW(), INTERVAL 1 week);
|
||||
REPLACE INTO Events_Month SELECT Id,MonitorId,StartTime,DiskSpace FROM Events WHERE StartTime > DATE_SUB(NOW(), INTERVAL 1 month);
|
||||
REPLACE INTO Events_Archived SELECT Id,MonitorId,DiskSpace FROM Events WHERE Archived=1;
|
||||
|
||||
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;
|
||||
|
||||
--
|
||||
-- Add some additional monitor preset values
|
||||
-- Add Protocol column to Storage
|
||||
--
|
||||
|
||||
INSERT INTO MonitorPresets VALUES (NULL,'D-link DCS-930L, 640x480, mjpeg','Remote','http',0,0,'http','simple','<ip-address>',80,'/mjpeg.cgi',NULL,640,480,3,NULL,0,NULL,NULL,NULL,100,100);
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'Protocol'
|
||||
) > 0,
|
||||
"SELECT 'Column Protocol already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `Protocol` TEXT AFTER `Id`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Add PathToIndex column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'PathToIndex'
|
||||
) > 0,
|
||||
"SELECT 'Column PathToIndex already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `PathToIndex` TEXT AFTER `Hostname`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Add PathToZMS column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'PathToZMS'
|
||||
) > 0,
|
||||
"SELECT 'Column PathToZMS already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `PathToZMS` TEXT AFTER `PathToIndex`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Add Port column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'Port'
|
||||
) > 0,
|
||||
"SELECT 'Column Port already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `Port` INTEGER UNSIGNED AFTER `Hostname`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
|
|
@ -125,7 +125,7 @@ Requires: perl(Net::FTP)
|
|||
Requires: perl(LWP::Protocol::https)
|
||||
Requires: ca-certificates
|
||||
Requires: zip
|
||||
%{systemd_requires}
|
||||
%{?systemd_requires}
|
||||
|
||||
Requires(post): %{_bindir}/gpasswd
|
||||
Requires(post): %{_bindir}/chown
|
||||
|
|
|
@ -3,7 +3,7 @@ Section: net
|
|||
Priority: optional
|
||||
Maintainer: Dmitry Smirnov <onlyjob@debian.org>
|
||||
Uploaders: Vagrant Cascadian <vagrant@debian.org>
|
||||
Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apache2-dev, dh-linktree
|
||||
Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apache2-dev, dh-linktree, dh-systemd, dh-apache2
|
||||
,cmake
|
||||
,libx264-dev, libmp4v2-dev
|
||||
,libavdevice-dev (>= 6:10~)
|
||||
|
|
|
@ -311,7 +311,7 @@ There are a number of specific reasons why processor loads can be high either by
|
|||
|
||||
The main causes are.
|
||||
|
||||
* Using a video palette other than greyscale or RGB24. This can cause a relatively minor performace hit, though still significant. Although some cameras and cards require using planar palettes ZM currently doesn't support this format internally and each frame is converted to an RGB representation prior to processing. Unless you have compelling reasons for using YUV or reduced RGB type palettes such as hitting USB transfer limits I would experiment to see if RGB24 or greyscale is quicker. Put your monitors into 'Monitor' mode so that only the capture daemons are running and monitor the process load of these (the 'zmc' processes) using top. Try it with various palettes to see if it makes a difference.
|
||||
* Using a video palette other than greyscale or RGB24. This can cause a relatively minor performance hit, though still significant. Although some cameras and cards require using planar palettes ZM currently doesn't support this format internally and each frame is converted to an RGB representation prior to processing. Unless you have compelling reasons for using YUV or reduced RGB type palettes such as hitting USB transfer limits I would experiment to see if RGB24 or greyscale is quicker. Put your monitors into 'Monitor' mode so that only the capture daemons are running and monitor the process load of these (the 'zmc' processes) using top. Try it with various palettes to see if it makes a difference.
|
||||
* Big image sizes. A image of 640x480 requires at least four times the processing of a 320x240 image. Experiment with different sizes to see what effect it may have. Sometimes a large image is just two interlaced smaller frames so has no real benefit anyway. This is especially true for analog cameras/cards as image height over 320 (NTSC) or 352 PAL) are invariably interlaced.
|
||||
* Capture frame rates. Unless there's a compelling reason in your case there is often little benefit in running cameras at 25fps when 5-10fps would often get you results just as good. Try changing your monitor settings to limit your cameras to lower frame rates. You can still configure ZM to ignore these limits and capture as fast as possible when motion is detected.
|
||||
* Run function. Obviously running in Record or Mocord modes or in Modect with lots of events generates a lot of DB and file activity and so CPU and load will increase.
|
||||
|
|
|
@ -58,7 +58,7 @@ Maximum FPS
|
|||
Alarm Maximum FPS
|
||||
If you have specified a Maximum FPS it may be that you don’t want this limitation to apply when your monitor is recording motion or other event. This setting allows you to override the Maximum FPS value if this circumstance occurs. As with the Maximum FPS setting leaving this blank implies no limit so if you have set a maximum fps in the previous option then when an alarm occurs this limit would be ignored and ZoneMinder would capture as fast as possible for the duration of the alarm, returning to the limited value after the alarm has concluded. Equally you could set this to the same, or higher (or even lower) value than Maximum FPS for more precise control over the capture rate in the event of an alarm.
|
||||
|
||||
**IMPORTANT:** This field is subject to the same limitations as the Maxium FPS field. Ignoring these limitations will produce undesriable results.
|
||||
**IMPORTANT:** This field is subject to the same limitations as the Maximum FPS field. Ignoring these limitations will produce undesriable results.
|
||||
|
||||
Reference Image Blend %ge
|
||||
Each analysed image in ZoneMinder is a composite of previous images and is formed by applying the current image as a certain percentage of the previous reference image. Thus, if we entered the value of 10 here, each image’s part in the reference image will diminish by a factor of 0.9 each time round. So a typical reference image will be 10% the previous image, 9% the one before that and then 8.1%, 7.2%, 6.5% and so on of the rest of the way. An image will effectively vanish around 25 images later than when it was added. This blend value is what is specified here and if higher will make slower progressing events less detectable as the reference image would change more quickly. Similarly events will be deemed to be over much sooner as the reference image adapts to the new images more quickly. In signal processing terms the higher this value the steeper the event attack and decay of the signal. It depends on your particular requirements what the appropriate value would be for you but start with 10 here and adjust it (usually down) later if necessary.
|
||||
|
@ -205,7 +205,8 @@ Warm-up Frames
|
|||
Pre/Post Event Image Buffer
|
||||
These options determine how many frames from before and after an event should be preserved with it. This allows you to view what happened immediately prior and subsequent to the event. A value of 10 for both of these will get you started but if you get a lot of short events and would prefer them to run together to form fewer longer ones then increase the Post Event buffer size. The pre-event buffer is a true buffer and should not really exceed half the ring buffer size. However the post-event buffer is just a count that is applied to captured frames and so can be managed more flexibly. You should also bear in mind the frame rate of the camera when choosing these values. For instance a network camera capturing at 1FPS will give you 10 seconds before and after each event if you chose 10 here. This may well be too much and pad out events more than necessary. However a fast video card may capture at 25FPS and you will want to ensure that this setting enables you to view a reasonable time frame pre and post event.
|
||||
Stream Replay Image Buffer
|
||||
This option ...
|
||||
The number of frames buffered to allow pausing and rewinding of the stream when live viewing a monitor. A value of 0 disables the feature.
|
||||
Frames are buffered to ZM_PATH_SWAP. If this path points to a physical drive, a lot of IO will be caused during live view / montage. If you experience high system load in those situations, either disable the feature or use a RAM drive for ZM_PATH_SWAP.
|
||||
Alarm Frame Count
|
||||
This option allows you to specify how many consecutive alarm frames must occur before an alarm event is generated. The usual, and default, value is 1 which implies that any alarm frame will cause or participate in an event. You can enter any value up to 16 here to eliminate bogus events caused perhaps by screen flickers or other transients. Values over 3 or 4 are unlikely to be useful however. Please note that if you have statistics recording enabled then currently statistics are not recorded for the first ‘Alarm Frame Count’-1 frames of an event. So if you set this value to 5 then the first 4 frames will be missing statistics whereas the more usual value of 1 will ensure that all alarm frames have statistics recorded.
|
||||
|
||||
|
|
|
@ -25,15 +25,13 @@ sub GetServices {
|
|||
soap_action => 'http://www.onvif.org/ver10/device/wsdl/GetServices',
|
||||
style => 'document',
|
||||
body => {
|
||||
|
||||
|
||||
'use' => 'literal',
|
||||
use => 'literal',
|
||||
namespace => 'http://schemas.xmlsoap.org/wsdl/soap/',
|
||||
encodingStyle => '',
|
||||
parts => [qw( ONVIF::Device::Elements::GetServices )],
|
||||
},
|
||||
header => {
|
||||
|
||||
|
||||
},
|
||||
headerfault => {
|
||||
|
||||
|
@ -50,9 +48,7 @@ sub GetServiceCapabilities {
|
|||
soap_action => 'http://www.onvif.org/ver10/device/wsdl/GetServiceCapabilities',
|
||||
style => 'document',
|
||||
body => {
|
||||
|
||||
|
||||
'use' => 'literal',
|
||||
use => 'literal',
|
||||
namespace => 'http://schemas.xmlsoap.org/wsdl/soap/',
|
||||
encodingStyle => '',
|
||||
parts => [qw( ONVIF::Device::Elements::GetServiceCapabilities )],
|
||||
|
@ -3059,7 +3055,7 @@ Returns a L<ONVIF::Device::Elements::SetClientCertificateModeResponse|ONVIF::Dev
|
|||
|
||||
=head3 GetRelayOutputs
|
||||
|
||||
This method has been depricated with version 2.0. Refer to the DeviceIO service.
|
||||
This method has been deprecated with version 2.0. Refer to the DeviceIO service.
|
||||
|
||||
Returns a L<ONVIF::Device::Elements::GetRelayOutputsResponse|ONVIF::Device::Elements::GetRelayOutputsResponse> object.
|
||||
|
||||
|
@ -3069,7 +3065,7 @@ Returns a L<ONVIF::Device::Elements::GetRelayOutputsResponse|ONVIF::Device::Elem
|
|||
|
||||
=head3 SetRelayOutputSettings
|
||||
|
||||
This method has been depricated with version 2.0. Refer to the DeviceIO service.
|
||||
This method has been deprecated with version 2.0. Refer to the DeviceIO service.
|
||||
|
||||
Returns a L<ONVIF::Device::Elements::SetRelayOutputSettingsResponse|ONVIF::Device::Elements::SetRelayOutputSettingsResponse> object.
|
||||
|
||||
|
@ -3085,7 +3081,7 @@ Returns a L<ONVIF::Device::Elements::SetRelayOutputSettingsResponse|ONVIF::Devic
|
|||
|
||||
=head3 SetRelayOutputState
|
||||
|
||||
This method has been depricated with version 2.0. Refer to the DeviceIO service.
|
||||
This method has been deprecated with version 2.0. Refer to the DeviceIO service.
|
||||
|
||||
Returns a L<ONVIF::Device::Elements::SetRelayOutputStateResponse|ONVIF::Device::Elements::SetRelayOutputStateResponse> object.
|
||||
|
||||
|
|
|
@ -830,7 +830,7 @@ Returns a L<ONVIF::PTZ::Elements::SetPresetResponse|ONVIF::PTZ::Elements::SetPre
|
|||
|
||||
=head3 RemovePreset
|
||||
|
||||
Operation to remove a PTZ preset for the Node in the selected profile. The operation is supported if the PresetPosition capability exists for teh Node in the selected profile.
|
||||
Operation to remove a PTZ preset for the Node in the selected profile. The operation is supported if the PresetPosition capability exists for the Node in the selected profile.
|
||||
|
||||
Returns a L<ONVIF::PTZ::Elements::RemovePresetResponse|ONVIF::PTZ::Elements::RemovePresetResponse> object.
|
||||
|
||||
|
|
|
@ -812,7 +812,7 @@ shared_data The general mapped memory section
|
|||
size The size, in bytes, of this section
|
||||
valid Flag indicating whether this section has been initialised
|
||||
active Flag indicating whether this monitor is active (enabled/disabled)
|
||||
signal Flag indicating whether this monitor is reciving a valid signal
|
||||
signal Flag indicating whether this monitor is receiving a valid signal
|
||||
state The current monitor state, see the STATE constants below
|
||||
last_write_index The last index, in the image buffer, that an image has been saved to
|
||||
last_read_index The last index, in the image buffer, that an image has been analysed from
|
||||
|
|
|
@ -454,6 +454,12 @@ MAIN: while( $loop ) {
|
|||
my $Event = $fs_events->{$fs_event_id};
|
||||
|
||||
if ( ! defined( $db_events->{$fs_event_id} ) ) {
|
||||
# Long running zmaudits can find events that were created after we loaded all db events.
|
||||
# So do a secondary lookup
|
||||
if ( ZoneMinder::Event->find_one(Id=>$fs_event_id) ) {
|
||||
Debug("$$Event{Id} found in secondary lookup.");
|
||||
next;
|
||||
}
|
||||
my $age = $Event->age();
|
||||
|
||||
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
|
||||
|
|
|
@ -749,7 +749,7 @@ void Monitor::AddPrivacyBitmask( Zone *p_zones[] ) {
|
|||
}
|
||||
|
||||
Monitor::State Monitor::GetState() const {
|
||||
return( (State)shared_data->state );
|
||||
return (State)shared_data->state;
|
||||
}
|
||||
|
||||
int Monitor::GetImage( int index, int scale ) {
|
||||
|
|
13
src/zmu.cpp
13
src/zmu.cpp
|
@ -463,10 +463,10 @@ int main(int argc, char *argv[]) {
|
|||
} // end if auth
|
||||
|
||||
if ( mon_id > 0 ) {
|
||||
fprintf(stderr,"Monitor %d\n", mon_id);
|
||||
//fprintf(stderr,"Monitor %d\n", mon_id);
|
||||
Monitor *monitor = Monitor::Load(mon_id, function&(ZMU_QUERY|ZMU_ZONES), Monitor::QUERY);
|
||||
if ( monitor ) {
|
||||
fprintf(stderr,"Monitor %d(%s)\n", monitor->Id(), monitor->Name());
|
||||
//fprintf(stderr,"Monitor %d(%s)\n", monitor->Id(), monitor->Name());
|
||||
if ( verbose ) {
|
||||
printf("Monitor %d(%s)\n", monitor->Id(), monitor->Name());
|
||||
}
|
||||
|
@ -479,9 +479,9 @@ int main(int argc, char *argv[]) {
|
|||
bool have_output = false;
|
||||
if ( function & ZMU_STATE ) {
|
||||
Monitor::State state = monitor->GetState();
|
||||
if ( verbose )
|
||||
if ( verbose ) {
|
||||
printf("Current state: %s\n", state==Monitor::ALARM?"Alarm":(state==Monitor::ALERT?"Alert":"Idle"));
|
||||
else {
|
||||
} else {
|
||||
if ( have_output ) printf("%c", separator);
|
||||
printf("%d", state);
|
||||
have_output = true;
|
||||
|
@ -560,6 +560,11 @@ int main(int argc, char *argv[]) {
|
|||
if ( verbose )
|
||||
printf( "Forcing alarm on\n" );
|
||||
monitor->ForceAlarmOn( config.forced_alarm_score, "Forced Web" );
|
||||
while ( monitor->GetState() != Monitor::ALARM ) {
|
||||
// Wait for monitor to notice.
|
||||
usleep(1000);
|
||||
}
|
||||
printf( "Alarmed event id: %" PRIu64 "\n", monitor->GetLastEventId() );
|
||||
}
|
||||
if ( function & ZMU_NOALARM ) {
|
||||
if ( verbose )
|
||||
|
|
|
@ -76,7 +76,7 @@ fi;
|
|||
|
||||
if [ "$DISTROS" == "" ]; then
|
||||
if [ "$RELEASE" != "" ]; then
|
||||
DISTROS="xenial,bionic,trusty"
|
||||
DISTROS="xenial,bionic,cosmic,disco,trusty"
|
||||
else
|
||||
DISTROS=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`;
|
||||
fi;
|
||||
|
|
|
@ -65,18 +65,17 @@ class HostController extends AppController {
|
|||
$isZmAuth = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH')))['Config']['Value'];
|
||||
|
||||
if ( $isZmAuth ) {
|
||||
// In future, we may want to completely move to AUTH_HASH_LOGINS and return &auth= for all cases
|
||||
require_once "../../../includes/auth.php"; # in the event we directly call getCredentials.json
|
||||
$this->Session->read('user'); # this is needed for command line/curl to recognize a session
|
||||
$zmAuthRelay = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_RELAY')))['Config']['Value'];
|
||||
if ( $zmAuthRelay == 'hashed' ) {
|
||||
$zmAuthHashIps = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_IPS')))['Config']['Value'];
|
||||
$credentials = 'auth='.generateAuthHash($zmAuthHashIps);
|
||||
} else if ( $zmAuthRelay == 'plain' ) {
|
||||
} else {
|
||||
// user will need to append the store password here
|
||||
$credentials = 'user='.$this->Session->read('user.Username').'&pass=';
|
||||
$appendPassword = 1;
|
||||
} else if ( $zmAuthRelay == 'none' ) {
|
||||
$credentials = 'user='.$this->Session->read('user.Username');
|
||||
}
|
||||
}
|
||||
return array($credentials, $appendPassword);
|
||||
|
|
|
@ -198,26 +198,28 @@ class Event {
|
|||
|
||||
public function getStreamSrc( $args=array(), $querySep='&' ) {
|
||||
|
||||
$streamSrc = ZM_BASE_PROTOCOL.'://';
|
||||
$streamSrc = '';
|
||||
$Server = null;
|
||||
if ( $this->Storage()->ServerId() ) {
|
||||
# The Event may have been moved to Storage on another server,
|
||||
# So prefer viewing the Event from the Server that is actually
|
||||
# storing the video
|
||||
$Server = $this->Storage()->Server();
|
||||
$streamSrc .= $Server->Hostname();
|
||||
if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
}
|
||||
} else if ( $this->Monitor()->ServerId() ) {
|
||||
# Assume that the server that recorded it has it
|
||||
$Server = $this->Monitor()->Server();
|
||||
$streamSrc .= $Server->Hostname();
|
||||
if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
}
|
||||
} else if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= $_SERVER['SERVER_NAME'].':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
} else {
|
||||
$streamSrc .= $_SERVER['HTTP_HOST'];
|
||||
# A default Server will result in the use of ZM_DIR_EVENTS
|
||||
$Server = new Server();
|
||||
}
|
||||
|
||||
# If we are in a multi-port setup, then use the multiport, else by
|
||||
# passing null Server->Url will use the Port set in the Server setting
|
||||
$streamSrc .= $Server->Url(
|
||||
ZM_MIN_STREAMING_PORT ?
|
||||
ZM_MIN_STREAMING_PORT+$this->{'MonitorId'} :
|
||||
null);
|
||||
|
||||
if ( $this->{'DefaultVideo'} and $args['mode'] != 'jpeg' ) {
|
||||
$streamSrc .= ( ZM_BASE_PATH != '/' ? ZM_BASE_PATH : '' ).'/index.php';
|
||||
$args['eid'] = $this->{'Id'};
|
||||
|
@ -238,10 +240,10 @@ class Event {
|
|||
if ( ZM_OPT_USE_AUTH ) {
|
||||
if ( ZM_AUTH_RELAY == 'hashed' ) {
|
||||
$args['auth'] = generateAuthHash(ZM_AUTH_HASH_IPS);
|
||||
} elseif ( ZM_AUTH_RELAY == 'plain' ) {
|
||||
} else if ( ZM_AUTH_RELAY == 'plain' ) {
|
||||
$args['user'] = $_SESSION['username'];
|
||||
$args['pass'] = $_SESSION['password'];
|
||||
} elseif ( ZM_AUTH_RELAY == 'none' ) {
|
||||
} else if ( ZM_AUTH_RELAY == 'none' ) {
|
||||
$args['user'] = $_SESSION['username'];
|
||||
}
|
||||
}
|
||||
|
@ -328,25 +330,20 @@ class Event {
|
|||
# The thumbnail is theoretically the image with the most motion.
|
||||
# We always store at least 1 image when capturing
|
||||
|
||||
$streamSrc = ZM_BASE_PROTOCOL.'://';
|
||||
$streamSrc = '';
|
||||
$Server = null;
|
||||
if ( $this->Storage()->ServerId() ) {
|
||||
$Server = $this->Storage()->Server();
|
||||
$streamSrc .= $Server->Hostname();
|
||||
if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
}
|
||||
} else if ( $this->Monitor()->ServerId() ) {
|
||||
# Assume that the server that recorded it has it
|
||||
$Server = $this->Monitor()->Server();
|
||||
$streamSrc .= $Server->Hostname();
|
||||
if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
}
|
||||
|
||||
} else if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= $_SERVER['SERVER_NAME'].':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'});
|
||||
} else {
|
||||
$streamSrc .= $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
$Server = new Server();
|
||||
}
|
||||
$streamSrc .= $Server->Url(
|
||||
ZM_MIN_STREAMING_PORT ?
|
||||
ZM_MIN_STREAMING_PORT+$this->{'MonitorId'} :
|
||||
null);
|
||||
|
||||
$streamSrc .= ( ZM_BASE_PATH != '/' ? ZM_BASE_PATH : '' ).'/index.php';
|
||||
$args['eid'] = $this->{'Id'};
|
||||
|
@ -358,10 +355,10 @@ class Event {
|
|||
if ( ZM_OPT_USE_AUTH ) {
|
||||
if ( ZM_AUTH_RELAY == 'hashed' ) {
|
||||
$args['auth'] = generateAuthHash(ZM_AUTH_HASH_IPS);
|
||||
} elseif ( ZM_AUTH_RELAY == 'plain' ) {
|
||||
} else if ( ZM_AUTH_RELAY == 'plain' ) {
|
||||
$args['user'] = $_SESSION['username'];
|
||||
$args['pass'] = $_SESSION['password'];
|
||||
} elseif ( ZM_AUTH_RELAY == 'none' ) {
|
||||
} else if ( ZM_AUTH_RELAY == 'none' ) {
|
||||
$args['user'] = $_SESSION['username'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,20 +280,13 @@ private $control_fields = array(
|
|||
}
|
||||
}
|
||||
|
||||
public function getStreamSrc( $args, $querySep='&' ) {
|
||||
public function getStreamSrc($args, $querySep='&') {
|
||||
|
||||
$streamSrc = $this->Server()->Url(
|
||||
ZM_MIN_STREAMING_PORT ?
|
||||
ZM_MIN_STREAMING_PORT+$this->{'Id'} :
|
||||
null);
|
||||
|
||||
$streamSrc = ZM_BASE_PROTOCOL.'://';
|
||||
if ( isset($this->{'ServerId'}) and $this->{'ServerId'} ) {
|
||||
$Server = new Server( $this->{'ServerId'} );
|
||||
$streamSrc .= $Server->Hostname();
|
||||
if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'Id'});
|
||||
}
|
||||
} else if ( ZM_MIN_STREAMING_PORT ) {
|
||||
$streamSrc .= $_SERVER['SERVER_NAME'].':'.(ZM_MIN_STREAMING_PORT+$this->{'Id'});
|
||||
} else {
|
||||
$streamSrc .= $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
$streamSrc .= ZM_PATH_ZMS;
|
||||
|
||||
$args['monitor'] = $this->{'Id'};
|
||||
|
@ -315,9 +308,9 @@ private $control_fields = array(
|
|||
$args['rand'] = time();
|
||||
}
|
||||
|
||||
$streamSrc .= '?'.http_build_query( $args,'', $querySep );
|
||||
$streamSrc .= '?'.http_build_query($args,'', $querySep);
|
||||
|
||||
return( $streamSrc );
|
||||
return $streamSrc;
|
||||
} // end function getStreamSrc
|
||||
|
||||
public function Width($new = null) {
|
||||
|
@ -600,13 +593,15 @@ private $control_fields = array(
|
|||
$source = preg_replace( '/^.*\//', '', $this->{'Path'} );
|
||||
} elseif ( $this->{'Type'} == 'Ffmpeg' || $this->{'Type'} == 'Libvlc' || $this->{'Type'} == 'WebSite' ) {
|
||||
$url_parts = parse_url( $this->{'Path'} );
|
||||
if ( ZM_WEB_FILTER_SOURCE == 'Hostname' ) { # Filter out everything but the hostname
|
||||
if ( ZM_WEB_FILTER_SOURCE == 'Hostname' ) {
|
||||
# Filter out everything but the hostname
|
||||
if ( isset($url_parts['host']) ) {
|
||||
$source = $url_parts['host'];
|
||||
} else {
|
||||
$source = $this->{'Path'};
|
||||
}
|
||||
} elseif ( ZM_WEB_FILTER_SOURCE == "NoCredentials" ) { # Filter out sensitive and common items
|
||||
} elseif ( ZM_WEB_FILTER_SOURCE == "NoCredentials" ) {
|
||||
# Filter out sensitive and common items
|
||||
unset($url_parts['user']);
|
||||
unset($url_parts['pass']);
|
||||
#unset($url_parts['scheme']);
|
||||
|
|
|
@ -5,23 +5,25 @@ $server_cache = array();
|
|||
|
||||
class Server {
|
||||
private $defaults = array(
|
||||
'Id' => null,
|
||||
'Name' => '',
|
||||
'Hostname' => '',
|
||||
'zmaudit' => 1,
|
||||
'zmstats' => 1,
|
||||
'zmtrigger' => 0,
|
||||
'Id' => null,
|
||||
'Name' => '',
|
||||
'Protocol' => '',
|
||||
'Hostname' => '',
|
||||
'Port' => null,
|
||||
'PathPrefix' => '/zm',
|
||||
'zmaudit' => 1,
|
||||
'zmstats' => 1,
|
||||
'zmtrigger' => 0,
|
||||
);
|
||||
|
||||
|
||||
public function __construct( $IdOrRow = NULL ) {
|
||||
global $server_cache;
|
||||
public function __construct($IdOrRow = NULL) {
|
||||
global $server_cache;
|
||||
$row = NULL;
|
||||
if ( $IdOrRow ) {
|
||||
if ( is_integer($IdOrRow) or ctype_digit($IdOrRow) ) {
|
||||
$row = dbFetchOne('SELECT * FROM Servers WHERE Id=?', NULL, array($IdOrRow));
|
||||
if ( !$row ) {
|
||||
Error("Unable to load Server record for Id=" . $IdOrRow);
|
||||
Error('Unable to load Server record for Id='.$IdOrRow);
|
||||
}
|
||||
} elseif ( is_array($IdOrRow) ) {
|
||||
$row = $IdOrRow;
|
||||
|
@ -33,13 +35,58 @@ class Server {
|
|||
}
|
||||
$server_cache[$row['Id']] = $this;
|
||||
} else {
|
||||
$this->{'Name'} = '';
|
||||
$this->{'Hostname'} = '';
|
||||
# Set defaults
|
||||
foreach ( $this->defaults as $k => $v ) $this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
|
||||
public function Hostname( $new = null ) {
|
||||
if ( $new != null )
|
||||
$this->{'Hostname'} = $new;
|
||||
|
||||
if ( isset( $this->{'Hostname'}) and ( $this->{'Hostname'} != '' ) ) {
|
||||
return $this->{'Hostname'};
|
||||
} else if ( $this->Id() ) {
|
||||
return $this->{'Name'};
|
||||
}
|
||||
return $_SERVER['SERVER_NAME'];
|
||||
}
|
||||
|
||||
public function Protocol( $new = null ) {
|
||||
if ( $new != null )
|
||||
$this->{'Protocol'} = $new;
|
||||
|
||||
if ( isset($this->{'Protocol'}) and ( $this->{'Protocol'} != '' ) ) {
|
||||
return $this->{'Protocol'};
|
||||
}
|
||||
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http';
|
||||
}
|
||||
|
||||
public function Port( $new = '' ) {
|
||||
if ( $new != '' )
|
||||
$this->{'Port'} = $new;
|
||||
|
||||
if ( isset($this->{'Port'}) and $this->{'Port'} ) {
|
||||
return $this->{'Port'};
|
||||
}
|
||||
return $_SERVER['SERVER_PORT'];
|
||||
}
|
||||
|
||||
public function PathToZMS( $new = null ) {
|
||||
if ( $new != null )
|
||||
$this{'PathToZMS'} = $new;
|
||||
if ( $this->Id() and $this->{'PathToZMS'} ) {
|
||||
return $this->{'PathToZMS'};
|
||||
} else {
|
||||
return ZM_PATH_ZMS;
|
||||
}
|
||||
}
|
||||
public function UrlToZMS( ) {
|
||||
return $this->Url().$this->PathToZMS();
|
||||
}
|
||||
|
||||
public function Url( $port = null ) {
|
||||
$url = ZM_BASE_PROTOCOL . '://';
|
||||
$url = $this->Protocol().'://';
|
||||
if ( $this->Id() ) {
|
||||
$url .= $this->Hostname();
|
||||
} else {
|
||||
|
@ -48,17 +95,25 @@ class Server {
|
|||
if ( $port ) {
|
||||
$url .= ':'.$port;
|
||||
} else {
|
||||
$url .= ':'.$_SERVER['SERVER_PORT'];
|
||||
$url .= ':'.$this->Port();
|
||||
}
|
||||
$url .= $_SERVER['PHP_SELF'];
|
||||
return $url;
|
||||
}
|
||||
public function Hostname() {
|
||||
if ( isset( $this->{'Hostname'} ) and ( $this->{'Hostname'} != '' ) ) {
|
||||
return $this->{'Hostname'};
|
||||
}
|
||||
return $this->{'Name'};
|
||||
}
|
||||
|
||||
public function PathToIndex( $new = null ) {
|
||||
if ( $new != null )
|
||||
$this->{'PathToIndex'} = $new;
|
||||
|
||||
if ( isset($this->{'PathToIndex'}) and $this->{'PathToIndex'} ) {
|
||||
return $this->{'PathToIndex'};
|
||||
}
|
||||
return $_SERVER['PHP_SELF'];
|
||||
}
|
||||
|
||||
public function UrlToIndex( ) {
|
||||
return $this->Url().$this->PathToIndex();
|
||||
}
|
||||
|
||||
public function __call($fn, array $args){
|
||||
if ( count($args) ) {
|
||||
$this->{$fn} = $args[0];
|
||||
|
@ -66,13 +121,13 @@ class Server {
|
|||
if ( array_key_exists($fn, $this) ) {
|
||||
return $this->{$fn};
|
||||
} else {
|
||||
if ( array_key_exists( $fn, $this->defaults ) ) {
|
||||
if ( array_key_exists($fn, $this->defaults) ) {
|
||||
return $this->defaults{$fn};
|
||||
} else {
|
||||
$backTrace = debug_backtrace();
|
||||
$file = $backTrace[1]['file'];
|
||||
$line = $backTrace[1]['line'];
|
||||
Warning( "Unknown function call Server->$fn from $file:$line" );
|
||||
Warning("Unknown function call Server->$fn from $file:$line");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +172,7 @@ class Server {
|
|||
}
|
||||
$results = dbFetchAll( $sql, NULL, $values );
|
||||
if ( $results ) {
|
||||
return array_map( function($id){ return new Server($id); }, $results );
|
||||
return array_map(function($id){ return new Server($id); }, $results);
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
@ -137,5 +192,5 @@ class Server {
|
|||
return $results[0];
|
||||
}
|
||||
|
||||
}
|
||||
} # end class Server
|
||||
?>
|
||||
|
|
|
@ -53,7 +53,7 @@ function CORSHeaders() {
|
|||
preg_match('/^(https?:\/\/)?'.preg_quote($Server->Name(),'/').'/i', $_SERVER['HTTP_ORIGIN'])
|
||||
) {
|
||||
$valid = true;
|
||||
Logger::Debug("Setting Access-Controll-Allow-Origin from " . $_SERVER['HTTP_ORIGIN']);
|
||||
Logger::Debug("Setting Access-Control-Allow-Origin from " . $_SERVER['HTTP_ORIGIN']);
|
||||
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
|
||||
header('Access-Control-Allow-Headers: x-requested-with,x-request');
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
class Server {
|
||||
constructor(json) {
|
||||
for( var k in json ) {
|
||||
this[k] = json[k];
|
||||
}
|
||||
}
|
||||
url(port=0){
|
||||
return location.protocol+'//'+this.Hostname+
|
||||
(port ? ':'+port : '') +
|
||||
( ( this.PathPrefix && this.PathPrefix != 'null') ? this.PathPrefix : '');
|
||||
}
|
||||
};
|
|
@ -584,6 +584,8 @@ $SLANG = array(
|
|||
'Parameter' => 'Parameter',
|
||||
'Password' => 'Password',
|
||||
'PasswordsDifferent' => 'The new and confirm passwords are different',
|
||||
'PathToIndex' => 'Path To Index',
|
||||
'PathToZMS' => 'Path To ZMS',
|
||||
'Paths' => 'Paths',
|
||||
'Pause' => 'Pause',
|
||||
'PhoneBW' => 'Phone B/W',
|
||||
|
|
|
@ -150,6 +150,7 @@ input,textarea,select,button,.btn-primary {
|
|||
font-weight: 400;
|
||||
font-size: 100%;
|
||||
color: #333333;
|
||||
background-color: #f8f8f8;
|
||||
text-align: left;
|
||||
border-radius:4px;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,8 @@ input,textarea,select,button {
|
|||
border: 1px #7f7fb2 solid;
|
||||
font-family: inherit;
|
||||
font-size: 100%;
|
||||
color: #333333;
|
||||
color: #333333;
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
input[type=text], input[type=password], textarea {
|
||||
|
|
|
@ -119,6 +119,7 @@ echo output_link_if_exists( array(
|
|||
<script src="skins/<?php echo $skin; ?>/js/chosen/chosen.jquery.min.js"></script>
|
||||
<script src="skins/<?php echo $skin; ?>/js/dateTimePicker/jquery-ui-timepicker-addon.js"></script>
|
||||
|
||||
<script src="<?php echo cache_bust('js/Server.js'); ?>"></script>
|
||||
<script>
|
||||
jQuery(document).ready(function(){
|
||||
jQuery("#flip").click(function(){
|
||||
|
@ -127,16 +128,8 @@ echo output_link_if_exists( array(
|
|||
Cookie.write( 'zmHeaderFlip', jQuery('#flip').hasClass('glyphicon-menu-up') ? 'up' : 'down', { duration: 10*365 } );
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
//<![CDATA[
|
||||
<!--
|
||||
var $j = jQuery.noConflict();
|
||||
// $j is now an alias to the jQuery function; creating the new alias is optional.
|
||||
|
||||
//-->
|
||||
//]]>
|
||||
</script>
|
||||
<script src="skins/<?php echo $skin; ?>/views/js/state.js"></script>
|
||||
<?php
|
||||
|
|
|
@ -205,7 +205,6 @@ if ( currentView != 'none' && currentView != 'login' ) {
|
|||
}
|
||||
|
||||
function setNavBar(data) {
|
||||
console.log(data);
|
||||
if ( data.auth ) {
|
||||
if ( data.auth != auth_hash ) {
|
||||
// Update authentication token.
|
||||
|
|
|
@ -31,6 +31,7 @@ var navBarRefresh = <?php echo 1000*ZM_WEB_REFRESH_NAVBAR ?>;
|
|||
var currentView = '<?php echo $view ?>';
|
||||
var thisUrl = "<?php echo ZM_BASE_URL.$_SERVER['PHP_SELF'] ?>";
|
||||
var skinPath = "<?php echo ZM_SKIN_PATH ?>";
|
||||
var serverId = '<?php echo defined('ZM_SERVER_ID') ? ZM_SERVER_ID : '' ?>';
|
||||
|
||||
var canEditSystem = <?php echo canEdit('System' )?'true':'false' ?>;
|
||||
var canViewSystem = <?php echo canView('System' )?'true':'false' ?>;
|
||||
|
|
|
@ -38,6 +38,8 @@ $Monitor = $Event->Monitor();
|
|||
|
||||
if (isset($_REQUEST['rate'])) {
|
||||
$rate = validInt($_REQUEST['rate']);
|
||||
} else if ( isset($_COOKIE['zmEventRate']) ) {
|
||||
$rate = $_COOKIE['zmEventRate'];
|
||||
} else {
|
||||
$rate = reScale(RATE_BASE, $Monitor->DefaultRate(), ZM_WEB_DEFAULT_RATE);
|
||||
}
|
||||
|
|
|
@ -235,6 +235,7 @@ function getCmdResponse( respObj, respText ) {
|
|||
streamPause( );
|
||||
} else {
|
||||
$j('#rateValue').html(streamStatus.rate);
|
||||
Cookie.write('zmEventRate', streamStatus.rate*100, {duration: 10*365});
|
||||
streamPlay( );
|
||||
}
|
||||
$j('#progressValue').html(secsToTime(parseInt(streamStatus.progress)));
|
||||
|
@ -303,8 +304,10 @@ function playClicked( ) {
|
|||
}
|
||||
|
||||
function vjsPlay() { //catches if we change mode programatically
|
||||
stopFastRev();
|
||||
if ( intervalRewind )
|
||||
stopFastRev();
|
||||
$j('#rateValue').html(vid.playbackRate());
|
||||
Cookie.write('zmEventRate', vid.playbackRate(), {duration: 10*365});
|
||||
streamPlay();
|
||||
}
|
||||
|
||||
|
@ -331,6 +334,7 @@ function streamFastFwd( action ) {
|
|||
if ( rates.indexOf(vid.playbackRate()*100)-1 == -1 )
|
||||
setButtonState($('fastFwdBtn'), 'unavail');
|
||||
$j('#rateValue').html(vid.playbackRate());
|
||||
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365});
|
||||
} else {
|
||||
streamReq.send(streamParms+"&command="+CMD_FASTFWD);
|
||||
}
|
||||
|
@ -359,6 +363,7 @@ function streamSlowRev( action ) {
|
|||
function stopFastRev() {
|
||||
clearInterval(intervalRewind);
|
||||
vid.playbackRate(1);
|
||||
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365});
|
||||
revSpeed = .5;
|
||||
}
|
||||
|
||||
|
@ -369,13 +374,14 @@ function streamFastRev( action ) {
|
|||
setButtonState( $('slowFwdBtn'), 'unavail' );
|
||||
setButtonState( $('slowRevBtn'), 'unavail' );
|
||||
setButtonState( $('fastRevBtn'), 'active' );
|
||||
if ( vid ) { //There is no reverse play with mp4. Set the speed to 0 and manualy set the time back.
|
||||
if ( vid ) { //There is no reverse play with mp4. Set the speed to 0 and manually set the time back.
|
||||
revSpeed = rates[rates.indexOf(revSpeed*100)-1]/100;
|
||||
if ( rates.indexOf(revSpeed*100) == 0 ) {
|
||||
setButtonState( $('fastRevBtn'), 'unavail' );
|
||||
}
|
||||
clearInterval(intervalRewind);
|
||||
$j('#rateValue').html(-revSpeed);
|
||||
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365});
|
||||
intervalRewind = setInterval(function() {
|
||||
if (vid.currentTime() <= 0) {
|
||||
clearInterval(intervalRewind);
|
||||
|
@ -997,8 +1003,13 @@ function initPage() {
|
|||
vid.on('pause', vjsPause);
|
||||
vid.on('click', function(event){handleClick(event);});
|
||||
vid.on('timeupdate', function (){$j('#progressValue').html(secsToTime(Math.floor(vid.currentTime())))});
|
||||
|
||||
if ( rate > 1 ) {
|
||||
// rate should be 100 = 1x, etc.
|
||||
vid.playbackRate(rate/100);
|
||||
}
|
||||
} else {
|
||||
progressBarNav ();
|
||||
progressBarNav();
|
||||
streamCmdTimer = streamQuery.delay( 250 );
|
||||
if ( canStreamNative ) {
|
||||
var imageFeed = $('imageFeed');
|
||||
|
|
|
@ -41,6 +41,7 @@ var filterQuery = '<?php echo isset($filterQuery)?validJsStr(htmlspecialchars_de
|
|||
var sortQuery = '<?php echo isset($sortQuery)?validJsStr(htmlspecialchars_decode($sortQuery)):'' ?>';
|
||||
|
||||
var rates = <?php echo json_encode(array_keys($rates)) ?>;
|
||||
var rate = '<?php echo $rate ?>'; // really only used when setting up initial playback rate.
|
||||
var scale = "<?php echo $scale ?>";
|
||||
var LabelFormat = "<?php echo validJsStr($Monitor->LabelFormat())?>";
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ monitorData[monitorData.length] = {
|
|||
'connKey': <?php echo $monitor->connKey() ?>,
|
||||
'width': <?php echo $monitor->Width() ?>,
|
||||
'height':<?php echo $monitor->Height() ?>,
|
||||
'url': '<?php echo $monitor->Url() ?>',
|
||||
'url': '<?php echo $monitor->UrlToIndex() ?>',
|
||||
'onclick': function(){createPopup( '?view=watch&mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo reScale( $monitor->Width(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->Height(), $monitor->PopupScale() ); ?> );},
|
||||
'type': '<?php echo $monitor->Type() ?>',
|
||||
'refresh': '<?php echo $monitor->Refresh() ?>'
|
||||
|
|
|
@ -117,24 +117,21 @@ function getImageSource( monId, time ) {
|
|||
Event = events[Frame.EventId];
|
||||
|
||||
var storage = Storage[Event.StorageId];
|
||||
if ( storage.ServerId ) {
|
||||
var server = Servers[storage.ServerId];
|
||||
if ( server ) {
|
||||
//console.log( server.Hostname + " for event " + eId[i] );
|
||||
return location.protocol + '//' + server.Hostname +
|
||||
//'/cgi-bin/zms?mode=jpeg&replay=single&event=' + event_id +
|
||||
//'&frame='+Frame.FrameId +
|
||||
'/zm/index.php?view=image&eid=' + Frame.EventId + '&fid='+Frame.FrameId +
|
||||
"&width=" + monitorCanvasObj[monId].width +
|
||||
"&height=" + monitorCanvasObj[monId].height;
|
||||
} else {
|
||||
console.log("No server found for " + storage.ServerId );
|
||||
}
|
||||
var server = storage.ServerId ? Servers[storage.ServerId] : Servers[serverId];
|
||||
if ( server ) {
|
||||
return server.url() +
|
||||
//location.protocol + '//' + server.Hostname +
|
||||
//'/cgi-bin/zms?mode=jpeg&replay=single&event=' + event_id +
|
||||
//'&frame='+Frame.FrameId +
|
||||
'/index.php?view=image&eid=' + Frame.EventId + '&fid='+Frame.FrameId +
|
||||
"&width=" + monitorCanvasObj[monId].width +
|
||||
"&height=" + monitorCanvasObj[monId].height;
|
||||
}
|
||||
console.log("No server found for " + ( storage.ServerId ? storage.ServerId : serverId ));
|
||||
//console.log("No storage found for " + eStorageId[i] );
|
||||
return '/zm/index.php?view=image&eid=' + Frame.EventId + '&fid='+frame_id + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
//return "/cgi-bin/zms?mode=single&replay=single&event=" + Frame.EventId + '&time='+time+ "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
return "/cgi-bin/zms?mode=jpeg&replay=single&event=" + Frame.EventId + '&frame='+frame_id + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
//return "/cgi-bin/zms?mode=jpeg&replay=single&event=" + Frame.EventId + '&frame='+frame_id + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
} // end found Frame
|
||||
return '';
|
||||
//return "no data";
|
||||
|
@ -168,7 +165,7 @@ function imagedone( obj, monId, success ) {
|
|||
}
|
||||
} else {
|
||||
if ( monitorLoadingStageURL[monId] == "" ) {
|
||||
console.log("Not showing image for " + monId );
|
||||
//console.log("Not showing image for " + monId );
|
||||
// This means that there wasn't a loading image placeholder.
|
||||
// So we weren't actually loading an image... which seems weird.
|
||||
return;
|
||||
|
@ -246,7 +243,7 @@ console.log("Current time " + currentTimeSecs + " + " + playSecsperInterval + "
|
|||
setSpeed(0);
|
||||
outputUpdate(currentTimeSecs);
|
||||
} else {
|
||||
console.log("Current time " + currentTimeSecs + " + " + playSecsperInterval );
|
||||
//console.log("Current time " + currentTimeSecs + " + " + playSecsperInterval );
|
||||
outputUpdate(playSecsperInterval + currentTimeSecs);
|
||||
}
|
||||
return;
|
||||
|
@ -368,7 +365,7 @@ function drawGraph() {
|
|||
underSlider=undefined;
|
||||
return;
|
||||
}
|
||||
var rowHeight=parseInt(cHeight / (numMonitors + 1) ); // Leave room for a scale of some sort
|
||||
var rowHeight = parseInt(cHeight / (numMonitors + 1) ); // Leave room for a scale of some sort
|
||||
|
||||
// first fill in the bars for the events (not alarms)
|
||||
|
||||
|
@ -473,7 +470,7 @@ function outputUpdate(time) {
|
|||
drawSliderOnGraph(time);
|
||||
for ( var i=0; i < numMonitors; i++ ) {
|
||||
var src = getImageSource(monitorPtr[i],time);
|
||||
console.log("New image src: " + src);
|
||||
//console.log("New image src: " + src);
|
||||
loadImage2Monitor(monitorPtr[i],src);
|
||||
}
|
||||
currentTimeSecs = time;
|
||||
|
|
|
@ -118,13 +118,13 @@ echo " };\n";
|
|||
echo "var maxScore=$maxScore;\n"; // used to skip frame load if we find no alarms.
|
||||
} // end if initialmodeislive
|
||||
|
||||
echo "var Storage = [];\n";
|
||||
echo "\nvar Storage = [];\n";
|
||||
foreach ( Storage::find() as $Storage ) {
|
||||
echo 'Storage[' . $Storage->Id() . '] = ' . json_encode($Storage). ";\n";
|
||||
echo 'Storage[' . $Storage->Id() . '] = ' . json_encode($Storage). ";\n";
|
||||
}
|
||||
echo "\nvar Servers = [];\n";
|
||||
foreach ( Server::find() as $Server ) {
|
||||
echo 'Servers[' . $Server->Id() . '] = ' . json_encode($Server). ";\n";
|
||||
echo 'Servers[' . $Server->Id() . '] = new Server(' . json_encode($Server). ");\n";
|
||||
}
|
||||
echo '
|
||||
var monitorName = [];
|
||||
|
|
|
@ -48,7 +48,7 @@ var maxDisplayEvents = <?php echo 2 * MAX_EVENTS ?>;
|
|||
var monitorId = <?php echo $monitor->Id() ?>;
|
||||
var monitorWidth = <?php echo $monitor->Width() ?>;
|
||||
var monitorHeight = <?php echo $monitor->Height() ?>;
|
||||
var monitorUrl = '<?php echo $monitor->Url(); ?>';
|
||||
var monitorUrl = '<?php echo $monitor->UrlToIndex(); ?>';
|
||||
var monitorType = '<?php echo ( $monitor->Type() ) ?>';
|
||||
var monitorRefresh = '<?php echo ( $monitor->Refresh() ) ?>';
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ var streamMode = "<?php echo $streamMode ?>";
|
|||
var connKey = '<?php echo $connkey ?>';
|
||||
|
||||
var monitorId = <?php echo $monitor->Id() ?>;
|
||||
var monitorUrl = '<?php echo ( $monitor->Url() ) ?>';
|
||||
var monitorUrl = '<?php echo ( $monitor->UrlToIndex() ) ?>';
|
||||
|
||||
var streamSrc = "<?php echo preg_replace( '/&/', '&', $streamSrc ) ?>";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var connKey = '<?php echo $connkey ?>';
|
||||
var monitorUrl = '<?php echo ( $monitor->Url() ) ?>';
|
||||
var monitorUrl = '<?php echo ( $monitor->UrlToIndex() ) ?>';
|
||||
var CMD_QUIT = <?php echo CMD_QUIT ?>;
|
||||
|
||||
|
|
|
@ -208,7 +208,9 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
|
|||
<thead class="thead-highlight">
|
||||
<tr>
|
||||
<th class="colName"><?php echo translate('Name') ?></th>
|
||||
<th class="colHostname"><?php echo translate('Hostname') ?></th>
|
||||
<th class="colUrl"><?php echo translate('Url') ?></th>
|
||||
<th class="colPathToIndex"><?php echo translate('PathToIndex') ?></th>
|
||||
<th class="colPathToZMS"><?php echo translate('PathToZMS') ?></th>
|
||||
<th class="colStatus"><?php echo translate('Status') ?></th>
|
||||
<th class="colMonitorCount"><?php echo translate('Monitors') ?></th>
|
||||
<th class="colCpuLoad"><?php echo translate('CpuLoad') ?></th>
|
||||
|
@ -222,27 +224,33 @@ foreach ( array_map('basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
|
|||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach( dbFetchAll( 'SELECT *,(SELECT COUNT(Id) FROM Monitors WHERE ServerId=Servers.Id) AS MonitorCount FROM Servers ORDER BY Id' ) as $row ) {
|
||||
$monitor_counts = dbFetchAssoc('SELECT Id,(SELECT COUNT(Id) FROM Monitors WHERE ServerId=Servers.Id) AS MonitorCount FROM Servers', 'Id', 'MonitorCount');
|
||||
foreach ( Server::find() as $Server ) {
|
||||
?>
|
||||
<tr>
|
||||
<td class="colName"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', validHtmlStr($row['Name']), $canEdit ) ?></td>
|
||||
<td class="colHostname"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', validHtmlStr($row['Hostname']), $canEdit ) ?></td>
|
||||
<td class="colStatus
|
||||
<?php if ( $row['Status'] == 'NotRunning' ) { echo 'danger'; } ?>
|
||||
"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', validHtmlStr($row['Status']), $canEdit ) ?></td>
|
||||
<td class="colMonitorCount"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', validHtmlStr($row['MonitorCount']), $canEdit ) ?></td>
|
||||
<td class="colCpuLoad
|
||||
<?php if ( $row['CpuLoad'] > 5 ) { echo 'danger'; } ?>
|
||||
"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server',$row['CpuLoad'], $canEdit ) ?></td>
|
||||
<td class="colMemory
|
||||
<?php if ( $row['FreeMem']/$row['TotalMem'] < .1 ) { echo 'danger'; } ?>"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', human_filesize($row['FreeMem']) . ' / ' . human_filesize($row['TotalMem']), $canEdit ) ?></td>
|
||||
<td class="colSwap
|
||||
<?php if ( (!$row['TotalSwap']) or ($row['FreeSwap']/$row['TotalSwap'] < .1) ) { echo 'danger'; } ?>"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', human_filesize($row['FreeSwap']) . ' / ' . human_filesize($row['TotalSwap']) , $canEdit ) ?></td>
|
||||
<td class="colStats"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', $row['zmstats'] ? 'yes' : 'no', $canEdit ) ?></td>
|
||||
<td class="colAudit"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', $row['zmaudit'] ? 'yes' : 'no', $canEdit ) ?></td>
|
||||
<td class="colTrigger"><?php echo makePopupLink( '?view=server&id='.$row['Id'], 'zmServer', 'server', $row['zmtrigger'] ? 'yes' : 'no', $canEdit ) ?></td>
|
||||
<td class="colName"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Name()), $canEdit) ?></td>
|
||||
<td class="colUrl"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Url()), $canEdit) ?></td>
|
||||
<td class="colPathToIndex"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->PathToIndex()), $canEdit) ?></td>
|
||||
<td class="colPathToZMS"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->PathToZMS()), $canEdit) ?></td>
|
||||
<td class="colStatus <?php if ( $Server->Status() == 'NotRunning' ) { echo 'danger'; } ?>">
|
||||
<?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($Server->Status()), $canEdit) ?></td>
|
||||
<td class="colMonitorCount">
|
||||
<?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', validHtmlStr($monitor_counts[$Server->Id()]), $canEdit) ?>
|
||||
</td>
|
||||
<td class="colCpuLoad <?php if ( $Server->CpuLoad() > 5 ) { echo 'danger'; } ?>">
|
||||
<?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server',$Server->CpuLoad(), $canEdit) ?>
|
||||
</td>
|
||||
<td class="colMemory <?php if ( $Server->FreeMem()/$Server->TotalMem() < .1 ) { echo 'danger'; } ?>">
|
||||
<?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', human_filesize($Server->FreeMem()) . ' / ' . human_filesize($Server->TotalMem()), $canEdit) ?>
|
||||
</td>
|
||||
<td class="colSwap <?php if ( (!$Server->TotalSwap()) or ($Server->FreeSwap()/$Server->TotalSwap() < .1) ) { echo 'danger'; } ?>">
|
||||
<?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', human_filesize($Server->FreeSwap()) . ' / ' . human_filesize($Server->TotalSwap()) , $canEdit) ?>
|
||||
</td>
|
||||
<td class="colStats"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', $Server->zmstats() ? 'yes' : 'no', $canEdit) ?></td>
|
||||
<td class="colAudit"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', $Server->zmaudit() ? 'yes' : 'no', $canEdit) ?></td>
|
||||
<td class="colTrigger"><?php echo makePopupLink('?view=server&id='.$Server->Id(), 'zmServer', 'server', $Server->zmtrigger() ? 'yes' : 'no', $canEdit) ?></td>
|
||||
|
||||
<td class="colMark"><input type="checkbox" name="markIds[]" value="<?php echo $row['Id'] ?>" onclick="configureDeleteButton( this );"<?php if ( !$canEdit ) { ?> disabled="disabled"<?php } ?>/></td>
|
||||
<td class="colMark"><input type="checkbox" name="markIds[]" value="<?php echo $Server->Id() ?>" onclick="configureDeleteButton(this);"<?php if ( !$canEdit ) { ?> disabled="disabled"<?php } ?>/></td>
|
||||
</tr>
|
||||
<?php } #end foreach Server ?>
|
||||
</tbody>
|
||||
|
|
|
@ -23,31 +23,23 @@ if ( !canEdit('System') ) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( $_REQUEST['id'] ) {
|
||||
if ( !($newServer = dbFetchOne('SELECT * FROM Servers WHERE Id = ?', NULL, ARRAY($_REQUEST['id'])) ) ) {
|
||||
$view = 'error';
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$newServer = array();
|
||||
$newServer['Name'] = translate('NewServer');
|
||||
$newServer['Hostname'] = '';
|
||||
$newServer['zmstats'] = '';
|
||||
$newServer['zmaudit'] = '';
|
||||
$newServer['zmtrigger'] = '';
|
||||
$Server = new Server($_REQUEST['id']);
|
||||
if ( $_REQUEST['id'] and ! $Server->Id() ) {
|
||||
$view = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
$focusWindow = true;
|
||||
|
||||
xhtmlHeaders(__FILE__, translate('Server').' - '.$newServer['Name']);
|
||||
xhtmlHeaders(__FILE__, translate('Server').' - '.$Server->Name());
|
||||
?>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div id="header">
|
||||
<h2><?php echo translate('Server').' - '.$newServer['Name'] ?></h2>
|
||||
<h2><?php echo translate('Server').' - '.$Server->Name() ?></h2>
|
||||
</div>
|
||||
<div id="content">
|
||||
<form name="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onsubmit="return validateForm(this, <?php echo empty($newServer['Name'])?'true':'false' ?>)">
|
||||
<form name="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onsubmit="return validateForm(this, <?php echo empty($Server->Name())?'true':'false' ?>)">
|
||||
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
||||
<input type="hidden" name="object" value="server"/>
|
||||
<input type="hidden" name="id" value="<?php echo validHtmlStr($_REQUEST['id']) ?>"/>
|
||||
|
@ -55,31 +47,47 @@ xhtmlHeaders(__FILE__, translate('Server').' - '.$newServer['Name']);
|
|||
<tbody>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('Name') ?></th>
|
||||
<td><input type="text" name="newServer[Name]" value="<?php echo $newServer['Name'] ?>"/></td>
|
||||
<td><input type="text" name="newServer[Name]" value="<?php echo $Server->Name() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('Protocol') ?></th>
|
||||
<td><input type="text" name="newServer[Protocol]" value="<?php echo $Server->Protocol() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('Hostname') ?></th>
|
||||
<td><input type="text" name="newServer[Hostname]" value="<?php echo $newServer['Hostname'] ?>"/></td>
|
||||
<td><input type="text" name="newServer[Hostname]" value="<?php echo $Server->Hostname() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('Port') ?></th>
|
||||
<td><input type="number" name="newServer[Port]" value="<?php echo $Server->Port() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('PathToIndex') ?></th>
|
||||
<td><input type="text" name="newServer[PathToIndex]" value="<?php echo $Server->PathToIndex() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('PathToZMS') ?></th>
|
||||
<td><input type="text" name="newServer[PathToZMS]" value="<?php echo $Server->PathToZMS() ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('RunStats') ?></th>
|
||||
<td>
|
||||
<input type="radio" name="newServer[zmstats]" value="1"<?php echo $newServer['zmstats'] ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmstats]" value="0"<?php echo $newServer['zmstats'] ? '' : ' checked="checked"' ?>/> No
|
||||
<input type="radio" name="newServer[zmstats]" value="1"<?php echo $Server->zmstats() ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmstats]" value="0"<?php echo $Server->zmstats() ? '' : ' checked="checked"' ?>/> No
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('RunAudit') ?></th>
|
||||
<td>
|
||||
<input type="radio" name="newServer[zmaudit]" value="1"<?php echo $newServer['zmaudit'] ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmaudit]" value="0"<?php echo $newServer['zmaudit'] ? '' : ' checked="checked"' ?>/> No
|
||||
<input type="radio" name="newServer[zmaudit]" value="1"<?php echo $Server->zmaudit() ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmaudit]" value="0"<?php echo $Server->zmaudit() ? '' : ' checked="checked"' ?>/> No
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php echo translate('RunTrigger') ?></th>
|
||||
<td>
|
||||
<input type="radio" name="newServer[zmtrigger]" value="1"<?php echo $newServer['zmtrigger'] ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmtrigger]" value="0"<?php echo $newServer['zmtrigger'] ? '' : ' checked="checked"' ?>/> No
|
||||
<input type="radio" name="newServer[zmtrigger]" value="1"<?php echo $Server->zmtrigger() ? ' checked="checked"' : '' ?>/> Yes
|
||||
<input type="radio" name="newServer[zmtrigger]" value="0"<?php echo $Server->zmtrigger() ? '' : ' checked="checked"' ?>/> No
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in New Issue