Skip to content

Instantly share code, notes, and snippets.

View adionditsak's full-sized avatar

Anders Aarvik adionditsak

View GitHub Profile
@adionditsak
adionditsak / Calculate milliwatt per second in Debian
Last active October 21, 2024 09:27
Calculate milliwatt per second in Debian
sudo -v; old_energy_uj=0 old_time=0; while :; do energy_uj=$(sudo cat /sys/class/powercap/intel-rapl/*/energy_uj); time=$(date +%s%N); echo $(( (energy_uj - old_energy_uj) * 1000000 / (time - old_time) )); old_time=$time old_energy_uj=$energy_uj; sleep 1; done
@adionditsak
adionditsak / consul
Created January 30, 2017 10:26
consul startup/service script (ubuntu 14)
#
# Daemon for consul
#
# chkconfig: 345 98 20
# description: Daemon for consul
# processname: consul
### BEGIN INIT INFO
# Provides: consul
# Required-Start: $network
@adionditsak
adionditsak / vault
Created January 30, 2017 09:49
vault startup/service script (ubuntu 14)
#
# Daemon for vault
#
# chkconfig: 345 99 20
# description: Daemon for vault
# processname: vault
### BEGIN INIT INFO
# Provides: vault
# Required-Start: $network
@adionditsak
adionditsak / elasticsearch_lastlog.py
Last active February 2, 2017 13:48
Check_mk plugin to check for last log from Elasticsearch compared to current time
#!/usr/bin/env python
import requests
import datetime
import json
import os
"""
Check_mk plugin to check for last log from Elasticsearch compared to current time
"""
@adionditsak
adionditsak / generatehostsfile.sh
Created February 12, 2016 12:28
Generate hosts file with AWS ec2 private IP's
#!/bin/bash
# Generate hosts-file with private IP's in AWS ec2
# Vars
hosts_file="/etc/hosts"
region="eu-west-1"
# AWS call
described_instances=`aws ec2 describe-instances --region ${region}`
@adionditsak
adionditsak / tput_menu.sh
Created February 23, 2015 08:19
tput cli menu dummy with 4 options
#!/bin/bash
tput clear
main_menu()
{
until [ option = 4 ]; do
tput setb 2
tput setf 5
read -p """
@adionditsak
adionditsak / SRX cheatsheet
Created February 17, 2015 15:38
Juniper SRX cheatsheet
# Juniper SRX cheatsheet
#Help
help
<command> ?
#Show
show configuration
@adionditsak
adionditsak / cecho.sh
Created February 4, 2015 07:10
cecho.sh - colorize shell output with pipe
cecho(){
BLACK="\033[0;30m"
BLUE="\033[0;34m"
GREEN="\033[0;32m"
CYAN="\033[0;36m"
RED="\033[0;31m"
PURPLE="\033[0;35m"
ORANGE="\033[0;33m"
LGRAY="\033[0;37m"
DGRAY="\033[1;30m"
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];
@adionditsak
adionditsak / countrequests.sh
Last active August 29, 2015 14:13
Count files appended last 10 seconds for access logs and errors logs...
#!/bin/bash
# Count appended lines last 10 seconds simultanously
# CentOS/RHEL
LOGPATH="/var/log/httpd/"
# Ubuntu/Debian
# LOGPATH="/var/log/apache2/"