Incorrect stats on console

Forum for questions and support relating to the 1.32.x releases only.
Post Reply
superdipak
Posts: 14
Joined: Tue Oct 30, 2018 4:37 pm

Incorrect stats on console

Post by superdipak »

Hi,

I've recently upgraded from zoneminder 1.30.4 to 1.32.2. All looks to be fine after the upgrade except that I cannot reset my events stats to zero. I have truncated the following tables in the database

Events
Events_Archived
Events_Day
Events_Hour
Events_Month
Events_Week
Stats

and have also cleared off all files under my ZM_DIR_EVENTS and ZM_DIR_IMAGES folders as specified in a .conf file under /etc/zm/conf.d

Regardless of the above actions, the zoneminder 1.32.2 console refuses to reset the number of events to zero and keeps showing previous figures. With version 1.30.4, I could always reset all event stats to zero by truncating the Events table in the database and by clearing off my events storage folders.

Please, could someone provide a solution for this apparently bizarre behaviour? Is there a cache somewhere that I am not aware of?

Any pointers would be most appreciated.

Regards

Dipak Jha
superdipak
Posts: 14
Joined: Tue Oct 30, 2018 4:37 pm

Re: Incorrect stats on console

Post by superdipak »

Hi,

I have been able to figure this out. In version 1.32.2 stats are also stored in the MySQL database (table: Monitors) which I don't think is good data design. Stats should be stored in the Event* tables which should be linked to Monitors using the MonitorID foreign key relationship.

Anyway, here are my steps now to purge zoneminder of all events and logs:

Stop zoneminder

Code: Select all

systemctl stop zoneminder
Delete all event files (I have 6 cameras)

Code: Select all

rm -rf <path to storage folder>/events/[1-6]/*
Log on to the database and run the following SQLs

Code: Select all

truncate table Events; truncate table Events_Archived; truncate table Events_Day; truncate table Events_Hour; truncate table Events_Month; truncate table Events_Week; truncate table Logs; truncate table States; truncate table Stats; truncate table Frames;

update Monitors set TotalEvents = 0, HourEvents = 0, DayEvents = 0, WeekEvents = 0, MonthEvents = 0, ArchivedEvents = 0, MonthEventDiskSpace = null, WeekEventDiskSpace = null, DayEventDiskSpace = null, HourEventDiskSpace = null, TotalEventDiskSpace = null;
Start zoneminder

Code: Select all

systemctl start zoneminder
Please let me know if I am doing anything wrong here.

Regards,

Dipak Jha
User avatar
iconnor
Posts: 2880
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Incorrect stats on console

Post by iconnor »

Scanning over the Event* tables is actually quite intensive when you have a lot of events. Instead of doing that we use triggers to update the summary fields in the Monitors table.

Database design for scalability is not as obvious as you might think. I had to learn a lot to get ZM to scale to over 800 cameras.
superdipak
Posts: 14
Joined: Tue Oct 30, 2018 4:37 pm

Re: Incorrect stats on console

Post by superdipak »

Hi iconnor,

It is my privilege to interact with you directly. I now see the point and also recall that I had done something similar on an eCommerce website with a huge number of saleable products (and their prices, stock levels etc). My apologies for the oversight.

Great product and a fantastic release (1.32.2). All works fine for me now.

Thanks for your response and the support you are offering

Regards

Dipak Jha
trumee
Posts: 69
Joined: Tue Mar 08, 2011 3:33 pm

Re: Incorrect stats on console

Post by trumee »

superdipak wrote: Wed Oct 31, 2018 5:59 am Hi,

I have been able to figure this out. In version 1.32.2 stats are also stored in the MySQL database (table: Monitors) which I don't think is good data design. Stats should be stored in the Event* tables which should be linked to Monitors using the MonitorID foreign key relationship.

Anyway, here are my steps now to purge zoneminder of all events and logs:

Stop zoneminder

Code: Select all

systemctl stop zoneminder
Delete all event files (I have 6 cameras)

Code: Select all

rm -rf <path to storage folder>/events/[1-6]/*
Log on to the database and run the following SQLs

Code: Select all

truncate table Events; truncate table Events_Archived; truncate table Events_Day; truncate table Events_Hour; truncate table Events_Month; truncate table Events_Week; truncate table Logs; truncate table States; truncate table Stats; truncate table Frames;

update Monitors set TotalEvents = 0, HourEvents = 0, DayEvents = 0, WeekEvents = 0, MonthEvents = 0, ArchivedEvents = 0, MonthEventDiskSpace = null, WeekEventDiskSpace = null, DayEventDiskSpace = null, HourEventDiskSpace = null, TotalEventDiskSpace = null;
Start zoneminder

Code: Select all

systemctl start zoneminder
Please let me know if I am doing anything wrong here.

Regards,

Dipak Jha
Thanks, with this instructions I was able to reset the events in the database.
trumee
Posts: 69
Joined: Tue Mar 08, 2011 3:33 pm

Re: Incorrect stats on console

Post by trumee »

In 1.36.x i had to do,

Code: Select all

truncate table Event_Summaries; 
update Event_Summaries set TotalEvents = 0, HourEvents = 0, DayEvents = 0, WeekEvents = 0, MonthEvents = 0, ArchivedEvents = 0, MonthEventDiskSpace = null, WeekEventDiskSpace = null, DayEventDiskSpace = null, HourEventDiskSpace = null, TotalEventDiskSpace = null; 
Post Reply