Skip to content

Instantly share code, notes, and snippets.

View thanosa75's full-sized avatar

Thanos thanosa75

View GitHub Profile
@thanosa75
thanosa75 / colored-git.sh
Created November 29, 2012 17:06
Colored prompt with git support
# add this snippet in your .bashrc and enjoy a green foreground color,
# with HH:MM time info, plus directory and git data on a directory that
# has git information (git repo)
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# parse and create the prompt
function parse_git_branch {
@thanosa75
thanosa75 / lvs-backup-v2.sh
Last active December 16, 2015 00:09
v2 of the lvsbackup.sh script, now using S3 for storage
#!/bin/bash
#
# lvsbackup.sh - backup a mongo secondary by rsync/tgz
#
# LICENSE
#
# Copyright (c) 2013, Thanos Angelatos agelatos@gmail.com
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@thanosa75
thanosa75 / capture.txt
Created June 20, 2013 09:51
fsyncLock and Unlock are stackable!!
mongo localhost:27018
MongoDB shell version: 2.4.3
connecting to: localhost:27018/test
dev-mcs-01:SECONDARY> serverIsLocked = function () {
... var co = db.currentOp();
... if (co && co.fsyncLock) {
... return true;
... }
... return false;
... }
Tue Jun 25 11:41:08 [conn757] command PRD01_UCS_ROLLUPS.$cmd command: { distinct: "OutboundMessage", key: "eventId", query: { status: "DELIVERED", lastUpdateDate: { $gte: new Date(1372130940000), $lt: new Date(1372159560000) } } } ntoreturn:1 keyUpdates:0 numYields: 192015 locks(micros) r:1664868415 reslen:154 844300ms
Tue Jun 25 11:44:05 [conn757] command PRD01_UCS_ROLLUPS.$cmd command: { aggregate: "OutboundMessage", pipeline: [ { $match: { domain.$id: 141, status: "DELIVERED", lastUpdateDateOrig: { $gte: new Date(1372130940000), $lt: new Date(1372159560000) } } }, { $project: { campaignId: true, stepId: true, eventId: true, messageResourceId: true, segmentId: true, receivedDate: "$receivedDateNorm" } }, { $group: { _id: { campaignId: "$campaignId", stepId: "$stepId", eventId: "$eventId", messageResourceId: "$messageResourceId", segmentId: "$segmentId", receivedDate: "$receivedDate" }, count: { $sum: { $const: 1 } } } } ], fromRouter: true } ntoreturn:1 keyUpdates:0 locks(micros) r:107722 reslen:50 107ms
Tu
package com.ericsson.sm.core.smpp.internal;
import java.util.Random;
import com.cloudhopper.commons.charset.CharsetUtil;
import com.cloudhopper.smpp.SmppConstants;
import com.cloudhopper.smpp.SmppSession;
import com.cloudhopper.smpp.pdu.SubmitSm;
import com.cloudhopper.smpp.type.Address;
@thanosa75
thanosa75 / find_in_redis.sh
Last active March 4, 2022 05:49
Example of SCAN / COUNT looking for patterns in REDIS
#!/bin/bash
# sample code demonstrating a pattern search with SCAN
# using a COUNT "work intent"
if [ $# -ne 3 ]
then
echo "Find matching a pattern using SCAN "
echo "Usage: $0 <host> <port> <pattern>"
exit 1
@thanosa75
thanosa75 / setup417.sh
Created October 15, 2015 15:57
Reproducing DATAREDIS-417
#!/bin/bash
## the following line connects to REDIS @ DB:10 and creates 20M keys
## to reproduce the bug, compile and run the spring boot project attached here
##
redis-cli -h localhost -n 10 -n 10 "DEBUG" "POPULATE" "20000000"
@thanosa75
thanosa75 / check-power.sh
Last active February 23, 2017 09:17
Script that checks a monitor host (via MAC address) to see if it is alive. If not, it will SSH (assume keys have been setup) to another host and shut it down.
#!/bin/bash
#
# A quick-and-dirty UPS shutdown monitor by Thanos
#
# Can perform shutdown of a "precious" machine that is on a UPS
# based on network reachability of a "inexpensive" machine that is
# not on a UPS. In my case, the "inexpensive" is a RPI that is always on.
#
# Cron entry for this script (uses "pi" user):
# */2 * * * * /home/pi/check-power.sh > /home/pi/powercheck.log 2>&1
@thanosa75
thanosa75 / check_speedport2i.sh
Last active May 28, 2022 17:55
Fetching ZTE SpeedPort Entry 2i (VDSL modem/router, COSMOTE Greece) modem statistics for Zabbix or other purposes
#!/bin/bash
## Available to all; taken from https://github.com/NMichas/icinga-speedport2i - slight mods
## to work with Zabbix 3.4
##
## -h (hostname) Mandatory. script does not work without.
## if no other parameter is provided, a summary with all values is given.
##
## each of the other parameters calls it again grepping the particular value.
# Gather command-line parameters.
@thanosa75
thanosa75 / Template Linux Disk IO.xml
Last active December 27, 2017 17:45
Configuration for Zabbix agent for retrieval of disk metrics: OPS / ms / sectors etc
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>2.0</version>
<date>2017-12-27T13:49:57Z</date>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>