Thursday, January 22, 2009

Nagios Plugin to check file age on remote machine

You have to have a user account on the remote machine with ssh public and private key setup so that nagios user can login with our a password. The time is in seconds.

Nagios Command definition is as follows


define command{
command_name check_remote_fileage
command_line $USER1$/check_remote_fileage -H user@$HOSTADDRESS$ -f $ARG1$ -w $ARG2$ -c $ARG3$
}



Script


#!/bin/bash
if (( $# < 8 )); then
echo "Usage: $0 -H hostname -f remote file path -w warn -c crit"
exit 3
fi

while getopts "H:f:w:c:" OPT; do
case "$OPT" in
H) HOST=$OPTARG
;;
f) File=$OPTARG
;;
w) w=$OPTARG
;;
c) c=$OPTARG
;;
\?) echo "Error"
exit 3;
;;
esac
done

CURRTIME=$(ssh $HOST "perl -e 'print time;'")
FILETIME=$(ssh $HOST "perl -e 'printf "%d\n", ((stat(shift))[9]);' $File")
let "DIFFTIME = CURRTIME - FILETIME"
if (( $DIFFTIME >= $w && $DIFFTIME < $c)) ; then
echo "WARNING: $File is $DIFFTIME sec old (threshold w= $w) "
exit 1
elif (( $DIFFTIME >= $c)) ;then
echo "CRITICAL: $File is $DIFFTIME sec old (threshold c= $c) "
exit 2;
else
echo "OK: $File is with in threshold $w / $c "
exit 0
fi

Friday, September 5, 2008

NetBackup Activity Monitor

At my work during project Go Live! sessions I am often asked for the status of the scheduled backup which end early in the morning on weekends. I hate to wake up early on weekends so this is a nice little thing I do to achieve the task while I am sleeping. 

I found neat little perl script which uses the following two tools from netbackup to give a nicely formatted output in email. The tools are bpdbjobs which lists the list of jobs performed and bperror which gives you the status of the job. 

Click here for the original post and script. 

Now once you have the script which sends an email, all I have to do is set an at job to execute the script at the time the user wants the status of the backup. 

Google Chrome Froze

After using Google chrome [BETA] for couple of days, the much hyped sandboxing failed today for me. While browsing a site with flash plugin, the browser froze, it was unresponsive. Their feature of being able to close bad tabs failed as I was not able to get the Task manager from the browser itself. I opened up Task manager to see bunch of chrome.exe processes. I assumed the one which takes up the maximum memory to be the actual browser itself and the rest as tabs and started killing each one of them until the browser is responsive again, but by that time I have lost all the other tabs I was browsing.
This could have happened as plugins themselves are run as separate process. A small widget or a program which runs outside of the browser that works the same way as the task manager for google chrome would be useful in this scenario as you could just fire up the second program to identify and kill the troubling process, just a thought.

Monday, July 21, 2008

IE bug or feature?

I have recently noticed the following behavior testing IE. Here is an explanation on what is happening

Steps
1. Start IE and look at the task manager to see how much memory is being used.
(Observation): iexplore.exe starts with some memory X MB.
2. Start a new window by clicking File-->New Window check the memory.
(Observation): The iexplore.exe process increases by 2-3 MB in memory usage total X+2MB
3. Now Start IE by double clicking the shortcut or the iexplore.exe directly.
(Observation): You will find a new iexplore.exe process running with X MB
4. Repeat step 3 multiple times.
(Observation): New iexplore.exe processes start with X MB of memory.

Now for the Bug or Feature discussion.
Advantages
Lets look at what we can achieve with this behavior.
When started using step 3 above each iexplore.exe has its own session. So you can have multiple sessions from a server with different useraccounts.
Ex: You can login as different users and check / complete your tasks in google.com all simultaneosly.
Disadvantages
Every time you start iexplore.exe the starting memory usage (X MB) is close to 10x more than opening a new window using step 2. Image why the computer is all slow all of a sudden if you are browing online.

Conclusion
Using firefox you share a session always across multiple browser windows does not depend on how you open a new browser window/tab. Now its upto you to decide whether this is a feature that MS gives its users or is it a bug they have been ignoring to fix.

Tuesday, July 8, 2008

Windows LPR on Unix

Solaris
From your Solaris system, do this (assumes printer IP is 192.168.1.99):

# lpadmin -p hp3200m -s 192.168.1.99 -I any

Type the following to set the default printer (assuming the printer is hp3200m):

# lpadmin -d hp3200m

You need to be sure that print services are started (/usr/lib/lpsched or the equivalent command using Service Management Facility [SMF] in the Solaris 10 OS).

BigAdmin

Linux
#lpadmin -p LinuxPrinterName -E -v lpd://IP_ADDRESS/WindowsPrinterName

Wednesday, July 2, 2008

AT related

Users can schedule jobs to be run at a future time using the at command and the usage is simple refer "man at". Now once the job is scheduled you can look at the jobs in the at queue using at -l or atq commands.

Once you get the queue to see what is present in the at job look in /var/spool/cron/atjobs/< job name>

Thursday, June 26, 2008

Install openoffice from yum

# yum groupinstall "Office/Productivity"