Wednesday, 17 September 2014

How To : Install Linux Kernel 3.16.3 in Ubuntu/Linux Mint Systems

    The Linux Kernel 3.16.3 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. This article will guide you to install or upgrade to Linux Kernel 3.16.3 in your Ubuntu or Linux Mint system.


Installation

For 32-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.3-utopic/linux-headers-3.16.3-031603_3.16.3-031603.201409171435_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.3-utopic/linux-headers-3.16.3-031603-generic_3.16.3-031603.201409171435_i386.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.3-utopic/linux-image-3.16.3-031603-generic_3.16.3-031603.201409171435_i386.deb
Install them.

$ sudo dpkg -i linux-headers-3.16.3*.deb linux-image-3.16.3*.deb
Reboot the system.

sudo reboot

For 64-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.3-utopic/linux-headers-3.16.3-031603_3.16.3-031603.201409171435_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.3-utopic/linux-headers-3.16.3-031603-generic_3.16.3-031603.201409171435_amd64.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.3-utopic/linux-image-3.16.3-031603-generic_3.16.3-031603.201409171435_amd64.deb
Install them.

$ sudo dpkg -i linux-headers-3.16.3*.deb linux-image-3.16.3*.deb
Reboot the system.

sudo reboot

To uninstall,

sudo apt-get remove linux-headers-3.16.3* linux-image-3.16.3*

Nagios XI: A Bash Plugin to Monitor Load Average on Remote Linux Server

  • This is a plugin designed using Bash script.
  • This plugin is created so that 'Performance Gauges' in Nagios XI work properly, showing appropriate 'Warning' and 'Critical' regions.

See Also: How To : Create Nagios Plugin Using a BASH Script




For Performance Gauges to show details properly, performance data should be in following format:

'VarName'=CurrentValue Unit;WarningValue;CriticalValue;MininumValue;MaximumValue

Important:

1. It uses the output of 'uptime' command.
2. Warning and Critical thresholds are 80% and 90% of the total number of processor cores.
For Ex: If you are using 16 core processor, Warning threshold will be 80% of 16 i.e. '12.8' and Critical threshold will be 90% of 16 i.e. '14.4'
3. If the calculated value, may it be 1 min load, 5 min load or 15 min load, exceeds the thresholds, status will be set accordingly (OK, WARNING or CRITICAL).

Script:


#!/bin/bash

UPTIME=`uptime`
load1=`echo $UPTIME | awk -F, '{print $4}' | cut -d: -f 2 | xargs`
load5=`echo $UPTIME | awk -F, '{print $5}' | xargs`
load15=`echo $UPTIME | awk -F, '{print $6}' | xargs`

intload1=`echo "scale=1; $load1*100" | bc -l | cut -d "." -f 1`
intload5=`echo "scale=1; $load5*100" | bc -l | cut -d "." -f 1`
intload15=`echo "scale=1; $load15*100" | bc -l | cut -d "." -f 1`

Nprocs=`grep "processor" /proc/cpuinfo | wc -l`

wthreshold=80
cthreshold=90

warn=`scale=1; echo "$wthreshold * $Nprocs" | bc -l | cut -d "." -f 1`
crit=`scale=1; echo "$cthreshold * $Nprocs" | bc -l | cut -d "." -f 1`

actwarn=`echo "scale=1; $warn/100" | bc -l`
actcrit=`echo "scale=1; $crit/100" | bc -l`

if [ "$intload1" -le "$warn"  -a  "$intload5" -le "$warn"  -a  "$intload15" -le "$warn" ]
then
        STATUS="OK"
        EXIT="0"
elif [ "$intload1" -gt "$warn" -o "$intload5" -gt "$warn" -o "$intload15" -gt "$warn" ]
then
        if [ "$intload1" -gt "$crit" -o "$intload5" -gt "$crit" -o "$intload15" -gt "$crit" ]
        then
        STATUS="CRITICAL"
        EXIT="2"
        else
        STATUS="WARNING"
        EXIT="1"
        fi
else
STATUS="UNKNOWN"
EXIT="3"
fi

