Skip to content

Instantly share code, notes, and snippets.

Shinji Tanaka stanaka

Block or report user

Report or block stanaka

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stanaka
stanaka / anomaly_detection.rb
Created Apr 15, 2016
Simple Anomaly Detection for Mackerel
View anomaly_detection.rb
#! /usr/bin/env ruby
require "mackerel"
require "net/http"
require "uri"
require "pp"
require "date"
@mackerel_api_key = "<APIKEY>"
service = "<SERVICE>"
@stanaka
stanaka / mackerel-graph-builder.html
Last active Dec 7, 2016
save this html as a local file, then open the file.
View mackerel-graph-builder.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Mackerel Graph Builder</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
function update() {
var d = $("#def")[0].value;
var o = $("#org")[0].value;
@stanaka
stanaka / mackerel_estimate_filesystem_lifetime.py
Created Dec 20, 2015
Estimate filesystem lifetime with Mackerel
View mackerel_estimate_filesystem_lifetime.py
# -*- coding: utf-8 -*-
import requests
import time
import json
from StringIO import StringIO
import re
import sys
import os
@stanaka
stanaka / mackerel_metric.py
Created Dec 20, 2015
Regression analysis with Mackerel
View mackerel_metric.py
# -*- coding: utf-8 -*-
import requests
import time
import json
from StringIO import StringIO
import re
import sys
import os
View mackerel-plugin-smc.rb
#! /usr/bin/env ruby
$now = Time.now
$cmd = "/Users/stanaka/git/github.com/stanaka/mackerel-osx/smc"
def smc(item)
ret = `#{$cmd} read #{item}`
ret = ret.split(/\t/)
if ret[1]
ret[1].to_i
View mackerel-agent.conf
pidfile = "/usr/local/var/run/mackerel-agent.pid"
root = "/usr/local/var/mackerel-agent"
verbose = false
apikey = "APIKEY"
[plugin.metrics.battery]
command = "ruby /usr/local/bin/mackerel-osx-battery.rb"
View mackerel-osx-battery.rb
#! /usr/bin/env ruby
$ioreg = `ioreg -r -n AppleSmartBattery`
$now = Time.now
def asb(item)
ret = $ioreg.match(/(#{item})[\"= ]+(\d+)$/)
ret[2].to_i
end
View mackerel-agent.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>io.mackerel</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
View gist:4b181125c32f57057408
- Official Blog https://blog.docker.com/2014/10/announcing-docker-global-hack-day-2/
- Kick off presentation from the core team https://docker.com/community/globalhackday
-
@stanaka
stanaka / main.go
Created Sep 17, 2014
time.Now()を実行するだけのGo
View main.go
package main
import "fmt"
import "time"
func main() {
t := time.Now()
fmt.Printf("Now: %v\n", t)
}
You can’t perform that action at this time.