User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Mon Nov 19, 2012 2:15 pm

I've added the 'ramlog' to #Required-Start & #Required-Stop fields for a lot of daemons and with no succes at this point. This is the output when starting manually.

Code: Select all

[email protected]:~# /etc/init.d/ramlog start
[FAIL                           Error: /var/log is in use... failed!
The list of open files: (You need to close below daemons if you want to start/stop ramlog manually)

COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
rsyslogd  1937 root    1w   REG  179,2   405830 2789 /var/log/syslog
rsyslogd  1937 root    2w   REG  179,2   249542 2438 /var/log/kern.log
rsyslogd  1937 root    5w   REG  179,2    22169 3560 /var/log/debug
rsyslogd  1937 root    6w   REG  179,2   234511 3565 /var/log/messages
rsyslogd  1937 root    7w   REG  179,2     1114 1381 /var/log/bandwidth
rsyslogd  1937 root    8w   REG  179,2   408101 2437 /var/log/daemon.log
rsyslogd  1937 root    9w   REG  179,2    33440 2785 /var/log/auth.log
console-k 2273 root    8w   REG  179,2   146247   24 /var/log/ConsoleKit/history

Test result: ramlog cannot be started or stopped at the moment.
[email protected]:~#
I cannot find the rsyslogd or console-k in the /etc/init.d/ directory so I can't add the Required Start&Stop for those.
What I really miss is the log for ramlog during startup. /var/log/messages doesn't show anything for ramlog.
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

freemanbubu
Posts: 111
Joined: Sun Jun 17, 2012 11:12 am

Re: using logrotate and ramlog

Mon Nov 19, 2012 6:18 pm

hum.... :|

Can you perform a backup of your SD card (win32diskimager) and try install ramlog on a fresh raspbian install ?

If it works, you just have to backup your config files, restore your image, and compare....

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Tue Nov 20, 2012 8:24 am

I like your drastic approach :) but I need some time to test it this way. Maybe I'll wait till my other Pi's are delivered, I have to make three different setups then and they will all run Ramlog.

Thanks so far, to be continued!
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

freemanbubu
Posts: 111
Joined: Sun Jun 17, 2012 11:12 am

Re: using logrotate and ramlog

Tue Nov 20, 2012 10:34 am

I suggest this drastic approach because I don't understand your problem.

Your confg files looks good, and you try a lot of combinations, so...

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Tue Nov 20, 2012 12:47 pm

I've done a couple of things to remove ramlog from my Pi:

Code: Select all

apt-get remove ramlog
apt-get purge ramlog
apt-get clean
Reboot

Code: Select all

grep "ramlog" * in the /etc/init.d/
removed ramlog from all daemon config files

Code: Select all

updatedb
locate ramlog
The locate only finds the installation .deb file. I guess it's really gone now.
I'll give it another (last) try on this installation, do you think I've done everything to clean my Pi from ramlog?
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Tue Nov 20, 2012 2:15 pm

Check it out, I got a tmpfs :)
future readers: check out my previous post for how I cleaned my system from all ramlog files and settings.

The virtual ram drive is 220M, that's just crazy, although it's not all allocated because HTOP shows only 40MB MEM used :?

Two issues:
When I ask ramlog for the status it's reporting 'stopped' and I guess that's not ok.
The memory is set to 30M in /etc/init.d/ramlog file. Is this the right file to set this?

Code: Select all

[email protected] ~ $ df -h
Filesystem               Size  Used Avail Use% Mounted on
rootfs                   7.3G  3.0G  4.0G  43% /
/dev/root                7.3G  3.0G  4.0G  43% /
devtmpfs                 220M     0  220M   0% /dev
tmpfs                     44M  220K   44M   1% /run
tmpfs                    5.0M     0  5.0M   0% /run/lock
tmpfs                     88M     0   88M   0% /run/shm
/dev/mmcblk0p1            56M   17M   40M  30% /boot
ramlog-tmpfs             220M   32K  220M   1% /var/log
//192.168.0.107/Backups  928G  725G  204G  79% /mnt/NAS
[email protected] ~ $

Code: Select all

[email protected] ~ $ sudo /etc/init.d/ramlog status
ramlog is stopped

[email protected] ~ $ sudo /etc/init.d/ramlog start

/etc/init.d/ramlog: 470: /etc/init.d/ramlog: nfo: not found
[FAIL] ramlog: get_state error: Multiple devices running at the same time. failed!
/etc/init.d/ramlog

Code: Select all

### BEGIN INIT INFO
# Provides: ramlog
# Required-Start:
# Should-Start: $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: moves /var/log into ramdisk
# Description: ramlog daemon moves /var/log to ramdisk on startup and copies it back to harddrive on shutdown or restart
### END INIT INFO
                                                                                                                                                                                              
############################################################
# Ramlog default variables - please change variables in 
# /etc/sysconfig/ramlog on Fedora/CentOS systems and in
# /etc/default/ramlog on Ubuntu/Debian systems

RAMDISKTYPE=0
TMPFS_RAMFS_SIZE=30m
KERNEL_RAMDISK_SIZE=MAX
LOGGING=1
LOGNAME=ramlog
VERBOSE=1
CONFIGFILE=/etc/init.d/ramlog
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

freemanbubu
Posts: 111
Joined: Sun Jun 17, 2012 11:12 am

Re: using logrotate and ramlog

Tue Nov 20, 2012 7:22 pm

The memory is set to 30M in /etc/init.d/ramlog file. Is this the right file to set this?
Wrong:

ramlog config file is here:

Code: Select all

/etc/default/ramlog
You have to config this line (here, 10M for tmpfs), be carefull, "10" won't work, "10m" will work
TMPFS_RAMFS_SIZE=10m


My config file :

Code: Select all

#Ramlog service configuration

RAMDISKTYPE=0           #0 = tmpfs (can be swapped)
                        #1 = ramfs (no max size in older kernels, cannot be swapped, not SELinux friendly)
                        #2 = old kernel ramdisk
                        # (kernel ramdisk needs kernel parameter "ramdisk_size=" in kilobytes as default kernel ramdisk size
                        #  is usually lower than the size of the /var/log)

TMPFS_RAMFS_SIZE=10m    #Maximum size of memory to be used by tmpfs or ramfs.
                        # The value can be percentage of total RAM or size in megabytes - for example:
                        # TMPFS_RAMFS_SIZE=40%
                        # TMPFS_RAMFS_SIZE=100m
                        # Empty value means default tmpfs/ramfs size: TMPFS_RAMFS_SIZE=
                        # For more options please check 'man mount', section 'Mount options for tmpfs'
                        # (by the way - ramfs supports size limit in newer kernels as well despite man says there are no mount options)
                        # It has only effect if RAMDISKTYPE=0 or 1

KERNEL_RAMDISK_SIZE=MAX #Kernel ramdisk size in kilobytes or MAX to use entire ramdisk. It has only effect if RAMDISKTYPE=2

LOGGING=1               #0=off, 1=on
LOGNAME=ramlog          #name of the ramlog log file (makes sense if LOGGING=1)

VERBOSE=1               #0=off, 1=on (if 1, teststartstop puts detials to the logs and it is called after start or stop fails)

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Wed Nov 21, 2012 9:16 am

When I set this setting in the right configuration file ramlog stops working. So I add the 10m or 20m or 10% to /etc/default/ramlog, then I reboot, then I notice the ramdisk is gone (df -h) and ramlog didn't start.

This is crazy but the best part is this; when I remove the setting it still won't start and the ramdisk will never be created again, ever. Only after I completely remove and re-install ramlog, the ramdisk is created again. I though it might be permissions on the /etc/default/ramlog but they look ok.

Code: Select all

-rw-r--r-- 1 root root 1202 Nov 21 10:06 ramlog  
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

