Skip to content

Instantly share code, notes, and snippets.

View dfrankel33's full-sized avatar

Dave Frankel dfrankel33

View GitHub Profile
@dfrankel33
dfrankel33 / windows-node-grafana-agent.yaml
Last active October 15, 2022 17:37
Grafana Agent - Windows - Example Config
integrations:
agent:
enabled: false
windows_exporter:
enabled: true
prometheus_remote_write:
- basic_auth:
password: GCLOUD_API_KEY
username: GCLOUD_PROM_USER_ID
url: GCLOUD_PROM_ENDPOINT
@dfrankel33
dfrankel33 / linux-node-grafana-agent.yaml
Last active January 5, 2022 14:12
Grafana Agent - Linux - Example Config
integrations:
agent:
enabled: false
node_exporter:
enabled: true
prometheus_remote_write:
- basic_auth:
password: GCLOUD_API_KEY
username: GCLOUD_PROM_USER_ID
url: GCLOUD_PROM_ENDPOINT
@dfrankel33
dfrankel33 / create_vpc_route_via_nat_gateway.rb
Created January 29, 2018 20:40
RCL definition to create a VPC Route where a NAT Gateway is the next hop
define create_nat_route($route_table_id, $nat_gateway_id, $region) return $response do
$response = http_request(
host: "ec2."+$region+".amazonaws.com/?Action=CreateRoute&DestinationCidrBlock=0.0.0.0/0&RouteTableId="+$route_table_id+"&NatGatewayId="+$nat_gateway_id+"&Version=2016-11-15",
https: true,
verb: "post",
signature: {"type": "aws"}
)
end
@dfrankel33
dfrankel33 / create_vpc_route_via_nat_gateway.rb
Created January 29, 2018 20:40
RCL definition to create a VPC Route where a NAT Gateway is the next hop
define create_nat_route($route_table_id, $nat_gateway_id, $region) return $response do
$response = http_request(
host: "ec2."+$region+".amazonaws.com/?Action=CreateRoute&DestinationCidrBlock=0.0.0.0/0&RouteTableId="+$route_table_id+"&NatGatewayId="+$nat_gateway_id+"&Version=2016-11-15",
https: true,
verb: "post",
signature: {"type": "aws"}
)
end
define run_rightscript_by_name(@target, $script_name, $inputs) do
@script = rs_cm.right_scripts.index(latest_only: true, filter: [join(["name==", $script_name])])
@task = @target.run_executable(right_script_href: @script.href, inputs: $inputs )
sleep_until(@task.summary =~ "^(Completed|Aborted)")
if @task.summary =~ "Aborted"
raise "Failed to run " + $script_name
end
end
@dfrankel33
dfrankel33 / Base64_Encode_Decode.rb
Created August 31, 2017 21:42
RCL Functions for Base64 Decoding & Encoding
define base64_encode($string) return $value do
$response = http_post( url: join(["https://www.base64encode.org/enc/", $string]) )
$1 = split($response["body"], "Result goes here...\">")
$value = split($1[1], "</textarea>")
$value = $value[0]
end
define base64_decode($string) return $value do
$response = http_post( url: join(["https://www.base64decode.org/dec/", $string]) )
$1 = split($response["body"], "Result goes here...\">")
function Import-ServerTemplate {
<#
.SYNOPSIS
Import ServerTemplate from the RightScale MultiCloud Marketplace
.PARAMETER RsEndpoint
RightScale API Endpoint. Only valid values are: us-3.rightscale.com OR us-4.rightscale.com
.PARAMETER RsAccountNum
RightScale Account Number
.PARAMETER RsEmail
Email address of RightScale user
function Import-ServerTemplate {
<#
.SYNOPSIS
Import ServerTemplate from the RightScale MultiCloud Marketplace
.PARAMETER RsEndpoint
RightScale API Endpoint. Only valid values are: us-3.rightscale.com OR us-4.rightscale.com
.PARAMETER RsAccountNum
RightScale Account Number
.PARAMETER RsEmail
Email address of RightScale user
#USAGE:
# 1) Execute both functions below in a PowerShell session or ISE session
# 2) Execute Copy-ARMImage. Required params: AZURE_DESTINATION_SUBSCRIPTION_ID, AZURE_SOURCE_SUBSCRIPTION_ID, DESTINATION_STORAGE_ACCOUNT, IMAGE_URI, AZURE_USERNAME, AZURE_PASSWORD, LogFile
function Write-LogFile {
[CmdletBinding()]
Param([string]$Message, [string]$MessageType, [string]$LogFile)
$source = $((Get-Variable -Scope 1 MyInvocation -ValueOnly).MyCommand.Name)
#API Docs: http://reference.rightscale.com/selfservice/manager/index.html#/1.0/controller/V1::Controller::ScheduledAction/create
#$name is a human-readable name for the scheduled action. ie "my scheduled action"
#$action is one of: "launch","start","stop","terminate","run"
#$operation_name is only necessary if $action = "run". it's value is the custom operation name
#$recurrence is an RRULE as described by RFC 5545. ie "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"
#$timezone in standardized tzinfo names (http://www.iana.org/time-zones) ie "America/Los_Angeles" or "UTC"
#$first_occurrence in ISO-8601 DateTime format. ie "2014-07-24T00:00:00+00:00"
#Create RUN scheduled action:
rs_ss.scheduled_actions.create(