Skip to content

Instantly share code, notes, and snippets.

Uwe Grawert grawert

View GitHub Profile
@grawert
grawert / k8s_create_user_cert.sh
Created Sep 19, 2019
Create new user certificate and kubeconfig for Kubernetes
View k8s_create_user_cert.sh
#!/bin/bash
# Create new user certificate and kubeconfig
# Run me as user 'root' on K8s master node
CA_LOCATION="/etc/kubernetes/pki"
KUBECONFIG="./kubeconfig"
KEY_LEN="2048"
DAYS_VALID="500"
@grawert
grawert / SingletonClass.m
Created Sep 17, 2017
Singleton Class in Objective-C
View SingletonClass.m
#import <Foundation/Foundation.h>
@interface SingletonClass : NSObject
@property (class, readonly) id sharedSingletonClass;
@end
@implementation SingletonClass
static SingletonClass *_sharedSingletonClass;
View nagios_check_file_age.sh
#!/bin/bash
NAGIOS_EXIT_OK=0
NAGIOS_EXIT_WARNING=1
NAGIOS_EXIT_CRITICAL=2
NAGIOS_EXIT_UNKOWN=3
FILES=
function help_and_exit() {
@grawert
grawert / amq_exchange_sniffer.py
Last active Mar 19, 2020
Sniff amq messages by connecting to an exchange with routing key
View amq_exchange_sniffer.py
#!/usr/bin/env python
import sys
import optparse
import logging as log
from kombu import BrokerConnection
from kombu import Exchange
from kombu import Queue
from kombu.mixins import ConsumerMixin
class QueueDump(ConsumerMixin):
@grawert
grawert / os_server_states.sql
Created Jun 7, 2016
Query Openstack VM status
View os_server_states.sql
-- list of VMs in stopped or shutdown status
SELECT display_name AS vm_name, vm_state, host, user_id,
(select name from keystone.project where id = project_id) AS project_name
FROM nova.instances
WHERE deleted = 0 AND vm_state NOT LIKE 'active' AND (power_state != 0x00);
-- nova quota usage (RAM, CPU) for a project
SELECT resource, in_use, reserved, user_id FROM nova.quota_usages
WHERE project_id = (SELECT id FROM keystone.project WHERE name like 'OS_TENANT_ID')
View rabbitmq_check_crendetials.py
#!/usr/bin/env python
import socket
from kombu import Connection
host = "localhost"
port = 5672
user = "username"
password = "secret"
vhost = "/"
url = 'amqp://{0}:{1}@{2}:{3}/{4}'.format(user, password, host, port, vhost)
with Connection(url) as c:
@grawert
grawert / jenkins_delete_user_credentials.groovy
Created Mar 28, 2016
Delete user credentials by username in Jenkins
View jenkins_delete_user_credentials.groovy
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
def credentials_for_username(String username) {
def username_matcher = CredentialsMatchers.withUsername(username)
def available_credentials =
CredentialsProvider.lookupCredentials(
StandardUsernameCredentials.class,
Jenkins.getInstance(),
@grawert
grawert / jenkins_check_ssh_credentials.groovy
Created Mar 28, 2016
Check credentials by name if they already exist in Jenkins
View jenkins_check_ssh_credentials.groovy
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
def credentials_for_username(String username) {
def username_matcher = CredentialsMatchers.withUsername(username)
def available_credentials =
CredentialsProvider.lookupCredentials(
StandardUsernameCredentials.class,
Jenkins.getInstance(),
hudson.security.ACL.SYSTEM
@grawert
grawert / jenkins_add_ssh_credentials.groovy
Created Mar 28, 2016
Add direct SSH credentials to Jenkins
View jenkins_add_ssh_credentials.groovy
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
credentials = new BasicSSHUserPrivateKey(
CredentialsScope.GLOBAL,
"",
"username_HERE",
You can’t perform that action at this time.