You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServerStatus.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright 2011 gitblit.com.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.gitblit.models;
  17. import java.io.Serializable;
  18. import java.util.Date;
  19. import java.util.Map;
  20. import java.util.TreeMap;
  21. import com.gitblit.Constants;
  22. /**
  23. * ServerStatus encapsulates runtime status information about the server
  24. * including some information about the system environment.
  25. *
  26. * @author James Moger
  27. *
  28. */
  29. public class ServerStatus implements Serializable {
  30. private static final long serialVersionUID = 1L;
  31. public final Date bootDate;
  32. public final String version;
  33. public final String releaseDate;
  34. public final boolean isGO;
  35. public final Map<String, String> systemProperties;
  36. public final long heapMaximum;
  37. public volatile long heapAllocated;
  38. public volatile long heapFree;
  39. public String servletContainer;
  40. public ServerStatus(boolean isGO) {
  41. this.bootDate = new Date();
  42. this.version = Constants.VERSION;
  43. this.releaseDate = Constants.VERSION_DATE;
  44. this.isGO = isGO;
  45. this.heapMaximum = Runtime.getRuntime().maxMemory();
  46. this.systemProperties = new TreeMap<String, String>();
  47. put("file.encoding");
  48. put("java.home");
  49. put("java.awt.headless");
  50. put("java.io.tmpdir");
  51. put("java.runtime.name");
  52. put("java.runtime.version");
  53. put("java.vendor");
  54. put("java.version");
  55. put("java.vm.info");
  56. put("java.vm.name");
  57. put("java.vm.vendor");
  58. put("java.vm.version");
  59. put("os.arch");
  60. put("os.name");
  61. put("os.version");
  62. }
  63. private void put(String key) {
  64. systemProperties.put(key, System.getProperty(key));
  65. }
  66. }