### set_HProf.jacl
###
###
###
###
###

proc set_HProf {cname nname sname} {

    global AdminConfig
    global AdminControl
    global AdminApp

    set serverid [$AdminConfig getid /Cell:$cname/Node:$nname/Server:$sname/]

    if {[llength $serverid] == 0} {
        puts "Serverid null - returning "
        exit
    }

    set jvm [$AdminConfig list JavaVirtualMachine $serverid]
    $AdminConfig modify $jvm  [list [list runHProf true ] [list hprofArguments "file=heapdump.txt"] ]
    $AdminConfig save

    set Sync1 [$AdminControl completeObjectName type=NodeSync,node=$nname,*]

    set xstatus [$AdminControl invoke $Sync1 sync]
    puts $xstatus

    if {$xstatus == "false"} {
        puts "Unable to synchronize..."
    }
}

###
### Main
###

if { !($argc == 3) } {
   puts ""
   puts "Usage:  "
   puts " "
   puts "wsadmin.sh -username system -password password -f set_HProf.jacl cellname nodename servername"
   puts ""
   puts "For example:  "
   puts " "
   puts "wsadmin.sh -username was -password notiv@ -f  set_HProf.jacl venusNetwork venus ops_1_1"
} else {
   set xcell        [lindex $argv 0]
   set xnode        [lindex $argv 1]
   set xserver      [lindex $argv 2]
   set_HProf $xcell $xnode $xserver
}