MEWBIES@: Facebook Twitter G+ YouTube DeviantArt Forum Wall
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ██
█▌ - HANDLING GLFTPD LOGS - █▌
█▌ █▌
█ ▐▌
█ CHANGING LOGGING OPTIONS IN GLFTPD SERVER: ▐▌
█ `````````````````````````````````````````` ▐▌
█ View section 1. item 7. of glftpd.docs for different switches. For myself ▐▌
█ I don't need to log uploads and downloads, nor every IP logged onto site: ▐▌
█ -x glftpd only log ips on errors (default everything logged) ▐▌
█ -o Logs downloads /glftpd/ftp-data/logs/xferlog. ▐▌
█ -i Logs uploads to /glftpd/ftp-data/logs/xferlog. ▐▌
█ To change these options for example: ▐▌
█ su ▐▌
█ pico /etc/inetd.conf ▐▌
█ Has this: ▐▌
█ glftpd stream tcp nowait root /usr/sbin/tcpd /jail/glftpd/bin/glftpd -l -o -i -r /jail/glftpd.conf -s/jail/glftpd/bin/glstrings.bin -e
█ ▐▌
█ I changed it to: ▐▌
█ glftpd stream tcp nowait root /usr/sbin/tcpd /jail/glftpd/bin/glftpd -l -x -r /jail/glftpd.conf -s/jail/glftpd/bin/glstrings.bin -e
█ ▐▌
█ Restart the server for the changes to affect: ▐▌
█ /etc/init.d/openbsd-inetd restart ▐▌
█ ▐▌
█ KEEPING THE DIRECTORY LOG IN SHAPE: ▐▌
█ ``````````````````````````````````` ▐▌
█ View section 1. item 12. of glftpd.docs. ▐▌
█ Included with glftpd are two binaries, oldirclean2.c and glupdate.c, to ▐▌
█ help keep directories and the log for directories, dirlog, in shape. If ▐▌
█ you don't use 'olddirclean2' the 'dirlog' will contain every directory ▐▌
█ ever made on your server and continue to grow until there is no disk space ▐▌
█ left to grow :). If users use 'site search' the results can show ▐▌
█ directories that have long been removed from the server and 'site new' ▐▌
█ won't be sorted properly. ▐▌
█ To re-add moved or new directories that weren't created through glftpd you ▐▌
█ need to use 'glupdate'. ▐▌
█ To use both of these it's as simple as adding them to your crontab, with ▐▌
█ glupdate to perform first, so dirlog can follow. We'll do that after, here ▐▌
█ are some notes first, and test runs to be sure the paths are correct for ▐▌
█ your installation: ▐▌
█ su ▐▌
█ The logs are here: ▐▌
█ ls -al /jail/glftpd/ftp-data/logs/ ▐▌
█ View last 10 entires on dirlog: ▐▌
█ tail -10 cat /jail/glftpd/ftp-data/logs/dirlog ▐▌
█ The glupdate needs to be run in each section on the server. To perform a ▐▌
█ directory update manually as root in incoming for example: ▐▌
█ /jail/glftpd/bin/glupdate /jail/glftpd/site/incoming ▐▌
█ Or in ZIPS for examples: ▐▌
█ /jail/glftpd/bin/glupdate /jail/glftpd/site/ZIPS ▐▌
█ ▐▌
█ To view olddrclean2 help and switches: ▐▌
█ /jail/glftpd/bin/olddirclean2 -h ▐▌
█ ▐▌
█ To perform a cleaning of dirlog manually if root: ▐▌
█ /jail/glftpd/bin/olddirclean2 > /jail/glftpd/ftp-data/logs/dirlog ▐▌
█ To perform a cleaning manually as a user, as long as user has permissions ▐▌
█ in /jail/, you need to first: ▐▌
█ chmod +s /jail/glftpd/bin/olddirclean2 ▐▌
█ Then view your log again: ▐▌
█ tail -10 cat /jail/glftpd/ftp-data/logs/dirlog ▐▌
█ ▐▌
█ If all worked fine add to your crontab the glupdate- changing the paths to ▐▌
█ your own section, and oldirclean2 to perform after glupdate. For example ▐▌
█ since I like a nice and tidy server I run both twice a day every day, mine ▐▌
█ has this: ▐▌
█ crontab -e ▐▌
0 0 * * * /jail/glftpd/bin/reset -e -r /jail/glftpd.conf
59 12,23 * * * /usr/sbin/chroot /jail/glftpd /bin/cleanup >/dev/null 2>&1
1 12,0 * * * /jail/glftpd/bin/glupdate /jail/glftpd/site/incoming >/dev/null 2>&1
1 12,0 * * * /jail/glftpd/bin/glupdate /jail/glftpd/site/ZIPS >/dev/null 2>&1
1 12,0 * * * /jail/glftpd/bin/glupdate /jail/glftpd/site/SFV >/dev/null 2>&1
2 12,0 * * * /jail/glftpd/bin/olddirclean2 -PD >/dev/null 2>&1
█ ▐▌
█ So this means for each line above: ▐▌
█ At 12:00 AM daily reset will reset server's statistics ▐▌
█ At 12:59 PM & 11:59 PM daily cleanup will remove dead symbolic links ▐▌
█ At 12:01 PM & 12:01 AM daily glupdate will add any moved or new ▐▌
█ directories not created with gl to dir list. ▐▌
█ At 12:02 PM & 12:01 AM daily olddirclean2 will replace dirlog and delete ▐▌
█ the old one. ▐▌
█ ▐▌
█ GLFTPD LOG ROTATION: ▐▌
█ ```````````````````` ▐▌
█ View section VII item 1. of glftpd.docs for a description of each log. The ▐▌
█ logs are here: ▐▌
█ ls -al /jail/glftpd/ftp-data/logs/ ▐▌
█ Take note of the perms, owner and group as we'll need this for the ▐▌
█ logrotate config file to recreate the same. For example dupelog: ▐▌
█ -rw-rw-rw- 1 root root 0 2010-07-04 06:25 dupelog ▐▌
█ Which is perms 666, owner root, group root. ▐▌
█ ▐▌
█ View last 10 entires on error.log for example: ▐▌
█ tail -10 cat /jail/glftpd/ftp-data/logs/error.log ▐▌
█ You can also view errors in error.log via a site cmd: ▐▌
█ site errlog 5 ▐▌
█ ▐▌
█ We'll use 'logrotate' to rotate the logs. ▐▌
█ cat /etc/logrotate.conf ▐▌
█ This contains the default settings for logrotate itself, not exactly which ▐▌
█ logs to rotate. Skim over it to get an understanding. You'll notice that ▐▌
█ it should have: include /etc/logrotate.d ▐▌
█ If it doesn't have that line, add it. ▐▌
█ This will direct it to configuration files which will override logrotate's ▐▌
█ default. Some packages will auto schedule their logs to be rotated, ▐▌
█ placing their rotation configuration file in one the directories here - ▐▌
█ depending on its parameters: ▐▌
█ /etc/cron.d ▐▌
█ /etc/cron.daily ▐▌
█ /etc/cron.hourly ▐▌
█ /etc/cron.monthly ▐▌
█ /etc/cron.weekly ▐▌
█ To learn more: man logrotate and there is an informative article HERE. ▐▌
█ ▐▌
█ First we need to create the configuration file for logrotate. We'll do ▐▌
█ only dupelog first for this example: ▐▌
█ pico /etc/logrotate.d/glftpd ▐▌
/jail/glftpd/ftp-data/logs/dupelog {
daily
missingok
rotate 1
nocompress
delaycompress
notifempty
create 666 root root
sharedscripts
postrotate
/etc/init.d/openbsd-inetd reload > /dev/null 2>&1
endscript
}
█ ▐▌
█ You don't need to chmod it. It should have already perms 644: -rw-r--r-- ▐▌
█ ls -al /etc/logrotate.d/ ▐▌
█ ▐▌
█ The above will rotate dupelog daily, leaving only 1 backup log. If you ▐▌
█ want it to rotate daily and/or when it meets a certain size, 'add' this ▐▌
█ line for example: ▐▌
█ size 10M ▐▌
█ G= Gigabyte M= Megabyte k=Kilobytes. If you want it to rotate only when it ▐▌
█ meets a certain size, remove the time (daily/weekly/monthly) directive and ▐▌
█ use the size directive only. ▐▌
█ ▐▌
█ To test it, without actually rotating the log: ▐▌
█ logrotate --debug --force /etc/logrotate.d/glftpd ▐▌
█ ▐▌
█ To rotate the log manually: ▐▌
█ logrotate --force -v /etc/logrotate.d/glftpd ▐▌
█ ▐▌
█ BTW you can also change logrotate's defaults so that if it isn't stated in ▐▌
█ a configuration file, it will use the settings here: ▐▌
█ pico /etc/logrotate.conf ▐▌
█ For example I changed mine from weekly to daily, and rotate 4 to rotate 1. ▐▌
█ This will affect all logs that logrotate looks after if it isn't stated in ▐▌
█ their own configuration files. ▐▌
█ ▐▌
█ OK so to rotate all of glftpd's logs I use the same configuration file we ▐▌
█ created earlier (pico /etc/logrotate.d/glftpd) and list all logs on there ▐▌
█ with the settings that I want. ▐▌
█ First list the correct perms, owner group for each log: ▐▌
█ ls -al /jail/glftpd/ftp-data/logs/ ▐▌
█ perms 666: ▐▌
█ -rw-rw-rw- 1 root root 22176 2010-05-14 09:35 dupefile ▐▌
█ -rw-rw-rw- 1 root root 0 2010-06-23 07:47 dupelog ▐▌
█ -rw-rw-rw- 1 root root 209942 2010-06-22 09:30 dupelog.1 ▐▌
█ -rw-rw-rw- 1 root root 2133279 2010-06-22 10:55 glftpd.log ▐▌
█ ▐▌
█ perms: 644 ▐▌
█ -rw-r--r-- 1 root root 2016 2010-06-22 09:32 dirlog ▐▌
█ -rw-r--r-- 1 root root 507600 2010-06-23 04:15 laston.log ▐▌
█ -rw-r--r-- 1 root root 974685 2010-06-22 09:32 login.log ▐▌
█ -rw-r--r-- 1 root root 0 2009-05-07 12:25 nukelog ▐▌
█ -rw-r--r-- 1 root root 310 2010-06-22 09:13 olddirclean.log ▐▌
█ -rw-r--r-- 1 root root 0 2009-05-07 12:25 request.log ▐▌
█ -rw-r--r-- 1 root root 1254487 2010-06-21 04:22 sysop.log ▐▌
█ -rw-r--r-- 1 root root 4836615 2010-06-21 05:31 xferlog ▐▌
█ -rw-r--r-- 1 root root 12210 2010-06-22 09:29 error.log ▐▌
█ -rw-r--r-- 1 root root 216 2010-06-03 08:01 oneliners.log ▐▌
█ ▐▌
█ Change the directives to suit your self. For mine I have don't need old ▐▌
█ logs compressed and I want 0 byte files rotated. The reason for this is my ▐▌
█ server isn't used very often and if a new log is 0 bytes it won't rotate ▐▌
█ it where the the backup log could contain much information, that I have no ▐▌
█ use for. ▐▌
█ pico /etc/logrotate.d/glftpd ▐▌
█ This is what mine has to cover all of glftpd logs: ▐▌
/jail/glftpd/ftp-data/logs/dupelog /jail/glftpd/ftp-data/logs/glftpd.log /jail/glftpd/ftp-data/logs/dupefile {
daily
missingok
rotate 1
nocompress
delaycompress
create 666 root root
}
/jail/glftpd/ftp-data/logs/sysop.log /jail/glftpd/ftp-data/logs/xferlog /jail/glftpd/ftp-data/logs/nukelog /jail/glftpd/ftp-data/logs/l*.log /jail/glftpd/ftp-data/logs/dirlog {
daily
missingok
rotate 1
nocompress
delaycompress
create 644 root root
}
/jail/glftpd/ftp-data/logs/oneliners.log {
monthly
missingok
rotate 1
nocompress
delaycompress
create 644 root root
}
/jail/glftpd/ftp-data/logs/error.log {
weekly
missingok
rotate 1
nocompress
delaycompress
create 666 root root
sharedscripts
postrotate
/etc/init.d/openbsd-inetd reload > /dev/null 2>&1
endscript
}
█ To test it, without actually rotating the logs: ▐▌
█ logrotate --debug --force /etc/logrotate.d/glftpd ▐▌
█ ▐▌
█ To rotate the logs manually: ▐▌
█ logrotate --force -v /etc/logrotate.d/glftpd ▐▌
█ ▐▌
█ ls -al /jail/glftpd/ftp-data/logs/ ▐▌
█ ▐▌
█ //---------------------------------------------------------------------- ▐▌
█ ▐▌
█ If you find mistakes, have suggestions, and or questions please post at ▐▌
█ mewbies forum HERE - thank you. ▐▌
█ ▐▌
█ Last update on 05 Jul '10 ▐▌
█ ▐▌
█▌ █▌
█▌ - mewbies.com - █▌
█▌ █▌
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██