How to find the Swap usage of Guest VMs KVM

  • How to find the Swap usage of Virtual Machines from a Swapped KVM host
find /proc -maxdepth 2 -path "/proc/[0-9]*/status" -readable -exec awk -v FS=":" '{process[$1]=$2;sub(/^[ \t]+/,"",process[$1]);} END {if(process["VmSwap"] && process["VmSwap"] != "0 kB") printf "%10s %-30s %20s\n",process["Pid"],process["Name"],process["VmSwap"]}' '{}' \;|grep qemu
  • Output
     3529 qemu-system-x86                            15112 kB
      6362 qemu-system-x86                           151732 kB
     16441 qemu-system-x86                            32040 kB
     25338 qemu-system-x86                           267232 kB
     29052 qemu-system-x86                            66408 kB
     34747 qemu-system-x86                             7252 kB
     34876 qemu-system-x86                            26576 kB
     44797 qemu-system-x86                            11164 kB
     44838 qemu-system-x86                            77052 kB
     45507 qemu-system-x86                            13928 kB
     53475 qemu-system-x86                             8144 kB
     55232 qemu-system-x86                            22288 kB

How to install OpenVPN in Openstack Environment

Preface Use Case Deployment Setup Installation VDC Configuration Client Configuration Preface OpenVPN is an open-source commercial software that implements Virtual Private Network (VPN) techniques to create secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities. It uses a custom security protocol that utilizes SSL/TLS for key exchange. It is capable of traversing network address translators (NATs) and firewalls. It was written by James Yonan and is published under the GNU General Public License. [Read More]

Diagnose network with MTR

Preface MTR is a powerful tool which enables administrators to diagnose and isolate networking errors and provide reports of network status to upstream providers. MTR represents an evolution of the traceroute command by providing a greater data sample, as if augmenting traceroute with ping output. This document provides an in depth overview of MTR, the data it generates, and how to interpret and draw conclusions based on the data provided by it. [Read More]

Deny traffic based on Country Iptables

Preface Some countries are blacklisted in ecommerce area due to spam flooding and DoS attacks. Its not difficult to find the root of an IP address. So the following script will block country based traffic in to your web server. The data will be updated in every day through a cronjob. You need to visit this SITE to download the zone file for which country you need to block. mkdir -p /opt/scripts [Read More]

Prevent DOS using iptables

Preface A major problem facing by mail server admin is DOS (Deniel Of Service) attack. Hackers will try to mess up with the most popular ports of a UNIX/LINUX machines. We can prevent this my writing an IPTABLE rule in the server. The working is ,if some one is trying make connection continuously through a specified port the rule will block the IPADDRESS permanently. Here I am stating the securing of PORT 25 (SMTP) here you can use your own [Read More]

Benchmarking SSD

How to Test Write Speed How to Test Read Speed How to Test Write Speed sync; dd if=/dev/zero of=tempfile bs=1M count=1024; sync 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 3.28696 s, 327 MB/s How to Test Read Speed dd if=tempfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 0.159273 s, 6.7 GB/s Clear the Cache and Run again sudo /sbin/sysctl -w vm. [Read More]

Monitor file changes realtime

Everybody knows top or htop. Ever wished there was something similar but to monitor your files instead of CPU usage and processes? Well, there is. Run this: watch -d -n 2 ‘df; ls -FlAt;’ and you’ll get to spy on which files are getting written on your system. Every time a file gets modified it will get highlighted for a second or so. The above command is useful when you grant someone SSH access to your box and wish to know exactly what they’re modifying. [Read More]

EXT4 Filesystem Size

What is an EXT4 The ext4 file system is a scalable extension of the ext3 file system. It can support files and file systems up to 16 terabytes in size. It also supports an unlimited number of sub-directories (the ext3 file system only supports up to 32,000), though once the link count exceeds 65,000 it resets to 1 and is no longer increased. Ext4 uses extents (as opposed to the traditional block mapping scheme used by ext2 and ext3), which improves performance when using large files and reduces metadata overhead for large files. [Read More]

Grep command to find your files

Preface grep command syntax redirect output using pipe Regex patterns using -E Preface One of the most useful and versatile commands in a Linux terminal environment is the “grep” command. The name “grep” stands for “global regular expression print”. This means that grep can be used to see if the input it receives matches a specified pattern. This seemingly trivial program is extremely powerful when used correctly. Its ability to sort input based on complex rules makes it a popular link in many command chains. [Read More]

How to Check Meltdown CPU Vulnerability in Linux

Meltdown is a chip-level security vulnerability that breaks the most fundamental isolation between user programs and the operating system. It allows a program to access the operating system kernel’s and other programs’ private memory areas, and possibly steal sensitive data, such as passwords, crypto-keys and other secrets. spectre-meltdown-checker is a simple shell script to check if your Linux system is vulnerable against the 3 “speculative execution” CVEs (Common Vulnerabilities and Exposures) that were made public early this year. [Read More]