if [ $STATUS = "UNKNOWN" ]
then
echo "$STATUS- No data" && exit $EXIT
else
echo "$STATUS- Load Average: $load1, $load5, $load15 | load1=$load1;$actwarn;$actcrit;; load5=$load5;$actwarn;$actcrit;; load15=$load15;$actwarn;$actcrit;;"

How To Use:

To monitor remote Linux server:
1. Keep the plugin in /usr/local/nagios/libexec directory.
2. Add following line to the nrpe.cfg file:

command[check_loadaverage.sh]=sudo /usr/local/nagios/libexec/check_loadaverage.sh
3. Add the following line to /etc/sudoers file:

nagios ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/check_loadaverage.sh

Usage:

On Monitoring Server:

./check_nrpe -H 128.9.45.13 -c check_loadavg.sh
Output:

OK- Load Average: 0.09, 0.05, 0.01 | load1=0.09;6.4;7.2;; load5=0.05;6.4;7.2;; load15=0.01;6.4;7.2;;

Tuesday, 16 September 2014

How To : Install/Upgrade to Linux Kernel 3.17-RC5 in Ubuntu/Linux Mint Systems

    The Linux Kernel 3.17-RC5 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. This article will guide you to install or upgrade to Linux Kernel 3.17-RC5 in your Ubuntu or Linux Mint system.


Installation

For 32-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc5-utopic/linux-headers-3.17.0-031700rc5_3.17.0-031700rc5.201409151105_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc5-utopic/linux-headers-3.17.0-031700rc5-generic_3.17.0-031700rc5.201409151105_i386.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc5-utopic/linux-image-3.17.0-031700rc5-generic_3.17.0-031700rc5.201409151105_i386.deb
Install them.

$ sudo dpkg -i linux-headers-3.17*.deb linux-image-3.17*.deb
Reboot the system.

sudo reboot

For 64-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc5-utopic/linux-headers-3.17.0-031700rc5_3.17.0-031700rc5.201409151105_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc5-utopic/linux-headers-3.17.0-031700rc5-generic_3.17.0-031700rc5.201409151105_amd64.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc5-utopic/linux-image-3.17.0-031700rc5-generic_3.17.0-031700rc5.201409151105_amd64.deb
Install them.

$ sudo dpkg -i linux-headers-3.17*.deb linux-image-3.17*.deb
Reboot the system.

sudo reboot

To uninstall,

sudo apt-get remove linux-headers-3.17* linux-image-3.17*

Sunday, 7 September 2014

How To : Install/Upgrade to Linux Kernel 3.17-RC4 in Ubuntu/Linux Mint Systems

    The Linux Kernel 3.17-RC4 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. This article will guide you to install or upgrade to Linux Kernel 3.17-RC4 in your Ubuntu or Linux Mint system.


Installation

For 32-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc4-utopic/linux-headers-3.17.0-031700rc4_3.17.0-031700rc4.201409071935_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc4-utopic/linux-headers-3.17.0-031700rc4-generic_3.17.0-031700rc4.201409071935_i386.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc4-utopic/linux-image-3.17.0-031700rc4-generic_3.17.0-031700rc4.201409071935_i386.deb
Install them.

$ sudo dpkg -i linux-headers-3.17*.deb linux-image-3.17*.deb
Reboot the system.

sudo reboot

For 64-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc4-utopic/linux-headers-3.17.0-031700rc4_3.17.0-031700rc4.201409071935_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc4-utopic/linux-headers-3.17.0-031700rc4-generic_3.17.0-031700rc4.201409071935_amd64.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc4-utopic/linux-image-3.17.0-031700rc4-generic_3.17.0-031700rc4.201409071935_amd64.deb
Install them.

$ sudo dpkg -i linux-headers-3.17*.deb linux-image-3.17*.deb
Reboot the system.

sudo reboot

To uninstall,

sudo apt-get remove linux-headers-3.17* linux-image-3.17*

Saturday, 6 September 2014

How To : Install AMD Catalyst™ Radeon R9 285 14.30 Graphics Driver in Linux


Linux Distributions Supported

  • Red Hat Enterprise Linux Suite 6.4 and 6.5
  • SUSE® Linux Enterprise 11 SP3
  • OpenSUSE 13.1
  • Ubuntu 12.04 and above

Installation

Download the package from the Source

Unzip the file.

