Skip to content

Instantly share code, notes, and snippets.

package main
import (
"errors"
"io"
"log"
"os"
"time"
"github.com/goftp/server"
@discobean
discobean / extract_nginx_codes.py
Created October 24, 2016 01:19
Extracts nginx status codes and can print status codes of a specific search result
#!/usr/bin/python
import re, sys, fileinput
try:
search = sys.argv[1]
except:
search = '5'
class NginxLogParser:
@discobean
discobean / extract_nginx_hostname.py
Created October 24, 2016 01:18
Extracts nginx hostname from nginx log files
#!/usr/bin/python
import re, sys, fileinput
class NginxLogParser:
"""
This class implements a nginx log parser. After feeding a nginx log format, it generates a regex for
that specify format. Then we use this regex to extract useful information from nginx log.
"""
format_directive = r'(\S)?\$([\w_]+)(\S)?'