:::: MENU ::::

Posts Categorized / Linux

  • Oct 19 / 2016
  • 0
Linux

Apache Tomcat – Get logs directly cleaned with rotation

Tomcat allows you to rotate easily your log files with AccessLogValve but it can be more difficult to get cleaning in logs directories automatically.

For that, you can easily use some smart find commands combined with actions:

  1. Get logs older than 3 days compressed so they can be smaller but still accessible
  2. Get logs older than 60 days deleted permanently

You will probably have to adjust the logs path depending on your needs, and you can also modify the retention time for each action.
Once the command looks correct with what you’re expecting, you can set them up as cron so it can be executed automatically every day.

  • Oct 14 / 2016
  • 0
Linux

Generate a random file with specific size

It’s possible to easily generate a random file with specific size filled differently depending on the needs:

  • Fill a 200MB file with zeroes
  • Fill a 200MB file with random values (longer than zeroes – depending on processor)
  • Sep 27 / 2016
  • 0
Linux

Escape sequences for SSH (when you’re stuck)

You can get stuck with your ssh session when your network is changing or when there’s a network disruption. You will face a lock leading to the unability to stop your session, even by doing a CTRL-C.

That’s why there’s some escape sequences you can use in that case (especially the first one when you’re stuck):

Note that escapes are only recognized immediately after newline.

  • Sep 16 / 2016
  • 0
Linux

Renew a GPG key when you get “GPG error – KEYEXPIRED”

Getting this error when trying to update packages on your linux distro using apt?

This just means that the GPG key is expired and that you need to renew it.

You can list expired keys and get the ID by using this command:

Here, we can see that ID “4BD6EC30” is expired and is leading to the issue.

Let’s now update this key:

And you can now perform the update properly, you won’t get error anymore.

  • Sep 07 / 2016
  • 0
Linux

Send an UDP packet with NetCat

It can be needed to test an UDP connection with a server to ensure that connectivity is working and double check the data received.

Let’s take a simple example with a remote logstash server:
– Server mylogstash.mydomain.local
– Listening on port 5000

On emitter side, we are sending an UDP packet simulating a log line coming from an application:

On receiving server side, we are executing a tcpdump to check that packet is correctly coming with good content:

Here we are! It’s very simple to control UDP flows or simply check connection between 2 servers.

  • Aug 22 / 2016
  • 0
Linux

Find and identify where inodes are used

Your monitoring system is claiming that your server is running out of free inodes but your disks are not full at all? Maybe you just need to check your filesystem usage and how many files are being used at the same time… Here are some tips to check and identify the inodes being used.

First of all, you can check percentage of inodes used with this simple command:

You will see inode usage for your partitions and mouting points:

Here, we can easily see that /var is using 83% of inodes, which is quite high.

Let’s now identify how those inodes are used with a compound command using find:

You will get a sorted result like this (I truncated to display only the last lines which are the most important):

We can clearly see that inodes are mostly used by /var/spool/postfix/maildrop. You just have to go in that folder and check if files are useful and/or if you can do some cleaning there.
Then, once files are removed and directory clean, your inodes will be freed and everything will be back to normal!

Question ? Contact