$ unzip ~/Downloads/amd-radeon-r9-285-linux-14.30.1005-aug29.zip
Make the file executable.

$ cd fglrx*

$ sudo chmod +x amd-driver-installer*.run
End the graphic session with the appropriate command from the list of commands given below:

# For Ubuntu LightDM [DEFAULT]
$ sudo service lightdm stop

#For Gnome GDM
$ sudo service gdm stop

#For Linux Mint MDM
$ sudo service mdm stop
Run the executable.

$ sudo ./amd-driver-installer*.run
Start the graphic session with the appropriate command from the list of commands given below:

# For Ubuntu LightDM [DEFAULT]
$ sudo service lightdm start

#For Gnome GDM
$ sudo service gdm start

#For Linux Mint MDM
$ sudo service mdm start

A Bash Script to Install/Upgrade to Linux Kernel 3.16.2 in Linux Systems

The Linux Kernel 3.16.2 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. The following BASH script, when executed, despite of the system architecture (valid only for i386, i686 and x86_64 based systems), installs Linux kernel 3.16.2 in your Linux systems.



Note: Make sure that you execute this script as a ROOT user.

Usage:

./script_name.sh
Script:

#!/bin/sh

# Check if the user is ROOT
if [ $(id -u) -ne 0 ]
then
    echo "You are not ROOT! Please login as ROOT."
    exit
fi

# Latest Available Kernel version
LatestKernel="3.16.2-031602-generic"

# Required Packages
Headers_All="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-headers-3.16.2-031602_3.16.2-031602.201409052035_all.deb"
Headers_i386="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-headers-3.16.2-031602-generic_3.16.2-031602.201409052035_i386.deb"
Image_i386="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-image-3.16.2-031602-generic_3.16.2-031602.201409052035_i386.deb"
Headers_amd64="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-headers-3.16.2-031602-generic_3.16.2-031602.201409052035_amd64.deb"
Image_amd64="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-image-3.16.2-031602-generic_3.16.2-031602.201409052035_amd64.deb"

# Debian Packages
DEB="linux-headers-3.16.2*.deb linux-image-3.16.2*.deb"

# Currently Installed Kernel Version
CurrentKernel_release=$(uname -r) 

# System Architecture
SystemArch=$(uname -i)

# Check if System already has latest kernel installed
if [ "$CurrentKernel" = "$LatestKernel" ]
then
    echo "Wow! Your System is Already Updated to Latest Available Kernel Version!"
    echo "Program will now exit..."
    sleep 2s
    exit
fi

# If latest kernel is not available, then check the system architecture and download necessary packages

# For 32-bit Systems

if [ $SystemArch = "i386" ] || [ $SystemArch = "i686" ]
then

    echo "Kernel upgrade process for 32-bit systems will now start..."
    sleep 2s
    echo "Downloading required packages.."
    sleep 2s

    wget $Headers_All
    wget $Headers_i386
    wget $Image_i386

    echo "Download process completed. Packages are present in $(pwd) directory"
    sleep 2s

    echo "Installing the packages..."
    dpkg -i $DEB

# For 64-bit Systems
elif [ $SystemArch = "x86_64" ]
then
    echo "Kernel upgrade process for 64-bit systems will now start..." 
    sleep 2s

    wget $Headers_All
    wget $Headers_amd64
    wget $Image_amd64

    echo "Download process completed. Packages are present in $(pwd) directory"
    sleep 2s

    echo "Installing the packages..."
    dpkg -i $DEB

# If system architecture is not compatible
else
    echo "Packages for following system architecture not found :  $SystemArch"
    echo "Program will now exit..."
    sleep 2s
exit
fi

    echo "Your system has been successfully upgraded to latest kernel version $(LatestKernel)."
    echo "System will now reboot."
    sleep 5s
    shutdown -r now
NOTE: Above script worked perfectly on my i386 system. I need confirmation from i686 and x86_64 users, if it works fine for them. Please suggest any changes to be incorporated.

Friday, 5 September 2014

How To : Install Linux Kernel 3.16.2 in Ubuntu/Linux Mint Systems

    The Linux Kernel 3.16.2 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. This article will guide you to install or upgrade to Linux Kernel 3.16.2 in your Ubuntu or Linux Mint system.



