#!/usr/bin/perl ### ### The following sript will check if the system has the correct defination ### for Daylight Saving Time. The start of Daylight saving time has changed ### to the second Sunday in March starting in 2007. ### ### The script displays the time before and after the switch to Daylight ### saving time. The Time zone name should change, for example CDT to CST. ### The script has been tested on Solaris, Red Hat and AIX. ### ### Original posted on: ### http://blight.ca/twiki/bin/view/Notes/CheckDaylightSaving ### ### ### Update (02/21/2007): ### ### This script works great on all of my SunFire v240s and also on our ### SunFire E25k domains; however, it displays the error message on a ### SunFire v210 even though the changes have taken effect. ### ### I contacted Sun Support initially and they had me run a few commands ### to check if the changes were made: ### ### zdump -v US/Eastern | grep 2007 ### zdump -v EST5EDT | grep 2007 ### ### You can change them for each timezone. For example: ### zdump -v US/pacific | grep 2007 ### zdump -v PST5PDT | grep 2007 ### use POSIX qw/mktime strftime/; $before = mktime( 59, 59, 1, 11, 2, 107 ); $after = $before + 1; $s_before = localtime( $before ); $s_after = localtime( $after ); $zone_before = strftime "%Z", localtime( $before ); $zone_after = strftime "%Z", localtime( $after ); if( $ARGV[0] =~ /-v/ ) { print "\nTest if new timezone definitions are current for standard and\n"; print "daylight saving. Starting in 2007 it should switch on second\n"; print "Sunday in March, not April in most locations in North America\n\n"; print "$s_before $zone_before and 1 second later its $s_after $zone_after\n\n"; $os = `uname -s`; chop( $os ); if( $os eq "SunOS" ) { $x = `echo \$TZ`; print "local TZ environment variable: $x\n"; system( "ls -al /etc/TIMEZONE" ); system( "ls -al /etc/default/init" ); system( "cat /etc/default/init" ); } elsif( $os eq "Linux" ) { system( "ls -al /etc/sysconfig/clock" ); system( "cat /etc/sysconfig/clock" ); } elsif( $os eq "AIX" ) { $x = `echo \$TZ`; print "local TZ environment variable: $x\n"; system( "ls -al ls /etc/environment" ); system( "grep \"TZ=\" /etc/environment" ); } print "\n"; } ### Output print "\n\n\n\n\n"; if ( $zone_before ne $zone_after ) { print "timezones standard/daylight saving time test out okay\n"; } else { print "**** Error ****** \n"; print "TimeZone standard/daylight saving time doesn't test out okay\n"; } ############################################################################## ### This script is submitted to BigAdmin by a user of the BigAdmin community. ### Sun Microsystems, Inc. is not responsible for the ### contents or the code enclosed. ### ### ### Copyright 2008 Sun Microsystems, Inc. ALL RIGHTS RESERVED ### Use of this software is authorized pursuant to the ### terms of the license found at ### http://www.sun.com/bigadmin/common/berkeley_license.html ##############################################################################