This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| DATAFILE="/var/tmp/nagios_check_forkrate.dat" | |
| VALID_INTERVAL=600 | |
| OK=0 | |
| WARNING=1 | |
| CRITICAL=2 | |
| UNKNOWN=-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Show the rate of swapping (in number of pages) between executions | |
| OK=0 | |
| WARNING=1 | |
| CRITICAL=2 | |
| UNKNOWN=-1 | |
| EXITFLAG=$OK | |
| WARN_THRESHOLD=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # ************************************************* | |
| # chkconfig: 2345 99 99 | |
| # description: notify email address on system boot. | |
| # ************************************************* | |
| # Installing: | |
| # 1) save as /etc/rc.d/init.d/notify | |
| # 2) set the desired email address in "MAILADD" variable | |
| # 3) chmod a+w /etc/rc.d/init.d/notify |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # call like this on the target server: | |
| # NODENAME='foo' CHEF_ENV='production' RUNLIST='["role[foo]","recipe[bar]"]' CHEFREPO='git@example.com:repo.git' bash <( curl -L https://raw.github.com/gist/1026628 ) | |
| # You will need to ensure that the ssh key is already set up on the server. | |
| set -e | |
| export CHEF_DIR="${HOME}/chef" | |
| sudo rm -rf $CHEF_DIR | |
| mkdir -p "$CHEF_DIR" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Step 1. | |
| Edit /etc/security/limits.conf | |
| Step 2. | |
| Notice this is set to all processes but if you have a process running as a service account replace the * with the service account. | |
| Step 3. | |
| Next, you will have to restart the process for this change to go into effect. | |
| # vi /etc/security/limits.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # herein we backup our indexes! this script should run at like 6pm or something, after logstash | |
| # rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas, | |
| # compress the data files, create a restore script, and push it all up to S3. | |
| TODAY=`date +"%Y.%m.%d"` | |
| INDEXNAME="logstash-$TODAY" # this had better match the index name in ES | |
| INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/" | |
| BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put" | |
| BACKUPDIR="/mnt/es-backups/" | |
| YEARMONTH=`date +"%Y-%m"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| def lensort(list): | |
| for index in range(1,len(list)): | |
| currentValue = list[index] | |
| position = index | |
| while position > 0 and len(list[position - 1]) > len(currentValue): | |
| list[position] = list[position - 1] | |
| position = position -1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin//env python | |
| # reverse print the contents of a file | |
| import sys | |
| x = open(sys.argv[1]).readlines() | |
| y = [] | |
| m = len(x) - 1 | |
| for i in range(len(x)): | |
| print x[m] | |
| m = m -1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # usage : word_frequency.py foo.txt | |
| # will print the words frequency in random order | |
| def word_frequency(words): | |
| """ Returns frequency of each word given a list of words. | |
| >>> word_frequency.py([a,b,a]) | |
| {'a': 2, 'b' : 1} | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> content = urllib2.urlopen('http://httpbin.org/get').read() | |
| >>> print content | |
| { | |
| "args": {}, | |
| "headers": { | |
| "Accept-Encoding": "identity", | |
| "Connection": "close", | |
| "Host": "httpbin.org", | |
| "User-Agent": "Python-urllib/2.7", | |
| "X-Request-Id": "5a77cb68-7064-4997-afc1-4481f4bfa706" |
OlderNewer