×


Category: Docker


Use the Jinja2 Template in Ansible - Step by step guide ?

This article covers how to use Jinja2 templating engine to carry out more involved and dynamic file modifications with Ansible. In fact, Jinja2 is a powerful and easy to use python-based templating engine that comes in handy in an IT environment with multiple servers where configurations vary every other time. Creating static configuration files for each of these nodes is tedious and may not be a viable option since it will consume more time and energy.


Linux date command with example usages

This article covers the date command in Linux and showcased some of the command options that you can use to make the most of the command. In fact, Linux date command displays and sets the system date and time. This command also allows users to print the time in different formats and calculate future and past dates.


Monitor Linux performance using sysstat tool

This article covers how to install Linux Sysstat Utilities For Monitoring System Performance. In fact, Sysstat is a powerful monitoring tool for Linux environments. 

Basically, Sysstat is actually a collection of utilities designed to collect information about the performance of a Linux installation and record them over time.


Main features of Sysstat:

  • Display average statistics values at the end of the reports.
  • On-the-fly detection of new devices (disks, network interfaces, etc.) that are created or registered dynamically.
  • Support for UP and SMP machines, including machines with hyperthreaded or multi-core processors.
  • Support for hotplug CPUs (it detects automagically processors that are disabled or enabled on the fly) and tickless CPUs.
  • Works on many different architectures, whether 32- or 64-bit.
  • Needs very little CPU time to run (written in C).
  • System statistics collected by sar/sadc can be saved in a file for future inspection. You can configure the length of data history to keep. There is no limit for this history length but the available space on your storage device.
  • System statistics collected by sar/sadc can be exported in various different formats (CSV, XML, JSON, SVG, etc.). DTD and XML Schema documents are included in sysstat package. JSON output format is also available for mpstat and iostat commands.
  • iostat can display statistics for devices managed by drivers in userspace like spdk.
  • Smart color output for easier statistics reading.

Different methods of installing Sysstat on any Linux distribution ?

1. Install from RHEL/Fedora/CentOS

Execute:

$ sudo yum install sysstat

CentOS and Fedora systems call the collector process using a cron job in /etc/cron.d and it's enabled by default. On recent versions, systemd is used instead of cron. You may need to enable and start the sysstat service:

$ sudo systemctl enable sysstat
$ sudo systemctl start sysstat


2. Install from Ubuntu

Execute:

$ sudo apt-get install sysstat

Then enable data collecting:

$ sudo vi /etc/default/sysstat

change ENABLED="false" to ENABLED="true"

save the file

Last, restart the sysstat service:

$ sudo service sysstat restart


3. Install Sysstat from sources

Clone sysstat public repository with:

$ git clone git://github.com/sysstat/sysstat

Then configure sysstat for your system:

$ cd sysstat
$ ./configure

You can set several variables and parameters on the command line. For example you can enter the following option to activate data collecting (either using cron or systemd):

$ ./configure --enable-install-cron

Enter ./configure --help to display all possible options.

Finally, Compile and install:

$ make
$ sudo make install


Create a virtual machine in KVM on the command line

This article covers how to create and manage guest virtual machines on KVM from the command-line. In fact, KVM (Kernel based Virtual Machine) is an opensource virtualization technology built for Linux machines. It comprises a kernel module – kvm.ko which provides the core virtualization platform and a processor-specific module ( kvm-intel.ko for Intel processors or kvm-amd.ko for AMD processors ).


How to Install KVM, Qemu, virt-manager & libvirtd daemon ?

To install KVM and associated packages, run the below command:

$ sudo apt install -y qemu qemu-kvm libvirt-daemon libvirt-clients bridge-utils virt-manager

The command installs the following packages:

  • qemu-kvm –  This is the main KVM package that provides virtualization support.
  • libvirt – Includes the libvirtd daemon which supports creation and management of virtual machines.
  • libvirt-client – This package provides the virsh utility used for interacting with virtual machines.
  • virt-install – A utility that helps you to create virtual machines and install OS on those virtual machines from command line.
  • virt-viewer – A utility that displays the graphical view for the virtual machine.

Once installed, we need to confirm if the required kvm modules are loaded. Therefore, run the command:

$ lsmod | grep kvm

Additionally, confirm that the libvirtd daemon is running as follows:

$ sudo systemctl status libvirtd.service


sysctl command in Linux - Explained with examples

This article covers how to use the sysctl command in Linux through examples. In fact, sysctl is used to modify kernel parameters at runtime. The parameters available are those listed under /proc/sys/. Procfs is required for sysctl support in Linux.


rm command in Linux - Explained with examples

This article covers how to use the rm command in Linux. In fact, the rm command is used for removing/deleting files and directories.


How to remove directories using rm command?

If you are trying to remove a directory, then you need to use the -r command line option. Otherwise, rm will throw an error saying what you are trying to delete is a directory:

$ rm -r [dir name]

For example:

$ rm -r testdir


How to make rm prompt before every removal ?

If you want rm to prompt before each delete action it performs, then use the -i command line option: 

$ rm -i [file or dir]

For example, suppose you want to delete a directory 'testdir' and all its contents, but want rm to prompt before every deletion, then here's how you can do that:

$ rm -r -i testdir