Skip to content

Instantly share code, notes, and snippets.

View alxschwarz's full-sized avatar

Alexander Feller alxschwarz

View GitHub Profile
@alxschwarz
alxschwarz / gist:3128734
Created July 17, 2012 11:02
String replace in file
def string_replace(init_string, replace_string, file_name)
file = File.new(file_name)
lines = file.readlines
file.close
changes = false
x = 0
lines.each do |line|
changes = true if line.sub!(init_string, replace_string)
end
@alxschwarz
alxschwarz / detect_crash.py
Created August 28, 2012 06:49
Detect Crash Dump
#!/usr/bin/python
import os
import subprocess
import shutil
import socket
def detect_coredump():
os.chdir("/var/crash")
return os.path.isfile("_var_games.0.crash")
@alxschwarz
alxschwarz / lwp.conf
Created October 7, 2013 14:15
LXC Web Panel Upstart script
#!upstart
description "Upstart script for LXC Web Panel "
author "Alexander 'AlexFinn' Ivanov <[email protected]>"
start on net-device-up
stop on shutdown
script
WORK_DIR="/srv/lwp"
@alxschwarz
alxschwarz / jira.service
Created August 29, 2014 19:08
systemd service file for Atlassian Jira
[Unit]
Description=Atlassian Jira Service
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/opt/atlassian/jira/bin/start-jira.sh
ExecStop=/opt/atlassian/jira/bin/stop-jira.sh
[Install]
@alxschwarz
alxschwarz / node.service
Created August 29, 2014 19:10
Example systemd file for Node.js service
[Service]
WorkingDirectory=/srv/ajs-node/current/
ExecStart=/usr/bin/npm start
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=ajs-node
User=ajs
Group=ajs
@alxschwarz
alxschwarz / newrelic.yml
Created February 20, 2015 09:31
Example ansible tasks for newrelic package installing
---
- name: Install the NewRelic rpm from a remote repo
yum: name=http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm state=present
tags: newrelic
- name: Temporary disabling SELinux
command: setenforce 0
- name: Install NewRelic monitoring package
yum: name=newrelic-sysmond state=latest
log_format logstash '$remote_addr [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'$request_time '
'$upstream_response_time';
NGUSERNAME [a-zA-Z\.\@\-\+_%]+
NGUSER %{NGUSERNAME}
NGINXACCESS %{IPORHOST:clientip} \[%{HTTPDATE:timestamp}\] "%{WORD:verb} %{URIPATHPARAM:request} HTTP/%{NUMBER:httpversion}" %{NUMBER:response} (?:%{NUMBER:bytes}|-) (?:"(?:%{URI:referrer}|-)"|%{QS:referrer}) %{QS:agent} %{NUMBER:request_time} %{NUMBER:upstream_responce_time}
@alxschwarz
alxschwarz / ap-install.sh
Last active February 24, 2016 19:29
Ansible & Packer install sript
#!/bin/bash
echo "#####################################################"
echo " *** Updating cache ***"
echo "#####################################################"
sudo apt-get update -y
echo "#####################################################"
echo "*** Installing software-properties-common package ***"
echo "#####################################################"
sudo apt-get install software-properties-common -y
@alxschwarz
alxschwarz / install-clang.sh
Last active June 29, 2016 11:27
clang-3.8.sh
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
print_status() {
echo
echo "## $1"
echo
}