Ali cloud support reporting custom data monitor , you can use ps, jstat, jcmd, jstat commands, get java process key index information , and regularly report data through crontab mechanism, you can see the chart trend in Ali cloud console, and may set the alarm rule.
- crontab -e, acquiring data every minute
*/1 * * * * sh /soft/shells/check_apps.sh >> /var/log/cms_check.log
- Calling script summary data, it requires three parameters: metricName value appName
/soft/shells/cms_upload.sh threads $threads $appName
- Data reported by java code, you need to configure Ali cloud account accessKeyId , Secret
/log?type=metric&metricName=&value=&appName=
- Year Old percentage of memory used: jstat -gcutil $ pid | tail -1 | awk '{print $ 4}'
too much memory data selection using a percentage years old, about 75% can set the alarm. If long-term accounting for less than 30%, you can consider reducing the memory allocation years old. - Average gc time: Reference check_gc.sh , bc used to calculate the time in milliseconds
if the memory allocation is insufficient, will cause frequent gc, gc time-consuming and the average will be very long, usually more normal within 10ms, 300ms can set the alarm. - Application number of threads: Reference check_threads.sh ,
Light-4j small footprint, but the default is 200 worker threads, 1G of memory for a nuclear cloud host is still too much, it is possible to reduce the number of worker threads.