ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Apr 07, 2017 5:35 am

Fox Mulder wrote:For Debian or Raspbian there is a predefined systemd task for using a ramdisk for /tmp.
https://wiki.debian.org/SSDOptimization ... ia_RAMDISK

For /sys/log on tmpfs i wrote a little script which automatically syncs the content to the sd-card and back within certain intervals to keep the logs but reduce the writes to the sd-card. I think i posted it in some earlier posts here.

Ciao,
Rainer
Tried starting tmp.mount with systemctl start tmp.mount, but tmp.mount isn't located in /usr/share/systemd/ directory. I think i need to remove tmp from fstab.

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Apr 07, 2017 8:22 am

314_PIE wrote:Tried starting tmp.mount with systemctl start tmp.mount, but tmp.mount isn't located in /usr/share/systemd/ directory. I think i need to remove tmp from fstab.
It could be that the file is not located at the mentioned location anymore (outdated documentation). I think i remember copying it from another path. Maybe just try to find the file on the whole sd-card.

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Apr 07, 2017 9:50 am

Fox Mulder wrote:
314_PIE wrote:Tried starting tmp.mount with systemctl start tmp.mount, but tmp.mount isn't located in /usr/share/systemd/ directory. I think i need to remove tmp from fstab.
It could be that the file is not located at the mentioned location anymore (outdated documentation). I think i remember copying it from another path. Maybe just try to find the file on the whole sd-card.
I checked the status:

Code: Select all

 pi@PiZeroW:~ $ sudo systemctl status tmp.mount
● tmp.mount - /tmp
   Loaded: loaded (/etc/fstab; enabled)
   Active: active (mounted) since Thu 2017-04-06 18:50:58 AEST; 24h ago
    Where: /tmp
     What: tmpfs
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)

Apr 06 18:50:58 PiZeroW systemd[1]: Mounted /tmp.
Apr 07 15:22:45 PiZeroW systemd[1]: Mounted /tmp.
Apr 07 15:34:32 PiZeroW systemd[1]: Mounted /tmp.

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Apr 07, 2017 10:10 am

314_PIE wrote:I checked the status:

Code: Select all

 pi@PiZeroW:~ $ sudo systemctl status tmp.mount
● tmp.mount - /tmp
   Loaded: loaded (/etc/fstab; enabled)
   Active: active (mounted) since Thu 2017-04-06 18:50:58 AEST; 24h ago
    Where: /tmp
     What: tmpfs
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)

Apr 06 18:50:58 PiZeroW systemd[1]: Mounted /tmp.
Apr 07 15:22:45 PiZeroW systemd[1]: Mounted /tmp.
Apr 07 15:34:32 PiZeroW systemd[1]: Mounted /tmp.
Ok i think because you added the tmpfs manually in /etc/fstab it also works. I didn't add it to fstab and just activated tmp.mount. So my status looks like the following:

Code: Select all

● tmp.mount - Temporary Directory
   Loaded: loaded (/lib/systemd/system/tmp.mount; enabled)
   Active: active (mounted) since Fr 2017-04-07 10:12:05 CEST; 1h 55min ago
    Where: /tmp
     What: tmpfs
     Docs: man:hier(7)
           http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
  Process: 211 ExecMount=/bin/mount -n tmpfs /tmp -t tmpfs -o mode=1777,strictatime,size=4096M (code=exited, status=0/SUCCESS)

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Apr 07, 2017 10:34 am

Fox Mulder wrote:
314_PIE wrote:I checked the status:

Code: Select all

 pi@PiZeroW:~ $ sudo systemctl status tmp.mount
● tmp.mount - /tmp
   Loaded: loaded (/etc/fstab; enabled)
   Active: active (mounted) since Thu 2017-04-06 18:50:58 AEST; 24h ago
    Where: /tmp
     What: tmpfs
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)

Apr 06 18:50:58 PiZeroW systemd[1]: Mounted /tmp.
Apr 07 15:22:45 PiZeroW systemd[1]: Mounted /tmp.
Apr 07 15:34:32 PiZeroW systemd[1]: Mounted /tmp.
Ok i think because you added the tmpfs manually in /etc/fstab it also works. I didn't add it to fstab and just activated tmp.mount. So my status looks like the following:

Code: Select all

