Skip to content

Instantly share code, notes, and snippets.

View dhiren051's full-sized avatar
🎯
Focusing

DM dhiren051

🎯
Focusing
  • Cypress, CA
View GitHub Profile
@dhiren051
dhiren051 / gist:3ca969bf0a24a229a86b69f8e2c0ee36
Created August 13, 2019 23:50
prometheus pushgateway python test metrics
#!/usr/bin/env python
from prometheus_client import start_http_server,Summary,Counter,Gauge,CollectorRegistry,push_to_gateway
import random
import time
import sys
def test_push_with_groupingkey(n,t):
registry = CollectorRegistry()
@dhiren051
dhiren051 / docker-compose.yml
Created August 13, 2019 22:40 — forked from brunosimioni/docker-compose.yml
Docker Compose to Prometheus, PushGateway and Grafana setup
version: '2.1'
networks:
monitor-net:
driver: bridge
volumes:
prometheus_data: {}
grafana_data: {}
mappings:
- match: consul.*.runtime.*
name: consul_runtime
labels:
host: '{{ inventory_hostname }}'
type: $2
- match: consul.runtime.total_gc_pause_ns
name: consul_runtime_total_gc_pause_ns
labels:
host: '{{ inventory_hostname }}'
consul.*.runtime.*
name="consul_runtime"
type="$2"
host="{{ inventory_hostname }}"
consul.runtime.total_gc_pause_ns
name="consul_runtime_total_gc_pause_ns"
type="$2"
host="{{ inventory_hostname }}"

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
brew cask reinstall vagrant
# this might take a long time
vagrant plugin update
@dhiren051
dhiren051 / node_exporter_memtest.sh
Created July 16, 2019 17:46
To compare values of linux node and prometheus node exporter
#!/bin/bash
set -e -o pipefail
date
free -b
curl -s 'http://localhost:9100/metrics?collect\[\]=meminfo' |
egrep '^node_memory_Mem(Total|Free|Available)_bytes'
egrep 'Mem(Total|Free|Available):' /proc/meminfo |
awk '{print $1 $2 * 1024}'
free -b
date
@dhiren051
dhiren051 / monitor.sh
Created May 2, 2019 19:40 — forked from mayconbordin/monitor.sh
Shell script for logging CPU, memory, network and HDD usage
#!/bin/bash
usage() {
echo "Usage: $0 COMMAND"
echo ""
echo "Commands:"
echo " start <output-dir> <interval> [<cpu-mem-net-log> <hdd-log>] Start the monitor"
echo " stop Stop the monitor"
exit 1
}
@dhiren051
dhiren051 / blackbox-consul
Created April 11, 2019 21:29 — forked from ycyr/blackbox-consul
prometheus-consul
- job_name: 'blackbox'
metrics_path: /probe
consul_sd_configs:
- server: '192.168.0.30:8500'
relabel_configs:
- source_labels: [__meta_consul_tags]
regex: .*,blackbox,.*
action: keep
- source_labels: [__meta_consul_service]
target_label: job