SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
Systeme.java
1/*
2 * Class: Systeme
3 * Description: Provides tools related to the system or the computer
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since January 2011
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.util;
26
27import java.lang.management.*;
28import java.util.*;
29import java.text.*;
30import java.net.*;
31
37public class Systeme {
38 private Systeme() {
39 }
40
46 public static String getHostName() {
47 String host;
48 try {
49 InetAddress machine = InetAddress.getLocalHost();
50 host = machine.getHostName();
51 } catch (UnknownHostException uhe) {
52 host = "unknown host machine";
53 }
54 // host = System.getenv("HOSTNAME");
55 int j = host.indexOf('.');
56 String name;
57 if (j >= 0)
58 name = host.substring(0, j);
59 else
60 name = host;
61 return name;
62 }
63
70 public static String getProcessInfo() {
71 StackTraceElement[] stack = Thread.currentThread().getStackTrace();
72 StackTraceElement mai = stack[stack.length - 1];
73 String str = mai.getClassName();
74
75 RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
76 Date startTime = new Date(runtime.getStartTime());
77 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss");
78
79 str += " [" + runtime.getName() + "]";
80 str += " [" + dateFormat.format(startTime) + "]";
81
82 return str;
83 }
84
85}
static String getProcessInfo()
Returns information about the running process: name, id, host name, date and time.
Definition Systeme.java:70
static String getHostName()
Returns the name of the host computer.
Definition Systeme.java:46