001/*
002 * Copyright 2008-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2008-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2008-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.monitors;
037
038
039
040import java.util.ArrayList;
041import java.util.Collections;
042import java.util.LinkedHashMap;
043import java.util.List;
044import java.util.Map;
045
046import com.unboundid.ldap.sdk.Entry;
047import com.unboundid.util.NotMutable;
048import com.unboundid.util.NotNull;
049import com.unboundid.util.Nullable;
050import com.unboundid.util.StaticUtils;
051import com.unboundid.util.ThreadSafety;
052import com.unboundid.util.ThreadSafetyLevel;
053
054import static com.unboundid.ldap.sdk.unboundidds.monitors.MonitorMessages.*;
055
056
057
058/**
059 * This class defines a monitor entry that provides information about the system
060 * and JVM on which the Directory Server is running.
061 * <BR>
062 * <BLOCKQUOTE>
063 *   <B>NOTE:</B>  This class, and other classes within the
064 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
065 *   supported for use against Ping Identity, UnboundID, and
066 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
067 *   for proprietary functionality or for external specifications that are not
068 *   considered stable or mature enough to be guaranteed to work in an
069 *   interoperable way with other types of LDAP servers.
070 * </BLOCKQUOTE>
071 * <BR>
072 * The information that may be available includes:
073 * <UL>
074 *   <LI>The name of the operating system on which the server is running.</LI>
075 *   <LI>The number of CPUs available to the JVM.</LI>
076 *   <LI>The Java classpath in use by the server.</LI>
077 *   <LI>The amount of memory currently used by the JVM.</LI>
078 *   <LI>The maximum amount of memory that the JVM will be allowed to use.</LI>
079 *   <LI>The amount of memory held by the JVM that is marked as "free" and can
080 *       be used to allocate new objects.</LI>
081 *   <LI>The hostname for the underlying system.</LI>
082 *   <LI>The location in which the server is installed on the
083 *       underlying system.</LI>
084 *   <LI>The current working directory for the server process.</LI>
085 *   <LI>The path to the Java installation being used to run the server.</LI>
086 *   <LI>The vendor that provides the Java installation being used to run the
087 *       server.</LI>
088 *   <LI>The Java version string for the Java installation being used to run
089 *       the server.</LI>
090 *   <LI>The vendor that provides the JVM being used by the Java installation
091 *       being used to run the server.</LI>
092 *   <LI>The JVM version string for the Java installation being used to run the
093 *       server.</LI>
094 *   <LI>The JVM architecture data model (i.e., whether it is a 32-bit or 64-bit
095 *       JVM).</LI>
096 *   <LI>The arguments provided to the JVM when running the server.</LI>
097 * </UL>
098 * The server should present at most one system info monitor entry.  It can be
099 * retrieved using the {@link MonitorManager#getSystemInfoMonitorEntry} method.
100 * This entry provides specific methods for accessing this system information
101 * (e.g., the {@link SystemInfoMonitorEntry#getOperatingSystem}
102 * method can be used to retrieve the name of the operating system).
103 * Alternately, this information may be accessed using the generic API.  See the
104 * {@link MonitorManager} class documentation for an example that demonstrates
105 * the use of the generic API for accessing monitor data.
106 */
107@NotMutable()
108@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
109public final class SystemInfoMonitorEntry
110       extends MonitorEntry
111{
112  /**
113   * The structural object class used in system info monitor entries.
114   */
115  @NotNull static final String SYSTEM_INFO_MONITOR_OC =
116       "ds-system-info-monitor-entry";
117
118
119
120  /**
121   * The name of the attribute that provides the number of CPUs available to the
122   * JVM.
123   */
124  @NotNull private static final String ATTR_AVAILABLE_CPUS = "availableCPUs";
125
126
127
128  /**
129   * The name of the attribute that provides the server Java classpath.
130   */
131  @NotNull private static final String ATTR_CLASSPATH = "classPath";
132
133
134
135  /**
136   * The name of the attribute that provides the environment variables defined
137   * for the server process.
138   */
139  @NotNull private static final String ATTR_ENVIRONMENT_VARIABLE =
140       "environmentVariable";
141
142
143
144  /**
145   * The name of the attribute that provides the amount of free memory within
146   * the JVM.
147   */
148  @NotNull private static final String ATTR_FREE_MEMORY = "freeUsedMemory";
149
150
151
152  /**
153   * The name of the attribute that provides the system hostname.
154   */
155  @NotNull private static final String ATTR_HOSTNAME = "systemName";
156
157
158
159  /**
160   * The name of the attribute that provides the server instance root.
161   */
162  @NotNull private static final String ATTR_INSTANCE_ROOT = "instanceRoot";
163
164
165
166  /**
167   * The name of the attribute that provides the server Java home.
168   */
169  @NotNull private static final String ATTR_JAVA_HOME = "javaHome";
170
171
172
173  /**
174   * The name of the attribute that provides the server Java vendor.
175   */
176  @NotNull private static final String ATTR_JAVA_VENDOR = "javaVendor";
177
178
179
180  /**
181   * The name of the attribute that provides the server Java version.
182   */
183  @NotNull private static final String ATTR_JAVA_VERSION = "javaVersion";
184
185
186
187  /**
188   * The name of the attribute that provides the server JVM architecture (e.g.,
189   * 32-bit / 64-bit).
190   */
191  @NotNull private static final String ATTR_JVM_ARCHITECTURE =
192       "jvmArchitecture";
193
194
195
196  /**
197   * The name of the attribute that provides the set of arguments provided when
198   * starting the JVM.
199   */
200  @NotNull private static final String ATTR_JVM_ARGUMENTS = "jvmArguments";
201
202
203
204  /**
205   * The name of the attribute that provides the process ID of the JVM in which
206   * the server is running.
207   */
208  @NotNull private static final String ATTR_JVM_PID = "jvmPID";
209
210
211
212  /**
213   * The name of the attribute that provides the server JVM vendor.
214   */
215  @NotNull private static final String ATTR_JVM_VENDOR = "jvmVendor";
216
217
218
219  /**
220   * The name of the attribute that provides the server JVM version.
221   */
222  @NotNull private static final String ATTR_JVM_VERSION = "jvmVersion";
223
224
225
226  /**
227   * The name of the attribute that provides the maximum amount of memory
228   * available to the JVM.
229   */
230  @NotNull private static final String ATTR_MAX_MEMORY = "maxMemory";
231
232
233
234  /**
235   * The name of the attribute that provides information about the server's
236   * operating system.
237   */
238  @NotNull private static final String ATTR_OPERATING_SYSTEM =
239       "operatingSystem";
240
241
242
243  /**
244   * The name of the attribute that provides the name of the default SSL context
245   * protocol that has been selected by the server.
246   */
247  @NotNull private static final String ATTR_SSL_CONTEXT_PROTOCOL =
248       "sslContextProtocol";
249
250
251
252  /**
253   * The name of the attribute that provides the set of system properties
254   * defined in the JVM.
255   */
256  @NotNull private static final String ATTR_SYSTEM_PROPERTY = "systemProperty";
257
258
259
260  /**
261   * The name of the attribute that provides the amount of memory currently used
262   * by the JVM.
263   */
264  @NotNull private static final String ATTR_USED_MEMORY = "usedMemory";
265
266
267
268  /**
269   * The name of the attribute that provides the name of the user as whom the
270   * server is running.
271   */
272  @NotNull private static final String ATTR_USER_NAME = "userName";
273
274
275
276  /**
277   * The name of the attribute that provides the server working directory.
278   */
279  @NotNull private static final String ATTR_WORKING_DIRECTORY =
280       "workingDirectory";
281
282
283
284  /**
285   * The serial version UID for this serializable class.
286   */
287  private static final long serialVersionUID = 2709857663883498069L;
288
289
290
291  // The number of available CPUs.
292  @Nullable private final Long availableCPUs;
293
294  // The amount of free memory held by the JVM.
295  @Nullable private final Long freeMemory;
296
297  // The PID of the JVM in which the server is running.
298  @Nullable private final Long jvmPID;
299
300  // The maximum amount of memory the JVM can use.
301  @Nullable private final Long maxMemory;
302
303  // The amount of memory currently held by the JVM.
304  @Nullable private final Long usedMemory;
305
306  // The set of environment variables defined in the server process.
307  @NotNull private final Map<String,String> environmentVariables;
308
309  // The set of system properties defined in the JVM.
310  @NotNull private final Map<String,String> systemProperties;
311
312  // The server's classpath.
313  @Nullable private final String classpath;
314
315  // The server's hostname.
316  @Nullable private final String hostname;
317
318  // The path to the server instance root.
319  @Nullable private final String instanceRoot;
320
321  // The server's Java home.
322  @Nullable private final String javaHome;
323
324  // The server's Java vendor string.
325  @Nullable private final String javaVendor;
326
327  // The server's Java version string.
328  @Nullable private final String javaVersion;
329
330  // The server's JVM architecture.
331  @Nullable private final String jvmArchitecture;
332
333  // The set of arguments provided to the JVM.
334  @Nullable private final String jvmArguments;
335
336  // The server's JVM vendor string.
337  @Nullable private final String jvmVendor;
338
339  // The server's JVM version string.
340  @Nullable private final String jvmVersion;
341
342  // The name of the operating system on which the server is running.
343  @Nullable private final String operatingSystem;
344
345  // The name of the default SSL context protocol that has been selected by the
346  // server.
347  @Nullable private final String sslContextProtocol;
348
349  // The name of the user as whom the server is running.
350  @Nullable private final String userName;
351
352  // The path to the server's current working directory.
353  @Nullable private final String workingDirectory;
354
355
356
357  /**
358   * Creates a new system info monitor entry from the provided entry.
359   *
360   * @param  entry  The entry to be parsed as a system info monitor entry.  It
361   *                must not be {@code null}.
362   */
363  public SystemInfoMonitorEntry(@NotNull final Entry entry)
364  {
365    super(entry);
366
367    availableCPUs      = getLong(ATTR_AVAILABLE_CPUS);
368    classpath          = getString(ATTR_CLASSPATH);
369    freeMemory         = getLong(ATTR_FREE_MEMORY);
370    hostname           = getString(ATTR_HOSTNAME);
371    instanceRoot       = getString(ATTR_INSTANCE_ROOT);
372    javaHome           = getString(ATTR_JAVA_HOME);
373    javaVendor         = getString(ATTR_JAVA_VENDOR);
374    javaVersion        = getString(ATTR_JAVA_VERSION);
375    jvmArchitecture    = getString(ATTR_JVM_ARCHITECTURE);
376    jvmArguments       = getString(ATTR_JVM_ARGUMENTS);
377    jvmPID             = getLong(ATTR_JVM_PID);
378    jvmVendor          = getString(ATTR_JVM_VENDOR);
379    jvmVersion         = getString(ATTR_JVM_VERSION);
380    maxMemory          = getLong(ATTR_MAX_MEMORY);
381    operatingSystem    = getString(ATTR_OPERATING_SYSTEM);
382    sslContextProtocol = getString(ATTR_SSL_CONTEXT_PROTOCOL);
383    usedMemory         = getLong(ATTR_USED_MEMORY);
384    userName           = getString(ATTR_USER_NAME);
385    workingDirectory   = getString(ATTR_WORKING_DIRECTORY);
386
387    final List<String> envValues = getStrings(ATTR_ENVIRONMENT_VARIABLE);
388    final LinkedHashMap<String,String> envMap =
389         new LinkedHashMap<>(StaticUtils.computeMapCapacity(envValues.size()));
390    for (final String s : envValues)
391    {
392      final int eqPos = s.indexOf("='");
393      if (eqPos > 0)
394      {
395        final String name = s.substring(0, eqPos);
396        if (eqPos != (s.length() - 2))
397        {
398          envMap.put(name, s.substring(eqPos+2, (s.length() - 1)));
399        }
400      }
401    }
402    environmentVariables = Collections.unmodifiableMap(envMap);
403
404    final List<String> propValues = getStrings(ATTR_SYSTEM_PROPERTY);
405    final LinkedHashMap<String,String> propMap =
406         new LinkedHashMap<>(StaticUtils.computeMapCapacity(propValues.size()));
407    for (final String s : propValues)
408    {
409      final int eqPos = s.indexOf("='");
410      if (eqPos > 0)
411      {
412        final String name = s.substring(0, eqPos);
413        if (eqPos != (s.length() - 2))
414        {
415          propMap.put(name, s.substring(eqPos+2, (s.length() - 1)));
416        }
417      }
418    }
419    systemProperties = Collections.unmodifiableMap(propMap);
420  }
421
422
423
424  /**
425   * Retrieves the number of CPUs available to the JVM.
426   *
427   * @return  The number of CPUs available to the JVM, or {@code null} if it was
428   *          not included in the monitor entry.
429   */
430  @Nullable()
431  public Long getAvailableCPUs()
432  {
433    return availableCPUs;
434  }
435
436
437
438  /**
439   * Retrieves the server's Java classpath.
440   *
441   * @return  The server's Java classpath, or {@code null} if it was not
442   *          included in the monitor entry.
443   */
444  @Nullable()
445  public String getClassPath()
446  {
447    return classpath;
448  }
449
450
451
452  /**
453   * Retrieves the environment variables available to the server process, mapped
454   * from variable name to the corresponding value.
455   *
456   * @return  The environment variables available to the server process, or an
457   *          empty map if it was not included in the monitor entry.
458   */
459  @NotNull()
460  public Map<String,String> getEnvironmentVariables()
461  {
462    return environmentVariables;
463  }
464
465
466
467  /**
468   * Retrieves the amount of memory in bytes held by the JVM that is currently
469   * marked as free.
470   *
471   * @return  The amount of memory in bytes held by the JVM that is currently
472   *          marked as free, or {@code null} if it was not included in the
473   *          monitor entry.
474   */
475  @Nullable()
476  public Long getFreeMemory()
477  {
478    return freeMemory;
479  }
480
481
482
483  /**
484   * Retrieves the server's hostname.
485   *
486   * @return  The server's hostname, or {@code null} if it was not included in
487   *          the monitor entry.
488   */
489  @Nullable()
490  public String getHostname()
491  {
492    return hostname;
493  }
494
495
496
497  /**
498   * Retrieves the path to the directory in which the Directory Server is
499   * installed.
500   *
501   * @return  The path to the directory in which the Directory Server is
502   *          installed, or {@code null} if it was not included in the monitor
503   *          entry.
504   */
505  @Nullable()
506  public String getInstanceRoot()
507  {
508    return instanceRoot;
509  }
510
511
512
513  /**
514   * Retrieves the path to the Java installation used by the server.
515   *
516   * @return  The path to the Java installation used by the server, or
517   *          {@code null} if it was not included in the monitor entry.
518   */
519  @Nullable()
520  public String getJavaHome()
521  {
522    return javaHome;
523  }
524
525
526
527  /**
528   * Retrieves the server's Java vendor string.
529   *
530   * @return  The server's Java vendor string, or {@code null} if it was not
531   *          included in the monitor entry.
532   */
533  @Nullable()
534  public String getJavaVendor()
535  {
536    return javaVendor;
537  }
538
539
540
541  /**
542   * Retrieves the server's Java version string.
543   *
544   * @return  The server's Java version string, or {@code null} if it was not
545   *          included in the monitor entry.
546   */
547  @Nullable()
548  public String getJavaVersion()
549  {
550    return javaVersion;
551  }
552
553
554
555  /**
556   * Retrieves the server's JVM architecture data mode, which should indicate
557   * whether the server is running a 32-bit or 64-bit JVM.
558   *
559   * @return  The server's JVM architecture data model, or {@code null} if it
560   *          was not included in the monitor entry.
561   */
562  @Nullable()
563  public String getJVMArchitectureDataModel()
564  {
565    return jvmArchitecture;
566  }
567
568
569
570  /**
571   * Retrieves a list of the arguments provided to the JVM when the server was
572   * started.
573   *
574   * @return  A list of the arguments provided to the JVM when the server was
575   *          started, or {@code null} if it was not included in the monitor
576   *          entry.
577   */
578  @Nullable()
579  public String getJVMArguments()
580  {
581    return jvmArguments;
582  }
583
584
585
586  /**
587   * Retrieves the process ID of the JVM in which the server is running.
588   *
589   * @return  The process ID of the JVM in which the server is running, or
590   *          {@code null} if it was not included in the monitor entry.
591   */
592  @Nullable()
593  public Long getJVMPID()
594  {
595    return jvmPID;
596  }
597
598
599
600  /**
601   * Retrieves the server's JVM vendor string.
602   *
603   * @return  The server's JVM vendor string, or {@code null} if it was not
604   *          included in the monitor entry.
605   */
606  @Nullable()
607  public String getJVMVendor()
608  {
609    return jvmVendor;
610  }
611
612
613
614  /**
615   * Retrieves the server's JVM version string.
616   *
617   * @return  The server's JVM version string, or {@code null} if it was not
618   *          included in the monitor entry.
619   */
620  @Nullable()
621  public String getJVMVersion()
622  {
623    return jvmVersion;
624  }
625
626
627
628  /**
629   * Retrieves the maximum amount of memory in bytes that the JVM will be
630   * allowed to use.
631   *
632   * @return  The maximum amount of memory in bytes that the JVM will be allowed
633   *          to use, or {@code null} if it was not included in the monitor
634   *          entry.
635   */
636  @Nullable()
637  public Long getMaxMemory()
638  {
639    return maxMemory;
640  }
641
642
643
644  /**
645   * Retrieves information about the operating system on which the server is
646   * running.
647   *
648   * @return  Information about the operating system on which the server is
649   *          running, or {@code null} if it was not included in the monitor
650   *          entry.
651   */
652  @Nullable()
653  public String getOperatingSystem()
654  {
655    return operatingSystem;
656  }
657
658
659
660  /**
661   * Retrieves the name of the default SSL context protocol that has been
662   * selected by the server.
663   *
664   * @return  The name of the default SSL context protocol that has been
665   *          selected by the server.
666   */
667  @Nullable()
668  public String getSSLContextProtocol()
669  {
670    return sslContextProtocol;
671  }
672
673
674
675  /**
676   * Retrieves the system properties defined in the server JVM, mapped from
677   * property name to the corresponding value.
678   *
679   * @return  The system properties defined in the server JVM, or an empty map
680   *          if it was not included in the monitor entry.
681   */
682  @NotNull()
683  public Map<String,String> getSystemProperties()
684  {
685    return systemProperties;
686  }
687
688
689
690  /**
691   * Retrieves the amount of memory in bytes currently held by the JVM used to
692   * run the server.
693   *
694   * @return  The amount of memory in bytes currently held by the JVM used to
695   *          run the server, or {@code null} if it was not included in the
696   *          monitor entry
697   */
698  @Nullable()
699  public Long getUsedMemory()
700  {
701    return usedMemory;
702  }
703
704
705
706  /**
707   * Retrieves the name of the user as whom the server is running.
708   *
709   * @return  The name of the user as whom the server is running, or
710   *          {@code null} if it was not included in the monitor entry.
711   */
712  @Nullable()
713  public String getUserName()
714  {
715    return userName;
716  }
717
718
719
720  /**
721   * Retrieves the path to the server's current working directory.  This is
722   * generally the path to the directory from which the server was started.
723   *
724   * @return  The path to the server's current working directory, or
725   *          {@code null} if it was not included in the monitor entry.
726   */
727  @Nullable()
728  public String getWorkingDirectory()
729  {
730    return workingDirectory;
731  }
732
733
734
735  /**
736   * {@inheritDoc}
737   */
738  @Override()
739  @NotNull()
740  public String getMonitorDisplayName()
741  {
742    return INFO_SYSTEM_INFO_MONITOR_DISPNAME.get();
743  }
744
745
746
747  /**
748   * {@inheritDoc}
749   */
750  @Override()
751  @NotNull()
752  public String getMonitorDescription()
753  {
754    return INFO_SYSTEM_INFO_MONITOR_DESC.get();
755  }
756
757
758
759  /**
760   * {@inheritDoc}
761   */
762  @Override()
763  @NotNull()
764  public Map<String,MonitorAttribute> getMonitorAttributes()
765  {
766    final LinkedHashMap<String,MonitorAttribute> attrs =
767         new LinkedHashMap<>(StaticUtils.computeMapCapacity(30));
768
769    if (hostname != null)
770    {
771      addMonitorAttribute(attrs,
772           ATTR_HOSTNAME,
773           INFO_SYSTEM_INFO_DISPNAME_HOSTNAME.get(),
774           INFO_SYSTEM_INFO_DESC_HOSTNAME.get(),
775           hostname);
776    }
777
778    if (operatingSystem != null)
779    {
780      addMonitorAttribute(attrs,
781           ATTR_OPERATING_SYSTEM,
782           INFO_SYSTEM_INFO_DISPNAME_OPERATING_SYSTEM.get(),
783           INFO_SYSTEM_INFO_DESC_OPERATING_SYSTEM.get(),
784           operatingSystem);
785    }
786
787    if (jvmArchitecture != null)
788    {
789      addMonitorAttribute(attrs,
790           ATTR_JVM_ARCHITECTURE,
791           INFO_SYSTEM_INFO_DISPNAME_JVM_ARCHITECTURE.get(),
792           INFO_SYSTEM_INFO_DESC_JVM_ARCHITECTURE.get(),
793           jvmArchitecture);
794    }
795
796    if (javaHome != null)
797    {
798      addMonitorAttribute(attrs,
799           ATTR_JAVA_HOME,
800           INFO_SYSTEM_INFO_DISPNAME_JAVA_HOME.get(),
801           INFO_SYSTEM_INFO_DESC_JAVA_HOME.get(),
802           javaHome);
803    }
804
805    if (javaVersion != null)
806    {
807      addMonitorAttribute(attrs,
808           ATTR_JAVA_VERSION,
809           INFO_SYSTEM_INFO_DISPNAME_JAVA_VERSION.get(),
810           INFO_SYSTEM_INFO_DESC_JAVA_VERSION.get(),
811           javaVersion);
812    }
813
814    if (javaVendor != null)
815    {
816      addMonitorAttribute(attrs,
817           ATTR_JAVA_VENDOR,
818           INFO_SYSTEM_INFO_DISPNAME_JAVA_VENDOR.get(),
819           INFO_SYSTEM_INFO_DESC_JAVA_VENDOR.get(),
820           javaVendor);
821    }
822
823    if (jvmVersion != null)
824    {
825      addMonitorAttribute(attrs,
826           ATTR_JVM_VERSION,
827           INFO_SYSTEM_INFO_DISPNAME_JVM_VERSION.get(),
828           INFO_SYSTEM_INFO_DESC_JVM_VERSION.get(),
829           jvmVersion);
830    }
831
832    if (jvmVendor != null)
833    {
834      addMonitorAttribute(attrs,
835           ATTR_JVM_VENDOR,
836           INFO_SYSTEM_INFO_DISPNAME_JVM_VENDOR.get(),
837           INFO_SYSTEM_INFO_DESC_JVM_VENDOR.get(),
838           jvmVendor);
839    }
840
841    if (jvmArguments != null)
842    {
843      addMonitorAttribute(attrs,
844           ATTR_JVM_ARGUMENTS,
845           INFO_SYSTEM_INFO_DISPNAME_JVM_ARGUMENTS.get(),
846           INFO_SYSTEM_INFO_DESC_JVM_ARGUMENTS.get(),
847           jvmArguments);
848    }
849
850    if (jvmPID != null)
851    {
852      addMonitorAttribute(attrs,
853           ATTR_JVM_PID,
854           INFO_SYSTEM_INFO_DISPNAME_JVM_PID.get(),
855           INFO_SYSTEM_INFO_DESC_JVM_PID.get(),
856           jvmPID);
857    }
858
859    if (sslContextProtocol != null)
860    {
861      addMonitorAttribute(attrs,
862           ATTR_SSL_CONTEXT_PROTOCOL,
863           INFO_SYSTEM_INFO_DISPNAME_SSL_CONTEXT_PROTOCOL.get(),
864           INFO_SYSTEM_INFO_DESC_SSL_CONTEXT_PROTOCOL.get(),
865           sslContextProtocol);
866    }
867
868    if (classpath != null)
869    {
870      addMonitorAttribute(attrs,
871           ATTR_CLASSPATH,
872           INFO_SYSTEM_INFO_DISPNAME_CLASSPATH.get(),
873           INFO_SYSTEM_INFO_DESC_CLASSPATH.get(),
874           classpath);
875    }
876
877    if (instanceRoot != null)
878    {
879      addMonitorAttribute(attrs,
880           ATTR_INSTANCE_ROOT,
881           INFO_SYSTEM_INFO_DISPNAME_INSTANCE_ROOT.get(),
882           INFO_SYSTEM_INFO_DESC_INSTANCE_ROOT.get(),
883           instanceRoot);
884    }
885
886    if (workingDirectory != null)
887    {
888      addMonitorAttribute(attrs,
889           ATTR_WORKING_DIRECTORY,
890           INFO_SYSTEM_INFO_DISPNAME_WORKING_DIRECTORY.get(),
891           INFO_SYSTEM_INFO_DESC_WORKING_DIRECTORY.get(),
892           workingDirectory);
893    }
894
895    if (availableCPUs != null)
896    {
897      addMonitorAttribute(attrs,
898           ATTR_AVAILABLE_CPUS,
899           INFO_SYSTEM_INFO_DISPNAME_AVAILABLE_CPUS.get(),
900           INFO_SYSTEM_INFO_DESC_AVAILABLE_CPUS.get(),
901           availableCPUs);
902    }
903
904    if (usedMemory != null)
905    {
906      addMonitorAttribute(attrs,
907           ATTR_USED_MEMORY,
908           INFO_SYSTEM_INFO_DISPNAME_USED_MEMORY.get(),
909           INFO_SYSTEM_INFO_DESC_USED_MEMORY.get(),
910           usedMemory);
911    }
912
913    if (maxMemory != null)
914    {
915      addMonitorAttribute(attrs,
916           ATTR_MAX_MEMORY,
917           INFO_SYSTEM_INFO_DISPNAME_MAX_MEMORY.get(),
918           INFO_SYSTEM_INFO_DESC_MAX_MEMORY.get(),
919           maxMemory);
920    }
921
922    if (freeMemory != null)
923    {
924      addMonitorAttribute(attrs,
925           ATTR_FREE_MEMORY,
926           INFO_SYSTEM_INFO_DISPNAME_FREE_MEMORY.get(),
927           INFO_SYSTEM_INFO_DESC_FREE_MEMORY.get(),
928           freeMemory);
929    }
930
931    if (userName != null)
932    {
933      addMonitorAttribute(attrs,
934           ATTR_USER_NAME,
935           INFO_SYSTEM_INFO_DISPNAME_USER_NAME.get(),
936           INFO_SYSTEM_INFO_DESC_USER_NAME.get(),
937           userName);
938    }
939
940    if (! environmentVariables.isEmpty())
941    {
942      final ArrayList<String> envList =
943           new ArrayList<>(environmentVariables.size());
944      for (final Map.Entry<String,String> e : environmentVariables.entrySet())
945      {
946        envList.add(e.getKey() + "='" + e.getValue() + '\'');
947      }
948
949      addMonitorAttribute(attrs,
950           ATTR_ENVIRONMENT_VARIABLE,
951           INFO_SYSTEM_INFO_DISPNAME_ENV_VAR.get(),
952           INFO_SYSTEM_INFO_DESC_ENV_VAR.get(),
953           envList);
954    }
955
956    if (! systemProperties.isEmpty())
957    {
958      final ArrayList<String> propList =
959           new ArrayList<>(systemProperties.size());
960      for (final Map.Entry<String,String> e : systemProperties.entrySet())
961      {
962        propList.add(e.getKey() + "='" + e.getValue() + '\'');
963      }
964
965      addMonitorAttribute(attrs,
966           ATTR_SYSTEM_PROPERTY,
967           INFO_SYSTEM_INFO_DISPNAME_SYSTEM_PROP.get(),
968           INFO_SYSTEM_INFO_DESC_SYSTEM_PROP.get(),
969           propList);
970    }
971
972    return Collections.unmodifiableMap(attrs);
973  }
974}