Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vStone
vStone / calculate_memory_use.rb
Created February 9, 2018 07:37
Puppet function to calculate memory usage.
# frozen_string_literal: true
# File goes into lib/puppet/functions/ of some module
# You can use this function to dynamically calculate memory use for a certain process.
# The java JVM for example.
#
# Its possible to calculate memory based upon fixed numbers (would like 512M but with a minimum of 256M) or
# with percentages (give me half but with a minimum of 256M).
#
@vStone
vStone / upgrade_kernel.sh
Created December 4, 2017 15:12
Gentoo kernel upgrade (must enable config support in kernel cfr /proc/config.gz)
#!/bin/bash -e
errr() {
echo "$@" 1>&2
exit 1;
}
(
cd linux/
@vStone
vStone / telemeter.sh
Created September 14, 2017 16:53
Telenet Telemeter Script
#!/bin/bash
# requirements:
# - curl
# - nokogiri
# usage: fill in username and password here, execute, and it spits out json array with your usage
username=<< Fill your username in here >>
password=<< Fill your password in here >>
$ puppet apply --modulepath=. -e 'include test'
Warning: ModuleLoader: module 'test' has unresolved dependencies - it will only see those that are resolved. Use 'puppet module list --tree' to see information about modules
(file & line not available)
Error: Evaluation Error: Error while evaluating a Function Call, can't modify frozen String at /home/jan/tmp/test/manifests/init.pp:4:16 on node minimoose.home.vstone.be
module Puppet::Parser::Functions
newfunction(:calculate_memory_use, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
calculate_memory_use(use, reserved, minimum=0)
[*use*] How much memory should I use (of the non-reserved space left)
* Floating numbers smaller than 1 are interpreted as percentage.
* Anything else is used as size.
@vStone
vStone / external_facter_helper.rb
Created August 22, 2016 08:38
Use external facter for unit testing facts: spec/helpers/external_facter_helper.rb
require 'yaml'
module RSpecHelper
module SystemFacter
def self.resolve_fact (fact, stubs = {}, facter_path = (ENV['FACTER_PATH'] || '/usr/bin/facter'))
env_values = {}
command = [ facter_path, '--yaml']
facts_path = File.expand_path(File.dirname(__FILE__) + '/../../lib/facter')
@vStone
vStone / keybase.md
Created August 11, 2016 06:10
Keybase proof

Keybase proof

I hereby claim:

  • I am vstone on github.
  • I am vstone (https://keybase.io/vstone) on keybase.
  • I have a public key ASCF9MBdc4aceHSGtMwqgiPx42QaaXu9Ge0GQZDfJgTLZQo

To claim this, I am signing this object:

@vStone
vStone / list-git-tags.groovy
Created April 14, 2015 08:58
Jenkins groovy script which lists remote tags.
/*** BEGIN META {
"name": "List GIT TAGS",
"comment": "You can use this to fill up a dynamic list parameter with tags. Optionally, you can filter the tags to show. You can include a fallback branch as ALWAYS_INCLUDE like 'develop'",
"parameters": [ 'FILTER', 'REMOTE', 'ALWAYS_INCLUDE' ],
"core": "1.580",
"authors": [
{ name : "Jan Vansteenkiste" }
]
} END META**/
@vStone
vStone / list-git-branches.groovy
Created April 14, 2015 08:56
Jenkins groovy script which lists remote branches.
/*** BEGIN META {
"name": "List GIT Branches",
"comment": "You can use this to fill up a dynamic list parameter with branches. Optionally, you can filter the branches to show.",
"parameters": [ 'FILTER', 'REMOTE' ],
"core": "1.580",
"authors": [
{ name : "Jan Vansteenkiste" }
]
} END META**/
#!/bin/bash
( echo 'VM|Status|IP|Memory|OS';
for node in `lxc-ls -1`; do
tmpfile=`mktemp -t lxc-info-$node-XXXXXXX`;
lxc-info -n $node | sed 's@[ ]*:[ ]*@:@' > $tmpfile
status=$( cat $tmpfile | grep 'State:' | awk -F: '{print $2}' );
ip=""; mem=""; os=""; osver="";
if [ "$status" == "RUNNING" ]; then