Search Repository
TIMVKN.NL/TECH hosts a repository of scripts and patterns I’ve created over the course of time.
TIMVKN.NL/TECH hosts a repository of scripts and patterns I’ve created over the course of time.
Follow the steps below to enable and retreive debug logging from a specific APIM resource.
First retrieve an access token. This can be done by de following PowerShell commands (cloud shell):
az account set --subscription {subscription-id)
az account get-access-token
You can also use the folowing command to retrieve a list of apiIds so you can past the specific apiId path directly into the apiId key in the body.
az apim api list --resource-group {resource-group-name} --service-name {apim-service-name} --query "[].{Name:displayName, apiId:id}" -o table
Retrieve debug credentials by doing below HTTP POST.
POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.ApiManagement/service/{apim-service-name}/gateways/managed/listDebugCredentials?api-version=2023-05-01-preview HTTP/1.1
Content-Type: application/json
Authorization: Bearer {access-token}
{
"credentialsExpireAfter": "PT1H",
"apiId": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.ApiManagement/service/{apim-service-name}/apis/{api-name}",
"purposes": ["tracing"]
}
Copy the token from the reponse and add it as a header value (Apim-Debug-Authorization) in the specific api-call where you want the debugging to take place…
GET https://example.com/rest/api HTTP/1.1
Apim-Debug-Authorization: aid=api-name...
In the header value of the response from the specific api there should also be a header value (Apim-Trace-Id) which you can use to retrieve the trace.
POST https://management.azure.com/subscriptions{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.ApiManagement/service/{apim-service-name}/gateways/managed/listTrace?api-version=2023-05-01-preview HTTP/1.1
Content-Type: application/json
Authorization: Bearer {access-token}
{ "traceId": "{apim-trace-id}" }
Quickly ban or unban an ip using fail2ban recidive policy.
sudo fail2ban-client set recidive [banip|unbanip] 192.168.1.1
Activate (and deactivate) log queries to file.
set global log_output = 'FILE';
set global general_log_file='/path/to/file.log';
set global general_log = [1|0];
sudo ufw status [numbered]
sudo ufw [delete] allow 443/tcp
sudo ufw [delete] allow from 10.0.0.1 proto tcp to any port 443 comment 'allow https trafic from 10.0.0.1'
sudo ufw [delete] [insert 1] reject from 10.0.0.0/24 comment 'Denies all trafic from specific subnet'
sudo ufw [delete] reject out to any proto tcp port 25
sudo ufw [delete] reject out to 192.168.5.0/24 proto tcp port 80,443
sudo ufw delete {rownumber}
# Add essential proc subs: /proc/sys, /proc/cpuinfo, /proc/modules
twadmin -m P /etc/tripwire/twpol.txt
tripwire --init
tripwire --check [--email-report]
tripwire --update --twrfile /var/lib/tripwire/report/servername-YYYYMMDD-HHMMSS.twr
Update script with last report:
lastfilename=(`ls -Art /var/lib/tripwire/report/ | tail -n 1`)
sudo tripwire --update --twrfile /var/lib/tripwire/report/${lastfilename}
I was doing some maintenance on my local NAS. I used the command below to effectively move data from one location to another without losing file attributes.
rsync -avzhP --remove-source-files /mnt/das-2T-1/source/ /mnt/das-2T-1/destination/ [--dry-run]
You can also temporarily cancel the move and when you start the command again it continues where it stopped.
I also did some internal replication using replication tasks on my TrueNAS device. This creates a snapshot of the data set to replicate to an empty dataset. The destination dataset is overwritten so this option cannot be used to merge datasets. If you want to merge datasets is best to use the rsync option mentioned above.
Al shortlist of my most frequently used nano (editor) shortcuts besides CRTL-X (EXIT) and CTRL-W (SEARCH) obviously.
LINE NUMBERS TOGGLE ALT-N
LINE WRAPPING TOGGLE ALT-S
LINE COMMENT TOGGLE ALT-3
CUT LINE CTRL-K
PASTE LINE CTRL-U
Check this overview page for a full list of shortcuts.
Force file timestamp to a specific datetime.
touch -t 202301251415.00 Filename
Delete evicted pods from current OpenShift project.
oc get pods | grep Evicted | awk '{print $1}' | xargs oc delete pod
Create an OpenShift secret from the command line.
oc create secret generic gateway1 --from-file=server.p12