Installation

For 32-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-headers-3.16.2-031602_3.16.2-031602.201409052035_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-headers-3.16.2-031602-generic_3.16.2-031602.201409052035_i386.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-image-3.16.2-031602-generic_3.16.2-031602.201409052035_i386.deb
Install them.

$ sudo dpkg -i linux-headers-3.16.2*.deb linux-image-3.16.2*.deb
Reboot the system.

sudo reboot

For 64-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-headers-3.16.2-031602_3.16.2-031602.201409052035_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-headers-3.16.2-031602-generic_3.16.2-031602.201409052035_amd64.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16.2-utopic/linux-image-3.16.2-031602-generic_3.16.2-031602.201409052035_amd64.deb
Install them.

$ sudo dpkg -i linux-headers-3.16.2*.deb linux-image-3.16.2*.deb
Reboot the system.

sudo reboot

To uninstall,

sudo apt-get remove linux-headers-3.16.2* linux-image-3.16.2*

Monday, 1 September 2014

FUSER Command in Linux

FUSER is a Linux command that enlists all the processes which  are using a particular file/directory. Not only the processes, the details about the owner of the process, the Access Type and the PID (Process ID) are also provided.



In most of the articles on Linux Commands, I have quoted that "The most basic use of any command is when it is executed without any arguments". Lets check if it is true in the case of fuser:

mandar@LinuxBox:~$ fuser
No process specification given
Usage: fuser [-fMuv] [-a|-s] [-4|-6] [-c|-m|-n SPACE] [-k [-i] [-SIGNAL]] NAME...
       fuser -l
       fuser -V
Show which processes use the named files, sockets, or filesystems.

  -a,--all              display unused files too
  -i,--interactive      ask before killing (ignored without -k)
  -k,--kill             kill processes accessing the named file
  -l,--list-signals     list available signal names
  -m,--mount            show all processes using the named filesystems or block device
  -M,--ismountpoint     fulfill request only if NAME is a mount point
  -n,--namespace SPACE  search in this name space (file, udp, or tcp)
  -s,--silent           silent operation
  -SIGNAL               send this signal instead of SIGKILL
  -u,--user             display user IDs
  -v,--verbose          verbose output
  -w,--writeonly        kill only processes with write access
  -V,--version          display version information
  -4,--ipv4             search IPv4 sockets only
  -6,--ipv6             search IPv6 sockets only
  -                     reset options

  udp/tcp names: [local_port][,[rmt_host][,[rmt_port]]]
No, it needs an argument and all the available options are displayed before you. How to use them, lets see.

The most basic use of fuser command is to determine which processes are using a particular file/directory. In this case, just provide file/directory name as an argument to the fuser command.

fuser [FILE/DIRECTORY-NAME]
Example:
Lets see the processes that are using my 'home' directory:

mandar@LinuxBox:~$ fuser ~
/home/mandar:         1437c  1484c  1503c  1520c  1521c  1526c  1527c  1531c  1536c  1537c  1649c  1661c  1679c  1682c  1797c  1819c  1875c  1938c  2461c
So, here is the list of PIDs. But what about that extra 'c' character?

The 'c' character indicates the Access type, and there are several types of access, which are:
  • c - Current Directory
  • e - Executable
  • f - Open file for reading
  • F - Open file for writing
  • r - Root directory
  • m - Memory Mapped File/Directory
So, if we wish to check for the root directory, the output would look like:

mandar@LinuxBox:~$ fuser /
/:                    1437r  1475rc  1476rc  1484r  1495rc  1497rc  1503r  1512rc  1517rc  1519rc  1520r  1521r  1526r  1527r  1529rc  1531r  1536r  1537r  1547rc  1556rc  1560rc  1565rc  1570rc  1577rc  1584rc  1586rc  1588rc  1590rc  1593rc  1595rc  1597rc  1627rc  1647rc  1649r  1661r  1669rc  1679r  1682r  1684rc  1691rc  1696rc  1701rc  1710rc  1715rc  1718rc  1719rc  1721rc  1766rc  1794rc  1797r  1819r  1875r  1938r  2461r  2477rc  2991rc
Above commands will just display PIDs and Access types of the processes, for more detailed version, you can use option -v as follows:

