Friday, February 19, 2010

Tell Whether fsck Is About to Check A Filesystem

How can one determine if a disk will be fsck'd at next boot? Basically, use tune2fs. Here's a potentially useful script. We probably also want to know which filesystems are set to never notify. That information is not captured in this script. This type of data will help when planning downtimes.


# intervalwarn sets the number of seconds prior to the check interval that we would like to be notified
# a setting of zero will only warn when the interval has actually been exceeded
# the notification will not be worded properly for values > 0
# mountwarn defines how many mounts before maxmounts we would like to be notified

# notice is the message that will be sent if fsck is imminent
notice="Notice: fsck will automatically check /$dev if remounted (or upon server reboot).  Use tune2fs for details."
# noticesubject is the short description (or subject line) of the notice
noticesubject="impending fsck notice"

for dev in $(fsck -AN|sed "s/.* \///"|grep dev)

  # will it fsck on remount/reboot due to unchecked mounts exceeding the max mounts setting?
  maxmountcount=$(tune2fs -l /$dev |grep "^Maximum mount count:"|sed -r 's/^.* ([0-9\-]*)$/\1/')
  mountcount=$(tune2fs -l /$dev |grep "^Mount count:"|sed -r 's/^.* ([0-9]*)$/\1/')
  let mountdiff=$maxmountcount-$mountcount
  if [["$mountdiff == "1"]]
  then #do stuff like set a factor fact or this:

  # will it fsck on remount/reboot due to the time since the last mount?
  # the "Next check after:" field will not be present if "Check interval" is 0
  # (i.e. don't use that field in a script)
  lastcheck=$(tune2fs -l /$dev |grep "^Last checked:"|sed -r 's/^.*d:(.*)$/\1/')
  lastchecksecs=$(date -d "$lastchecked" +%s)
  checkinterval=$(tune2fs -l /$dev |grep "^Check interval:"|sed -r 's/^.*l:(.*)\(.*$/\1/')
  curdate=$(date +%s)
  let secsleft=$curdate-$checkinterval
  if [[ "$secsleft" <= "$intervalwarn" ]]
  then # do stuff like set a factor fact or this:


# send a notice
if [[ "$notify" == "true" ]]
  echo $notice | /bin/mail -s "$noticesubject" root

Thursday, February 18, 2010

Configuring Screen for Multiple Remote Sessions

I typically SSH to a single machine at work which serves as a Basion Host. From there, I log into various machines inside the network. Screen allows me to have my sessions persist between logins to the bastion host. Typically, only the process name is shown in the "<ctrl>+a+<">" list of screens. This .screenrc allows me to see the hosts to which I've connected. It doesn't work well for Solaris hosts, though.

windowlist title "Num Hardstatus %80=Title%=Flags"
windowlist string "%3n %h %80=%t%=%f"
shelltitle '$ |bash:'

Screenshot of the 'screens' list

Wednesday, February 17, 2010

Oracle Calendar on 64-bit Ubuntu Karmic


mkdir lib32
cd lib32
dpkg -X libstdc++5_3.3.6-17ubuntu1_i386.deb
mv usr/lib/ to ./
rm -r usr *.deb
cd ..
mkdir lib
dpkg -X libstdc++5_3.3.6-17ubuntu1_amd64.deb
mv usr/lib/ to ./
rm -r usr *.deb
cd ..
mkdir lib
download the oracle calendar client from Oracle or Sitesoft
tar xzvf $thepackage
export LD_LIBRARY_PATH=$HOME/lib:$HOME/lib32
cd OracleCalendar_inst
sudo ./
  • install to /usr/local/lib/oraclecalendar
  • link to /usr/local/lib

To run the app

export LD_LIBRARY_PATH=$HOME/lib:$HOME/lib32

A script to for a menu launcher

  • create the following script somewhere and chmod 755
export LD_LIBRARY_PATH=$HOME/lib:$HOME/lib32
  • Use "System->Preferences->Main Menu" to create a menu item for the script