Skip to content

Instantly share code, notes, and snippets.

Umberto Nicoletti unicolet

Block or report user

Report or block unicolet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@unicolet
unicolet / rd-clean.sh
Created Apr 8, 2015
Shell script to purge Rundeck execution history
View rd-clean.sh
#!/bin/sh
# setup ~/.pgpass to allow passwordless connection to postgres
# keep last 30 executions for each job
KEEP=30
cd /var/lib/rundeck/logs/rundeck
JOBS=`find . -maxdepth 3 -path "*/job/*" -type d`
View envoy.grok
# envoy default log format:
# https://www.envoyproxy.io/docs/envoy/latest/configuration/access_log#config-access-log-default-format
#
# [%START_TIME%] "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%"
# %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION%
# %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%"
# "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"
#
ENVOY \[%{TIMESTAMP_ISO8601:timestamp}\] "%{DATA:method} %{DATA:original_path} %{DATA:protocol}" %{DATA:response_code} %{DATA:response_flags} %{NUMBER:bytes_rcvd} %{NUMBER:bytes_sent} %{NUMBER:duration} %{DATA:upstream_svc_time} "%{DATA:x-forwarded-for}" "%{DATA:useragent}" "%{DATA:request_id}" "%{DATA:authority}" "%{DATA:upstream_host}"
@unicolet
unicolet / zfs_report.sh
Last active Jul 26, 2018 — forked from duedal/zfs_report.sh
ZFS On Linux Version. Note that drive health is not reported since I am running ZFS on a VM
View zfs_report.sh
#!/bin/sh
echo "ZFS listing:"
/sbin/zfs list
echo
echo "ZFS compression ratio:"
/sbin/zfs get compressratio | /bin/grep -v @
echo
View fosdem2018_compilation.md
View score.java
public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
final float score = score();
final int maxDoc = context.reader().maxDoc();
return new BulkScorer() {
@Override
public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException {
max = Math.min(max, maxDoc);
FakeScorer scorer = new FakeScorer();
scorer.score = score;
collector.setScorer(scorer);
View example_spec.rb
# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
files = Dir['conf.d/*.conf']
@@configuration = String.new
files.sort.each do |file|
@@configuration << File.read(file)
end
describe "simple test" do
@unicolet
unicolet / el_template.json
Created Sep 11, 2014
Elastisearch template for apache extended log format
View el_template.json
{
"template":"logstash-*",
"settings":{
"index.refresh_interval":"5s"
},
"mappings":{
"_default_":{
"dynamic_templates":[
{
"string_fields":{
View .kitchen.yml
provisioner:
omnibus_cachier: true
name: salt_solo
formula: service
state_top:
base:
"*":
- service
@unicolet
unicolet / ratelimit.py
Last active May 10, 2016
Warning: crude hack ahead! Implement a rate limiting state module for SaltStack reactors. State is maintained in a sqlite database.
View ratelimit.py
import salt.exceptions
import logging
import time
__name__ = 'ratelimit'
log = logging.getLogger(__name__)
def event(name, event_in, event_out):
bucket = {}
@unicolet
unicolet / opennms_event_param_functions.sql
Last active Apr 22, 2016
Two postgres functions to retrieve param values from OpenNMS events.eventparms column. Tested on postgres 9.4
View opennms_event_param_functions.sql
CREATE OR REPLACE FUNCTION event_pval_num(p_eventparams text, p_param text) RETURNS integer AS $$
BEGIN
RETURN (regexp_matches(p_eventparams,p_param||'=(\d+)'))[1];
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION event_pval_txt(p_eventparams text, p_param text) RETURNS text AS $$
BEGIN
RETURN (regexp_matches(p_eventparams,p_param||'=(.*?)\(string'))[1];
END;
You can’t perform that action at this time.