Ещё несколько скриптов Jython для просмотра и массового редактирования настроек Java Vitrual Machine на серверах приложений WebSphere. Скрипты работают с такими параметрами, как Heap size и Verbose GC, но при желании вы можете легко адаптировать их для своих целей – при условии, что вы знаете, как узнать название необходимого вам параметра.
1. Просмотр параметров Heap size:
# Выдает heap size Java Virtual Machine на всех серверах в ячейке.
import sys
import java
lineSeparator = java.lang.System.getProperty('line.separator')
servers = AdminConfig.list('Server')
servers = servers.split(lineSeparator)
for server in servers:
serverName = AdminConfig.showAttribute(server,"name")
if (serverName != 'nodeagent') & (serverName != 'dmgr'):
jvm = AdminConfig.list('JavaVirtualMachine',server)
heapMin = AdminConfig.showAttribute(jvm,'initialHeapSize')
heapMax = AdminConfig.showAttribute(jvm,'maximumHeapSize')
print serverName +'\t'+ heapMin +'\t'+ heapMax
import sys
import java
lineSeparator = java.lang.System.getProperty('line.separator')
servers = AdminConfig.list('Server')
servers = servers.split(lineSeparator)
for server in servers:
serverName = AdminConfig.showAttribute(server,"name")
if (serverName != 'nodeagent') & (serverName != 'dmgr'):
jvm = AdminConfig.list('JavaVirtualMachine',server)
heapMin = AdminConfig.showAttribute(jvm,'initialHeapSize')
heapMax = AdminConfig.showAttribute(jvm,'maximumHeapSize')
print serverName +'\t'+ heapMin +'\t'+ heapMax
2. Изменение Heap size:
# Модифицирует heap size Java Virtual Machine на всех серверах в ячейке.
import sys
import java
heapSetMin = '512'
heapSetMax = '1024'
lineSeparator = java.lang.System.getProperty('line.separator')
servers = AdminConfig.list('Server')
servers = servers.split(lineSeparator)
for server in servers:
serverName = AdminConfig.showAttribute(server,"name")
if (serverName != 'nodeagent') & (serverName != 'dmgr'):
jvm = AdminConfig.list('JavaVirtualMachine',server)
AdminConfig.modify(jvm,[['initialHeapSize',heapSetMin], ['maximumHeapSize',heapSetMax]])
heapMin = AdminConfig.showAttribute(jvm,'initialHeapSize')
heapMax = AdminConfig.showAttribute(jvm,'maximumHeapSize')
print serverName +'\t'+ heapMin +'\t'+ heapMax
AdminConfig.save()
import sys
import java
heapSetMin = '512'
heapSetMax = '1024'
lineSeparator = java.lang.System.getProperty('line.separator')
servers = AdminConfig.list('Server')
servers = servers.split(lineSeparator)
for server in servers:
serverName = AdminConfig.showAttribute(server,"name")
if (serverName != 'nodeagent') & (serverName != 'dmgr'):
jvm = AdminConfig.list('JavaVirtualMachine',server)
AdminConfig.modify(jvm,[['initialHeapSize',heapSetMin], ['maximumHeapSize',heapSetMax]])
heapMin = AdminConfig.showAttribute(jvm,'initialHeapSize')
heapMax = AdminConfig.showAttribute(jvm,'maximumHeapSize')
print serverName +'\t'+ heapMin +'\t'+ heapMax
AdminConfig.save()
3. Просмотр настройки Verbose garbage collection:
# Выдает heap size Java Virtual Machine на всех серверах в ячейке.
import sys
import java
lineSeparator = java.lang.System.getProperty('line.separator')
servers = AdminConfig.list('Server')
servers = servers.split(lineSeparator)
for server in servers:
serverName = AdminConfig.showAttribute(server,"name")
if (serverName != 'nodeagent') & (serverName != 'dmgr'):
jvm = AdminConfig.list('JavaVirtualMachine',server)
gc = AdminConfig.showAttribute(jvm,'verboseModeGarbageCollection')
print serverName +'\t'+ gc
import sys
import java
lineSeparator = java.lang.System.getProperty('line.separator')
servers = AdminConfig.list('Server')
servers = servers.split(lineSeparator)
for server in servers:
serverName = AdminConfig.showAttribute(server,"name")
if (serverName != 'nodeagent') & (serverName != 'dmgr'):
jvm = AdminConfig.list('JavaVirtualMachine',server)
gc = AdminConfig.showAttribute(jvm,'verboseModeGarbageCollection')
print serverName +'\t'+ gc
4. Изменение настройки Verbose GC:
# Выдает heap size Java Virtual Machine на всех серверах в ячейке.
import sys
import java
lineSeparator = java.lang.System.getProperty('line.separator')
servers = AdminConfig.list('Server')
servers = servers.split(lineSeparator)
for server in servers:
serverName = AdminConfig.showAttribute(server,"name")
if (serverName != 'nodeagent') & (serverName != 'dmgr'):
jvm = AdminConfig.list('JavaVirtualMachine',server)
gc = AdminConfig.showAttribute(jvm,'verboseModeGarbageCollection')
print serverName +'\t'+ gc
if gc == 'false':
print "Setting Verbose GC to true"
print AdminConfig.modify(jvm, [['verboseModeGarbageCollection','true']])
gc = AdminConfig.showAttribute(jvm,'verboseModeGarbageCollection')
print serverName +'\t'+ gc
AdminConfig.save()
import sys
import java
lineSeparator = java.lang.System.getProperty('line.separator')
servers = AdminConfig.list('Server')
servers = servers.split(lineSeparator)
for server in servers:
serverName = AdminConfig.showAttribute(server,"name")
if (serverName != 'nodeagent') & (serverName != 'dmgr'):
jvm = AdminConfig.list('JavaVirtualMachine',server)
gc = AdminConfig.showAttribute(jvm,'verboseModeGarbageCollection')
print serverName +'\t'+ gc
if gc == 'false':
print "Setting Verbose GC to true"
print AdminConfig.modify(jvm, [['verboseModeGarbageCollection','true']])
gc = AdminConfig.showAttribute(jvm,'verboseModeGarbageCollection')
print serverName +'\t'+ gc
AdminConfig.save()