freemanbubu
Posts: 111
Joined: Sun Jun 17, 2012 11:12 am

Re: using logrotate and ramlog

Wed Nov 21, 2012 3:23 pm

In ramlog website's documentation, they recommend to reboot twice after a config change.

You install ramlog from a user using "sudo", or from root user ?

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Wed Nov 21, 2012 6:02 pm

I did the install using sudo.

If I set the memory size, the whole thing stops working.
Tried it 3 times and booted 3 times between every try ;)

This is my /etc/default/ramlog

Code: Select all

#Ramlog service configuration

RAMDISKTYPE=0           #0 = tmpfs (can be swapped)
                        #1 = ramfs (no max size in older kernels, cannot be swapped, not SELinux friendly)
                        #2 = old kernel ramdisk
                        # (kernel ramdisk needs kernel parameter "ramdisk_size=" in kilobytes as default kernel ramdisk size
                        #  is usually lower than the size of the /var/log)

TMPFS_RAMFS_SIZE=30m    #Maximum size of memory to be used by tmpfs or ramfs.
                        # The value can be percentage of total RAM or size in megabytes - for example:
                        # TMPFS_RAMFS_SIZE=40%
                        # TMPFS_RAMFS_SIZE=100m
                        # Empty value means default tmpfs/ramfs size: TMPFS_RAMFS_SIZE=
                        # For more options please check 'man mount', section 'Mount options for tmpfs'
                        # (by the way - ramfs supports size limit in newer kernels as well despite man says there are no mount options)
                        # It has only effect if RAMDISKTYPE=0 or 1

KERNEL_RAMDISK_SIZE=MAX #Kernel ramdisk size in kilobytes or MAX to use entire ramdisk. It has only effect if RAMDISKTYPE=2

LOGGING=1               #0=off, 1=on
LOGNAME=ramlog          #name of the ramlog log file (makes sense if LOGGING=1)

VERBOSE=1               #0=off, 1=on (if 1, teststartstop puts detials to the logs and it is called after start or stop fails)
I've got a lot of things running from OpenVPN to 'Shell in a Box' and this must be the must puzzling installation I ever did..

Thanks freemanbubu, for your effort :D
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Thu Nov 22, 2012 10:37 am

OK.

Completely started all-over again.

Installed using sudo and rebooted 3 times after each change.
It's working now;

Code: Select all

df -h
ramlog-tmpfs              30M 1012K   30M   4% /var/log 
Nonetheless, when I run /etc/init.d/ramlog status it reports ramlog stopped :x
Maybe that's because it runs no daemon or anything and I just shouldn't use this command.
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

freemanbubu
Posts: 111
Joined: Sun Jun 17, 2012 11:12 am

Re: using logrotate and ramlog

Thu Nov 22, 2012 11:51 am

In my case :

Code: Select all

[email protected] /etc/init.d $ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          7.4G  1.6G  5.5G  23% /
/dev/root       7.4G  1.6G  5.5G  23% /
devtmpfs        117M     0  117M   0% /dev
tmpfs            24M  212K   24M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            47M     0   47M   0% /run/shm
/dev/mmcblk0p1   56M   34M   23M  60% /boot
/dev/root       7.4G  1.6G  5.5G  23% /var/log.hdd
ramlog-tmpfs     10M  2.7M  7.4M  27% /var/log
[email protected] /etc/init.d $ service ramlog status
ramlog is running...
Ramlog running fine

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Thu Nov 22, 2012 1:15 pm

Ramlog is now logging everything to RAM and just deleting/dumping the data when it reboots, it's a monster! :evil:

I do not have this line:
/dev/root 7.4G 1.6G 5.5G 23% /var/log.hdd
That's the place it should write the log to but it never created the mount point, hmm..

