Skip to content

Instantly share code, notes, and snippets.

Avatar

Gunhee Lee gunlee01

View GitHub Profile
@gunlee01
gunlee01 / FiberTest.java
Created Sep 20, 2020
Project Loom, fiber(virtual thread) test generating stack trace.
View FiberTest.java
package gunlee.demo.fiber;
import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
View Throwable2.java
public class Throwable2 extends Throwable {
public Throwable2() {
}
public List<StackTraceElement> stacks(int req) {
List<StackTraceElement> stacks = new ArrayList<>();
try {
Method getStackTraceDepth = Throwable.class.getDeclaredMethod("getStackTraceDepth");
View alert5.java
String counterName = "Elapsed90%";
String objType = $counter.getObjType();
String objName = $counter.getObjName();
float value = $counter.getFloatValue();
float tps = $counter.getFloatValue("TPS");
String widgetUrl = "http://my-scouter-webapi-ip:6180/widget/simple/counter.html?source=";
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyyMMdd");
long now = System.currentTimeMillis();
View alert4.java
String objType = $counter.getObjType();
String objName = $counter.getObjName();
float avgTpsCurrent = $counter.getLatestAvg(30); //latest 30s avg
float avgTps3minAgo = $counter.getAvg(180+30, 30); //3min ago 30s avg
String title = "TPS fluctuation alert";
String message = "TPS is highly(over 1.5x) incresed in 3min\n";
message += "[TPS current] " + $$.formatNumber(avgTpsCurrent) + "\n";
message += "[TPS 3min ago] " + $$.formatNumber(avgTps3minAgo) + "\n";
message += "[objType] " + objType + "\n";
View alert3.java
String objType = $counter.getObjType();
String objName = $counter.getObjName();
float value = $counter.getFloatValue();
float tps = $counter.getFloatValue("TPS");
String title = "Elapsed time alert";
String message = "Elapsed is over 2,000ms\n";
message += "[current value] " + $$.formatNumber(value, 0) + "ms\n";
message += "[objType] " + objType + "\n";
message += "[objName] " + objName + "\n";
@gunlee01
gunlee01 / alert2.java
Last active May 23, 2018
scouter alert scripting #2
View alert2.java
String objType = $counter.getObjType();
String objName = $counter.getObjName();
float value = $counter.getFloatValue();
float tps = $counter.getFloatValue("TPS");
String title = "Elapsed time alert";
String message = "Elapsed is over 2000ms\n";
message += "[current value] " + value + "ms\n";
message += "[objType] " + objType + "\n";
message += "[objName] " + objName + "\n";
@gunlee01
gunlee01 / alert1.java
Last active May 23, 2018
scouter alert scripting #1
View alert1.java
float value = $counter.getFloatValue();
if(value > 2000) {
$counter.fatal("Alert title", "msg: Elapsed is over 2000ms");
}
@gunlee01
gunlee01 / hashUtil.js
Created May 17, 2018
Scouter Hash util by javascript
View hashUtil.js
const table = [
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
View scouter.properties
ext_plugin_line_send_alert=true
ext_plugin_line_access_token=Tl++IYUAOdtcHQfr7+3ieTIQs8/M9DTdBIrrwkm58KzuX03paU3gq8hxUrAA7NTERS3PJ9n8Q2=
ext_plugin_line_group_id=C0246cfsdf6599ec6ddesdf12bec77eb4a
View push-to-line.sh
curl -X POST \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {ENTER_ACCESS_TOKEN}' \
-d '{
"to": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"messages":[
{
"type":"text",
"text":"Hello, world1"
},