Skip to content

Instantly share code, notes, and snippets.

@dehio3
dehio3 / get_summary.sh
Last active June 23, 2016 14:05
各ESXiにssh接続し、仮想サーバのサマリー情報を取得するスクリプト(実行シェル)
#!/bin/sh
#接続するESXiのIPアドレスを設定
servers="
192.168.1.XXX
"
#接続するESXiのユーザーのパスワードを設定
#今回は全台共通にて存在するrootユーザーにて接続
#接続先のESXiにてrootユーザーのパスワードが全て同じ事が前提
password=*******
@dehio3
dehio3 / command
Created June 23, 2016 13:33
各ESXiにssh接続し、仮想サーバのサマリー情報を取得するスクリプト(ssh実行コマンドテキスト)
rm /tmp/vmsvc.summary* ; vim-cmd vmsvc/getallvm | awk -v esxi=`uname -n` '($1~/^[0-9]+$/){print $2;command = sprintf("vim-cmd vmsvc/get.summary %s > /tmp/vmsvc.summary,%s,%s",$1,esxi,$1);buf = system(command);close(command)}'
#!/bin/sh
ps aux | gawk -v time=`date '+%Y/%m/%d_%H:%M:%S'` '{ mem[$11] += $6 }END{for (i in mem){if(mem[i]!~/^0$/){printf("\"%s\",\"%s\",\"%s\"\n",time,i,mem[i])}}}'
@dehio3
dehio3 / slack_send_image.py
Last active March 15, 2019 09:13
slackへ画像をアップロード
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import logging
import requests
# logging
formatter = '%(asctime)s %(levelname)s %(name)s %(message)s'
@dehio3
dehio3 / dict_to_json.py
Last active April 24, 2019 05:26
ローカルにあるdict形式のデータファイルをjson形式のデータファイルに変換
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import ast
import glob
import json
import os
def dict_to_json(filename):
terraform {
backend "s3" {
bucket = "<bucket name>"
key = "terraform.tfstate"
region = "us-east-1"
}
}
provider "aws" {
region = "us-east-1"
}
module "ec2_test" {
source = "terraform-aws-modules/ec2-instance/aws"
version = "1.21.0"
name = "ec2-test"
instance_count = 1
ami = "ami-0b8d0d6ac70e5750c" #amzn2-ami-hvm-2.0.20181114-x86_64-ebs
instance_type = "t2.micro"
key_name = "test-key"
monitoring = false
vpc_security_group_ids = ["<vpc_security_group_ids>"]
version: 2.1
executors:
default:
working_directory: ~/aws-terraform
docker:
- image: hashicorp/terraform:light
commands:
install_tfnotify:
version: 2
defaults: &defaults
docker:
- image: hashicorp/terraform:0.11.13
environment:
AWS_DEFAULT_REGION: ap-northeast-1
tfnotify_install: &tfnotify_install
name: tfnotify install
name: 'Terraform GitHub Actions apply'
on:
push:
branches:
- master
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
steps: