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.

#!/bin/sh

# 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
intervalwarn=0
# mountwarn defines how many mounts before maxmounts we would like to be notified
mountwarn=1

# 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)
do

  # 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:
    notify=true
  fi

  # 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:
    notify=true
  fi

done

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

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

Installation

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

To run the app

export LD_LIBRARY_PATH=$HOME/lib:$HOME/lib32
/usr/local/bin/ocal

A script to for a menu launcher

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

References

http://hsmak.wordpress.com/2009/12/01/how-to-fix-libstdc5-dependency-problem-in-ubuntu-9-10/
http://prowiki.isc.upenn.edu/wiki/Oracle_Calendar_Desktop_Client_for_Linux