● tmp.mount - Temporary Directory
   Loaded: loaded (/lib/systemd/system/tmp.mount; enabled)
   Active: active (mounted) since Fr 2017-04-07 10:12:05 CEST; 1h 55min ago
    Where: /tmp
     What: tmpfs
     Docs: man:hier(7)
           http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
  Process: 211 ExecMount=/bin/mount -n tmpfs /tmp -t tmpfs -o mode=1777,strictatime,size=4096M (code=exited, status=0/SUCCESS)
Whats stored in your /tmp? Anything related to nginx stored in it?

I would have to add a maximum size to the /tmp directory in fstab which isn't included in what i searched online, only for /var/log.

Code: Select all

 
proc  /proc  proc    defaults  0  0
/dev  /mmcblk0p1  /bootvfat    defaults  0  2
/dev  /mmcblk0p2  /ext4    defaults,noatime  0  1
tmpfs  /tmp  tmpfs   defaults,noatime  0  0
tmpfs  /var/log  tmpfs   defaults,noatime,size=64m  0  0
#
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Apr 07, 2017 1:20 pm

314_PIE wrote: Whats stored in your /tmp? Anything related to nginx stored in it?

I would have to add a maximum size to the /tmp directory in fstab which isn't included in what i searched online, only for /var/log.

Code: Select all

 
proc  /proc  proc    defaults  0  0
/dev  /mmcblk0p1  /bootvfat    defaults  0  2
/dev  /mmcblk0p2  /ext4    defaults,noatime  0  1
tmpfs  /tmp  tmpfs   defaults,noatime  0  0
tmpfs  /var/log  tmpfs   defaults,noatime,size=64m  0  0
#
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
When you don' add the size attribute tmpfs uses dynamically up to half of installed memory. So i think you can remove the size parameter safely. I use apache and not nginx so i don't know what nginx stores in /tmp. But if /tmp is on the sd-card or tmpfs shouldn't bother nginx. I have all programs running fine with tmpfs for /tmp on the rpi, my main pc and my netbook for many months now.

Maybe try not adding it on fstab and just let tmp.mount handle it. Could be that it uses some different options for tmpfs.
For example for another tmpfs ramdisk i use the options "rw,size=4096M,nodev,nosuid,mode=0755". Don't know if i need all options, but i read it somewhere and it sounded good. :)

Ciao,
Rainer

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Apr 08, 2017 3:18 am

Fox Mulder wrote:
314_PIE wrote: Whats stored in your /tmp? Anything related to nginx stored in it?

I would have to add a maximum size to the /tmp directory in fstab which isn't included in what i searched online, only for /var/log.

Code: Select all

 
proc  /proc  proc    defaults  0  0
/dev  /mmcblk0p1  /bootvfat    defaults  0  2
/dev  /mmcblk0p2  /ext4    defaults,noatime  0  1
tmpfs  /tmp  tmpfs   defaults,noatime  0  0
tmpfs  /var/log  tmpfs   defaults,noatime,size=64m  0  0
#
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
When you don' add the size attribute tmpfs uses dynamically up to half of installed memory. So i think you can remove the size parameter safely. I use apache and not nginx so i don't know what nginx stores in /tmp. But if /tmp is on the sd-card or tmpfs shouldn't bother nginx. I have all programs running fine with tmpfs for /tmp on the rpi, my main pc and my netbook for many months now.

Maybe try not adding it on fstab and just let tmp.mount handle it. Could be that it uses some different options for tmpfs.
For example for another tmpfs ramdisk i use the options "rw,size=4096M,nodev,nosuid,mode=0755". Don't know if i need all options, but i read it somewhere and it sounded good. :)

Ciao,
Rainer
Ill just leave this to the side, as i removed both lines from fstab and did a reboot, hopefully that reverts it back to primary partition.

Since nginx wouldn't create the /etc/nginx files after reinstalls and fails to start... decided to install apache and the apache webpage appears and working on :80, i changed the ports in ports.conf and in sites-available/000-default.conf... but not sure how to set pikrellcam to talk to apache instead of nginx which i uninstalled. I installed apache first before installing pikrellcam.

Edit: Ok i editted sites-enabled/000-default.conf and changed the DocumentRoot to /home/pi/pikrellcam/www and restarted the service. Got a 403 Forbidden message, to do with permissions..

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Apr 10, 2017 5:33 am

