Skip to content

Instantly share code, notes, and snippets.

@johnybradshaw
johnybradshaw / AzureLogCreator.py
Created December 27, 2019 13:52
Simple python script to create a log source configured to work with Skytap audit logs (courtesy Ken Reycraft)
import json
import requests
import datetime
import hashlib
import hmac
import base64
# Update the customer ID to your Log Analytics workspace ID
customer_id = 'XXXXXXXXXXXXXXXXXX'
@johnybradshaw
johnybradshaw / ocp_builder.sh
Last active December 27, 2019 20:29
OpenShift Cluster Platform 4 - 3 master nodes, 3 worker nodes, network building script to be run on the Networking host
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
#############################
#
# OCP4 on Skytap Builder
#
#############################
apiVersion: v1
baseDomain: skytap.ninja #Change this to match your domain
compute:
- hyperthreading: Enabled
name: worker
replicas: 0
controlPlane:
hyperthreading: Enabled
name: master
replicas: 3
@johnybradshaw
johnybradshaw / delete_all_object_versions.sh
Last active March 4, 2022 09:23 — forked from weavenet/delete_all_object_versions.sh
Delete all versions of all files in s3 versioned bucket using AWS CLI and jq.
#!/bin/bash
#delete versions from a bucket, this will work with Scaleway
bucket=$1
location=$2
endpoint=".scw.cloud"
set -e
set -x
@johnybradshaw
johnybradshaw / wiz-azure-discovery.kql
Created March 21, 2023 12:26
Run this KQL in the Azure Resource Explorer to quickly out put all of the resources in a given tenant that would carry a cost as part of the Wiz platform
# KQL query to output the resource counts for Wiz to price against
Resources
| where type in (
"microsoft.compute/virtualmachines",
"microsoft.containerservice/managedclusters",
"microsoft.web/sites",
"microsoft.storage/storageaccounts",
"microsoft.classicstorage/storageaccounts",
"microsoft.dbformysql/servers",
"microsoft.dbformysql/flexibleservers")
@johnybradshaw
johnybradshaw / wiz-gcp-discovery.sql
Created March 22, 2023 16:37
Google Asset Query (https://console.cloud.google.com/iam-admin/asset-inventory/query) to extract all components for licensing in Wiz
# Google Asset Query (https://console.cloud.google.com/iam-admin/asset-inventory/query)
# This extracts all components for licensing in Wiz
SELECT
assetType,
COUNT(*) AS cnt
FROM
STANDARD_METADATA
WHERE
assetType IN
('compute.googleapis.com/Instance',
@johnybradshaw
johnybradshaw / service-now-discovery-azure.kql
Created March 29, 2023 09:17
Discovers, per tenant, workloads that create a licensing impact for Service Now ITOM
Resources
| where type in ('microsoft.sql/servers', 'microsoft.dbformysql/servers', 'microsoft.dbforpostgresql/servers', 'microsoft.documentdb/databaseaccounts', 'microsoft.cache/redis', 'microsoft.web/sites', 'microsoft.compute/virtualmachines', 'microsoft.containerinstance/containergroups' )
| extend resourceType = case(
type == 'microsoft.compute/virtualmachines', 'Virtual Machines',
type == 'microsoft.containerinstance/containergroups', 'Containers',
type in ('microsoft.sql/servers', 'microsoft.dbformysql/servers', 'microsoft.dbforpostgresql/servers', 'microsoft.documentdb/databaseaccounts',
'microsoft.cache/redis', 'microsoft.web/sites', 'Unknown' ), 'PaaS',
'Unknown'
)
| summarize count() by resourceType
@johnybradshaw
johnybradshaw / Azure_Discovery_Java_and_Oracle.kql
Created June 12, 2023 13:24
An Azure KQL query to discover all VMs that have either Java and/or Oracle installed
ConfigurationData
| where ConfigDataType == "Software"
| where SoftwareName contains "Java" or SoftwareName contains "Oracle"
| summarize SoftwareInstalled = strcat(iif(countif(SoftwareName contains "Java") > 0, "Java, ", ""), iif(countif(SoftwareName contains "Oracle") > 0, "Oracle", "")) by Computer
| order by SoftwareInstalled desc
@johnybradshaw
johnybradshaw / linode-cli-volumes-prune.sh
Created November 15, 2023 15:01
Delete/Prune all unattached volumes on Linode (Akamai)
#!/bin/bash
# Prune all unattached volumes
linode-cli volumes list --json | jq -r '.[] | select(.linode_id == null) | .id' | xargs -I {} linode-cli volumes delete {}
@johnybradshaw
johnybradshaw / acc-set-hostname.sh
Created November 22, 2023 10:40
Automatically set the hostname for Akamai Connect Cloud instances
#!/bin/bash
################################################################################################
# Usage #
################################################################################################
# Ensure a tag is created in the form: "tld: yourdomain.com" and applied to the Linode
# Add this to /usr/bin/local/acc-set-hostname.sh
# Call this file during the cloud-init <runcmd> block
################################################################################################
METADATA_TOKEN="$(curl -s -X PUT -H 'Metadata-Token-Expiry-Seconds: 3600' 'http://169.254.169.254/v1/token')"
METADATA_URL="http://169.254.169.254/v1/instance"