Skip to content

Instantly share code, notes, and snippets.

View joaompinto's full-sized avatar

João Pinto joaompinto

View GitHub Profile
#!/bin/bash
set -e
[[ $# != 2 ]] && echo "Usage: $0 projectDir snapshot.zip" && exit 1
projectDir=$1
snapZip=$2
tmpDir=$(mktemp -d)
unzip -d $tmpDir $snapZip
jarFiles=$(find $projectDir -name gdx*.jar)
@joaompinto
joaompinto / iostat_collect.sh
Created August 26, 2013 16:49
Collect iostat data with timestamps for easy csv import
#!/bin/bash
STATS_DIR=/var/adm/localstats/iostats
mkdir -p -m750 $STATS_DIR
function prefix_date {
is_device=0
while read line;
do
STATS_FILE=$STATS_DIR/iostats_$(date +"%Y%m%d").txt
"""
This script updates applications using the EARs placed on a specified dir
Usage:
wsadmin.sh -lang jython -f update_apps_from_dir.py apps_dir
"""
import os
import glob
@joaompinto
joaompinto / addusers_from_list.py
Last active December 24, 2015 03:59
Adds users from a list of users and sets them a random password
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This scrip adds users from a list of users, sets them a random password
# and forces their password to change on the first login.
# If the username already exists it will be silently skipped
# The list of users and passwords being created are printed
# Add the list of users (txt format) into the following user_data variable
# The format is: username real name
@joaompinto
joaompinto / check_tsm_last_backup.sh
Created September 28, 2013 10:57
This script reports the last backup status by checking the TSM scheduler log
#!/bin/sh
# This script reports the last backup status by checking the TSM scheduler log
[[ ! -f /opt/tivoli/tsm/client/ba/bin/dsm.sys ]] \
&& echo "$(hostname);Config file not found" && exit 0
SCHEDLOGNAME=$(grep -i SCHEDLOGN /opt/tivoli/tsm/client/ba/bin/dsm.sys | awk '{ print $2}')
LAST_MSG=$(grep "Elapsed processing time" $SCHEDLOGNAME| tail -1)
[[ -z "$LAST_MSG" ]] && LAST_MSG=$(grep "ANS1353E" $SCHEDLOGNAME| tail -1)
[[ -z "$LAST_MSG" ]] && LAST_MSG=$(tail -1 $SCHEDLOGNAME)
[[ -z "$LAST_MSG" ]] && LAST_MSG=$(tail -2 /var/log/dsmsched.log | head -1)
echo "$(hostname);$LAST_MS
#!/bin/bash
#
# /etc/init.d/nmon
#
# chkconfig: 345 70 55
# description: nmon init script
# Source function library.
. /etc/init.d/functions
@joaompinto
joaompinto / system_backup.sh
Last active August 29, 2015 13:56
system_backup.sh
tar -C / -czvpf /system_backup.tar.gz \
--one-file-system \
--exclude=run \
--exclude=sys \
--exclude=dev \
--exclude=system_backup.tar.gz \
--exclude=home \
--exclude=opt \
--exclude=var/cache/apt/archives \
. boot/ > >(tee /system_backup.log) 2> >(tee /system_backup.errors >&2)
@joaompinto
joaompinto / etc_cron.daily_nmon
Last active August 29, 2015 13:56
Files used to setup nmon as a service
#!/bin/sh
LOGDIR=/var/log/nmon
/etc/init.d/nmon stop
find $LOGDIR -name "*.nmon" -mtime -mmin +10 -exec gzip {} \;
find $LOGDIR -name "*.nmon.gz" -mtime +90 -exec rm {} \;
/etc/init.d/nmon start
@joaompinto
joaompinto / etc_profile.d_history_logging.sh
Last active August 29, 2015 13:56
etc_profile.d_history_logging.sh
#!/bin/sh
# avoid duplicates..
export HISTCONTROL=ignoredups:erasedups
# append history entries..
shopt -s histappend
# After each command, save and reload history
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
readonly PROMPT_COMMAND
@joaompinto
joaompinto / gist:141fa88b7912b0b32296
Created March 16, 2015 17:40
How to create a portable MSYS archive
Surviving on Windows with MSYS
If you are experienced Linux/Unix user you will get a bad time working on Windows, to my rescue comes MSYS which contains most of common utilities like tail, grep and friends. It does not require installation so it can be easily used from Windows servers.
Download the installer (mingw-get-*-bin.zip/ ) from:
http://sourceforge.net/projects/mingw/files/Installer/mingw-get/
Extract mingw-get-*-bin.zip to C:\mingw_install
From the command line:
cd C:\mingw_install\bin
mingw-get.exe install msys-mintty msys-grep msys-base msys-openssh