Still having problems with apache2, Im pretty sure Nginx is all preconfigured with the right file permissions after the install. Accessing webserver from browser: http://192.168.25.26:2100

Forbidden
You don't have permission to access / on this server.
Apache/2.4.10 (Raspbian) Server at 192.168.25.26 Port 2100

Here is my configs and what i did:

(/etc/apache2/sites-available/000-default.conf)

Code: Select all

ServerAdmin webmaster@localhost
ServerName localhost
DocumentRoot /home/pi/pikrellcam/www
<Directory /home/pi/pikrellcam/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    DirectoryIndex index.php
    Order allow,deny
    allow from all
</Directory>
Executed the following commands to solve the 403 error:

Code: Select all

chmod -R u+rwX,g+rX /home/pi/pikrellcam/www
and

Code: Select all

chown -R www-data.www-data /home/pi/pikrellcam/www
File permissions: (home/pi/pikrellcam/www/)

Code: Select all

pi@PiZeroW:~/pikrellcam/www $ ls -lh 
total 188K
prw-rw-r-- 1 www-data www-data    0 Apr  8 12:50 FIFO
lrwxrwxrwx 1 www-data www-data   33 Apr  8 12:47 archive -> /home/pi/pikrellcam/media/archive
-rw-r--r-- 1 www-data www-data 7.0K Apr  8 12:47 archive.php
-rw-r--r-- 1 www-data www-data 6.0K Apr  8 12:47 config-defaults.php
-rw-r--r-- 1 www-data www-data 1014 Apr  8 12:47 config.php
-rw-r--r-- 1 www-data www-data  589 Apr  8 12:47 control.php
-rw-r--r-- 1 www-data www-data  814 Apr  8 12:47 download.php
-rw-r--r-- 1 www-data www-data  145 Apr  8 12:47 fifo_command.php
-rw-r--r-- 1 www-data www-data  76K Apr  8 12:47 help.php
drwxr-xr-x 2 www-data www-data 4.0K Apr  8 12:47 images
-rw-r--r-- 1 www-data www-data  23K Apr  8 12:47 index.php
drwxr-xr-x 2 www-data www-data 4.0K Apr  8 12:47 js-css
-rw-r--r-- 1 www-data www-data 1.4K Apr  8 12:47 live.php
-rw-r--r-- 1 www-data www-data 2.3K Apr  8 12:47 log.php
lrwxrwxrwx 1 www-data www-data   25 Apr  8 12:47 media -> /home/pi/pikrellcam/media
-rw-r--r-- 1 www-data www-data  28K Apr  8 12:47 media-archive.php
-rw-r--r-- 1 www-data www-data  133 Apr  8 12:47 mjpeg_read.php
-rw-r--r-- 1 www-data www-data  479 Apr  8 12:47 mjpeg_stream.php
-rw-r--r-- 1 www-data www-data  492 Apr  8 12:47 sys_command.php
Error.log

Code: Select all

[Mon Apr 10 14:02:22.755484 2017] [mpm_event:notice] [pid 15789:tid 3069997584] AH00491: caught SIGTERM, shutting down
[Mon Apr 10 14:02:24.415623 2017] [mpm_event:notice] [pid 15936:tid 3069837840] AH00489: Apache/2.4.10 (Raspbian) configured -- resuming normal operations
[Mon Apr 10 14:02:24.416577 2017] [core:notice] [pid 15936:tid 3069837840] AH00094: Command line: '/usr/sbin/apache2'
[Mon Apr 10 14:02:55.466216 2017] [authz_core:error] [pid 15939:tid 3028284464] [client 192.168.25.23:49539] AH01630: client denied by server configuration: /home/pi/pikrellcam/www/
[Mon Apr 10 14:03:02.834058 2017] [authz_core:error] [pid 15940:tid 3045061680] [client 192.168.25.23:49541] AH01630: client denied by server configuration: /home/pi/pikrellcam/www/
[Mon Apr 10 15:02:34.299534 2017] [authz_core:error] [pid 15940:tid 3053450288] [client 192.168.25.23:50020] AH01630: client denied by server configuration: /home/pi/pikrellcam/www/

billw
Posts: 415
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Apr 10, 2017 2:44 pm

