Skip to content

Instantly share code, notes, and snippets.

View jrha's full-sized avatar

James Adams jrha

  • Rutherford Appleton Laboratory, Harwell, UK
View GitHub Profile
@jrha
jrha / example_config.php
Last active November 17, 2023 12:43
wLCG Network Monitoring for LibreNMS
// Add the following structure to librenms/config.php
// Array of arrays of LibreNMS port IDs per sub-site
$config['wlcg']['site_name'] = 'EXAMPLE';
$config['wlcg']['sub_sites'] = Array(
"EXAMPLE-LEGACY" => Array(
1234,
1235,
),
"EXAMPLE-LHCOPN" => Array(

Keybase proof

I hereby claim:

  • I am jrha on github.
  • I am jrha (https://keybase.io/jrha) on keybase.
  • I have a public key ASCqNvn3SXfc_fWSD16POsjqHyYMucqeDPxS-X-lCMGGIAo

To claim this, I am signing this object:

@jrha
jrha / searchprofile
Created May 31, 2018 08:37
aq showdeps & searchprofile
#!/bin/bash
if [[ "$#" -eq 2 ]]; then
showdeps $2 | xargs grep --color $1
else
echo "Usage: searchprofile NEEDLE HOSTNAME"
fi
@jrha
jrha / random_username.sh
Created May 1, 2018 12:00
Bash function to generate a simple, random, but pronouncable username
function generate_username {
# Generate a simple, random, but pronouncable username
username=""
for i in {1..4}; do
if [[ $((i%2)) == 0 ]]; then
charset="aeiou"
else
charset="bcdfghjklmnpqrstvwxyz"
fi
username="$username$(tr -dc "$charset" < /dev/urandom | head -c 1)"
#!/usr/bin/env python2
"""
Use VO card XML feed to generate vomses data
"""
from urllib2 import urlopen
from lxml import etree
URL = 'http://operations-portal.egi.eu/xml/voIDCard/public/all/true'
@jrha
jrha / namji.py
Last active June 2, 2017 15:27
Convert any positive integer into a DNS like name and vice-versa
#!/usr/bin/env python2
#
# Copyright 2017 Science & Technology Facilities Council
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# [
# '/home/tkk76468/quattordev/repos/ncm-ncd/target/lib/perl',
# '/home/tkk76468/quattordev/repos/ncm-ncd/src/test/perl',
# '/home/tkk76468/quattordev/repos/ncm-ncd/target/dependency/build-scripts',
# '/home/tkk76468/quattordev/install/lib/perl',
# '/home/tkk76468/quattordev/install/usr/lib/perl',
# '/home/tkk76468/quattordev/install/usr/lib/perl5/x86_64-linux-thread-multi',
# '/home/tkk76468/quattordev/install/usr/lib/perl5',
# '/usr/local/lib64/perl5',
# '/usr/local/share/perl5',
@jrha
jrha / config.pan
Last active September 20, 2016 09:33
Build motd from node metadata
unique template features/core/motd/config;
include 'components/filecopy/config';
variable MOTD_NODE_INFO ?= "";
variable motd_branch = format('%s (%s)', value('/metadata/template/branch/name'), value('/metadata/template/branch/type'));
variable motd_branch = if (path_exists('/metadata/template/branch/author')) {
format('%s/%s', value('/metadata/template/branch/author'), SELF);
@jrha
jrha / package_deb.sh
Created August 5, 2016 14:39
Debian packaging script with FPM for Maven
#!/usr/bin/env bash
echo
echo "FPM Packaging Script for Debian"
echo
echo "Environment Variables to script:"
echo "--------------------------------"
printenv | grep '^PKG'
echo "--------------------------------"
@jrha
jrha / firewall.pan
Last active August 29, 2015 14:22
Example of building firewall configuration for an elasticsearch cluster based on aquilon cluster membership
template elasticsearch/firewall;
include 'components/iptables/config';
include 'components/chkconfig/config';
variable ELASTICSEARCH_NODE_LIST ?= error('ELASTICSEARCH_NODE_LIST not defined, this should have been populated before the firewall setup was included!');
variable ELASTICSEARCH_PORTS = list('9200', '9300');