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