314_PIE wrote:Still having problems with apache2, Im pretty sure Nginx is all preconfigured with the right file permissions after the install. Accessing webserver from browser: http://192.168.25.26:2100

Forbidden
You don't have permission to access / on this server.
Apache/2.4.10 (Raspbian) Server at 192.168.25.26 Port 2100

Here is my configs and what i did:
If you change ownership of everything to www-data like that a lot won't work: scripts, upgrading, etc.
I forget the details of the issues I had at the time, but a Nginx install under /home/pi was trivial
compared to Apache. And it's a design goal I had that pikrellcam run as user pi and install under
/home/pi because a whole lot of things are much simpler for the pikrellcam architecture that way.
So I went with Nginx.

It should be possible to set up Apache, but I think you will need to search the web for a guide of
some kind on how to set up Apache to have a root under a home directory. I wonder if it's not a lot
less effort to get Nginx working?

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Apr 11, 2017 7:36 am

billw wrote:
314_PIE wrote:Still having problems with apache2, Im pretty sure Nginx is all preconfigured with the right file permissions after the install. Accessing webserver from browser: http://192.168.25.26:2100

Forbidden
You don't have permission to access / on this server.
Apache/2.4.10 (Raspbian) Server at 192.168.25.26 Port 2100

Here is my configs and what i did:
If you change ownership of everything to www-data like that a lot won't work: scripts, upgrading, etc.
I forget the details of the issues I had at the time, but a Nginx install under /home/pi was trivial
compared to Apache. And it's a design goal I had that pikrellcam run as user pi and install under
/home/pi because a whole lot of things are much simpler for the pikrellcam architecture that way.
So I went with Nginx.

It should be possible to set up Apache, but I think you will need to search the web for a guide of
some kind on how to set up Apache to have a root under a home directory. I wonder if it's not a lot
less effort to get Nginx working?
I gave up and went back to nginx, but i uninstalled php5 and all of its dependencies, as well as apache2, reinstalled pikrellcam again and i finally got it working without any errors. The only thing im concerned about is duplicated log files in /var/log, is it safe to remove the duplicated logs? They have logs stored in the files, strange that it doesn't overwrite the original file during every reinstall of pikrellcam. I remove the pikrellcam directory from /home/pi before reinstalling.
http://imgur.com/smchxy2
Fox Mulder wrote:
314_PIE wrote: Whats stored in your /tmp? Anything related to nginx stored in it?

I would have to add a maximum size to the /tmp directory in fstab which isn't included in what i searched online, only for /var/log.

Code: Select all

 
proc  /proc  proc    defaults  0  0
/dev  /mmcblk0p1  /bootvfat    defaults  0  2
/dev  /mmcblk0p2  /ext4    defaults,noatime  0  1
tmpfs  /tmp  tmpfs   defaults,noatime  0  0
tmpfs  /var/log  tmpfs   defaults,noatime,size=64m  0  0
#
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
When you don' add the size attribute tmpfs uses dynamically up to half of installed memory. So i think you can remove the size parameter safely. I use apache and not nginx so i don't know what nginx stores in /tmp. But if /tmp is on the sd-card or tmpfs shouldn't bother nginx. I have all programs running fine with tmpfs for /tmp on the rpi, my main pc and my netbook for many months now.

Maybe try not adding it on fstab and just let tmp.mount handle it. Could be that it uses some different options for tmpfs.
For example for another tmpfs ramdisk i use the options "rw,size=4096M,nodev,nosuid,mode=0755". Don't know if i need all options, but i read it somewhere and it sounded good. :)

Ciao,
Rainer
Im confused about this size=4096M, i assume its the amount of virtual ram as my Pi Zero is 512mb.

The tutorial you wrote up awhile back, was this your own or was it from a tutorial blog, i felt like i need more info during each step for /var/log. and how can i add this transientlog.service through SSH remotely?

So by my understanding, these scripts store /var/log into ramdisk, when the pi does a shutdown, the logs writes to primary disk once every shutdown to prevent the log files from disappering at bootup. So when the uptime is over a month, depending on the limit size stored in tmpfs, does the pi automatically reboots to refresh the ramdisk when it reaches its size limit?

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Apr 11, 2017 9:51 am

