Skip to content

Instantly share code, notes, and snippets.

View smortex's full-sized avatar
🌴
Eating 🥥 and ddrinking 🍹…

Romain Tartière smortex

🌴
Eating 🥥 and ddrinking 🍹…
View GitHub Profile
@smortex
smortex / riemann-query-each-node.rb
Created August 20, 2022 21:41
Gather the value of a Riemann metric for each node in PupppetDB
#!/opt/puppetlabs/puppet/bin/ruby
# Gather the value of a Riemann metric for each node in PupppetDB
require 'optparse'
require 'puppetdb'
require 'riemann'
usage = "usage: #{$PROGRAM_NAME} [metric]"
@smortex
smortex / riemann-wrapper.rb
Created July 26, 2022 01:26
Run multiple riemann-tools in a singe ruby process
#!/usr/bin/env ruby
# frozen_string_literal: true
Process.setproctitle($PROGRAM_NAME)
require 'riemann/tools/health'
require 'riemann/tools/net'
require 'riemann/tools/nut'
argv = ARGV.dup
{
"request": {
"url": "api/datasources/proxy/1/_msearch",
"method": "POST",
"data": "{\"search_type\":\"query_then_fetch\",\"ignore_unavailable\":true,\"index\":\"samplerr-*\"}\n{\"size\":0,\"query\":{\"bool\":{\"filter\":[{\"range\":{\"@timestamp\":{\"gte\":1656640431659,\"lte\":1656642231660,\"format\":\"epoch_millis\"}}},{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"service:\\\"memory\\\" AND host.keyword:(\\\"vps278346.vittoria.pro\\\") AND cfunc.keyword:\\\"avg\\\"\"}}]}},\"aggs\":{\"3\":{\"terms\":{\"field\":\"host.keyword\",\"size\":10,\"order\":{\"_key\":\"desc\"},\"min_doc_count\":1},\"aggs\":{\"2\":{\"date_histogram\":{\"field\":\"@timestamp\",\"min_doc_count\":0,\"extended_bounds\":{\"min\":1656640431659,\"max\":1656642231660},\"format\":\"epoch_millis\",\"interval\":\"20s\"},\"aggs\":{\"1\":{\"avg\":{\"field\":\"metric\"}}}}}}}}\n",
"hideFromInspector": false
},
"response": {
"responses": [
{
{
"request": {
"url": "api/datasources/proxy/1/_msearch",
"method": "POST",
"data": "{\"search_type\":\"query_then_fetch\",\"ignore_unavailable\":true,\"index\":\"samplerr-*\"}\n{\"size\":0,\"query\":{\"bool\":{\"filter\":[{\"range\":{\"@timestamp\":{\"gte\":1656615403174,\"lte\":1656624084514,\"format\":\"epoch_millis\"}}},{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"service:\\\"memory\\\" AND host.keyword:(\\\"vps278346.vittoria.pro\\\") AND cfunc.keyword:\\\"avg\\\"\"}}]}},\"aggs\":{\"3\":{\"terms\":{\"field\":\"host.keyword\",\"size\":10,\"order\":{\"_key\":\"desc\"},\"min_doc_count\":1},\"aggs\":{\"2\":{\"date_histogram\":{\"field\":\"@timestamp\",\"min_doc_count\":0,\"extended_bounds\":{\"min\":1656615403174,\"max\":1656624084514},\"format\":\"epoch_millis\",\"interval\":\"20s\"},\"aggs\":{\"1\":{\"avg\":{\"field\":\"metric\"}}}}}}}}\n",
"hideFromInspector": false
},
"response": {
"responses": [
{
{
"request": {
"url": "api/datasources/proxy/1/_msearch",
"method": "POST",
"data": "{\"search_type\":\"query_then_fetch\",\"ignore_unavailable\":true,\"index\":\"samplerr-*\"}\n{\"size\":0,\"query\":{\"bool\":{\"filter\":[{\"range\":{\"@timestamp\":{\"gte\":1656638495530,\"lte\":1656642095530,\"format\":\"epoch_millis\"}}},{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"service:\\\"disk\\\" AND host.keyword:(\\\"vps278346.vittoria.pro\\\") AND cfunc.keyword:\\\"avg\\\"\"}}]}},\"aggs\":{\"3\":{\"terms\":{\"field\":\"host.keyword\",\"size\":10,\"order\":{\"_key\":\"desc\"},\"min_doc_count\":1},\"aggs\":{\"4\":{\"terms\":{\"field\":\"service.keyword\",\"size\":10,\"order\":{\"_key\":\"desc\"},\"min_doc_count\":1},\"aggs\":{\"2\":{\"date_histogram\":{\"field\":\"@timestamp\",\"min_doc_count\":0,\"extended_bounds\":{\"min\":1656638495530,\"max\":1656642095530},\"format\":\"epoch_millis\",\"interval\":\"20s\"},\"aggs\":{\"1\":{\"avg\":{\"field\":\"metric\"}}}}}}}}}}\n",
"hideFromInspecto
POST /_msearch HTTP/1.1
Host: localhost:9200
User-Agent: Grafana/8.5.6
Content-Length: 670
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Content-Type: application/x-ndjson
Dnt: 1
Sec-Fetch-Dest: empty
@smortex
smortex / vhost.pp
Created February 9, 2021 00:46
IAC-1186 issue
$hostname = 'service.example.com'
apache::vhost { $hostname:
port => 443,
docroot => "${dashboard_path}/public",
# [...]
}
apache::vhost { "${hostname}:5556":
servername => $hostname,
My traceroute [vUNKNOWN]
zappy.home.sigabrt.org (192.168.1.80) 2018-12-28T10:29:08-1000
Keys: Help Display mode Restart statistics Order of fields quit
Packets Pings
Host Loss% Snt Last Avg Best Wrst StDev
1. 192.168.1.254 0.0% 4 6.5 6.0 5.3 6.5 0.6
2. 1.72.90.202.dsl.dyn.mana.pf 0.0% 4 7.5 8.9 7.5 10.9 1.6
3. 202.3.241.177 0.0% 4 10.1 8.3 7.2 10.1 1.3
4. 103.254.224.105 0.0% 4 8.3 8.0 6.6 8.7 0.9
5. 103.254.224.74
--- templates/stretch/etc/fail2ban/jail.conf.erb.orig 2018-07-25 16:29:44.719352000 +0200
+++ templates/stretch/etc/fail2ban/jail.conf.erb 2018-07-25 16:41:19.272398000 +0200
@@ -1,855 +1,941 @@
#
+# THIS FILE IS MANAGED BY PUPPET
+# <%= file %>
+#
# WARNING: heavily refactored in 0.9.0 release. Please review and
# customize settings for your setup.
#