Skip to content

Commit

Permalink
Merge branch 'master' into pr/127
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
matryer committed Jan 14, 2016
2 parents c608888 + faa6b23 commit 146b5a4
Show file tree
Hide file tree
Showing 25 changed files with 1,055 additions and 84 deletions.
16 changes: 12 additions & 4 deletions AWS/elb.30s.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/bin/sh

# Requires:
# awscli (https://aws.amazon.com/cli/)
#
# Percentage of healthy EC2 instances behind an ELB
# Dropdown with healthy and unhealthy totals
#
# Author Jonathan Keith
# by Jonathan Keith (http://github.com/joncse)
#
# <bitbar.title>AWS ELB Healthy Percentage</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Jonathan Keith</bitbar.author>
# <bitbar.author.github>joncse</bitbar.author.github>
# <bitbar.desc>Shows the percentage of healthy EC2 instances behind an ELB along with a dropdown to display the healthy and unhealthy totals.</bitbar.desc>
# <bitbar.dependencies>awscli</bitbar.dependencies>
# <bitbar.image>http://i.imgur.com/nQ6LzvZ.png</bitbar.image>
#
# Dependencies:
# awscli (https://aws.amazon.com/cli/)

export PATH='/usr/local/bin:/usr/bin:/bin:$PATH'

Expand Down
13 changes: 8 additions & 5 deletions Bitcoin/bitstamp.net/last.10s.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/bash

# Bitstamp rate
# BitBar plugin
# Shows last BTC price (in USD) on Bitstamp exchange.
#
# <bitbar.title>Bitstamp last price plugin</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Damien Lajarretie</bitbar.author>
# <bitbar.author.github>dlajarretie</bitbar.author.github>
# <bitbar.desc>Shows last BTC price (in USD) on Bitstamp exchange.</bitbar.desc>
# <bitbar.image>http://i.imgur.com/aQCqOW6.png</bitbar.image>
#
# by Damien Lajarretie
# Based on Coinbase bitbar plugin by Mat Ryer
#
# Shows last BTC price (in USD) on Bitstamp exchange.
#

echo -n "Bitstamp: $"; curl -s "https://www.bitstamp.net/api/ticker/" | egrep -o '"last": "[0-9]+(\.)?([0-9]{0,2}")?' | sed 's/"last": //' | sed 's/\"//g'
31 changes: 31 additions & 0 deletions Bitcoin/huobi.com/huobiprice.1s.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/python
# coding=utf-8

# <bitbar.title>Huobi last price plugin</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Sam Xie</bitbar.author>
# <bitbar.author.github>mountain3th</bitbar.author.github>
# <bitbar.desc>A very simple huobi last price display tool</bitbar.desc>
# <bitbar.dependencies>python</bitbar.dependencies>
#
# by mountain3th/Sam Xie

import urllib2


def price():
response = urllib2.urlopen('https://api.huobi.com/staticmarket/td_btc.html').read()
lines = response.split('\n')
last_line = lines[-2]
last_second_line = lines[-3]
open_price = float(lines[2])
last_price = float(last_second_line.split(',')[1])
current_price = float(last_line.split(',')[1])
return open_price, last_price, current_price

def prices_output():
open_price, last_price, current_price = price()
return u'火币网:¥%s%s %.2f' % (current_price, u'⬆️' if current_price > last_price else u'⬇️', (current_price - open_price) / open_price * 100) + '%'

if __name__ == '__main__':
print prices_output().encode('utf-8')
1 change: 1 addition & 0 deletions Dev/Docker/docker-status.1m.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# <bitbar.version>v1.1</bitbar.version>
# <bitbar.author>Manoj Mahalingam</bitbar.author>
# <bitbar.author.github>manojlds</bitbar.author.github>
# <bitbar.image>https://cloud.githubusercontent.com/assets/191378/12255368/1e671b32-b919-11e5-8166-6d975396f408.png</bitbar.image>
# <bitbar.desc>Displays the status of docker machines and running containers</bitbar.desc>
# <bitbar.dependencies>shell,docker,docker-machine</bitbar.dependencies>
#
Expand Down
63 changes: 63 additions & 0 deletions Dev/GitHub/github_watch.1h.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env ruby

# <bitbar.title>GitHub Watch</bitbar.title>
# <bitbar.version>v0.1.0</bitbar.version>
# <bitbar.author>D. Khamsing</bitbar.author>
# <bitbar.author.github>dkhamsing</bitbar.author.github>
# <bitbar.desc>Show GitHub stars ⭐️ for a list of repos</bitbar.desc>
# <bitbar.image>http://i.imgur.com/z1qhSun.png</bitbar.image>
# <bitbar.dependencies>ruby</bitbar.dependencies>
# <bitbar.abouturl>https://github.com/dkhamsing</bitbar.abouturl>

require 'open-uri'
require 'json'

REPOS = [
'dkhamsing/awesome_bot',
'dkhamsing/open-source-ios-apps'
]

VERSION = '0.1.0'

CONFIG_GITHUB_WATCH = 'stargazers_count'

CONFIG_SYMBOL = '★'

GITHUB_REPO_API = 'https://api.github.com/repos'

def get_stars(repos)
s = []
repos.each do |r|
repo_url = "#{GITHUB_REPO_API}/#{r}"
c = open repo_url
j = JSON.parse c.read
s.push j[CONFIG_GITHUB_WATCH]
end
s
end

