Welcome, guest | Sign In | My Account | Store | Cart

CloudScape - get network server runtime info.

Tcl, 150 lines
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
@echo off

setlocal

echo ###################################################
echo # Get Cloudscape runtime info on %computername%
echo ###################################################

set CLASSPATH=%CLASSPATH%;d:\IBM\Cloudscape_10.1\lib\derby.jar
set CLASSPATH=%CLASSPATH%;d:\IBM\Cloudscape_10.1\lib\derbyclient.jar
set CLASSPATH=%CLASSPATH%;d:\IBM\Cloudscape_10.1\lib\derbynet.jar
set CLASSPATH=%CLASSPATH%;d:\IBM\Cloudscape_10.1\lib\derbytools.jar

set logFileDir=D:\CloudscapeDatabases\trace

d:\tclBlendSun\bin\jtclsh.bat D:\scripts\TCL\JACL\cloudscape\getRunTimeInfo.tcl %logFileDir%

endlocal

==========================================================================

# 
# get cloudscape runtime info on local host.

####################################################################
# Patrick Finnegan 24/11/2005.  V1. 
####################################################################

puts "\n **** executing [info script] **** \n"

# make script drive independent.

set drive [lindex [file split [info script]] 0 ] 

puts "\n proclib = $drive/scripts/TCL/proclib"

source $drive/scripts/TCL/proclib/checkFile_proc.tcl
source $drive/scripts/TCL/proclib/smtp_proc.tcl
source $drive/scripts/TCL/proclib/reportHeader_proc.tcl

####################################################################
# Get Cloudscape connection.
####################################################################
proc runtimeInfo { } {

   puts "\n**********"
   puts "runtimeInfo"
   puts "**********\n"

   global env 
   global null

   set hostName [ lindex [ array get env COMPUTERNAME ] 1 ]
   #set hostAddress [ java::call InetAddress getByName $hostName ]
   set hostAddress [ java::call InetAddress getByName "0.0.0.0" ]

   if { [ catch { java::new NetworkServerControl $hostAddress 1527 } r ] == 0 } {
   
        set NetworkServerControl $r 

   } else {

        return -code error $r

   }

   puts "\nget runtime info\n" 

   if { [ catch { $NetworkServerControl getRuntimeInfo } r ] == 0 } {

          puts  $r 

   } else {

        return -code error $r

   } 

   return $r

}
####################################################################
# Main Control.
####################################################################

puts "\n argc = $argc \n"

if {$argc < 1} {
        return -code error "\nerror - not enough arguments supplied.\nSupply log directory."
}

set computerName  $::env(COMPUTERNAME)
set traceDir      [ lindex $argv 0 ]
set traceFile     [ file join $traceDir runTimeInfo\.txt ]
set traceFileId   [ open $traceFile  w ]

set body         $traceFile

checkFile $traceDir

set header   "$computerName: get Cloudscape runtime info."
reportHeader $traceFileId $header $traceFile

set computerTime [clock format [clock seconds] -format "%d-%m-%Y %H.%M.%S"]

puts "tracefile = $traceFile" 

#call java package 

package require java

# import required classes 

java::import java.net.InetAddress
java::import org.apache.derby.drda.NetworkServerControl

puts "\nimported classes are:\n"

foreach i [java::import] {
   
  puts [ format "%-5s %-50s" " " $i ] 

}

set null [ java::null ]

if { [ catch { runtimeInfo } r ] == 0 } {

     lappend msg "\n********* Cloudscape Runtime Info *********\n"
     lappend msg $r

} else {

     lappend msg "\n********* Cloudscape Runtime Info Failed *********\n"
     lappend msg $r

} 

foreach i $msg {

    puts $i
    puts $traceFileId $i

}

close $traceFileId

set subject       "$computerName: Cloudscape Runtime Info."
set emailAddress  you@yourmail.com
sendSimpleMessage $emailAddress $subject $body

This script uses the Cloudscape Java API to get the runtime info for a Cloudscape network server.

Requires Tclblend.

Tclblend: http://tcljava.sourceforge.net/docs/website/index.html. Tclblend Windows Build Instructions: http://wiki.tcl.tk/9993

Created by Patrick Finnegan on Wed, 7 Dec 2005 (MIT)
Tcl recipes (162)
Patrick Finnegan's recipes (56)

Required Modules

  • (none specified)

Other Information and Tasks