Skip to content

Instantly share code, notes, and snippets.

View hanynowsky's full-sized avatar
💭
I may be slow to respond.

Hanynowsky hanynowsky

💭
I may be slow to respond.
View GitHub Profile
@hanynowsky
hanynowsky / .gitconfig
Created April 11, 2018 13:58 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
@hanynowsky
hanynowsky / check_drbd.sh
Created April 3, 2018 13:21 — forked from holly/check_drbd.sh
keepalived+drbd sample
#!/bin/bash
EXIT_CODE=0
STATUS_FILE=/tmp/drbd.status
STATUS=$(sed -e 's/.* state:\(.*\)$/\1/' $STATUS_FILE)
if [ "${STATUS}" != "MASTER" ]; then
echo "current status is ${STATUS}. skip"
exit
@hanynowsky
hanynowsky / json_cleaner.py
Created January 26, 2018 18:35 — forked from liftoff/json_cleaner.py
Allow comments and trailing commas in JSON files using two simple Python functions to clean them up before parsing
#!/usr/bin/env python
"""
An example of how to remove comments and trailing commas from JSON before
parsing. You only need the two functions below, `remove_comments()` and
`remove_trailing_commas()` to accomplish this. This script serves as an
example of how to use them but feel free to just copy & paste them into your
own code/projects. Usage::
json_cleaner.py some_file.json
Checking disks behind RAID controllers
RAID controllers typically simulate a (logical) disk for each array of (physical) disks to the OS. Access to SMART functionality relies on ATA or SCSI pass through I/O controls providing direct access to each physical disk. But the standard I/O controls available are usually not designed to make this distinction between logical and physical disks. Therefore, smartmontools has to use vendor specific I/O controls. Support for disks behind RAID controllers is highly dependent on both platform and controller type.
RAID-Controller Linux FreeBSD NetBSD OpenBSD MacOS Solaris Windows
LSI 3ware SATA RAID controller -d 3ware,N /dev/twX 1. -d 3ware,N /dev/twX 2. - - - - /dev/sdX,N 3.
Areca SATA[/SAS] RAID controller -d areca,N[/E] /dev/sgX 4. -d areca,N[/E] /dev/arcmsrX 11. - - - - -d areca,N[/E] /dev/arcmsrX 12.
HighPoint RocketRAID SATA RAID controller -d hpt,L/M/N /dev/sdX 5. -d hpt,L/M/N /dev/hptX 6. - - - - -
CCISS (HP/Compaq Smart Array Controller
#!/opt/sensu/embedded/bin/ruby
# Author: Hanine.H - magicOnline
# January 2018
# Rudimentary Remediation For Sensu Client
#
# WARNING: Please do not forget to added permissions for user sensu
# in sudoers file. Example:
# sensu ALL=(root) NOPASSWD:/usr/sbin/service httpd reload
# sensu ALL=(root) NOPASSWD:/usr/sbin/service httpd restart
#! /usr/bin/env ruby
#
# metrics-netstat-tcp
#
# DESCRIPTION:
# Fetch metrics on TCP socket states from netstat. This is particularly useful
# on high-traffic web or proxy servers with large numbers of short-lived TCP
# connections coming and going.
#
# OUTPUT:
#!/usr/bin/env ruby
# Magic Online 2016
# # This extension mutator is supposed to format sensu events to InfluxDb line format
#! /usr/bin/env ruby
#
# mutator-influxdb-line-protocol
#
# DESCRIPTION:
# Mutates check results to conform to InfluxDB's line protocol format
#
@hanynowsky
hanynowsky / gist:0ea68ce8405038945fe1736abc0d01a2
Created November 28, 2016 13:56 — forked from juanje/gist:1310403
Use Ruby as AWK or Grep
# A few examples about how to use Ruby for parsing files as we could do
# with Awk or Grep. This is based on what I learn fro this post:
# http://code.joejag.com/2009/using-ruby-as-an-awk-replacement/
# Split each line with ':' and print the first $F[0] field
awk -F: '{ print $1 }' /etc/passwd
ruby -F: -nae 'puts $F[0]' /etc/passwd
# Parse the 'ps aux' output
# It'll print the ID process for the 'jojeda' user
require "sensu/extension"
require 'redis'
require 'json'
require 'socket'
require 'time'
# Author: MOL - November 2016
# Sensu: Tested on 0.26.5
# License: MIT
# This Sensu extension handler sends sensu events to a logstash instance
Error: selected is undefined
this.getSelected@https://monitor.magic.fr/bower_components/uchiwa-web/js/common.js?rel=1479176171587:54:5
this.silence@https://monitor.magic.fr/bower_components/uchiwa-web/js/services.js?rel=1479176171588:255:26
$scope.silence@https://monitor.magic.fr/bower_components/uchiwa-web/js/controllers.js?rel=1479176171587:273:7
anonymous/fn@https://monitor.magic.fr/bower_components/angular/angular.min.js?rel=1479176171588 line 218 > Function:2:409
b@https://monitor.magic.fr/bower_components/angular/angular.min.js?rel=1479176171588:116:148
Ic[b]</<.compile/</</e@https://monitor.magic.fr/bower_components/angular/angular.min.js?rel=1479176171588:259:195
sf/this.$get</n.prototype.$eval@https://monitor.magic.fr/bower_components/angular/angular.min.js?rel=1479176171588:135:215
sf/this.$get</n.prototype.$apply@https://monitor.magic.fr/bower_components/angular/angular.min.js?rel=1479176171588:135:447
Ic[b]</<.compile/</<@https://monitor.magic.fr/bower_components/angular/angular.min.js?rel=1479176