rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
yum install -y http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpmyum-config-manager --enable elrepo-kernel| import boto3 | |
| from boto3.session import Session | |
| def assume_role(arn, session_name): | |
| """aws sts assume-role --role-arn arn:aws:iam::00000000000000:role/example-role --role-session-name example-role""" | |
| client = boto3.client('sts') | |
| account_id = client.get_caller_identity()["Account"] | |
| print(account_id) |
| # Count total EBS based storage in AWS | |
| aws ec2 describe-volumes | jq "[.Volumes[].Size] | add" | |
| # Count total EBS storage with a tag filter | |
| aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add" | |
| # Describe instances concisely | |
| aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]' | |
| # Wait until $instance_id is running and then immediately stop it again | |
| aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id | |
| # Get 10th instance in the account |
| //DNS Query Program on Linux | |
| //Author : Silver Moon ([email protected]) | |
| //Dated : 29/4/2009 | |
| //Header Files | |
| #include<stdio.h> //printf | |
| #include<string.h> //strlen | |
| #include<stdlib.h> //malloc | |
| #include<sys/socket.h> //you know what this is for | |
| #include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc |
| { | |
| "template" : "logstash-*", | |
| "settings" : { | |
| "index.refresh_interval" : "5s" | |
| }, | |
| "mappings" : { | |
| "_default_" : { | |
| "_all" : {"enabled" : true, "omit_norms" : true}, | |
| "dynamic_templates" : [ { | |
| "message_field" : { |
| Problem: We have a log line that includes a perl class that we want to log the class | |
| and method in their respected fields. An example class and method in perl: | |
| Animal::Dog::bark | |
| In this example, "bark" is the method. "Animal::Dog" is the class. | |
| After some searching and hacking, I found a solution that works with Logstash 1.4.2 | |
| Assume the input is "Animal::Dog::bark". |
| #!/usr/bin/env bash | |
| # Issues a reset of the SuperMicro BMC via the web interface | |
| # | |
| # usage: supermicro-bmc-reset.sh <ipmi-host> | |
| # e.g.: supermicro-bmc-reset.sh 10.0.0.1 | |
| # | |
| set -x |
| curl -XDELETE 'localhost:9200/test' | |
| curl -XPUT 'localhost:9200/test/doc/1' -d ' | |
| { | |
| "sentence" : "Hi!", | |
| "value" : 1 | |
| } | |
| ' |