I’m looking to enhance our system monitoring application so that we can get alerts on cameras that haven’t had recordings in X days/hours, as well as monitoring total retention time. We currently only monitor if the camera is online or not, which doesn’t help if there is an issue with motion detection settings, archive problems, etc.
I’m hoping for something straightforward where I can query when the last recording was, total retention time, database size, etc. All I’ve come up with on my own is “pretending” I’m going to playback and use that information to get the information I need. That seems a bit kludgy, and wouldn’t provide the DB size for a particular camera.
Consider using the Configuration API. try the ConfigAPIClient and look at the storage information on recorder and camera classes. If you find what you need then try using the classes in VideoOS.Platform.dll with same content.
Thanks for the response. Unfortunately I cannot find any example of what you’re talking about. The ConfigAPIClient doesn’t seem to display anything related recordings or storage. The closest I saw was under a recording server there is a button to show cameras that have recordings stored on that server… but it doesn’t appear to do anything.
Let me try to be more clear in my example. If I have a camera X, I want to query:
Date/Time of last recording
Total retention time (ie this camera has 28 days worth of recordings stored)
Database size for said camera (this is probably the least important, I just threw it in there)
You can get the configured retention time from the ConfigurationAPI - but not the actual retention. To get that you need to access the Recording Server / Image Server and make a GoToBegin and GoToEnd and collect the timestamps. This will result in some extra disk/database operations - so not good to do if you intend to do this for many cameras, but OK for a few.
I’m trying to tackle this again after a break… I need to do it for every camera, so it may not be ideal. I’ve been trying the following code:
Item item = new Item(cameraFQID,cameraName);
JPEGVideoSource jpeg = new JPEGVideoSource(item);
jpeg.Init();
JPEGData jpegData;
...
jpegBeginData = jpeg.GetBegin(); // Always works
jpegEndData = jpeg.GetEnd(); // This randomly returns null. If I run it several times in a row some cameras return null on one run, but not another. Doesn't seem to be any pattern.
...
Any idea why GetEnd returns null sometimes?
Is there a better way to get the datetime of the first and last image?
I should’ve also said that if I put a loop in so GetEnd() is called repeatedly until it is not null that it usually returns a value on the 2nd or 3rd attempt.
Consider to use SequenceDataSource with parameters to get 1 info after 2010-01-01 to get first datetime, and one call to get 1 info before 2030-01-01 to get last recording. Ask for RecordingSequences type of information.
I’m having trouble getting results, probably just because I don’t understand what the parameters need to be. Here’s my test code:
Item item = VideoOS.Platform.Configuration.Instance.GetItem(cam.FQID);
SequenceDataSource sds = new SequenceDataSource(item);
List<object> start = sds.GetData(new DateTime(2000, 01, 01), new TimeSpan(0), 1, new
TimeSpan(36500,0,0), 1, DataType.SequenceTypeGuids.RecordingSequence);
List<object> end = sds.GetData(new DateTime(2099, 12, 31), new TimeSpan(36500, 0, 0), 1, new TimeSpan(0), 1, DataType.SequenceTypeGuids.RecordingSequence);
That code snip is formatted weird on my screen (when I pasted it in a bunch of spaces were added no matter what i did). Hopefully it gets fixed when I post.
Anyway, it appears you need a timespan before/after the date you specify to define the search range. I decided to start at year 2000 and search 100 years for the 1st result, and 2099 and search back 100 years for the 1st result. I get no results in either case.
Whoops, I thought I was specifying days not hours…
Anyway, with that fixed I’m getting results, but not what I need. The end date seems to be the issue. The timespan has to include times that recordings exist for it to return anything. It is returning the first (chronologically) result instead of the last. Is there a way to reverse that?
I typecast result to a SequenceData class and use data.EventSequence.StartDateTime on the first call, and data.EventSequence.EndDateTime on the 2nd call.
I am (Corporate itself actually). I figured out my issue; in my cutting/pasting I was referring to the same SequenceDataSource instead of the one from the second call. What’s confusing me (and why I didn’t catch it sooner) is, the EventSequence.EndDateTime I was getting back was in some cases several days after EventSequenceStartDateTime, even though I was only returning a single result. I would’ve figured the sequence would have been much shorter.
Anyway, I’ve got another question now that this is working. Is there any way to tell when a camera was added to the system? It looks like the createddate field doesn’t populate for cameras, just modifieddate. The intent of all this code is to connect Milestone to our monitoring platform and get alerts if a camera does not have a minimum amount of retention time, let’s say 30 days. Obviously for the first 30 days a cameras is online that doesn’t apply, but I’m not sure the best way to filter that out automatically.