mandar@LinuxBox:/$ fuser -v ~
                     USER        PID ACCESS COMMAND
/home/mandar:        mandar     1437 ..c.. gnome-session
                     mandar     1484 ..c.. gnome-settings-
                     mandar     1503 ..c.. metacity
                     mandar     1520 ..c.. unity-2d-panel
                     mandar     1521 ..c.. unity-2d-shell
                     mandar     1526 ..c.. nm-applet
                     mandar     1527 ..c.. gnome-fallback-
                     mandar     1531 ..c.. polkit-gnome-au
                     mandar     1536 ..c.. nautilus
                     mandar     1537 ..c.. bluetooth-apple
                     mandar     1649 ..c.. gdu-notificatio
                     mandar     1661 ..c.. telepathy-indic
                     mandar     1679 ..c.. gnome-screensav
                     mandar     1682 ..c.. zeitgeist-datah
                     mandar     1797 ..c.. gnome-terminal
                     mandar     1875 ..c.. update-notifier
                     mandar     1938 ..c.. deja-dup-monito
                     mandar     2461 ..c.. firefox
Another use of fuser is to show the processes using a particular TCP/UDP socket. To create a process that listens to TCP port 8080, netcat command can be executed as follows:

mandar@LinuxBox:~$ nc -l localhost 8080 &
[1] 4421
Now, let us execute fuser with option -n as follows:

mandar@LinuxBox:/$ fuser -v -n tcp 8080
                     USER        PID ACCESS COMMAND
8080/tcp:            mandar     4421 F.... nc
You can easily verify the output looking at the PID of the listed process.

Now, in order to kill this TCP listener, you can use option -k. When this option -k is used along with option -i, it will as you for the confirmation before directly killing the process. Here is the example:

mandar@LinuxBox:~$ fuser -i -k 8080/tcp
8080/tcp:             4421
Kill process 4421 ? (y/N) y
[1]+  Killed                  nc -l localhost 8080
If you don't use option -i, the case would be as follows:

mandar@LinuxBox:~$ fuser -k 8080/tcp
8080/tcp:             4421
[1]+  Killed                  nc -l localhost 8080
Apart from the KILL signal, you can send variety of signals that can be listed using option -l as follows:

mandar@LinuxBox:~$ fuser -l
HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM
STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH IO PWR SYS
UNUSED
So, in order to STOP a process, you would execute:

mandar@LinuxBox:~$ fuser -i -k STOP [FILE/DIRECTORY]
This will ask for your confirmation before deleting each process using the File/Directory Name specified.

Sunday, 31 August 2014

How To : Install/Upgrade to Linux Kernel 3.17-RC3 in Ubuntu/Linux Mint Systems

    The Linux Kernel 3.17-RC3 is now available for the users, announced Linus Torvalds. This Linux Kernel version comes with plenty of fixes and improvements. This article will guide you to install or upgrade to Linux Kernel 3.17-RC3 in your Ubuntu or Linux Mint system.


Installation

For 32-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc3-utopic/linux-headers-3.17.0-031700rc3_3.17.0-031700rc3.201409031132_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc3-utopic/linux-headers-3.17.0-031700rc3-generic_3.17.0-031700rc3.201409031132_i386.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc3-utopic/linux-image-3.17.0-031700rc3-generic_3.17.0-031700rc3.201409031132_i386.deb
Install them.

$ sudo dpkg -i linux-headers-3.17*.deb linux-image-3.17*.deb
Reboot the system.

sudo reboot

For 64-Bit Systems

Download the .deb packages.

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc3-utopic/linux-headers-3.17.0-031700rc3_3.17.0-031700rc3.201409031132_all.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc3-utopic/linux-headers-3.17.0-031700rc3-generic_3.17.0-031700rc3.201409031132_amd64.deb

$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17-rc3-utopic/linux-image-3.17.0-031700rc3-generic_3.17.0-031700rc3.201409031132_amd64.deb
Install them.

$ sudo dpkg -i linux-headers-3.17*.deb linux-image-3.17*.deb
Reboot the system.

sudo reboot

To uninstall,

sudo apt-get remove linux-headers-3.17* linux-image-3.17*

    Total Pageviews