I have an app that runs as a JVM in Windows 2008. I'd like to monitor it's memory usage and be sent an email if/when memory usage reaches a specific threshold. Is there a free utility or method for doing this?
|
|
The Win2008 OS can send alerts for performance counter threshold conditions.
|
|||||
|
|
You can setup monitoring with JMX. Is this a server app running on Tomcat or a JEE application server? or is this a command line Java application? or a Windows Service Wrapped Java app? Which JVM? What settings? Oracle JDK Rockit has a great memory monitor, Oracle JRockit Mission Control 4.1 or http://visualvm.java.net/index.html. You could write a thread within your app that sleeps and awakens to check memory. See these posts: http://stackoverflow.com/questions/1058991/how-to-monitor-java-memory-usage or http://stackoverflow.com/questions/74674/how-to-do-i-check-cpu-and-memory-usage-in-java |
|||
|
|
|
In fact JVM memory boundaries are controlled by startup parameters like Back to monitoring, it is possible to turn on JVM internal SNMP agent and then monitor memory usage of heaps and PermGen and through private SNMP community you can setup thresholds when exceeded JVM will send SNMP traps. In fact it is "enterprise solution of monitoring" by tools like HP OpenView. Cmdline parameters involved:
They are selfexplanatory. ACL file template is at
It expect you already put Not to forget mail sending, I'm doing JVM monitoring by Zabbix in conjunction with SNMP on cluster running nationwide backend cluster of Post Office. It covers all run time monitoring requirements. Zabbix can send you email or Jabber IM message in case of some trigger fired. Zabbix support SNMP agent monitoring and SNMP traps too. I ran month test of services in cloud, when monitored JVM was somewhere in USA and Zabbix server in Ireland... it worked well even for such distances/delays. Since version 2.0 there is JMX monitoring possible, but for secure environments it could be complicated, cause JMX-RMI setup some ports random. In general SNMP is enough for JVM run time monitoring and JMX can more help on development/test machines cause it can monitor application nuances. If you are in cloud with your Windows machine, you can use one of SaaS monitoring services. I was pretty impressed with NewRelic services. It is easy to setup and really helpful for development/test phases, cause can do things like thread dumps, slow SQL queries a.s.o. It can send emails when threshold reached. |
|||
|
|
|
You should be able to use the free version of our monitoring solution EventSentry, which can monitor performance counters, for this. The free edition is called "EventSentry Light" and you can download it from here. EventSentry can monitor any Windows performance counter, and in this case you'd probably want to monitor the counter Process(myprocess)\Working Set Where "myprocess" is the name of your process. The configuration is very flexible, you basically tell EventSentry how often to query the performance counter, and how long the counter value needs to exceed your limit before it should trigger an alert. When the alert is triggered, you will get an email that can (optionally) even include a chart attached to it (see http://www.eventsentry.com/images/screenshots/120706100728_eventsentry_performance_alert_1.png for an example). We use EventSentry internally for this same exact purpose, and the setup should only take you a few minutes. You can also use the commercial version which has a few more capabilities, such as collecting performance data over time with web-based reports. Disclaimer: I work for netikus.net. |
|||
|
|
|
You can run JMX, but it doesnt show e.g. garbage collector. You can also monitor the logfile. There is no utility to restart Java when it runs out of memory. But it's easy to code just in Java, and run as server, which checks for the apps if they are running OK, and the business logic you need to invent yourself, e.g. Anyway, to restart Java remotely over JMX, requires access to the server, so there is no utility to do these two at the same time - to actually run, watch, restart and monitor the Java Process. You can run this Java on another Java as well, so it will do monitoring and restarting at the same time, and would run a small java.exe to do it. |
||||
|
|