changeset 27:22a701699b2a

add Disk.jtp
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 02 Jul 2020 16:00:09 -0600
parents 0c48ede1829a
children 03e68185c2f5
files src/nabble/view/web/tools/Disk.java src/nabble/view/web/tools/Disk.jtp src/nabble/view/web/tools/Index.java src/nabble/view/web/tools/Index.jtp
diffstat 4 files changed, 60 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
diff -r 0c48ede1829a -r 22a701699b2a src/nabble/view/web/tools/Disk.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/nabble/view/web/tools/Disk.java	Thu Jul 02 16:00:09 2020 -0600
@@ -0,0 +1,29 @@
+
+package nabble.view.web.tools;
+
+import java.io.InputStream;
+import java.io.IOException;
+import javax.servlet.ServletException;
+import java.io.PrintWriter;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import fschmidt.util.java.IoUtils;
+
+
+public final class Disk extends HttpServlet {
+
+	protected void service(HttpServletRequest request,HttpServletResponse response)
+		throws ServletException, IOException
+	{
+		response.setContentType("text/plain");
+		PrintWriter out = response.getWriter();
+		Process process = Runtime.getRuntime().exec("df -h");
+		InputStream input = process.getInputStream();
+		byte[] result = IoUtils.readAll(input);
+		input.close();
+		String s = new String(result);
+		out.write(s);
+	}
+}
+
diff -r 0c48ede1829a -r 22a701699b2a src/nabble/view/web/tools/Disk.jtp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/nabble/view/web/tools/Disk.jtp	Thu Jul 02 16:00:09 2020 -0600
@@ -0,0 +1,29 @@
+<%
+package nabble.view.web.tools;
+
+import java.io.InputStream;
+import java.io.IOException;
+import javax.servlet.ServletException;
+import java.io.PrintWriter;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import fschmidt.util.java.IoUtils;
+
+
+public final class Disk extends HttpServlet {
+
+	protected void service(HttpServletRequest request,HttpServletResponse response)
+		throws ServletException, IOException
+	{
+		response.setContentType("text/plain");
+		PrintWriter out = response.getWriter();
+		Process process = Runtime.getRuntime().exec("df -h");
+		InputStream input = process.getInputStream();
+		byte[] result = IoUtils.readAll(input);
+		input.close();
+		String s = new String(result);
+		out.write(s);
+	}
+}
+%>
diff -r 0c48ede1829a -r 22a701699b2a src/nabble/view/web/tools/Index.java
--- a/src/nabble/view/web/tools/Index.java	Mon Jun 29 14:41:15 2020 -0600
+++ b/src/nabble/view/web/tools/Index.java	Thu Jul 02 16:00:09 2020 -0600
@@ -90,7 +90,7 @@
 		
 		out.print( "\r\n<html>\r\n	<head>\r\n		<title>Nabble tools</title>\r\n		<style type=\"text/css\">\r\n			.gray {\r\n				background-color: #eeeeee;\r\n				padding: .5em;\r\n			}\r\n			p { padding-left: .5em; }\r\n			td.row-label {\r\n				font-weight:bold;\r\n				padding: .1em .4em .1em 0;\r\n			}\r\n			td.row-separator { padding-top: 1em; }\r\n\r\n			td.category {\r\n				font-variant:small-caps;\r\n				text-align:center;\r\n				padding: 0 .5em;\r\n			}\r\n		</style>\r\n		<script type=\"text/javascript\">\r\n			var months = [\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"];\r\n			function fmt(i) { return i <= 9? \"0\" + i : i; };\r\n			function formatTime(date) {\r\n				var hours = date.getHours();\r\n				if( hours < 12 ) {\r\n					var xm = \"am\";\r\n					if (hours==0)\r\n						hours = 12;\r\n				} else {\r\n					var xm = \"pm\";\r\n					if (hours > 12)\r\n						hours -= 12;\r\n				}\r\n				return fmt(hours) + \":\" + fmt(date.getMinutes()) + xm;\r\n			};\r\n			function formatDate(date) {\r\n				return months[date.getMonth()] + \" \" + fmt(date.getDate()) + \", \" + date.getFullYear();\r\n			};\r\n			function formatDateTime(date) {\r\n				return formatDate(date) + \"; \" + formatTime(date);\r\n			};\r\n		</script>\r\n	</head>\r\n	<body style=\"font: .8em Verdana, Serif;\">\r\n		<p class=\"gray\">\r\n			Built time =\r\n			<b>\r\n			<script type=\"text/javascript\">\r\n				document.write(formatDateTime(new Date(" );
 		out.print( (new Date(ClassLoader.getSystemResource("nabble/view/web/Index.class").openConnection().getLastModified()).getTime()) );
-		out.print( ")));\r\n			</script>\r\n			</b>\r\n		</p>\r\n\r\n		<table style=\"font-size: 1em;\">\r\n			<tr>\r\n				<td class=\"category\" style=\"background-color:#fafafa;\">General</td>\r\n				<td style=\"padding:.5em 0\">\r\n					<p><a href=\"Admin.jtp\">Caches</a></p>\r\n					<p><a href=\"shell.luan\">Shell</a> (<a href=\"ShellHelp.jtp\">\r\n						<small>help</small>\r\n					</a>)\r\n					</p>\r\n					<p><a href=\"run.luan\">Run Batch</a></p>\r\n					<p><a href=\"SendMail.jtp\">Send mail</a></p>\r\n				</td>\r\n			</tr>\r\n			<tr>\r\n				<td class=\"category\" style=\"background-color:#e0e0e0;\">Sites</td>\r\n				<td style=\"padding:.5em 0\">\r\n					<p><a href=\"AdminNotice.jtp\">Administrator Notice</a></p>\r\n				</td>\r\n			</tr>\r\n			<tr>\r\n				<td class=\"category\" style=\"background-color:#d9d9d9;\">Others</td>\r\n				<td style=\"padding:.5em 0\">\r\n					<p><a href=\"TestMacro.jtp\">Test Macro</a></p>\r\n					<p><a href=\"Profile.jtp\">Profiling</a></p>\r\n					<p><a href=\"/tools2\">Generic tools</a></p>\r\n					<p><a href=\"OnlineUsers.jtp\">Online Users</a></p>\r\n				</td>\r\n			</tr>\r\n		</table>\r\n\r\n		<div class=\"gray\" style=\"margin: 1em 0\">\r\n			<table style=\"font-size:100%\">\r\n				<tr>\r\n					<td class=\"row-label\">Free Memory</td>\r\n					<td>\r\n						" );
+		out.print( ")));\r\n			</script>\r\n			</b>\r\n		</p>\r\n\r\n		<table style=\"font-size: 1em;\">\r\n			<tr>\r\n				<td class=\"category\" style=\"background-color:#fafafa;\">General</td>\r\n				<td style=\"padding:.5em 0\">\r\n					<p><a href=\"Admin.jtp\">Caches</a></p>\r\n					<p><a href=\"shell.luan\">Shell</a> (<a href=\"ShellHelp.jtp\">\r\n						<small>help</small>\r\n					</a>)\r\n					</p>\r\n					<p><a href=\"run.luan\">Run Batch</a></p>\r\n					<p><a href=\"SendMail.jtp\">Send mail</a></p>\r\n					<p><a href=\"Disk.jtp\">Disks</a></p>\r\n				</td>\r\n			</tr>\r\n			<tr>\r\n				<td class=\"category\" style=\"background-color:#e0e0e0;\">Sites</td>\r\n				<td style=\"padding:.5em 0\">\r\n					<p><a href=\"AdminNotice.jtp\">Administrator Notice</a></p>\r\n				</td>\r\n			</tr>\r\n			<tr>\r\n				<td class=\"category\" style=\"background-color:#d9d9d9;\">Others</td>\r\n				<td style=\"padding:.5em 0\">\r\n					<p><a href=\"TestMacro.jtp\">Test Macro</a></p>\r\n					<p><a href=\"Profile.jtp\">Profiling</a></p>\r\n					<p><a href=\"/tools2\">Generic tools</a></p>\r\n					<p><a href=\"OnlineUsers.jtp\">Online Users</a></p>\r\n				</td>\r\n			</tr>\r\n		</table>\r\n\r\n		<div class=\"gray\" style=\"margin: 1em 0\">\r\n			<table style=\"font-size:100%\">\r\n				<tr>\r\n					<td class=\"row-label\">Free Memory</td>\r\n					<td>\r\n						" );
 		out.print( (String.format("%.2f",free)) );
 		out.print( " Mb\r\n					</td>\r\n				</tr>\r\n				<tr>\r\n					<td class=\"row-label\">Used Memory</td>\r\n					<td>" );
 		out.print( (String.format("%.2f",used)) );
diff -r 0c48ede1829a -r 22a701699b2a src/nabble/view/web/tools/Index.jtp
--- a/src/nabble/view/web/tools/Index.jtp	Mon Jun 29 14:41:15 2020 -0600
+++ b/src/nabble/view/web/tools/Index.jtp	Thu Jul 02 16:00:09 2020 -0600
@@ -154,6 +154,7 @@
 							</p>
 							<p><a href="run.luan">Run Batch</a></p>
 							<p><a href="SendMail.jtp">Send mail</a></p>
+							<p><a href="Disk.jtp">Disks</a></p>
 						</td>
 					</tr>
 					<tr>