Also, when I reboot, it only runs the second time. So every other reboot, Ramlog is not running. Which means I always have to reboot twice :( it's a mess.
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: using logrotate and ramlog

Fri Dec 07, 2012 1:50 pm

I'm using ramlog 2.0.0 and it startup fine. When I do a reboot or shutdown console-k daemon still use the log and ramlog isn't ablo to shutdown itselt with success.
I already add the required-start and stop ramlog entry in /etc/init.d/rsyslog but I cannot fine the relative console-k script...
Some hints?

I solved the console-k problem adding

Code: Select all

# X-Stop-After: rsyslog console-k
in /etc/init.d/ramlog..

Now I have:
Currently running processes (pstree):
init-+-2*[logsave]
|-rc---startpar---sendsigs---pstree
'-rsyslogd---3*[{rsyslogd}]
[FAIL] killing all remaining processes...failed

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: using logrotate and ramlog

Fri Dec 07, 2012 2:23 pm

I cannot edit my last message.
I said a wrong thing: I still have the console-k problem; console-k is still having the log open....

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Fri Dec 07, 2012 2:31 pm

Hey McGyver,

Make sure you reboot TWICE after each change.

I had a lot of the same problems you encounter, but when I installed it on a clean version of Raspbian it's all working fine without any extra configuration.

You should edit the Ramlog configuration here:
/etc/default/ramlog so not in /etc/init.d/ramlog

Cheers, Thijs
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: using logrotate and ramlog

Fri Dec 07, 2012 2:59 pm

in /etc/init.d/ramlog I added the "related" daemon to stat/stop before/after ramlog daemon.
In /etc/default/ramlog I setted the size of the log tmpfs.
What you mean for "each change"?
I have to reboot twice after edit /etc/default/ramlog, twice after /etc/init.d/ramlog..?
Why with a fresh installation you have all working fine and on a normal installation there are so many issue :roll:

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Sat Dec 08, 2012 7:24 pm

For the config to kick in, reboot twice. Never change the /etc/init.d/ config file. Must be some kind of boot dependency but I can't figure it out.. Feel free to post here when you find it :mrgreen:
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: using logrotate and ramlog

Sun Dec 09, 2012 12:45 am

I removed ramlog and reinstalled again, rebooted 3 time but I still have the

Code: Select all

Currently running processes (pstree):
init-+-2*[logsave]
|-rc---startpar---sendsigs---pstree
'-rsyslogd---3*[{rsyslogd}]
[FAIL] killing all remaining processes...failed
Can someone that has ramlog working fine paste here his /etc/init.d/ramlog, /etc/default/ramlog and /etc/init.d/rsyslog, please?

And what about logrotate? How can I apply it? It doesn't help about SDHC wear but it reduces the space used by the logs.

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Sun Dec 09, 2012 1:50 pm

These are the configs at the Pi my Ramlog is working. If I copy them to the other Pi it still won't work but these are the right configs..

/etc/init.d/ramlog

Code: Select all

#!/bin/sh
#
# ramlog        daemon script that moves moves /var/log into ramdisk
#               (c) 2001,2010 Jan Andrejkovic, Licence GNU 3 or any newer GNU licence
#
# chkconfig: 2345 02 99
#
# description:  ramlog daemon moves /var/log to ramdisk on startup and copies it\
#               back to harddrive on shutdown or restart\
#               \
#               Visit ramlog homepage http://www.tremende.com/ramlog

### BEGIN INIT INFO
# Provides: ramlog
# Required-Start:
# Should-Start: $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: moves /var/log into ramdisk
# Description: ramlog daemon moves /var/log to ramdisk on startup and copies it back to harddrive on shutdown or restart
### END INIT INFO

############################################################
# Ramlog default variables - please change variables in 
# /etc/sysconfig/ramlog on Fedora/CentOS systems and in
# /etc/default/ramlog on Ubuntu/Debian systems

RAMDISKTYPE=0
TMPFS_RAMFS_SIZE=
KERNEL_RAMDISK_SIZE=MAX
LOGGING=1
LOGNAME=ramlog
VERBOSE=1
CONFIGFILE=/etc/init.d/ramlog
/etc/default/ramlog

Code: Select all

#Ramlog service configuration

RAMDISKTYPE=0           #0 = tmpfs (can be swapped)
                        #1 = ramfs (no max size in older kernels, cannot be swapped, not SELinux friendly)
                        #2 = old kernel ramdisk
                        # (kernel ramdisk needs kernel parameter "ramdisk_size=" in kilobytes as default kernel ramdisk size
                        #  is usually lower than the size of the /var/log)

TMPFS_RAMFS_SIZE=30m    #Maximum size of memory to be used by tmpfs or ramfs.
                        # The value can be percentage of total RAM or size in megabytes - for example:
                        # TMPFS_RAMFS_SIZE=40%
                        # TMPFS_RAMFS_SIZE=100m
                        # Empty value means default tmpfs/ramfs size: TMPFS_RAMFS_SIZE=
                        # For more options please check 'man mount', section 'Mount options for tmpfs'
                        # (by the way - ramfs supports size limit in newer kernels as well despite man says there are no mount options)
                        # It has only effect if RAMDISKTYPE=0 or 1

KERNEL_RAMDISK_SIZE=MAX #Kernel ramdisk size in kilobytes or MAX to use entire ramdisk. It has only effect if RAMDISKTYPE=2

LOGGING=1               #0=off, 1=on
LOGNAME=ramlog          #name of the ramlog log file (makes sense if LOGGING=1)

VERBOSE=1               #0=off, 1=on (if 1, teststartstop puts detials to the logs and it is called after start or stop fails)



/etc/init.d/rsyslog

Code: Select all

#! /bin/sh
### BEGIN INIT INFO
# Provides:          rsyslog
# Required-Start:    $remote_fs $time
# Required-Stop:     umountnfs $time
# X-Stop-After:      sendsigs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: enhanced syslogd
# Description:       Rsyslog is an enhanced multi-threaded syslogd.
#                    It is quite compatible to stock sysklogd and can be 
#                    used as a drop-in replacement.
### END INIT INFO

#
# Author: Michael Biebl <[email protected]>
#

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="enhanced syslogd"
NAME=rsyslog

RSYSLOGD=rsyslogd
RSYSLOGD_BIN=/usr/sbin/rsyslogd
RSYSLOGD_OPTIONS="-c5"
RSYSLOGD_PIDFILE=/var/run/rsyslogd.pid

SCRIPTNAME=/etc/init.d/$NAME
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

freemanbubu
Posts: 111
Joined: Sun Jun 17, 2012 11:12 am

Re: using logrotate and ramlog

Sun Dec 09, 2012 2:38 pm

You have no dependency with services ramlog and rsyslog in your files, and it works fine?

Each person who install this program have different difficulties...I don't understand... :(

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: using logrotate and ramlog

Fri Jan 18, 2013 2:02 pm

I retried again with a fresh sd.same issue...
I'm going to uninstall ramlog...it should be a very nice utils but I cannot have it working on my rasp... :?

Could be a solution to use a ramdisk and move logs there? And the second step should be logrotate.

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: using logrotate and ramlog

Fri Jan 18, 2013 2:10 pm

I got it to work on a fresh Raspbian installation only, it's possible to arrange somewhat of the same functionality yourself. You need to create a RAM-disc, change the LOG-file paths and create a script for the regular copy from RAM to disc.

If you try this 'manual' approach, I'll be happy to help :)
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: using logrotate and ramlog

Mon Jan 21, 2013 7:50 am

Thank you for you help and helpfulness!
As soon as I try this way I will update this thread

albundy
Posts: 31
Joined: Tue Jul 17, 2012 4:56 pm

Re: using logrotate and ramlog

Mon Jan 21, 2013 4:11 pm

Aren't you forgetting to do sudo update-rc.d ...... for every file in /etc/init.d when you change its contents?

Return to “Networking and servers”