Author: Sahil Suri

Using ShellCheck to write better shell scripts

Introduction Over the course of the last couple of years we’ve written numerous posts on understanding and experimenting with different aspects of bash shell scripting. In this article we’ll focus on how we could improve our shell scripts and write better and more maintainable code using a tool named ShellCheck. ShellCheck is a static analysis tool written in hasekell programming language and is meant to analyse shell scripts written to use the bash and sh shells. ShellCheck is aimed at providing the following set of features: To point out and clarify typical beginner’s syntax issues that cause a shell to give cryptic error messages. To point out and clarify typical intermediate level semantic problems that cause a shell to behave strangely and counter-intuitively. To point out subtle caveats, corner cases and pitfalls that may cause an advanced user’s otherwise working script to fail under future circumstances.   Installing ShellCheck Installing ShellCheck is a failry straightforward process. On RHEL based systems, we first need to ensure that the EPEL repository is available before we install ShellCheck. [root@linuxnix ~]# yum install epel-release -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.usonyx.net * epel: mirrors.aliyun.com * extras: centos.usonyx.net * nux-dextop: mirror.li.nux.ro * updates: centos.usonyx.net epel/x86_64/primary | 3.5 MB 00:00:00 epel 12619/12619 Package epel-release-7-11.noarch already installed and latest version Nothing to do [root@linuxnix ~]# Now that we have confirmed that...

Read More

How to setup MRTG to monitor network traffic on a Centos 6 system

Introduction There is a plethora of open source monitoring tools available in today. Some of these tools monitor a wide variety of metrics while some others have the capability to monitor a particular set of metrics really well. In this article, we will be setting up a monitoring tool named MRTG(Multi Router Traffic Grapher). MRTG is a free and open source monitoring tool written in perl and is used to monitor the traffic load on network links. It generates HTML pages containing PNG images which provide a LIVE visual representation of this traffic. The graphical representation of the data makes it easier to interpret and take action if needed. It helps you trace and troubleshoot network anomalies like Network traffic spikes. MRTG works with all network devices that support SNMP protocol.  It monitors SNMP network devices and draws pretty pictures showing how much traffic has passed through each interface.  MRTG runs on Unix/Linux, Windows and Netware systems. Step 1: Install Prerequisites: MRTG requires the apache web server and SNMP packages to be installed on the target server. [root@linuxnix ~]# yum install httpd -y Loaded plugins: fastestmirror, presto Setting up Install Process Loading mirror speeds from cached hostfile * base: download.nus.edu.sg * extras: download.nus.edu.sg * updates: download.nus.edu.sg No package snmp available. No package snmpd available. Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-69.el6.centos will be installed --> Finished...

Read More

How to resume unfinished yum transactions in Linux

Introduction The yum package manager maintains a history of all yum based transactions i.e. software installation, update and removal operations. This history is kept in an sqlite database (rpmdb) which is available in the /var/lib/yum/history/ directory. The transaction history in the rpmdb can be queried via the yum history command. We would also like to point out that a log of package installs, updates and removals is maintained in a text file as well located at /var/log/yum.log. The file provides one line descriptions about the yum related actions that were performed. But a very interesting facet of the yum transaction history is that transactions can be repeated and reversed and also incomplete transactions can actually be resumed. In this article we’ll be focusing on how we could resume incomplete yum transactions and complete them to fruition.   Demonstration With a basic understanding of how yum transactions are maintained, let’s perform a practical demonstration of how we could resume an incomplete yum transaction. Consider the following operation, we are just installing the openssl package on our system. What if during the installation we loose our network connectivity. This is just a single package so repeating the installation isn’t challenging but if it were an entire system update then redoing the entire task from scratch would be tedious. To simulate an interruption I hit the ctrl+c key to stop the yum...

Read More

Over 16,000 readers, Get fresh content from “The Linux juggernaut”

Email Subscribe

ABOUT ME..!

My photo
My name is Surendra Kumar Anne. I hail from Vijayawada which is cultural capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. At present I work at Bank of America as Sr. Analyst Systems and Administration. You can contact me at surendra (@) linuxnix dot com.