Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
#
#Find the pattern and complete the function:
#int[][] spiral(int n);
#where n is the size of the 2D array.
#Sample Result
#input = 3
#123
#894
#765
#!/bin/bash
now=$(date)
NAGIOS_CONFIG_FOLDER="/usr/local/nagios/etc"
files=`find $NAGIOS_CONFIG_FOLDER -type f -mmin -1`
if [[ $files == "" ]] ; then
echo "no change noticed in nagios config $now"
else
echo "Reloading nagios to load changed contents $NAGIOS_CONFIG_FOLDER at $now"
config_test=$(/usr/local/nagios/bin/nagios -f $NAGIOS_CONFIG_FOLDER/nagios.cfg)
if [ $? -eq 0 ]
@rakesh-patnaik
rakesh-patnaik / nagios4_debian_build.sh
Created January 11, 2018 06:26
bash script to build nagios4 packages from source
#!/usr/bin/env bash
sudo groupadd -g 3000 nagios
sudo useradd -u 3000 -g nagios -d /usr/local/nagios -c 'Nagios Admin' nagios
sudo apt-get install apache2
sudo adduser www-data nagios
VERSION=4.3.4
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-$VERSION.tar.gz
tar xzf nagios-$VERSION.tar.gz
sudo apt-get install checkinstall unzip -qq --yes --force-yes
cd nagios-$VERSION && {
git clone https://github.com/openstack/openstack-helm.git
cd openstack-helm/tools/vagrant
vagrant up
vagrant ssh
#list running pods
sudo kubectl get pods --all-namespaces
#list endpoints setup
sudo kubectl get endpoints --all-namespaces
helm repo add stable http://storage.googleapis.com/kubernetes-charts
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import termios, fcntl, sys, os
fd = sys.stdin.fileno()
oldterm = termios.tcgetattr(fd)
newattr = termios.tcgetattr(fd)
newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
termios.tcsetattr(fd, termios.TCSANOW, newattr)
oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
VERSION="0.10-0.10.1-1"
#wget https://3a98d2877cb62a6e6b14-93babe93196056fe375611ed4c1716dd.ssl.cf5.rackcdn.com/l/c/lma_collector-0.9-0.9.0-1.noarch.rpm
wget https://3a98d2877cb62a6e6b14-93babe93196056fe375611ed4c1716dd.ssl.cf5.rackcdn.com/sl0.10-0.10.1-1/lma_collector-0.10-0.10.1-1.noarch.rpm
#wget https://3a98d2877cb62a6e6b14-93babe93196056fe375611ed4c1716dd.ssl.cf5.rackcdn.com/e/k/elasticsearch_kibana-0.9-0.9.0-1.noarch.rpm
wget https://3a98d2877cb62a6e6b14-93babe93196056fe375611ed4c1716dd.ssl.cf5.rackcdn.com/sl0.10-0.10.1-1/elasticsearch_kibana-0.10-0.10.1-1.noarch.rpm
#wget https://3a98d2877cb62a6e6b14-93babe93196056fe375611ed4c1716dd.ssl.cf5.rackcdn.com/i/g/influxdb_grafana-0.9-0.9.0-1.noarch.rpm
wget https://3a98d2877cb62a6e6b14-93babe93196056fe375611ed4c1716dd.ssl.cf5.rackcdn.com/sl0.10-0.10.1-1/influxdb_grafana-0.10-0.10.1-1.noarch.rpm
#wget https://3a98d2877cb62a6e6b14-93babe93196056fe375611ed4c1716dd.ssl.cf5.rackcdn.com/l/n/lma_infrastructure_alerting-0.9-0.9.0-1.noarch.rpm
wget https://3a98d2877cb
SOURCE_BRANCH=stable/0.8
yum -y install createrepo rpm rpm-build dpkg-devel git
easy_install pip
pip install fuel-plugin-builder
git clone https://github.com/openstack/fuel-plugin-lma-collector.git
git clone https://github.com/openstack/fuel-plugin-lma-infrastructure-alerting.git
git clone https://github.com/openstack/fuel-plugin-influxdb-grafana.git
git clone https://github.com/openstack/fuel-plugin-elasticsearch-kibana.git
cd /root/fuel-plugin-lma-collector
git checkout $SOURCE_BRANCH
wget http://plugins.mirantis.com/repository/l/m/lma_collector/lma_collector-0.8-0.8.0-1.noarch.rpm
wget http://plugins.mirantis.com/repository/e/l/elasticsearch_kibana/elasticsearch_kibana-0.8-0.8.0-1.noarch.rpm
wget http://plugins.mirantis.com/repository/i/n/influxdb_grafana/influxdb_grafana-0.8-0.8.0-1.noarch.rpm
wget http://plugins.mirantis.com/repository/l/m/lma_infrastructure_alerting/lma_infrastructure_alerting-0.8-0.8.0-1.noarch.rpm
fuel plugins --install lma_collector-0.8-0.8.0-1.noarch.rpm
fuel plugins --install elasticsearch_kibana-0.8-0.8.0-1.noarch.rpm
fuel plugins --install influxdb_grafana-0.8-0.8.0-1.noarch.rpm
fuel plugins --install lma_infrastructure_alerting-0.8-0.8.0-1.noarch.rpm
fuel plugins
@rakesh-patnaik
rakesh-patnaik / composite nagios check
Created July 29, 2015 22:13
composite nagios check
#!/bin/bash
nrpe="/usr/local/nagios/libexec/check_nrpe"
hostname="127.0.0.1"
check_one="$1"
check_two="$2"
$nrpe -H $hostname -c $check_one
return_one=$?