def line(r, s)
repo_url = "https://github.com/#{r}"
puts "#{r} #{CONFIG_SYMBOL} #{s} | href=#{repo_url}"
end

def separator
puts '---'
end

def version_title
puts "GitHub Watch #{VERSION}"
end

# bitbar output
begin
get_stars(REPOS).each_with_index { |s, i| line REPOS[i], s.to_s }
separator
version_title
rescue => e
puts "#{CONFIG_SYMBOL} | color=red"
puts "Error: #{e}"
separator
version_title
exit
end
49 changes: 49 additions & 0 deletions Dev/Jenkins/jenkins-multiple-projects-status.1m.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
USER="username"
PASS="password"
BASE_URL="jenkins-address.com"
PROJECTS=("project1" "project2")

function displaytime {
local T=$1/1000
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
local output=""

if [[ $D -gt 0 || $H -gt 0 || $M -gt 10 ]]
then
output+=">10mn"
else
output+="${M}mn ${S}s"
fi

echo "${output} ago"
}

# beginning of display
echo "Jenkins Status"
echo "---"

for project in "${PROJECTS[@]}"
do
output="${project}: "
url="https://${USER}:${PASS}@${BASE_URL}/job/${project}/lastBuild/api/json?pretty=true"
query=$(curl --insecure --silent "${url}" | tail -30) # take only the end of output

success=$(echo "${query}" | grep "result" | awk '{print $3}') # grep the "result" line

if [[ $success == *"SUCCESS"* ]]
then
output+='🔵 '
else
output+='🔴 '
fi

timestamp=$(echo "${query}" | grep "timestamp" | awk '{print $3}') # grep the "timestamp" line
timestamp=${timestamp%?} # remove the trailing ','
currentTime=$(($(date +'%s * 1000 + %-N / 1000000'))) # generate a timestamp
output+=" $(displaytime $(( currentTime - timestamp )))"
echo "${output}"
done
17 changes: 17 additions & 0 deletions Dev/Logs/tail.5s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# <bitbar.title>tail</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Mat Ryer</bitbar.author>
# <bitbar.author.github>matryer</bitbar.author.github>
# <bitbar.desc>Tails a text file, set `FILE` env var. Perfect for tailing logs in the menu bar.</bitbar.desc>
# <bitbar.image>https://cloud.githubusercontent.com/assets/101659/12247623/b65b6f1e-b8ac-11e5-8ec2-6d9d885bfb6f.png</bitbar.image>
# <bitbar.dependencies></bitbar.dependencies>
# <bitbar.abouturl>https://github.com/matryer/bitbar-plugins/blob/master/Dev/Logs/tail.5s.sh</bitbar.abouturl>

LINES=15
FILE="path/to/file/to/tail"

echo -n ""
basename "$FILE"
echo ---
tail -n "$LINES" "$FILE"
16 changes: 9 additions & 7 deletions Dev/Nagios/nagios.sh → Dev/Nagios/nagios.30s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@

## set variables

URL="{set your nagios url here}" # ie nagios.example.com
URL="{set your nagios url here}" # ie nagios.example.com
NAME="{username}" # username
PASSWORD="{password}" # password
PASSWORD="{password}" # password

TEMP_FILE="/tmp/nagios.out"
TAC="tac.cgi"
STATUS="status.cgi"
DOWN="?hostgroup=all&style=hostdetail&hoststatustypes=4&hostprops=4"
DOWN="?hostgroup=all&style=hostdetail&hoststatustypes=4&hostprops=42"
CRITICAL="?host=all&style=detail&servicestatustypes=16"
WARNING="?host=all&style=detail&servicestatustypes=4"
UNKNOWN="?host=all&style=detail&servicestatustypes=8"
OK="?host=all&style=detail&servicestatustypes=2"

curl -s -u $NAME:$PASSWORD https://$URL/nagios/cgi-bin/$TAC > $TEMP_FILE

#down=`grep "$DOWN" $TEMP_FILE | grep | cut -d\> -f3 | cut -d\< -f1`
down=`grep "$DOWN" $TEMP_FILE | grep Down | cut -d\> -f3 | cut -d\< -f1`
critial=`grep "$CRITICAL" $TEMP_FILE | grep Critical | cut -d\> -f3 | cut -d\< -f1`
warning=`grep "$WARNING" $TEMP_FILE | grep Warning | cut -d\> -f3 | cut -d\< -f1`
unknown=`grep "$UNKNOWN" $TEMP_FILE | grep Unknown | cut -d\> -f3 | cut -d\< -f1`
ok=`grep "$OK" $TEMP_FILE | grep Ok | cut -d\> -f3 | cut -d\< -f1`

# insert host down here
#echo "$down | color=purple href=https://$URL/nagios/cgi-bin/$STATUS/$DOWN"
echo "$down | color=purple href=https://$URL/nagios/cgi-bin/$STATUS/$DOWN"
echo "$critial | color=red href=https://$URL/nagios/cgi-bin/$STATUS/$CRITICAL"
echo "$warning | color=yellow href=https://$URL/nagios/cgi-bin/$STATUS/$WARNING"
echo "$warning | color=brown href=https://$URL/nagios/cgi-bin/$STATUS/$WARNING"
echo "$unknown | color=orange href=https://$URL/nagios/cgi-bin/$STATUS/$UNKNOWN"
echo "$ok | color=green href=https://$URL/nagios/cgi-bin/$STATUS/$OK"
Loading

0 comments on commit 146b5a4

Please sign in to comment.