Skip to content

Instantly share code, notes, and snippets.

View p-v-a's full-sized avatar

Vladimir Pasashnikov p-v-a

View GitHub Profile
@p-v-a
p-v-a / iis-log-parse.ps1
Created May 10, 2023 03:57
Parse IIS logs with Powershell
$logFolder = 'C:\inetpub\logs\LogFiles\W3SVC1'
# sort with oldest file first
$files = Get-ChildItem -Path $logFolder -Filter '*.log' | sort name
foreach($file in $files) {
# skip the 3 header lines and remove the #Fields: part to be able to use the first line as headers
$log = get-content "$logFolder\$file" | select-object -skip 3 | foreach-object { $_ -replace '#Fields: ', ''} | convertfrom-csv -Delimiter ' '
# now search for 502 status and print the fields we need in a table
$log | where sc-status -eq '502' | Select-Object -Property date, time, s-ip, cs-method, cs-uri-stem, cs-username, sc-status | format-table
}
@p-v-a
p-v-a / ceph-sparsify.sh
Created April 19, 2020 10:22
Go through all RBD volumes and remove zero content (sparsify)
#!/bin/bash
for p in $(ceph osd pool ls)
do
for d in $(rbd --pool $p ls)
do
echo "Sparsifying $p:$d"
rbd sparsify --pool $p $d && echo "Successful"
done
done
@p-v-a
p-v-a / letsencrypt-dns-zentyal.sh
Created April 15, 2020 23:21
Snippent to configure Zentyal with Let's encrypt certificate using DNS challenge
#!/bin/bash
# Snippent to configure Zentyal with Let's encrypt certificate using DNS challenge
# Run as root, acme.sh doesn't like sudo
# GoDaddy API key
set GD_Secret=""
set GD_Key=""
set ACCOUNT_EMAIL=""
set HOST_FQDN=""
@p-v-a
p-v-a / 00-cloud-config.yml
Created March 31, 2020 09:23 — forked from janeczku/00-cloud-config.yml
Annotated RancherOS Cloud-init configuration snippets
#cloud-config
# Set the hostname for this machine (takes precedence over hostname assigned by DHCP lease).
hostname: myhost
# Authorize SSH keys for the `rancher` sudoer user
ssh_authorized_keys:
- ssh-rsa AAA...ZZZ example1@rancher