Skip to content

Instantly share code, notes, and snippets.

View rav94's full-sized avatar
🎯
Focusing

Ravindu Fernando rav94

🎯
Focusing
View GitHub Profile
@rav94
rav94 / Error_Reporter_nohup.sh
Last active December 16, 2017 04:12
Shell script for reporting nohup.out general errors into specified email/s.
#!/bin/bash
#Check whether a temporary file exisits
if [ ! -e nohup_errors_log ];
#If not you are here
then
#Grep for the desired pattern within your log file to catch the Error and Save the content to a new temporary file
grep "\[[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\},[0-9]\{3\}\] ERROR" /home/ubuntu/ravindu/nohup.out | sort > nohup_errors_log
#Mail the recorded error list to the desired mail (You can mail it to multiple uses also)
mail -s "Error Log for nohup.out" ravindu@mydomain.com < nohup_errors_log
@rav94
rav94 / remove-docker-dangling.service
Created October 14, 2017 06:13
Systemd Service file for removing Docker dangling images
[Unit]
Description=Removing Docker Dangling Images Cron Service
After=docker.service
Requires=docker.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c "/bin/docker rmi $(docker images --quiet --filter 'dangling=true')"
@rav94
rav94 / remove-docker-dangling.timer
Created October 14, 2017 06:15
Systemd timer for remove-docker-dangling.service - To run in daily frequency
[Unit]
Description=Run remove-docker-dangling.service every 30 minutes
[Timer]
OnCalendar=*:0/30
@rav94
rav94 / fabfile.py
Last active December 18, 2017 08:55
Manage Systemd Units on AWS CoreOS Tagged Instances with Fabric and boto
import boto, urllib2
from boto.ec2 import connect_to_region
from fabric.api import env, run, cd, settings, sudo
from fabric.api import parallel
import os
import sys
REGION = os.environ.get("AWS_EC2_REGION")
# Server user
env.user = "core"
# List of AWS private key Files
fab set_hosts:Name,${awsInstanceName},${regionName} restart_systemctl:servicefile=${serviceFileName}
@rav94
rav94 / release.sh
Last active November 3, 2020 18:31
Release a branch from master + updating maven POM file version to new version for multi module project.
#!/bin/bash
# current Git branch
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# current project name
projectName=$(git config --local remote.origin.url|sed -n 's#.*/\([^.]*\)\.git#\1#p')
# establish master branch name variables
masterBranch=$branch
@rav94
rav94 / Dockerfile
Created April 9, 2019 06:10
Filebeat Custom Dockerfile
FROM docker.elastic.co/beats/filebeat:6.5.2
# Copy custom configuration file
COPY filebeat.yml /usr/share/filebeat/filebeat.yml
USER root
# Create a directory to map volume with all docker log files
RUN mkdir /usr/share/filebeat/dockerlogs
RUN chown -R root /usr/share/filebeat/
RUN chmod -R go-w /usr/share/filebeat/
@rav94
rav94 / filebeat.yml
Last active April 10, 2019 05:51
Filebeat Configuration File
filebeat.inputs:
- type: docker
containers:
path: "/usr/share/dockerlogs/data"
stream: "stdout"
ids:
- "*"
cri.parse_flags: true
combine_partial: true
exclude_files: ['\.gz$']
@rav94
rav94 / filebeat.service
Created April 10, 2019 05:30
Filebeat Systemd Unit File
[Unit]
Description=Filebeat Docker Service
After=docker.service
Requires=docker.service
[Service]
Type=simple
User=root
TimeoutStartSec=0
Restart=on-failure
@rav94
rav94 / logstash.conf
Created April 10, 2019 05:45
Logstash configuration for basic filebeat log collection
input {
beats {
port => 5044
}
}
## Add your filters / logstash plugins configuration here
filter {