Skip to content

Instantly share code, notes, and snippets.

View niedbalski's full-sized avatar
👋
Be humble. Stay focused.

Jorge Niedbalski niedbalski

👋
Be humble. Stay focused.
View GitHub Profile
@niedbalski
niedbalski / python-fstab.py
Created May 22, 2014 21:56
python-fstab.py
class Fstab(file):
class Entry(object):
def __init__(self, device, mountpoint, filesystem,
options, d=0, p=0):
self.device = device
self.mountpoint = mountpoint
self.filesystem = filesystem
@niedbalski
niedbalski / netns-lxc.sh
Last active June 22, 2021 03:57
netns-lxc
$ source netns-lxc.sh && sudo veth_interface_for_lxc container_name
veth132
@niedbalski
niedbalski / act_as_executable.py
Last active May 29, 2021 09:43
act_as_executable decorator
#!/usr/bin/env python
__author__ = 'Jorge Niedbalski R. <jnr@pyrosome.org>'
from string import Template
import envoy
def act_as_executable(command):
@niedbalski
niedbalski / example.py
Last active May 29, 2021 09:43
Python class for manage fstab files.
from fstab import Fstab
Fstab.add('/dev/sda', '/mnt/sda', filesystem="xfs')
Fstab.add('/dev/sdb', '/mnt/sdb', filesystem="xfs')
Fstab.remove_by_mountpoint('/mnt/sda/')
fstab = Fstab()
fstab.add(Fstab.Entry('/dev/sdb', '/mnt/sdb', filesystem="xfs'))
@niedbalski
niedbalski / kill_proc_tree.py
Created September 8, 2015 15:35
kill_proc_tree.py
import psutil, os
def kill_proc_tree(pid, including_parent=True):
parent = psutil.Process(pid)
for child in parent.get_children(recursive=True):
child.kill()
if including_parent:
parent.kill()
me = os.getpid()
@niedbalski
niedbalski / config_map_augogen.go
Created April 5, 2021 03:11
config_map_augogen.go
// File autogenerated with github.com/calyptia/config-validator-api/tools
// Don't edit manually.
package main
type ConfigMapOptsT map[string]map[string][]string
var ConfigMapOpts = ConfigMapOptsT{
"input": {
"thermal": []string{
import:
- https://raw.githubusercontent.com/niedbalski/repeat/master/collections/netstat.yaml
- https://raw.githubusercontent.com/niedbalski/repeat/master/collections/sockstat.yaml
- https://raw.githubusercontent.com/niedbalski/repeat/master/collections/lxc.yaml
collections:
# sar:
# run-once: true
# exit-codes: 0 127 126
# script: |
# #!/bin/bash
#!/bin/bash
set -x
time mysql -ukeystone_admin -pYourPassHERE -hYourHostHERE <<EOF
use keystone;
drop table if exists temp_tokens;
create table temp_tokens
as (select * from token where expires >= NOW());
select count(*) from temp_tokens;
truncate table token;
insert into token select * from temp_tokens;
@niedbalski
niedbalski / oom-score.sh
Created August 18, 2020 21:53
oom-score.sh
#!/bin/bash
# Displays running processes in descending order of OOM score
printf 'PID\tOOM Score\tOOM Adj\tCommand\n'
while read -r pid comm; do [ -f /proc/$pid/oom_score ] && [ $(cat /proc/$pid/oom_score) != 0 ] && printf '%d\t%d\t\t%d\t%s\n' "$pid" "$(cat /proc/$pid/oom_score)" "$(cat /proc/$pid/oom_score_adj)" "$comm"; done < <(ps -e -o pid= -o comm=) | sort -k 2nr
@niedbalski
niedbalski / update-password.sh
Created June 10, 2020 21:37
update-password.sh
# curl https://gist.github.com/niedbalski/a6511e9bd3b6c674d9eb767211e5ccf3/raw/1909e266dcf5dc15ee43deef471f87b209d1ce7c/juju-pwhash
# p=$(openssl rand -hex 12) && printf "agent.conf=%s\nmongodb=%s\n" $p $(./juju-pwhash -p ${p})
agent.conf=2c0bdfcd9f61d5248005ff71
mongodb=9DYXMt1+hfklY2NiFcw2Y5dF
edit the agent.conf of the unit manually and change apipassword to ^^ agent.conf.
$ juju ssh -m controller 0
$ sudo su
# source <(curl -s https://gist.githubusercontent.com/msplival/b479edf76c4f9d1dda7a69e3addab6f5/raw/1d10eea9f0d1b459ee1fe4108cf9217eb3a46b5c/dialmgo-bionic)