314_PIE wrote:Im confused about this size=4096M, i assume its the amount of virtual ram as my Pi Zero is 512mb.
Maybe my options weren't optimal as example. It was from my main pc and not the Rpi. That's why i have a size of 4096MB. ;)
314_PIE wrote:The tutorial you wrote up awhile back, was this your own or was it from a tutorial blog, i felt like i need more info during each step for /var/log. and how can i add this transientlog.service through SSH remotely?
I wrote this tutorial myself after many try and error attempts from the internet. The "transientlog.sh" script is based on another script from the internet but i changed it heavily because the original script didn'tt work like i wanted.
To use it over SSH you just have to transfer the transientlog.sh script and transientlog.service file with help of SCP to the Rpi. Then you can activate it like i described. Alternatively if you don't need the old logs after a reboot you can just add a tmpfs to /var/log and that's all.
314_PIE wrote:So by my understanding, these scripts store /var/log into ramdisk, when the pi does a shutdown, the logs writes to primary disk once every shutdown to prevent the log files from disappering at bootup. So when the uptime is over a month, depending on the limit size stored in tmpfs, does the pi automatically reboots to refresh the ramdisk when it reaches its size limit?
Yes /var/log is stored in a ramdisk when running. At shutdown or user specific intervals (via crontab) the content is stored on the sd-card to back up the files for a reboot or crash. At bootup the ramdisk is filled with the backed up files so the log files start again where they stopped.
For the size limit within /var/log i use "logrotate" to rotate and gzip old logs after some time and they also get deleted when they are older than an predefined amount of time. With help of this the content of all log files doesn't grow larger at some point in time. For my Rpi i only got ~5MB in /var/log over many months since i use this setup. So i don't ave a problem with an ever growing log directory.

Ciao,
Rainer

billw
Posts: 415
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Apr 11, 2017 3:02 pm

Pikrellcam can record audio/video.

Jessie Lite users need libmp3lame0 installed or else pikrellcam will not run.
Minibian users need that and also libasound2.

See the Help page after upgrading.

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Apr 12, 2017 3:31 am

Fox Mulder wrote:To use it over SSH you just have to transfer the transientlog.sh script and transientlog.service file with help of SCP to the Rpi. Then you can activate it like i described. Alternatively if you don't need the old logs after a reboot you can just add a tmpfs to /var/log and that's all.
The only SSH client im using is on iOS, which only supports SFTP which i think does the same job as SCP. Yea i guess i don't really need old system logs, but i dont seem to understand how ramdisk can clear the actual logs in the .log files which i think removes the whole /var/log directory because it is stored in ramdisk. then after reboot things stop functioning because they cant store their logs.

Does this look normal for size? Not sure why dev/root is listed for /var/log.

Code: Select all

pi@PiZeroW:~ $ df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           186M  4.0K  186M   1% /tmp
pi@PiZeroW:~ $ 
pi@PiZeroW:~ $ df -h /var/log
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.2G  1.2G  5.8G  17% /
I added the following to tmpfs: both /tmp and /var/log.

Code: Select all

tmpfs  /tmp  tmpfs   rw,size=32M,nodev,nosuid,mode=0755  0  0
tmpfs  /var/log  tmpfs   rw,size=64M,nodev,nosuid,mode=0755  0  0

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Apr 12, 2017 9:20 am

314_PIE wrote:Yea i guess i don't really need old system logs, but i dont seem to understand how ramdisk can clear the actual logs in the .log files which i think removes the whole /var/log directory because it is stored in ramdisk. then after reboot things stop functioning because they cant store their logs.
The directory /var/log also exists on the sd-card and the ramdisk is mounted within it. When rebooting the whole content of the ramdisk is lost and after the startup the ramdisk is clean mounted in /var/log (because of the /etc/fstab entries) and all programs can write their logs into it. So i don't understand where you see a problem?
314_PIE wrote:Does this look normal for size? Not sure why dev/root is listed for /var/log.

Code: Select all

pi@PiZeroW:~ $ df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           186M  4.0K  186M   1% /tmp
pi@PiZeroW:~ $ 
pi@PiZeroW:~ $ df -h /var/log
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.2G  1.2G  5.8G  17% /
This shows only a ramdisk for /tmp and not for /var/log. You need to reboot after you changed /etc/fstab or have to manually mount the directories to see the changes. /dev/root is listed because /var/log resides within it and has no other filesystem mounted on top of it.
314_PIE wrote:I added the following to tmpfs: both /tmp and /var/log.

