#!/usr/bin/ruby -w =begin the mount point is the 2nd column(#1 starting from 0) for rclocal the mount point is the 7th column(#6 starting from 0) for fstab Right now we are searching for /nfs|smbfs|cifs|cvfs/ in fstab and all mounts in rclocal. If we add new filesystems, we will need to modify the script. =end require 'socket' #global variables begin with '$' $proc_mounts = File.open("/proc/mounts", "r").readlines $missing_mount = "su" #local variables fstab = File.open("/etc/fstab", "r").readlines rclocal = File.open("/etc/rc.local", "r").readlines def search_file (source_file, target_regex, col) for line in source_file unless /^#/ =~ line if(target_regex =~ line) src_file_elements = line.split() for rec in $proc_mounts was_found = false unless was_found == true rec.chomp! junk, mount_point, more_junk = rec.split if mount_point == src_file_elements[col] was_found = true break end end end if was_found == false $missing_mount = src_file_elements[col] end end end end end #main search_file(fstab, /nfs|smbfs|cifs|cvfs/, 1) search_file(rclocal, /^mount/, 6) if ($missing_mount.length > 3) puts "****Warning - " + $missing_mount + " does not seem to be mounted on " + Socket.gethostbyname(Socket.gethostname).first + ". Please check all mounts." exit(2) else puts "No missing mounts" exit(0) end