Skip to content

Instantly share code, notes, and snippets.

View lennartkoopmann's full-sized avatar
🤠

Lennart Koopmann lennartkoopmann

🤠
View GitHub Profile
public class GELFUDPDecoder extends FrameDecoder {
private static final Logger LOG = Logger.getLogger(GELFUDPDecoder.class);
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
if (buffer.readableBytes() < GELFUtilities.GELF_HEADER_TYPE_LENGTH) {
LOG.debug("Skipping GELF packet that is not even long enough to contain the required GELF header.");
return null;
}
public void registerInitializer(Initializer initializer) {
this.initializers.add(initializer);
}
@Override
public void run() {
...
// Call all registered initializers.
// Set createdAt to provided timestamp - Set to current time if not set.
double timestamp = this.jsonToDouble(json.get("timestamp"));
if (timestamp <= 0) {
this.message.setCreatedAt(Tools.getUTCTimestampWithMilliseconds());
} else {
this.message.setCreatedAt(timestamp);
}
lennart ♥ ~$ irb
irb(main):001:0> "02/04/2012".scan(/^(0)\d\/(0)\d\/\d{4}/)
=> [["0", "0"]]
irb(main):002:0>
{
:message => "foo bar, i completed a job",
:full_message => "this worked\nthis also worked\neven this worked\ni'm done \o/",
:host => "worker1",
:facility => "worker",
:severity => GELF::Levels::Notice,
:_process_id => aeh7aivai8Leiz8uce9woh6oogh2aeDa,
:_process_type => "image_transformation",
:_total_time_ms => 4529
}
lennart ~$ host httpbin.org
lennart ~$ host www.httpbin.org
www.httpbin.org is an alias for httpbin.herokuapp.com.
httpbin.herokuapp.com is an alias for ar.herokuapp.com.
ar.herokuapp.com is an alias for argon-stack-1879049447.us-east-1.elb.amazonaws.com.
argon-stack-1879049447.us-east-1.elb.amazonaws.com has address 107.22.181.229
argon-stack-1879049447.us-east-1.elb.amazonaws.com has address 107.20.207.77
argon-stack-1879049447.us-east-1.elb.amazonaws.com has address 107.20.154.48
argon-stack-1879049447.us-east-1.elb.amazonaws.com has address 107.22.178.183
argon-stack-1879049447.us-east-1.elb.amazonaws.com has address 50.17.208.142
^C
INFO : org.graylog2.messagequeue.MessageQueueFlusher - Message queue flusher called!
INFO : org.graylog2.messagequeue.MessageQueueFlusher - Closing message queue.
INFO : org.graylog2.messagequeue.MessageQueue - Read 174 messages from queue.
INFO : org.graylog2.messagequeue.MessageQueueFlusher - Flushing all 174 messages to indexer.
INFO : org.graylog2.messagequeue.MessageQueueFlusher - Finalizing message queue flushing.
lennart ♥ ~/workspace/graylog2/graylog2-server/target (develop)$
for((i=0; i<$SHLVL; i++)) ; do
SUBSHELLHEARTS=$SUBSHELLHEARTS♥
done
export PS1='\[\033[01;32m\]lennart\[\033[01;34m\] $SUBSHELLHEARTS \w\[\033[31m\]$(__git_ps1 " (%s)")\[\033[01;34m\]$\[\033[00m\] '
def parse_operator_options
string = @command.scan(/\..+\((.+?)\)/)[0][0]
singles = string.split(",")
parsed = Hash.new
singles.each do |single|
key = single.scan(/^(.+?)(\s|#{ALLOWED_CONDITIONALS.join('|')})/)[0][0].strip
value = typify_value(single.scan(/(#{ALLOWED_CONDITIONALS.join('|')})(.+)$/)[0][1].strip)
parsed[key.to_s] = value
protected void parseHost() {
int i = this.message.indexOf(' ');
if (i > -1) {
String hostAddress = null;
String hostName = null;
String providedHost = this.message.substring(0,i).trim();
hostAddress = this.inetAddress.getHostAddress();