Code: Select all

tmpfs  /tmp  tmpfs   rw,size=32M,nodev,nosuid,mode=0755  0  0
tmpfs  /var/log  tmpfs   rw,size=64M,nodev,nosuid,mode=0755  0  0
You should remove the size parameter for /tmp so it could use half of the useable memory. Because with 32MB it could be too small for some operations. Many programs use /tmp for temporary actions which can get larger than 32MB for a short amount of time. This could lock your system if the memory isn't available in /tmp.

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Apr 12, 2017 12:28 pm

Fox Mulder wrote:The directory /var/log also exists on the sd-card and the ramdisk is mounted within it. When rebooting the whole content of the ramdisk is lost and after the startup the ramdisk is clean mounted in /var/log (because of the /etc/fstab entries) and all programs can write their logs into it. So i don't understand where you see a problem?
Geez, this is not good... dont know what i did wrong, theres something wrong with tmpfs that fails to start nginx and removed the nginx log file by the looks of it.. I read your post and edited before proceeding to reboot.. yesterday, pikrellcam was working as expected after a reinstall, did couple reboots and nginx started up fine when checking the status.

Code: Select all

pi@PiZeroW:~ $ sudo /etc/init.d/nginx status
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Wed 2017-04-12 21:59:03 AEST; 12min ago
  Process: 745 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Apr 12 21:59:03 PiZeroW nginx[745]: nginx: [alert] could not open error log file: open() "/var/log/ngi...tory)Apr 12 21:59:03 PiZeroW nginx[745]: 2017/04/12 21:59:03 [emerg] 745#0: open() "/var/log/nginx/error.lo...tory)Apr 12 21:59:03 PiZeroW systemd[1]: nginx.service: control process exited, code=exited status=1
Apr 12 21:59:03 PiZeroW systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Apr 12 21:59:03 PiZeroW systemd[1]: Unit nginx.service entered failed state.
Apr 12 21:59:03 PiZeroW nginx[745]: nginx: configuration file /etc/nginx/nginx.conf test failed
Hint: Some lines were ellipsized, use -l to show in full.
pi@PiZeroW:~ $ 
pi@PiZeroW:~ $ cd /var/log/nginx/error.log
-bash: cd: /var/log/nginx/error.log: No such file or directory
pi@PiZeroW:~ $ 
pi@PiZeroW:~ $ cd /var/log/               
pi@PiZeroW:/var/log $ ls
auth.log  boot.log  btmp  daemon.log  debug  kern.log  messages  php5-fpm.log  syslog  wtmp
pi@PiZeroW:/var/log $ 
pi@PiZeroW:/var/log $
Here is syslogs

Code: Select all

Apr 12 21:56:15 PiZeroW systemd[1]: Started Update UTMP about System Runlevel Changes.
Apr 12 21:56:15 PiZeroW systemd[1]: Startup finished in 1.510s (kernel) + 15.637s (userspace) = 17.147s.
Apr 12 21:56:24 PiZeroW dhcpcd[596]: wlan0: no IPv6 Routers available
Apr 12 21:59:03 PiZeroW systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 12 21:59:03 PiZeroW nginx[745]: nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (2: No such file or directory)
Apr 12 21:59:03 PiZeroW nginx[745]: 2017/04/12 21:59:03 [emerg] 745#0: open() "/var/log/nginx/error.log" failed (2: No such file or directory)
Apr 12 21:59:03 PiZeroW systemd[1]: nginx.service: control process exited, code=exited status=1
Apr 12 21:59:03 PiZeroW systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Apr 12 21:59:03 PiZeroW systemd[1]: Unit nginx.service entered failed state.
Apr 12 21:59:03 PiZeroW nginx[745]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 12 21:59:37 PiZeroW systemd[1]: Time has been changed
Apr 12 21:59:49 PiZeroW wpa_supplicant[462]: wlan0: WPA: Group rekeying completed with *********** [GTK=CCMP]
pi@PiZeroW:/var/log $
Last edited by ldon13 on Tue Apr 25, 2017 3:58 am, edited 1 time in total.

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Apr 12, 2017 11:00 pm

