Skip to content

Instantly share code, notes, and snippets.

View girisagar46's full-sized avatar
🎯
Focusing

Sagar Giri girisagar46

🎯
Focusing
View GitHub Profile
import com.sun.net.httpserver.HttpServer;
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
// Just a service class which will provide the instance of PrometheusMeterRegistry
public class MetricService {
private static PrometheusMeterRegistry prometheusMeterRegistry = null;
public static PrometheusMeterRegistry getRegistry() {
if (prometheusMeterRegistry == null) {
prometheusMeterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
}
return prometheusMeterRegistry;
global:
scrape_interval: 10s
evaluation_interval: 10s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["127.0.0.1:9090"]
- job_name: "prome-java"
version: "3.8"
services:
prometheus:
image: prom/prometheus
container_name: prometheus
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
- ./data/prometheus:/data
command:
import com.sun.net.httpserver.HttpServer;
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
# using SendGrid's Python Library
# https://github.com/sendgrid/sendgrid-python
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
SENDGRID_API_KEY = "==="
message = Mail(
from_email='[email protected]',
@girisagar46
girisagar46 / ec2-userdata.sh
Created August 17, 2020 15:49
Simple ec2-userdata for apache server
#!/bin/bash
# Use this for your user data (script from top to bottom)
# install httpd (Linux 2 version)
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "<h1>Hello World from $(hostname -f)</h1>" > /var/www/html/index.html
==> mysql
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
@girisagar46
girisagar46 / config.yaml
Last active February 15, 2020 16:26
CircleCI check only changed files
version: 2.1
executors:
default:
working_directory: ~/workspace
docker:
- image: circleci/python:3.5
jobs:
lint:
executor:
name: default
@girisagar46
girisagar46 / aproducer.py
Created January 10, 2020 09:35 — forked from dabeaz/aproducer.py
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler: