Empty zip files uploaded to ftp server

Support and queries relating to all previous versions of ZoneMinder
Esky
Posts: 13
Joined: Wed Mar 19, 2008 11:58 am

Post by Esky »

that outputs the following to the log file:

Code: Select all

[Searching images in '/usr/share/zoneminder/event/10/2583/{*analyse,*capture}.jpg']
and if I look in that folder there are lots (6,8MB) of files like:

Code: Select all

-rw-r--r--   1 www-data www-data  35K 2008-04-13 19:54 010-capture.jpg
-rw-r--r--   1 www-data www-data  43K 2008-04-13 19:54 011-analyse.jpg
kevin_robson
Posts: 247
Joined: Sun Jan 16, 2005 11:26 am

Post by kevin_robson »

Not any the wizer then.

The path itself is OK, but I'm not sure the stuff on the end should there or not. I'd have thought that should have been resolved by this point.

I'm afraid you'll need someone a bit more savvy with perl. It would be interesting to try the above line on an older version that does work.
dom_
Posts: 4
Joined: Thu May 29, 2008 10:10 pm

Post by dom_ »

For some reason the <$var> thing is giving this error :

Code: Select all

readline() on unopened filehandle at 
this script does not display the directory content

Code: Select all

#!/usr/bin/perl
my $titi = "."."/"."{*.log,*.pl}";
foreach my $toto ( <$titi> ) {
        printf ( "$toto\n" );
}
whereas this one do :

Code: Select all

#!/usr/bin/perl
foreach my $toto ( <./{*.log,*.pl}> ) {
	printf ( "$toto\n" );
}
and this one do it too :

Code: Select all

#!/usr/bin/perl
my $titi = ".";
foreach my $toto ( <$titi/{*.log,*.pl}> ) {
	printf ( "$toto\n" );
}
So I added in zmfilter this var for now :
my $arch_image_path = getEventPath( $event )."/";
and replaced the create_archive line with this one :

Code: Select all

