mosquitto and ram log files tmpfs on a raspberry

141 views
Skip to first unread message

alex jennings

unread,
Apr 29, 2017, 6:30:35 PM4/29/17
to MQTT
I have been struggling with sd card reliability on my openhab based set up. So I have been trying to reduce write loads by moving log files to RAM.
Everything works fine except I can only seem to get location notfications in mosquito from owntracks. Region events and waypoints just don't come through when I try and follow.

I have added this to /etc/fstab
tmpfs   /var/log                tmpfs   size=20M,defaults,noatime,mode=0755 0 0
tmpfs  
/var/cache/apt/archives tmpfs   size=100M,defaults,noexec,nosuid,nodev,mode=0755 0 0
tmpfs  
/var/spool/cups         tmpfs   size=100M,defaults,noatime,mode=0755 0 0
tmpfs  
/var/spool/cups/tmp     tmpfs   defaults,noatime,mode=0755 0 0

I created a new file and set it to run at boot etc/init.d/prepare-dirs
Enter code here...#!/bin/bash
#
### BEGIN INIT INFO
# Provides:          prepare-dirs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Required-Start:
# Required-Stop:
# Short-Description: Create needed directories on /var/log/ for tmpfs at startup
# Description:       Create needed directories on /var/log/ for tmpfs at startup
### END INIT INFO
# needed Dirs
DIR[0]=/var/log/lighttpd
DIR[1]=/var/log/mosquitto
DIR[2]=/var/log/apt
DIR[3]=/var/log/ConsoleKit
DIR[4]=/var/log/fsck
DIR[5]=/var/log/news
DIR[6]=/var/log/ntpstats
DIR[7]=/var/log/samba
DIR[8]=/var/log/lastlog
DIR[9]=/var/log/exim4
DIR[10]=/var/log/watchdog
case "${1:-''}" in
  start)
        typeset -i i=0 max=${#DIR[*]}
        while (( i < max ))
        do
                mkdir  ${DIR[$i]}
                chmod 755 ${DIR[$i]}
                i=i+1
        done
        # set rights
        chown www-data.www-data ${DIR[0]}
    ;;
  stop)
    ;;
  restart)
   ;;
  reload|force-reload)
   ;;
  status)
   ;;
  *)
   echo "Usage: $SELF start"
   exit 1
   ;;
esac


and to begin with I was getting nothing at all but adding this to the start section of /etc/init.d/mosquitto
mkdir /var/log/mosquitto
mkdir /var/log/mosquitto.log

this is my mosquito.conf
  GNU nano 2.2.6                          File: /etc/mosquitto/mosquitto.conf                                                           
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
log_type warning
log_type notice
log_type information
log_type error
include_dir /etc/mosquitto/conf.d


any suggestions would be gratefully received
thanks


Reply all
Reply to author
Forward
0 new messages