Nagios/Bash – Example Script to Submit Passive Checks

submit_passive_check.sh – Contains functions to easily submit passive Nagios checks.  Very useful for servers that cannot run the NRPE agent.  The only external requirements are curl, awk, and grep which are installed by default on the majority of Linux based distros (ie: CheckPoint Gaia, F5, etc).  A simple example of checking the current CPU load […]

Read More →
Command Line Parsing in Bash Scripts

Simple example of parsing the command line in a bash script:

 

Read More →
Open MAN page in Gnome Yelp if an X Session is Running

Toss this in your ~/.bashrc to use the Gnome Yelp help viewer to open a man page.  This replaces the man command with a function and only uses the CLI version of man if there’s no running X session.

If an X session is running it instead opens the man page in Yelp as […]

Read More →
Trimming Whitespace in BASH

This function will trim leading and trailing tab and space characters from a string:

 

Read More →
UTF-8 Box Character Fix

This addresses issues displaying box/line drawing characters in PuTTY. In your PuTTY session settings go to Window -> Translation. Change the Remote character set to UTF-8. On your linux box open ~/.bash_profile with your favorite editor. At the bottom add “export NCURSES_NO_UTF8_ACS=1” without quotes. Save and exit. For the change to take place in your […]

Read More →
LVM – Resize and Create New Logical ext4 Volume

In this example I shrink the /home volume and create a new volume for /opt. Be sure to backup your data!! If you resize the volume you’re shrinking to less than the amount of data you have on it data WILL be destroyed!

 

Read More →
FHS – Filesystem Hierarchy Standard

Directory Purpose / Root directory of the entire file system hierarchy /bin Essential command binaries (all users) /boot Boot loader files. /dev Device Files /etc Host specific system wide configuration files /home Users home directories /lib Libraries essential for /bin and /sbin /media Mount points for removable media /mnt Temporary mounted file systems /opt Optional […]

Read More →
dmidecode

  DMI Keywords keyword types included bios 0, 13 system 1, 12, 15, 23, 32 baseboard 2, 10 chassis 3 processor 4 memory 5, 6, 16, 17 cache 7 connector 8 slot 9   DMI Types 0 BIOS 1 System 2 Base Board 3 Chassis 4 Processor 5 Memory Controller 6 Memory Module 7 […]

Read More →
Formatting With the date Command

Syntax:

    How do I save time/date format to a variable?

    %FORMAT String Description %% a literal % %a locale’s abbreviated weekday name (e.g., Sun) %A locale’s full weekday name (e.g., Sunday) %b locale’s abbreviated month name (e.g., Jan) %B locale’s full month name (e.g., January) %c locale’s date and […]

Read More →
crontab Format

[user] is only valid in the global crontab. It is not an option for individual user crontabs. Day of week: Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday 0 1 2 3 4 5 6 7   Format + Examples: Min Hour Day of Month Month Day of Week [user] Command #comment 02 14 * […]

Read More →