General Actions:
Log-in
Register
Wiki:
games
▼
:
Document Index
»
Space:
Admin
▼
:
Document Index
»
Page:
CheckXWikiConfig
Search
en
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
WebHome
»
XWiki and MySQL Configuration Check
»
XWiki Configuration Check
Wiki source code of
XWiki Configuration Check
Last modified by
Administrator
on 2010/09/22 19:05
Content
·
Comments
(0)
·
Annotations
(0)
·
Attachments
(0)
·
History
·
Information
Hide line numbers
1: = XWiki Configuration Check = 2: 3: {{groovy}} 4: import com.xpn.xwiki.util.Util; 5: // 6: // 7: // Sets the tomcat path to use 8: // 9: // 10: def appserverpath = ".." 11: // 12: // 13: // 14: 15: def printCacheMaxNodes(message, cache, wiki) { 16: def evictionregionconfig = wiki.getPrivateField(cache,"jbosscacheConfiguration").getJBossCacheConfiguration().getEvictionConfig().getEvictionRegionConfig("/") 17: def maxnodes = (evictionregionconfig==null) ? null : evictionregionconfig.getEvictionAlgorithmConfig().getMaxNodes() 18: println "* {{velocity filter="none"}} 19: ${message}: ${maxnodes}" 20: } 21: 22: def wiki = context.getContext().getWiki() 23: if (wiki!=null) { 24: println "1.1 Memory Configuration" 25: 26: println "This lists the memory settings of the Java VM and the current memory usage. An XWiki instance should be installed with at least 300Mb. A large one with at least 700Mb, especially if the cache settings are boosted. If after *flushing the cache*, the current free memory is low and the current total close to the maximum the instance might be running out of memory. " 27: println "* Max Memory: ${wiki.maxMemory()}" 28: println "* Current Total: ${wiki.totalMemory()}" 29: println "* Current Free: ${wiki.freeMemory()}" 30: 31: println "1.1 Database configuration" 32: 33: println "This lists the database settings of the Java VM and the current pool usage. An XWiki instance is set by default to 2 connections in the pool, which is ok for a very small instance. A large one with at least 10 or 20. If there is no activiy on the server, the active setting should be zero." 34: def provider = wiki.getStore().getStore().sessionFactory.connectionProvider 35: def ds = wiki.getPrivateField(provider,"ds") 36: def pool = wiki.getPrivateField(ds,"connectionPool") 37: 38: println "* Max Active (number of possible connections to the DB): $pool.maxActive" 39: println "* Max Idle (number of possible idle connections to the DB): $pool.maxIdle" 40: println "* Active (current active connections to the DB): $pool.numActive" 41: println "* Idle (current idle connections to the DB): $pool.numIdle" 42: 43: println "1.1 Cache configuration" 44: 45: println "This lists the main cache settings. An XWiki instance is set by default to 100 for the main cache which is ok for a small instance. A large one with at least 1000 (large XE) to 3000 (very large XE or large XEM). The page exist cache is set by default to 10000 which is good for any instance size." 46: 47: printCacheMaxNodes("Store Cache Eviction Policy Max nodes", wiki.store.cache, wiki) 48: printCacheMaxNodes("Store Page Cache Eviction Policy Max nodes", wiki.store.pageExistCache, wiki) 49: } 50: 51: println "1.1 Encoding Configuration" 52: 53: println "This lists ALL the encoding configuration of tomcat, xwiki, java. All should return UTF-8 except mail.mime.charset which can also return null (the file.encoding config will then be used)" 54: 55: def getEnvVars() { 56: Process p = null; 57: Properties envVars = new Properties(); 58: Runtime r = Runtime.getRuntime(); 59: String OS = System.getProperty("os.name").toLowerCase(); 60: // System.out.println(OS); 61: if (OS.indexOf("windows 9") > -1) { 62: p = r.exec( "command.com /c set" ); 63: } 64: else if ( (OS.indexOf("nt") > -1) 65: || (OS.indexOf("windows 2000") > -1 ) 66: || (OS.indexOf("windows xp") > -1) ) { 67: // thanks to JuanFran for the xp fix! 68: p = r.exec( "cmd.exe /c set" ); 69: } 70: else { 71: // our last hope, we assume Unix (thanks to H. Ware for the fix) 72: p = r.exec( "env" ); 73: } 74: BufferedReader br = new BufferedReader 75: ( new InputStreamReader( p.getInputStream() ) ); 76: String line; 77: while( (line = br.readLine()) != null ) { 78: int idx = line.indexOf( '=' ); 79: String key = line.substring( 0, idx ); 80: String value = line.substring( idx+1 ); 81: envVars.setProperty( key, value ); 82: // System.out.println( key + " = " + value ); 83: } 84: return envVars; 85: } 86: 87: 88: println "1.1.1 System environment" 89: 90: def envvars = getEnvVars(); 91: def lang = envvars.get("LANG") 92: println "* LANG: ${lang}" 93: 94: 95: println "1.1.1 Java command line" 96: 97: def fileenc = System.getProperty("file.encoding") 98: println "* file.encoding: ${fileenc}" 99: def mimecharset = System.getProperty("mail.mime.charset") 100: println "* mail.mime.charset: ${mimecharset}" 101: 102: def tomcatconffile = new File("${appserverpath}/conf/server.xml") 103: if (tomcatconffile.exists()) { 104: def node = new XmlParser().parse(tomcatconffile) 105: 106: println "1.1.1 Tomcat configuration" 107: for (connector in node.Service.Connector) { 108: urienc = connector.'@URIEncoding' 109: prot = connector.'@protocol' 110: println "* Procotol ${prot} has encoding ${urienc}" 111: } 112: } else { 113: println "The tomcat configuration file could not be found. You might not be using tomcat or the app server path (appserverpath) variable need to be set (you can edit the page to set it)" 114: } 115: 116: println "1.1.1 XWiki Configuration" 117: 118: def xwikicfgdir = new File("${appserverpath}/webapps/xwiki/WEB-INF/xwiki.cfg") 119: if (xwikicfgdir.exists()) { 120: def content = Util.getFileContent(xwikicfgdir) 121: def is = new ByteArrayInputStream(content.getBytes()); 122: def props = new Properties(); 123: props.load(is); 124: 125: println "* XWiki encoding: ${props.get("xwiki.encoding")}"; 126: } else { 127: println "The XWiki configuration file could not be found. The app server path (appserverpath) variable need to be set (you can edit the page to set it)" 128: } 129: 130: 131: println "1.1.1 XWiki web.xml" 132: 133: def xwikiwebxml = new File("${appserverpath}/webapps/xwiki/WEB-INF/web.xml") 134: 135: if (xwikiwebxml.exists()) { 136: def wnode = new XmlParser().parse(xwikiwebxml) 137: def found = false; 138: for (filter in wnode.filter) { 139: def filterclass = filter.'filter-class' 140: if (filterclass.text().equals("com.xpn.xwiki.web.SetCharacterEncodingFilter")) { 141: for (initparam in filter.'init-param') { 142: def paramname = initparam.'param-name'.text(); 143: def paramvalue = initparam.'param-value'.text(); 144: if (paramname=="encoding") { 145: println "* web.xml encoding: ${paramvalue} 146: {{/velocity}}" 147: found = true 148: } 149: } 150: } 151: } 152: if (found==false) { 153: println "The web.xml encoding param could not be found" 154: } 155: } else { 156: println "The XWiki web.xml could not be found. The app server path (appserverpath) variable need to be set (you can edit the page to set it)" 157: } 158: {{/groovy}}