major overhaul of the manage app's api-documentation functions.

things can now be rendered to static html, new helma features are
supported (prototype extension), everyhting is done in a nice and
clean way with skins.
This commit is contained in:
stefanp 2002-11-21 18:36:03 +00:00
parent 76bbe4053b
commit 7633e98eea
59 changed files with 1052 additions and 578 deletions

View file

@ -35,27 +35,50 @@ function countSessions_macro(par) {
/**
* macro returning the total number of sessions on this server
* macro returning the number of requests during the last 5 minutes
* @see global.formatCount
*/
function countRequests_macro(par) {
if ( app.requestStat==null ) {
function requestCount_macro(par) {
if (app.data.stat==null) {
return;
}
var arr = this.getApplications();
var arr = this.getApplications ();
var sum = 0;
for ( var i=0; i<arr.length; i++ ) {
if ( arr[i].getName()!=app.__app__.getName() ) {
var obj = app.requestStat.get(arr[i].name);
for (var i=0; i<arr.length; i++) {
if (arr[i].getName() != app.__app__.getName() ) { // don't include manage app
var obj = app.data.stat.get (arr[i].name);
if ( obj!=null ) {
sum += obj.last5Min;
sum += obj.requestCount;
}
}
}
return sum + formatCount(sum,par);
return sum + formatCount (sum,par);
}
/**
* macro returning the number of errors during the last 5 minutes
* @see global.formatCount
*/
function errorCount_macro(par) {
if (app.data.stat==null) {
return;
}
var arr = this.getApplications ();
var sum = 0;
for (var i=0; i<arr.length; i++) {
if (arr[i].getName() != app.__app__.getName() ) { // don't include manage app
var obj = app.data.stat.get (arr[i].name);
if ( obj!=null ) {
sum += obj.errorCount;
}
}
}
return sum + formatCount (sum,par);
}
function extensions_macro (par) {
var vec = this.getExtensions ();
var str = "";
@ -65,7 +88,7 @@ function extensions_macro (par) {
str += (par && par.separator) ? par.separator : ", ";
}
}
return str;
return (str=="") ? null : str;
}
/**
@ -163,28 +186,31 @@ function home_macro() {
/**
* Macro that returns the free memory in the java virtual machine
* @param format if "hr", value will be printed human readable
*/
function jvmFreeMemory_macro() {
var m = java.lang.Runtime.getRuntime().freeMemory();
return formatBytes(m);
function jvmFreeMemory_macro (param) {
var m = java.lang.Runtime.getRuntime ().freeMemory ();
return (param && param.hr) ? formatBytes (m) : m;
}
/**
* Macro that returns the total memory available to the java virtual machine
* @param format if "hr", value will be printed human readable
*/
function jvmTotalMemory_macro() {
function jvmTotalMemory_macro (param) {
var m = java.lang.Runtime.getRuntime().totalMemory();
return formatBytes(m);
return (param && param.hr) ? formatBytes (m) : m;
}
/**
* Macro that returns the used memory in the java virtual machine
* @param format if "hr", value will be printed human readable
*/
function jvmUsedMemory_macro() {
var m = java.lang.Runtime.getRuntime().totalMemory() - java.lang.Runtime.getRuntime().freeMemory();
return formatBytes(m);
function jvmUsedMemory_macro(param) {
var m = java.lang.Runtime.getRuntime ().totalMemory () - java.lang.Runtime.getRuntime ().freeMemory ();
return (param && param.hr) ? formatBytes (m) : m;
}

View file

@ -7,35 +7,40 @@
</tr>
<tr>
<td class="list_property" align="right" width="200">uptime:</td>
<td class="list_property">uptime:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.uptime %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200">version:</td>
<td class="list_property">version:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.version %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200">homedir:</td>
<td class="list_property">homedir:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.home %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200" valign="top">total active sessions:</td>
<td class="list_property" valign="top">total active sessions:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.countSessions default="&nbsp;" %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200" valign="top">total requests / 5 min:</td>
<td class="list_property" nowrap valign="top">total requests / 5 min:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.countRequests default="&nbsp;" %></td>
<td class="list_property" align="left"><% this.requestCount default="&nbsp;" %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200" valign="top">loaded extensions:</td>
<td class="list_property" norwrap valign="top">total errors / 5 min:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.errorCount default="&nbsp;" %></td>
</tr>
<tr>
<td class="list_property" valign="top">loaded extensions:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.extensions default="&nbsp;" %></td>
</tr>
@ -45,51 +50,51 @@
</tr>
<tr>
<td class="list_property" align="right" width="200">free memory:</td>
<td class="list_property">free memory:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.jvmFreeMemory %></td>
<td class="list_property" align="left"><% this.jvmFreeMemory hr="true" %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200">used memory:</td>
<td class="list_property">used memory:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.jvmUsedMemory %></td>
<td class="list_property" align="left"><% this.jvmUsedMemory hr="true" %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200">total memory:</td>
<td class="list_property">total memory:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.jvmTotalMemory %></td>
<td class="list_property" align="left"><% this.jvmTotalMemory hr="true" %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200">java:</td>
<td class="list_property">java:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.jvm %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200">javahome:</td>
<td class="list_property">javahome:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.jvmHome %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200">os:</td>
<td class="list_property">os:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.os %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200">localtime:</td>
<td class="list_property">localtime:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% now %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200" valign="top">timezone:</td>
<td class="list_property" valign="top">timezone:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.timezone %></td>
</tr>
<tr>
<td class="list_property" align="right" width="200" valign="top">loaded Jars:</td>
<td class="list_property" valign="top">loaded Jars:</td>
<td class="list_property" width="5">&nbsp;</td>
<td class="list_property" align="left"><% this.jvmJars %></td>
</tr>
@ -98,7 +103,7 @@
<td class="list_separator" colspan="3">server.properties</td>
</tr>
<% this.properties itemprefix='<tr><td class="list_property" align="right" width="200">' separator='</td><td class="list_property" width="5">&nbsp;</td><td class="list_property" align="left">' itemsuffix='</td></tr>' %>
<% this.properties itemprefix='<tr><td class="list_property">' separator='</td><td class="list_property" width="5">&nbsp;</td><td class="list_property" align="left">' itemsuffix='</td></tr>' %>
</table>

View file

@ -1,11 +1,12 @@
// strictly limit access to localhost:
if ( req.data.http_remotehost!="localhost" && req.data.http_remotehost!="127.0.0.1" ) {
app.__app__.logEvent( req.data.http_remotehost + " tried to access makekey");
return;
}
//// strictly limit access to localhost:
//if ( req.data.http_remotehost!="localhost" && req.data.http_remotehost!="127.0.0.1" ) {
// app.logEvent( req.data.http_remotehost + " tried to access makekey");
// return;
//}
if ( checkAuth()==false ) return;
if ( checkAuth()==false )
return;
createAuth();

37
Root/mrtg.hac Normal file
View file

@ -0,0 +1,37 @@
/**
* prints server-stats for mrtg-tool.
* doesn't check username or password, so that we don't have
* to write them cleartext in a mrtg-configfile but checks the
* remote address.
*/
if ( checkAddress()==false )
return;
if (req.data.action=="memory") {
res.write (this.jvmTotalMemory_macro () + "\n");
res.write (this.jvmFreeMemory_macro () + "\n");
res.write ("0\n0\n");
} else if (req.data.action=="netstat" && isLinux ()) {
var str = (new File("/proc/net/tcp")).readAll();
var arr = str.split("\n");
res.write (arr.length-2 + "\n");
res.write ("0\n0\n0\n");
} else if (req.data.action=="loadavg" && isLinux ()) {
// load average of last 5 minutes:
var str = (new File("/proc/loadavg")).readAll();
var arr = str.split(" ");
res.write (arr[1]*100 + "\n");
res.write ("0\n0\n0\n");
} else {
res.write ( "0\n0\n0\n0\n");
}