Skip to main content
  1. Posts/

Statutory warning: Decimals in your logrotate config can be bad for your server’s disk space

··308 words·2 mins·
DevOps Chef Logrotate Ruby

Last night as I was about to head to sleep, Sensu started emailing me about disk space warnings on one of the backend servers. That’s strange, I thought. I had set up logrotate with appropriate limits to ensure the log file size is reasonable and rotation happens on a daily basis.

Curious, I ssh’d into the server to investigate. Running a df -h indicated as expected the disk space in use was over 70% (which is the trigger for sensu to send a notification) and the log files had grown way over expected size. So why didn’t logrotate rotate the files? I ran logrotate again to see what’s happening

<br /> $ sudo /etc/cron.daily/logrotate<br /> error: backend:7 bad size '536870912.0'<br /> error: found error in "log/production.log", skipping

Huh, ok so now we know why logrotate didn’t run. But having a decimal in the config causes it to flag as bad size? I checked the documentation and it doesn’t mention so:

size size
              Log files are rotated when they grow bigger then size bytes.  If
              size  is  followed by M, the size if assumed to be in megabytes.
              If the k is used, the size is in kilobytes. So  size  100,  size
              100k, and size 100M are all valid.

Removing the decimal allowed logrotate to work fine and rotated the files. So that’s a TIL for me. In case you’re wondering how that decimal came into the picture, Chef is used as the CM tool for deploying all changes. The size is defined in a recipe as so

size (0.5 * (1024 * 1024 * 1024))<br /> maxsize (0.5 * (1024 * 1024 * 1024))

Now the first number is templated based on what service is being deployed and for the backend, it is configured as 0.5. Since Chef uses Ruby, this evaluates to ‘536870912.0’ and thus, the error.

Sathyajith Bhat
Author
Sathyajith Bhat
Author, AWS Container Hero and DevOps Specialist.

Related

Chef Zero, Cookbooks and Data Bags locations
··339 words·2 mins
DevOps Chef
I like chef-zero a lot. There’s so much overlap between chef’s products: chef-zero, chef-solo, chef-apply - yes, each have their own uses, but I digress. Chef-zero has been relatively pain-free for me - except when I tried to get it running - trying to figure out why it wasn’t fetching the cookbooks was so annoying! I went and RTFM couple of times, no dice. Then I decided to not skim read and read the entire thing.
DevOps Diaries: When Terminator terminates your MySQL imports onto an AWS Instance…
··627 words·3 mins
DevOps Aws
I have begun to use Terminator quite a lot. Terminator’s quite handy when you want to connect to multiple servers on a single terminal thanks to its split pane feature. (And yes I know about tmux & screen - I have screen on my servers, don’t want to get into the headache that is nested screen panes). Few days back we were preparing for a big migration & deploy and I was tasked upon to prepare a failover just in case the migration goes wrong.
Broken KDE Plasma 5.6 on Linux Mint 18
··501 words·3 mins
Opinions KDE
I’ve been a long time KDE user, loved the KDE 4.0 SC when it first arrived and probably one of the most vocal supporters for it when people were hating it. Since my recent job move, I’ve been using Linux desktop full-time. Since Linux Mint 18 was the only distro which supported WiFi/Display/Multi-monitor/HDMI out on my Lenovo E41-80(which comes with Skylake chipset), I stuck to it with the Cinnamon desktop.