314_PIE wrote:Geez, this is not good... dont know what i did wrong, theres something wrong with tmpfs that fails to start nginx and removed the nginx log file by the looks of it.. I read your post and edited before proceeding to reboot.. yesterday, pikrellcam was working as expected after a reinstall, did couple reboots and nginx started up fine when checking the status.
I think i know what the problem is. :idea:
nginx tries to write the log files into /var/log/nginx/. But after the reboot the directory /var/log is an empty ramdisk. nginx creates the log files but it doesn't create the parent directory /var/log/nginx for it. And because this directory is missing it can't start.

So i think you have a few options for this problem. Manually create the directory /var/log/nginx after reboot (maybe with a script). Or you use my transientlog.sh script which restores the content of /var/log after a reboot. But for my script you first should have a working /var/log structure on the disk which could be used as a starting point.

Because you said you doesn't need the old logs i would go the first way and create the missing directory from some startup script. Maybe create a little helper script for starting nginx or pikrellcam which first creates the missing directories in /var/log.

Ciao,
Rainer

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Apr 13, 2017 12:41 am

Fox Mulder wrote:Because you said you doesn't need the old logs i would go the first way and create the missing directory from some startup script. Maybe create a little helper script for starting nginx or pikrellcam which first creates the missing directories in /var/log.
I created a script:

Code: Select all

#!/bin/bash
#
# Nginx directory is created after every reboot with the use of crontab (@reboot) 
#
sudo mkdir -p /var/log/nginx
#
#
sudo touch /var/log/nginx/error.log  
#
#
sudo touch /var/log/nginx/access.log
#
exit 0
Crontab:

Code: Select all

@reboot pi home/pi/create_nginx_dir.sh start

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Apr 13, 2017 9:47 am

314_PIE wrote:I created a script:

Code: Select all

#!/bin/bash
#
# Nginx directory is created after every reboot with the use of crontab (@reboot) 
#
sudo mkdir -p /var/log/nginx
#
#
sudo touch /var/log/nginx/error.log  
#
#
sudo touch /var/log/nginx/access.log
#
exit 0
I don't think you need to create the *.log files because these are created at runtime. Only the directory is the crucial part here.

Does the creation of the directory help to get nginx working again?

rpiatf2f10
Posts: 27
Joined: Sat Apr 23, 2016 10:16 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Apr 13, 2017 8:48 pm

HI Billw and other experts here,

I'd like to get some help in getting network share working so that I can use remote mounted share, instead of local SD or USB card. I learned in the post that NFS can do storage as well as live view, having same effect as local USB. Others, like SMB may not be able to view stored files using live view.

Can it be done in next release in this script, $ cat pikrellcam/scripts/startup , so that we have a few options?
Option 1: with local USB disk
Option 2: with NFS
Option 3: with SMB, with limitations
option 4: with SSHFS
Option 5: others,,,

I got the following working manually, 192.168.100.200:/Surveillance /mnt/nfs nfs defaults,noatime,x-systemd.automount 0 0

I can get it into /etc/fstab as well; however, I don't know how to get Pikrellcam to use it as storage.....

Thanks a lot
peng

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Apr 14, 2017 6:23 am

Fox Mulder wrote:
314_PIE wrote:I created a script:

Code: Select all

#!/bin/bash
#
# Nginx directory is created after every reboot with the use of crontab (@reboot) 
#
sudo mkdir -p /var/log/nginx
#
#
sudo touch /var/log/nginx/error.log  
#
#
sudo touch /var/log/nginx/access.log
#
exit 0
I don't think you need to create the *.log files because these are created at runtime. Only the directory is the crucial part here.

Does the creation of the directory help to get nginx working again?
Got it working!!! Just needed to remove the 'pi' from crontabs and chmod +x.

Thanks Billw and Rainer for the help!
Ill get my Pikrellcam hocked up to my Driveway and upload an image of the motion region setup of my place! :)

Is it worth setting up SSL for Nginx? Im not going to be accessing it from outside of the network.

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Apr 14, 2017 9:11 am

314_PIE wrote:Is it worth setting up SSL for Nginx? Im not going to be accessing it from outside of the network.
If the pi is not reachable from the internet you don't need to bother with SSL. Else i would use it just to be sure that no one can sniff your data. ;)