if ( $arch_error = !Archive::Tar->create_archive( $arch_file, ZM_UPLOAD_ARCH_COMPRESS, <$arch_image_path/*.jpg> ) )
To note I am using perl v5.8.8

regards,
dom[/code]
haus
Posts: 213
Joined: Thu Oct 11, 2007 5:10 am

Post by haus »

Argh, I'm having this same issue on a fresh install of Ubuntu server 7.10 and 1.23.3 from Peter's .deb package. And I'm still having the "videos won't play when filter generated" problem I was having with 1.22.x and 7.04.

This is so frustrating. I'll look into your fix...I just can't understand why things always seem to require so much tweaking and fixing in order to get it working at a basic level. :?
haus
Posts: 213
Joined: Thu Oct 11, 2007 5:10 am

Post by haus »

I got closer. Based Dom_'s post, a similar edit to the zip archive section gets the files added, at least:

Code: Select all

 my $arch_image_path = getEventPath( $event ) . "/";
and

Code: Select all

 foreach my $image_file ( <$arch_image_path/*.jpg> )
But while my zip files are now bigger (761K, for example) and the files are clearly being added based on tailing zmfilter.log, the zip files still show up as blank from Windows. Need to spend more time on this, but it's partway there.

Ok, the zip is readable from Winzip and Windows XP sp2 says the content is blocked for security. So it looks like the ZM piece is fixed, at least. Thanks too all who responded and Dom_ for the explanation of no directory listing in Perl.
kevin_robson
Posts: 247
Joined: Sun Jan 16, 2005 11:26 am

Post by kevin_robson »

Has anyone sussed this out.

A zip file is generated and emailed. Its big (i.e. 2-3M) and is readable in linux using unzip and windows using winzip 11, but the windows compressed folder option and also ark under linux will not read it?

So the zip file is getting generated, but seems to have some sort of wierd incompatibility.

Any ideas?
haus
Posts: 213
Joined: Thu Oct 11, 2007 5:10 am

Post by haus »

I gave up; once I realized that zipping jpg files nets you absolutely nothing in terms of compression, I went with this solution that uploads jpgs directly instead of zips:

http://www.zoneminder.com/forums/viewtopic.php?t=11791

Now I can just view the "event.html" file (which I link to from my alarm notification emails) and I can see the whole event on one screen with clickable thumbnails.

Then I wrote a quick perl program to go through and periodically delete files and folders older than N days to reclaim disk space on my remote backup server.
kevin_robson
Posts: 247
Joined: Sun Jan 16, 2005 11:26 am

Post by kevin_robson »

Ah, just realised I'm sending as an email attachment, not ftping.
So I cant use this option.
It works, just certain unzippers dont like the file which I find quite baffling.
haus
Posts: 213
Joined: Thu Oct 11, 2007 5:10 am

Post by haus »

Kevin, did you try the "alternate mailer" option within ZM? On the email options tab (I believe) near the bottom, there's a checkbox to use newer (?) perl modules for sending the mail. I wonder if that would make a difference?

It didn't seem to work for me (none of my alarms turned into events for some reason), but you might give it a shot and see if it does a better job.
kevin_robson
Posts: 247
Joined: Sun Jan 16, 2005 11:26 am

Post by kevin_robson »

No I hadn't spotted that. Its actually set to the newer ones by default, which might explain why I've not seen this before on previous versions. I've set it back to the old one and will have a look at some of the events later.
Well spotted.
kevin_robson
Posts: 247
Joined: Sun Jan 16, 2005 11:26 am

Post by kevin_robson »

This doesn't make any difference either. Very strange. There has obvioulsy been some incompatibility introduced at some point, but at least I wan use winzip.
haus
Posts: 213
Joined: Thu Oct 11, 2007 5:10 am

Post by haus »

I'll agree with you on that, because I used to use the zip option as well and I don't think I ever had problems with it. But I can't say it's not some security patch that Microsoft issued via Windows Update, either - it may not be a "ZM change". There are threads about this issue all over the web, but few concrete solutions.

Since it's a security issue, I can imagine a couple of possibilities. I know that my ZM box sends mail as www-data@<<machine_name>> on behalf of <<email address on the options screen>>. This bothers me, but I can't figure out how to fix it. As I noted above, trying to change the mailer made all my alerts fail completely. So perhaps Windows doesn't like the fact that a ZIP file was sent on behalf of someone else. Try installing some local mail tools on your ZM box and mailing the ZM-generated zip file to yourself using OS mail tools. (On Ubuntu you can install mailutils to get a command line mail app.) If it works, that would isolate the problem to the ZM mailing system.

If that still fails, it is an issue with the zip file itself. Possibly a permissions issue - maybe the files are owned by one user and the zip is created by another user (unlikely, but hey...we're fishing here!). I would do a test by creating a zip file within windows with the same name as an event zip, move that to your box to an event that's already happened (with the same name, overwriting the existing zip with your "fake" zip), removing the "already sent" flag in the ZM event table, and resubmitting the event to zmfilter so that it emails it again. If it works, then you've definitely isolated the ZM zip method as the culprit. (Alternatively you could edit zmfilter.pl to just send the other zip file during an arbitrary alert, but I don't know how comfortable you are with Perl).

There may be other ZIP options within Perl or your OS that you can use, or you could try TAR compression, though it's a pain because Windows can't read TAR files natively.

If you find anything out, keep us updated!
c0mputerking
Posts: 190
Joined: Tue Sep 16, 2008 5:22 am

Post by c0mputerking »

I am having the same problem with empty zips output of zmfilter.pl looks good (see below) but on the other server i get this error

unzip Camera1-127.zip
Archive: Camera1-127.zip
warning [Camera1-127.zip]: zipfile is empty

Code: Select all

/usr/lib/zm/bin/zmfilter.pl
Net::FTP>>> Net::FTP(2.77)
Net::FTP>>>   Exporter(5.62)
Net::FTP>>>   Net::Cmd(2.29)
Net::FTP>>>   IO::Socket::INET(1.31)
Net::FTP>>>     IO::Socket(1.30_01)
Net::FTP>>>       IO::Handle(1.27)
Net::FTP=GLOB(0x8d31820)<<<220>>> USER c0mputerking
Net::FTP=GLOB(0x8d31820)<<<331>>> PASS ....
Net::FTP=GLOB(0x8d31820)<<<230>>> TYPE I
Net::FTP=GLOB(0x8d31820)<<<200>>> CWD zoneminder
Net::FTP=GLOB(0x8d31820)<<<250>>> ALLO 22
Net::FTP=GLOB(0x8d31820)<<<202>>> PASV
Net::FTP=GLOB(0x8d31820)<<<227>>> STOR Camera1-127.zip
Net::FTP=GLOB(0x8d31820)<<< 150 Opening BINARY mode data connection for Camera1-127.zip
Net::FTP=GLOB(0x8d31820)<<<226>>> QUIT
Net::FTP=GLOB(0x8d31820)<<< 221 Goodbye.
Fox68
Posts: 1
Joined: Mon Apr 13, 2009 5:48 pm

Post by Fox68 »

Hi!
I'm no no NO such a perl expert, but by googling found something.

If you replace line (zmfilter.pl):
if ( $arch_error = !Archive::Tar->create_archive( $arch_file, ZM_UPLOAD_ARCH_CO
MPRESS, <arch_image_path> ) )

with

if ( $arch_error = !Archive::Tar->create_archive( $arch_file, ZM_UPLOAD_ARCH_CO
MPRESS , glob("$arch_image_path*")) )

it seems to work somehow at least for me.

I have Fedora 10 and zoneminder-1.23.3-2.fc10.i386

Cheers :D
haus
Posts: 213
Joined: Thu Oct 11, 2007 5:10 am

Post by haus »

That snippet relates to tar files; we are working with ZIP files. Thanks for the tip though!
Locked