Skip to content

Instantly share code, notes, and snippets.

View askz's full-sized avatar
🎯
Focusing

Max: askz

🎯
Focusing
View GitHub Profile
@askz
askz / rpc.sh
Last active May 29, 2018 08:02
Universal rpc call
#!/bin/bash
TICKER=$(echo $1 | tr '[:upper:]' '[:lower:]')
METHOD=$2
PARAMS="${@:3}"
RPCUSER=main
RPCPORT=net
function join_by { local IFS="$1"; shift; echo "$*"; }
@askz
askz / bitcoin-monitor.md
Created May 11, 2018 10:04 — forked from ageis/bitcoin-monitor.md
Prometheus exporter for monitoring statistics of Bitcoin daemon

bitcoind-monitor.py

This is a script written in Python intended to run alongside a Bitcoin node and export statistics for monitoring purposes. It assumes the existence of bitcoin-cli in the PATH and access to the RPC interface over localhost.

It tracks stuff like: block height, difficulty, number of peers, network hash rate, errors, uptime in seconds, mempool size, size of recent blocks, number of transactions within blocks, chaintips, total bytes received and sent, and transaction inputs and outputs. These Bitcoin metrics are refreshed once every 5 minutes.

How it works

Prometheus is a monitoring system and time-series database.

komodo-core_1 | Executing: komodod -printtoconsole -txindex=1 -rpcuser=test -rpcpassword=net -ac_supply=257142857 -gen -datadir=/home/komodo/.komodo/TESTKMD -ac_name=TESTKMD
komodo-core_1 | call komodo_args.(komodod) NOTARY_PUBKEY.()
komodo-core_1 | >>>>>>>>>> TESTKMD: port.10782/10783 magic.7e51ad18 2119281944 257142857 coins
komodo-core_1 | error creating (genTESTKMD)
komodo-core_1 | initialized TESTKMD
komodo-core_1 | Zcash version v1.0.15-10d5104 (2018-04-17 15:42:39 +0300)
komodo-core_1 | Komodo version v1.0.15-10d5104 (2018-04-17 15:42:39 +0300)
komodo-core_1 | Using OpenSSL version OpenSSL 1.1.0d 26 Jan 2017
komodo-core_1 | Using BerkeleyDB version Berkeley DB 6.2.23: (March 28, 2016)
komodo-core_1 | Default data directory /home/komodo/.komodo/TESTKMD
______________________________________________________ test_getting_list_of_oauth2_clients_by_authorized_user[auth_scopes0] ______________________________________________________
flask_app_client = <AutoAuthFlaskClient <Flask 'app'>>
regular_user = <User(id=1, username="regular_user", email="[email protected]", is_internal=False, is_admin=False, is_regular_user=True, is_active=True, )>
regular_user_oauth2_client = <app.modules.auth.models.OAuth2Client object at 0x7ff93a0b7710>, auth_scopes = ['auth:read']
@pytest.mark.parametrize('auth_scopes', (
['auth:read'],
['auth:read', 'auth:write'],
))
@askz
askz / le-renew.sh
Created November 7, 2017 14:58
Renew Let's Encrypt certificates and put them in HAProxy ssl folder
#!/bin/bash
# Let's encrypt: renew certificates and put them in haproxy ssl folder for reloading.
# Maxime Saddok <[email protected]>
# put in /etc/cron.weekly/le-renew && chmod +x /etc/cron.weekly/le-renew
set -x
set -e
/opt/letsencrypt/letsencrypt-auto --standalone --standalone-supported-challenges http-01 --http-01-port 9999 renew;
@askz
askz / create-mysql.bash
Created May 16, 2017 17:58 — forked from omeinusch/create-mysql.bash
Simple bash script to create mysql db, user with generated password
#!/bin/bash
# The script will fail at the first error encountered
set -e
PASS=`pwgen -s 40 1`
mysql -uroot <<MYSQL_SCRIPT
CREATE DATABASE $1;
CREATE USER '$1'@'localhost' IDENTIFIED BY '$PASS';
GRANT ALL PRIVILEGES ON $1.* TO '$1'@'localhost';
@askz
askz / add-user.sh
Last active July 4, 2018 02:59 — forked from floudet/ssh-chroot-jail.sh
Chroot Jail for SSH/SFTP Access toolkit
#!/bin/bash
# add "prisoner" in the jail you created before !!
# USAGE : ./add-user.sh <username> <password> <type>
# Type 1 : sftp jailed user ; Type 2 ssh jailed user
# A password will be auto-generated with pwgen (sudo apt install pwgen)
# Set your jail path wherever you want.
JAIL_PATH=/home/www/
#Setup UID filter limit
export UGIDLIMIT=500
#copy /etc/passwd accounts to /opt/move/passwd.mig using awk to filter out system account
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /opt/move/passwd.mig
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /opt/move/group.mig
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd \
### Keybase proof
I hereby claim:
* I am askz on github.
* I am askz (https://keybase.io/askz) on keybase.
* I have a public key ASCNbD-Mt9XPOal6bL6ZXHe3eL4fI2oKH2ayfZE9UZ0Cswo
To claim this, I am signing this object:
@askz
askz / cli-mysql-to-innodb.php
Created April 5, 2017 16:29
Convert MyISAM to InnoDB - shell script
<?php
/*
* Use this version if you are NOT a Pantheon customer.
*/
$db = array();
/*
* Change these to match your database connection information
*/
$db['host'] = "localhost";