Skip to content

Instantly share code, notes, and snippets.

View unicolet's full-sized avatar

Umberto Nicoletti unicolet

View GitHub Profile
@unicolet
unicolet / rd-clean.sh
Created April 8, 2015 10:40
Shell script to purge Rundeck execution history
#!/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`
@unicolet
unicolet / idrac.py
Created September 1, 2020 11:00
Parse idrac logs and show the most relevant fields
import xml.etree.ElementTree as ET
import iso8601
tree = ET.parse('310TKQ2-log.xml')
root = tree.getroot()
for child in root:
timestamp = iso8601.parse_date(child.attrib["Timestamp"])
print("%s %s %s %s" % (timestamp, child.attrib["AgentID"], child.attrib["Severity"], child[0].text))
#!/usr/bin/python -u
import os
import sys
from datetime import datetime
import urllib2
import time
def get_gh_ratelimits(token):
def load_our_config(all=false)
files = Dir['conf.d/*.conf']
@@configuration = String.new
files.sort.each do |file|
if all
@@configuration << File.read(file)
elsif file !~ /output/ and file !~ /input/
@@configuration << File.read(file)
end
end
# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
describe "filebeat-forwarded plain text log" do
files = Dir['conf.d/*.conf']
@@configuration = String.new
files.sort.each do |file|
@@configuration << File.read(file)
end
# 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 July 26, 2018 17:08 — forked from cypres/zfs_report.sh
ZFS On Linux Version. Note that drive health is not reported since I am running ZFS on a VM
#!/bin/sh
echo "ZFS listing:"
/sbin/zfs list
echo
echo "ZFS compression ratio:"
/sbin/zfs get compressratio | /bin/grep -v @
echo
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);
# 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