Skip to content

Instantly share code, notes, and snippets.

View ohsawa0515's full-sized avatar

Shuichi Ohsawa ohsawa0515

View GitHub Profile
@ohsawa0515
ohsawa0515 / icinga.coffee
Last active December 11, 2015 08:04
hubotでicingaの通知をon/offするcoffeeスクリプト
# Description:
# Interact with the Icinga-Web API.
# Please set the environment variable.
# $ export ICINGA_URL="http://<icinga-url>"
# $ export ICINGA_AUTH_KEY="<icinga auth key>"
#
# Commands:
# hubot icinga start all <hosts> - Turn on the notification of the specified hosts of host and services
# hubot icinga stop all <hosts> - Turn off the notification of the specified hosts of host and services
# hubot icinga start host <hosts> - Turn on the notification of the specified hosts of host
@ohsawa0515
ohsawa0515 / Redisextend.pm
Last active August 29, 2015 14:24
CloudForecastでRedisのメトリクスを取得(本家のスクリプトを改造)
package CloudForecast::Data::Redisextend;
use CloudForecast::Data -base;
use CloudForecast::TinyClient;
=head1 NAME
CloudForecast::Data::Redisextend - redis resource monitor
=head1 SYNOPSIS
@ohsawa0515
ohsawa0515 / WinBasic.pm
Last active November 6, 2015 06:55
Cloudforecast でWindowsのリソース情報をSNMPによって取得する定義モジュール
package CloudForecast::Data::WinBasic;
use CloudForecast::Data -base;
=head1 NAME
CloudForecast::Data::WinBasic - Basic for Windows
=head1 DESCRIPTION
@ohsawa0515
ohsawa0515 / WinDisk.pm
Last active November 5, 2015 01:13
Cloudforecast でWindowsのDiskリソース情報を取得する定義モジュール
package CloudForecast::Data::WinDisk;
use CloudForecast::Data -base;
=head1 NAME
CloudForecast::Data::WinDisk - Disk resource for Windows
=head1 DESCRIPTION
@ohsawa0515
ohsawa0515 / WinDiskio.pm
Last active November 5, 2015 07:12
Cloudforecast でWindowsのDisk IO リソース情報を取得する定義モジュール
package CloudForecast::Data::WinDiskio;
use CloudForecast::Data -base;
=head1 NAME
CloudForecast::Data::WinDiskio - Disk IO resource for Windows
=head1 DESCRIPTION
@ohsawa0515
ohsawa0515 / Gpu.pm
Created November 6, 2015 06:55
Cloudforecast でGPUパフォーマンス状況をSNMPによって取得する定義モジュール
package CloudForecast::Data::Gpu;
use CloudForecast::Data -base;
use JSON qw/encode_json decode_json/;
rrds map { [ $_, 'GAUGE' ] } qw/cpu memory/;
graphs 'cpu' => 'GPU Usage [%]';
graphs 'memory' => 'GPU Memory Usage [%]';
@ohsawa0515
ohsawa0515 / gpu_performance.sh
Created November 6, 2015 06:58
GPUパフォーマンス情報を取得するスクリプト
#!/bin/sh
tmp=/tmp/nvidia_tmp.txt
/usr/bin/nvidia-smi -q -d UTILIZATION > $tmp
cpu=$(cat $tmp | awk '/Gpu/ {print $3}')
memory=$(cat $tmp | awk '/Memory.*:/ {print $3}')
echo "{\"cpu\":${cpu}, \"memory\":${memory}}"
exit 0
@ohsawa0515
ohsawa0515 / icinga_disable_checker.sh
Last active May 2, 2018 13:30
Icinga disable notification check script
#!/bin/bash
# Icinga disable notification checker
# Please install jq package before use.
# e.g. yum install jq
from_address="notification@hogehoge.com"
to_address=${1:-"foo@bar.example.com"}
set_body()
@ohsawa0515
ohsawa0515 / reprocess_batch.sh
Created September 2, 2016 07:52
AWS Lambda Based Amazon Redshift Database Loader で失敗したバッチを再実行するスクリプト
#!/bin/bash
region="ap-northeast-1"
error_batches=$(node queryBatches.js $region error)
i=0
while :
do
error_batch=$(echo $error_batches | jq -r .[$i])
if [ $? -ne 0 ]; then
@ohsawa0515
ohsawa0515 / cloudwatch2mackerel_service_metrics.py
Last active January 6, 2017 01:36
Send CloudWatch metics to Mackerel service metrics using Amazon Lambda.
# -*- coding: utf-8 -*-
import boto3, os, json, calendar
from base64 import b64decode
from datetime import datetime, timedelta
from urllib2 import Request, urlopen
os.environ['TZ'] = 'Asia/Tokyo'
mackerel_url = "https://mackerel.io/api/v0/services/%s/tsdb"
encrypted_mackerel_api_key = "<ENCRYPTED_API_KEY>"