Teknor
Posts: 4
Joined: Fri Apr 14, 2017 4:35 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Apr 14, 2017 4:41 pm

Is there a way to connect an IP cam to PiKrellCam? I have two Dahua IP network cameras on my RPI 2 which I would very much like to work together with PiKrellCam for motion detection. I have installed PiKrellCam, but can not see where to config the URL to the camera.

Any tips would be very much appreciated. Thanks.

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Apr 15, 2017 7:59 am

Teknor wrote:Is there a way to connect an IP cam to PiKrellCam? I have two Dahua IP network cameras on my RPI 2 which I would very much like to work together with PiKrellCam for motion detection. I have installed PiKrellCam, but can not see where to config the URL to the camera.

Any tips would be very much appreciated. Thanks.
Im pretty sure its not possible unless this camera can connect to the CSI or to a special HDMI connection which worked for the original Pi Zero without a CSI port. Not quite sure about IP cameras, with the connection through ethernet.
Fox Mulder wrote:If the pi is not reachable from the internet you don't need to bother with SSL. Else i would use it just to be sure that no one can sniff your data.
Yea cool, if i wasnt as worried i would be using Telnet for everything Haha. I set a password login for Pikrellcam.

Have you setup the email notify when motion detects movement? I tried setting it up through pikrellcam.conf and added a email address for recieving jpeg images. Im using Outlook and i have 2 step verification enabled. I checked the logs on Pikrellcam webpage system>Logs.

Code: Select all

convert /run/pikrellcam/motion_2017-04-15_17.02.29_0.jpg -crop 266x266+474+39 -resize 150x150\! /home/pi/pikrellcam/media/thumbs/motion_2017-04-15_17.02.29_0.th.jpg
17:02:44 : execl:[mpack -s pikrellcam@PiZeroW /run/pikrellcam/motion_2017-04-15_17.02.29_0.jpg ****************@outlook.com]
17:02:44 : event_preview_dispose(); removing /run/pikrellcam/motion_2017-04-15_17.02.29_0.jpg
Does the script reply to its self using my email address to receive a motion detection?
Last edited by ldon13 on Tue Apr 18, 2017 11:02 am, edited 4 times in total.

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Apr 18, 2017 7:57 am

Hope you guys had a great Easter Sunday, i did too :)

I went back into it to get another try, i got it to work but only for ssmtp command below that sent to my Outlook account successfully... i used App passwords for thr Auth section in ssmtp.conf. STARTTLS and port 587.

However, it seems to not work with mpack test command in order to send the jpeg motion images. Im not sure if it can talk to ssmtp.conf but i know ssmtp can.

Mpack:

Code: Select all

pi@PiZeroW:~ $ mpack -s "Pikrella" /home/pi/bob.sh My_Email_Address@outlook.com
sendmail: 501 5.5.4 Invalid Email address
pi@PiZeroW:~ $ 
Invalid Email address? Thats weird...

This command:

Code: Select all

pi@PiZeroW:~ $ echo "Hello world!" | mail -s "Test Subject" My_Email_Address@outlook.com
mail: cannot send message: Process exited with a non-zero status
pi@PiZeroW:~ $ 
and ssmtp command which worked successfully.

Code: Select all

pi@PiZeroW:~ $ ssmtp My_Email_Address@outlook.com
From: My_Email_Address@outlook.com
To: My_Email_Address@outlook.com
Subject: PiKrellllllcammmm

Testing Testing 1 2 3
pi@PiZeroW:~ $

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Apr 18, 2017 9:46 am

314_PIE wrote:I went back into it to get another try, i got it to work but only for ssmtp command below that sent to my Outlook account successfully... i used App passwords for thr Auth section in ssmtp.conf. STARTTLS and port 587.

However, it seems to not work with mpack test command in order to send the jpeg motion images. Im not sure if it can talk to ssmtp.conf but i know ssmtp can.
That's exactly the problem. ssmtp uses it's own configuration where mail and mpack uses the linux wide mail system like postfix, sendmail or exim. So to use these commands you have to install and setup one of these mail systems on the pi properly. But if ssmtp works then why not just use it instead of mpack?

Ciao,
Rainer

Return to “Camera board”