Created
April 3, 2024 07:00
-
-
Save ivarref/c76a34f734e78496c423c312330d330c to your computer and use it in GitHub Desktop.
TrayMonitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package no.nsd; | |
import java.awt.*; | |
import java.awt.event.*; | |
import java.io.IOException; | |
import java.net.ConnectException; | |
import java.net.URI; | |
import java.net.URISyntaxException; | |
import java.net.http.HttpClient; | |
import java.net.http.HttpRequest; | |
import java.net.http.HttpResponse; | |
import java.net.http.HttpTimeoutException; | |
import java.time.Duration; | |
import java.time.ZonedDateTime; | |
import java.time.format.DateTimeFormatter; | |
import java.util.Base64; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.ScheduledExecutorService; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.atomic.AtomicBoolean; | |
import java.util.concurrent.atomic.AtomicLong; | |
import javax.swing.*; | |
public class TrayMonitor { | |
private static volatile TrayIcon trayIcon; | |
public static void debug(String... args) { | |
StringBuilder sb = new StringBuilder(); | |
sb.append(pattern.format(ZonedDateTime.now())); | |
sb.append(" DEBUG "); | |
for (String s : args) { | |
sb.append(s); | |
sb.append(" "); | |
} | |
sb.deleteCharAt(sb.length() - 1); | |
//sout(sb.toString()); | |
} | |
public static void info(String... args) { | |
StringBuilder sb = new StringBuilder(); | |
sb.append(pattern.format(ZonedDateTime.now())); | |
sb.append(" INFO "); | |
for (String s : args) { | |
sb.append(s); | |
sb.append(" "); | |
} | |
sb.deleteCharAt(sb.length() - 1); | |
sout(sb.toString()); | |
} | |
public static void warn(String... args) { | |
StringBuilder sb = new StringBuilder(); | |
sb.append(pattern.format(ZonedDateTime.now())); | |
sb.append(" WARN "); | |
for (String s : args) { | |
sb.append(s); | |
sb.append(" "); | |
} | |
sb.deleteCharAt(sb.length() - 1); | |
sout(sb.toString()); | |
} | |
public static void error(String... args) { | |
StringBuilder sb = new StringBuilder(); | |
sb.append(pattern.format(ZonedDateTime.now())); | |
sb.append(" ERROR "); | |
for (String s : args) { | |
sb.append(s); | |
sb.append(" "); | |
} | |
sb.deleteCharAt(sb.length() - 1); | |
sout(sb.toString()); | |
} | |
public static final Base64.Decoder decoder = Base64.getDecoder(); | |
public static byte[] decode(String b64) { | |
return decoder.decode(b64); | |
} | |
public static final String redCircle = "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAAHrklEQVRoge1Zy24cxxU99eie7mlyZkiIkoh4k0W8MII4ASxRjKgYTgDL+ggjBLINEMBLw4GQ2D+QVZYKko9wHCCxIkRQJIeJso12tkGBkUQOyel31a0suqpZHHGGQ5qxN7xAY7qrq6vOuXXrPmqAczmXczmXb1LYWQ3075s3b+g8X6e6vkJEy9C6B8YkABhjFBNij3P+lAvxKJyfv/Pdjz++fxbzfiUCT27d6uxl2Ycqy97lnF+Oul0EUQQZBBCcA5w3HYmgiaDqGnVRoMgyGKKnQbf7h++PRh+wjY36ayfweG3tvTLPb4dx3Ov2euhEEWSngyAIwIUA4xyMNcMbY2CIQFqjrmuoskRZFMj29lDl+W6UJLdfv3fvN18LgS9u3lzc3N7+RArxRrKwgDhJEMUxZBCACQEuRKN9xg4RgDHQloTRGqquUeQ58jRFurMDpfVnF5Pk7W/fvTv8vxF4vLb2ap6m95P5+QtzgwGiuTmEYQgZBOBSgnMO7syG83ZwAwBEaH6ouZSCqmtUVYViNMJoOEQ6Gj3rz81df+3evSdnTuDx2tqrRZo+mh8M+slggDhJEFjwTIgGPGOA1bp/D2NAxhy6J6J2JeqqalZiOMT+cLjbC8Mrrz18OBMJPkunL1ZXF/P9/ftz/X4/6ffR9cBzziEYO9CEMWDGtGYDe8/cs9WaYAycc8ggQBCG6CYJkn4fc/1+f1iW95+srPRmwSZnIpDnnyRJcqHb6yHudpuNKmWjZXgmwg4W1BhzaAUYYzBHvOOMQUgJZgzibhdEBF1VSy+y7E8Arh2H7dgV+MfKyi8CId7o9n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Uy+MZ3xmM6qoMh5v8DGdCsvjCGr3cAAAAASUVORK5CYII="; | |
public static Image getImage(String base64) { | |
return (new ImageIcon(decode(base64))).getImage(); | |
} | |
public static final Image unhealthy = getImage(redCircle); | |
public static final Image healthy = getImage(pray); | |
public static final Image catHeartEyes = getImage("iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAAMe0lEQVRoge2Ye4xd1XXGf2vv87iPmbl3ZuzBHmzXLygBGwylNMRNBAE1jxYHmzRKo1LcQBOaRqW0DYjSkElb0kYOaQNIiQRJIFVKBMWGVpBCGqiMSIFCwIhHCWBiG2z8mPfMfZxz9l7945x52OPYVBDxj5e0de899+y1v2+t9e0XHLNjdsyO2btpcuiDoXu7TzXePCzwqPrgz+oX7d3+bgCbssm75y1MrG4S5f1W9COdFw69MPv/4NAOxsnFCD0KF2Cy80Y29/5tbf/gDfJZ0iMNtPPW+ge89x+vzw8DgUV7diYfVK8RgBpSa2TsuEXRZlWeGB/025f80fAjR/KnA5ixNb2Xp6pfEaUG4GAjcNXs9+ZkYGRL73/c/W3zocRkXPgJQ7kKwM9Q/ri+YfCh2e8O3zv/9OG97ZvaDf8bWapBXDH09UeICG9sb+GcTr9rA6F/aQzAvjcSXKpZUDLPBiGbll029oPZfosq+BZwdmMS7rnDUw1DPnaJe6C+fvDDs9+dkwFg+Zp0JY++tp9NAwf4+MWGk0+VExH+c2RLzy1Szq6hGX5U0b/A+zUikKU50FLZEpRDEMGE7TkEgnKIeiUqO8abaZBNuDM66vaOkS29XxCRG9o1+bdo1F2HlyuB4IVnlH/9Z8+KqI/VK3uAl1ceCvZwBGrHl3tYuzDk9Vcm+M5NLU77NWHD7xupdshntBV+Ou8nmMDQUY+YGGkCUO0tYUsBIkIYWdKWnxkotthSAB46e2F8KK/IalcIwhmq+v14RNuKxM0G3He38thWT1+pwtolC1lY6QBe7joUrDkMgaosWkxfucIJtToAzz+rvPRcAUYJxBpsHGDjk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ZZbRi0AU1o1HGWZm//NrM2a7MWmv0PblydmGDHmGkAAAAASUVORK5CYII="); | |
public static final Image scream = getImage("iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAAKOUlEQVRoge2Ye3BVxR3HP7tnz70JeQCBEE14CgpYpYCKikoRrSCWP/qHtlZr1foYdVrHqR3b+pi0VWt94SgWHdBKq3bGP5xp1WrlKeAUUTQBJT54JSEJ5EEM9+aec+89Z7d/nJObm+TexKCdznTYmd/s7tnf+e73u/vbs3sWjqfj6Xg6nv6XSXxTQK88v3xRXJffFJOVZ8dMxbg4FQUpiiRAVMR1kWl1S8Th1lLdtG2UaX/2+zfesemb6PdrCdhYXV3QNKnq4WYz+5pWMWPkVwE0YT7O1HVVUbvGLm765RVXVKeOlcMxC/jbn5+8a7/4TnVMVBZkIwkxOKQxoYQwG8VBZ6K/+b4rr7/90WPhMWwBr6759ZgOztjQKObNQvawDon3R+upm37PTT8h2jDBvFczQu1YdNVVD3X+1wT8/bnfT6+352/rsiaMEkKABIQgGPRsAflgs5QYgzFBjg4EjdINnSc5W8+57Kbqz79xAevWVJ9Sp87b0S0ripEC0UM+MwsiCy67nE3e9JbDGTDa9IrQhiJ9OD459c7cZdfd/8U3JuCV1XeUdRYu+DxmVY4RlkBIGZLPIp4RkG25BJgsAaZ3JrTBaI3xDaV+c/sss2HqOVc/dXQobuqrCPAKTnnTVWVjIioJUiAsgRACo31KvKOcMeMkQLDj0/3Eo2NB2v1mJCTqpyhJdXDGjMmh/17ikZGADET4GiMNjigbu8+f+SZw3lDchpyBf7x4962N9gVPCyUD4pYIRAiYWVbMvNnfJhKJAJBKpXivZhd1XRohVD8BHjNHSubNPr2v/0e11HXGM4vZ+KF5mknprT//3tX3PzUYPzlY4z+f/Fm0U538QES5RJSLrZLYKklEJbG62zl7zmyi0ShCBDMSjUY5Z84s7O42bMsPTWNbPla8lbPnzBroP3c2duIIkRA7wHeJqCRH1NTq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cCzLetP/2QibJMi0Lv1soZsanSX9vW1yjOVLpzWlV5oVeZa0xctj7jjUNMnTYKDSwoZCS2u5N7Knmm8dTJtlck3trbObHfpcLf29JXKMxUtlFMLXa6XSXL5sQSID6bkbKmJbjH40B1Uurgiu7bQNxlcF9Za3Dqz3fnhduXrb0a+UMmNKg3diQkwVgOhiwm4t3Tgrf1SWovl0bv1soYmb/gx7ZsHkuQunisEQI3JhYSy+VQRsK6SvIXu2eaBpkcmYzZfiEB5DLzQ9m2l1JNKq0VRn6hiRiQN6gqDJDmrTk0iAgfEysMTRZuLTgDic8KfsQHFJrS6UWmlak2oRgUVH3AiiOwRcU817+v/i3o06b98tQSqx8BLzXNw/m2CrNBKLQY1GyVxpUIexSfOyUGF2i0S7jhfejA1psbUmBr/P+O/tm1cA7cd/m4AAAAASUVORK5CYII="); | |
public static final AtomicBoolean running = new AtomicBoolean(true); | |
public static void setImage(Image img) { | |
if (trayIcon == null) { | |
warn("TrayIcon not ready."); | |
} else if (trayIcon.getImage() == img) { | |
debug("doing nothing."); | |
} else { | |
trayIcon.setImage(img); | |
} | |
} | |
public static void main(String[] args) { | |
info("TrayMonitor starting"); | |
UIManager.put("swing.boldMetal", Boolean.FALSE); | |
SwingUtilities.invokeLater(TrayMonitor::createAndShowGUI); | |
ScheduledExecutorService pool = Executors.newScheduledThreadPool(1); | |
AtomicLong count = new AtomicLong(0); | |
AtomicLong errorCount = new AtomicLong(0); | |
pool.scheduleAtFixedRate(() -> { | |
if (running.get()) { | |
long startTime = System.currentTimeMillis(); | |
boolean res = checkOnce(args); | |
long spentTime = System.currentTimeMillis() - startTime; | |
long cnt = count.incrementAndGet(); | |
if (res) { | |
errorCount.set(0); | |
info("All", "" + args.length, "services healthy in", "" + spentTime, "ms. Check count:", "" + cnt); | |
if (cnt == 1) { | |
setImage(catHeartEyes); | |
} | |
else if (cnt % 100 == 0) { | |
setImage(catHeartEyes); | |
} else if (cnt % 10 == 0) { | |
setImage(drool); | |
} else { | |
setImage(healthy); | |
} | |
} else { | |
long errCount = errorCount.incrementAndGet(); | |
warn("Some services unhealthy in", "" + spentTime, "ms. Error count:", ""+errCount); | |
if (errCount >= 5) { | |
setImage(scream); | |
} | |
else if (errCount >= 3) { | |
setImage(unhealthy); | |
} else { | |
setImage(nauseous); | |
} | |
} | |
} | |
} | |
, 0, 1, TimeUnit.MINUTES); | |
} | |
public static final DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | |
public synchronized static void sout(String txt) { | |
System.out.println(txt); | |
} | |
public static final HttpClient client = HttpClient.newHttpClient(); | |
public static boolean checkOnce(String[] args) { | |
for (String s : args) { | |
URI uri = null; | |
try { | |
uri = new URI(s); | |
} catch (URISyntaxException e) { | |
error("Bad URI syntax. Got:", s); | |
System.exit(1); | |
} | |
HttpRequest request = HttpRequest.newBuilder() | |
.uri(uri) | |
.timeout(Duration.ofSeconds(3)) | |
.GET() | |
.build(); | |
try { | |
long startTime = System.currentTimeMillis(); | |
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); | |
long spentTime = System.currentTimeMillis() - startTime; | |
String contentType = response.headers().firstValue("Content-Type").orElse("none"); | |
boolean textPlain = contentType.startsWith("text/plain"); | |
if (200 == response.statusCode() && (!textPlain || response.body().equalsIgnoreCase("OK"))) { | |
debug("Checking", s, "=> OK in", "" + spentTime, "ms"); | |
} else { | |
warn("Checking", s, "returned", "HTTP " + response.statusCode(), "Body:", response.body(), "in", "" + spentTime, "ms"); | |
return false; | |
} | |
} catch (IOException e) { | |
if (e instanceof ConnectException) { | |
error("Could not connect to", s); | |
} else if (e instanceof HttpTimeoutException) { | |
error("Request to", s, "timed out."); | |
} else { | |
error("Error while checking", s, ". Error message:", e.getMessage(), ". Class: " + e.getClass()); | |
} | |
return false; | |
} catch (InterruptedException e) { | |
warn("Interrupted"); | |
return false; | |
} | |
} | |
return true; | |
} | |
private static void createAndShowGUI() { | |
//Check the SystemTray support | |
if (!SystemTray.isSupported()) { | |
error("SystemTray is not supported"); | |
System.exit(1); | |
return; | |
} | |
final PopupMenu popup = new PopupMenu(); | |
trayIcon = new TrayIcon(sleepy); | |
trayIcon.setImageAutoSize(true); | |
final SystemTray tray = SystemTray.getSystemTray(); | |
// Create a popup menu components | |
MenuItem aboutItem = new MenuItem("About"); | |
CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size"); | |
CheckboxMenuItem cb2 = new CheckboxMenuItem("Set tooltip"); | |
Menu displayMenu = new Menu("Display"); | |
MenuItem errorItem = new MenuItem("Error"); | |
MenuItem warningItem = new MenuItem("Warning"); | |
MenuItem infoItem = new MenuItem("Info"); | |
MenuItem noneItem = new MenuItem("None"); | |
MenuItem exitItem = new MenuItem("Exit"); | |
//Add components to popup menu | |
popup.add(aboutItem); | |
popup.addSeparator(); | |
popup.add(cb1); | |
popup.add(cb2); | |
popup.addSeparator(); | |
popup.add(displayMenu); | |
displayMenu.add(errorItem); | |
displayMenu.add(warningItem); | |
displayMenu.add(infoItem); | |
displayMenu.add(noneItem); | |
popup.add(exitItem); | |
trayIcon.setPopupMenu(popup); | |
try { | |
tray.add(trayIcon); | |
} catch (AWTException e) { | |
error("TrayIcon could not be added."); | |
System.exit(1); | |
return; | |
} | |
trayIcon.addActionListener(e -> JOptionPane.showMessageDialog(null, | |
"This dialog box is run from System Tray")); | |
aboutItem.addActionListener(e -> JOptionPane.showMessageDialog(null, | |
"This dialog box is run from the About menu item")); | |
cb1.addItemListener(e -> { | |
int cb1Id = e.getStateChange(); | |
if (cb1Id == ItemEvent.SELECTED) { | |
trayIcon.setImageAutoSize(true); | |
} else { | |
trayIcon.setImageAutoSize(false); | |
} | |
}); | |
trayIcon.setToolTip("mjau..."); | |
cb2.addItemListener(e -> { | |
int cb2Id = e.getStateChange(); | |
if (cb2Id == ItemEvent.SELECTED) { | |
trayIcon.setToolTip("Sun TrayIcon"); | |
} else { | |
trayIcon.setToolTip(null); | |
} | |
}); | |
ActionListener listener = e -> { | |
MenuItem item = (MenuItem) e.getSource(); | |
//TrayIcon.MessageType type = null; | |
if ("Error".equals(item.getLabel())) { | |
//type = TrayIcon.MessageType.ERROR; | |
trayIcon.displayMessage("Sun TrayIcon Demo", | |
"This is an error message", TrayIcon.MessageType.ERROR); | |
} else if ("Warning".equals(item.getLabel())) { | |
//type = TrayIcon.MessageType.WARNING; | |
trayIcon.displayMessage("Sun TrayIcon Demo", | |
"This is a warning message", TrayIcon.MessageType.WARNING); | |
} else if ("Info".equals(item.getLabel())) { | |
//type = TrayIcon.MessageType.INFO; | |
trayIcon.displayMessage("Sun TrayIcon Demo", | |
"This is an info message", TrayIcon.MessageType.INFO); | |
} else if ("None".equals(item.getLabel())) { | |
//type = TrayIcon.MessageType.NONE; | |
trayIcon.displayMessage("Sun TrayIcon Demo", | |
"This is an ordinary message", TrayIcon.MessageType.NONE); | |
} | |
}; | |
errorItem.addActionListener(listener); | |
warningItem.addActionListener(listener); | |
infoItem.addActionListener(listener); | |
noneItem.addActionListener(listener); | |
exitItem.addActionListener(e -> { | |
tray.remove(trayIcon); | |
info("Exiting"); | |
System.exit(0); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment