Code Monkey home page Code Monkey logo

production-log-management's Introduction

Production log filter script

Shell script to monitor production server logs and store the result in a file.


Motivation:

To automate the monotonous task of monitoring the logs from a production/test server.
SSHing into the remote server eats up valuable time and resources
Basic commands such as df, top, etc can be easily appended to the script.
Filtering of logs using sed, awk and grep to only get the required information.
Force Redownloading the logs when necessary

This project consistd of two scripts each of which takes in appropriate arguments as denoted by its usage pattern.


prod-monitoring.sh

$ ./prod-monitor.sh [-u user] [-p pwd] [-f force-refresh] [-l logs-per-day] [- m month] [-d date] [-y year]
   
# -u user: user having access to the prod system
# -p passwd: passwd of the user having access to the prod system
# -f force-refresh: specify if logs have to be pulled from scratch
# -l maxLogsPerDay: How many logs do you need per day
# -m month: Month for which logs need
# -d date: date for which logs need to be created in the given month
# -y year: Year for which logs need to be created

Usage scenarios

To fetch logs for Jun 7

$ ./prod-monitor.sh -f 1 -d 5 -m Jun
    ******************
    Production log monitor script started
    Admin user: sn470454
    Monitor server: c0001413.prod.cloud.fedex.com
    Monitor directory: /var/fedex/por/logs/weblogic/por_c0001413.log
    Log month: Jun/2018
    Log date: 5
    Logs requested per day: 2
    ******************

    System up and running as of Fri Jun  8 07:44:07 GMT 2018

    Reusing previous logs. Force flag disabled
    Displaying log results
    Checking logs for Jun 5 
    ******************
    Jun 5, 2018 9:50:11 AM GMT	20% of the total memory in the server is free. 
    Jun 5, 2018 3:33:11 PM GMT	75% of the total memory in the server is free. 
    Size of /opt/fedex: 55%
    Size of /var/fedex: 57%
    CPU Usage as reported on the server: 0%
    ******************

To fetch logs for entire Jun given the current date is 7th June

$ ./prod-monitor-filter.sh -f 1 -m Jun 

    Checking logs for Jun 2018 uptil current date
    ******************
    Logs already filled for Jun 1,
    ******************
    Logs already filled for Jun 2,
    ******************
    Logs already filled for Jun 3,
    ******************
    Logs already filled for Jun 4,
    ******************
    Logs already filled for Jun 5,
    ******************
    Logs already filled for Jun 6,
    ******************
    Logs already filled for Jun 7,
    ******************

production-log-management's People

Contributors

aman-accolite avatar isopropylcyanide avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.