Skip to content

Instantly share code, notes, and snippets.

@matt448
matt448 / backup_nagios.sh
Created March 13, 2013 14:17
Simple backup script for Nagios on Ubuntu 12.04
#!/bin/bash
DATE=`date +%Y%m%d-%H%M`
sudo tar cfvz nagios_backup_$DATE.tgz /etc/nagios3 /etc/nagios-plugins /etc/nagios /usr/lib/nagios/plugins /usr/share/pnp4nagios/html /var/lib/pnp4nagios/perfdata /var/lib/nagios /var/lib/nagios3
@matt448
matt448 / check-template-json-webservice.py
Created March 18, 2013 17:06
Template Nagios check for web services that return JSON data.
#!/usr/bin/python
#########################################
# Notes
#########################################
#
#
# Author: Matthew McMillan - matthew.mcmillan@gmail.com
# Blog: http://matthewcmcmillan.blogspot.com
# Code repo: https://github.com/matt448/nagios-checks
@matt448
matt448 / check_sqs_depth.py
Created October 7, 2013 14:52
Nagios check for monitoring Amazon SQS queue depth
#!/usr/bin/python
##########################################################
#
# Written by Matthew McMillan, matthew.mcmillan@gmail.com
#
# Requires the boto library and a .boto file with read
# permissions to the queues.
#
@matt448
matt448 / can_sender.ino
Last active August 24, 2023 11:23
Arduino code for CAN bus sender example
// demo: CAN-BUS Shield, send data
#include <mcp_can.h>
#include <SPI.h>
//Pot for adjusting value
int sensorPin = A0;
int sensorValue = 0;
int cantxValue = 0;
void setup()
@matt448
matt448 / can_reciever.ino
Last active August 27, 2021 21:04
Code for example CAN bus receiver.
// demo: CAN-BUS Shield, receive data
#include "mcp_can.h"
#include <SPI.h>
#include <LiquidCrystal.h>
#include <stdio.h>
#define INT8U unsigned char
INT8U Flag_Recv = 0;
INT8U len = 0;
INT8U buf[8];
@matt448
matt448 / SPI_Digital_Pot_AD8403.ino
Created October 24, 2013 15:58
Example code for controlling an AD8403 Digital Potentiometer. Please see https://github.com/matt448/arduino for the latest version of this code.
/*
Digital Pot Control
This example controls an Analog Devices AD8403 digital potentiometer.
The AD8403 has 4 potentiometer channels. Each channel's pins are labeled
A - connect this to voltage
W - this is the pot's wiper, which changes when you set it
B - connect this to ground.
The AD8403 is SPI-compatible. To command it you send two bytes.
@matt448
matt448 / slack_nagios.sh
Last active February 13, 2023 15:38
Script to post Nagios notifications into a Slack channel
#!/bin/bash
# This script is used by Nagios to post alerts into a Slack channel
# using the Incoming WebHooks integration. Create the channel, botname
# and integration first and then add this notification script in your
# Nagios configuration.
#
# All variables that start with NAGIOS_ are provided by Nagios as
# environment variables when an notification is generated.
# A list of the env variables is available here:
@matt448
matt448 / commands.cfg
Created December 31, 2013 19:01
Configuration to be added to existing commands.cfg. This tells how to use the slack_nagios.sh script.
###############################
# Slack notifications
###############################
# 'notify-service-by-slack' command definition
define command {
command_name notify-service-by-slack
command_line /usr/local/bin/slack_nagios.sh > /tmp/slack.log 2>&1
}
@matt448
matt448 / contacts.cfg
Created December 31, 2013 19:07
Nagios configuration lines for adding Slack to contacts.
define contact {
contact_name slack
alias Slack
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-slack
host_notification_commands notify-host-by-slack
}
@matt448
matt448 / tft_test.ino
Last active November 3, 2017 20:21
This is a simple sketch I used to test the refresh rate of an Adafruit 2.2" TFT display on an Arduino Mega 2560. http://www.adafruit.com/products/1480
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9340.h"
#if defined(__SAM3X8E__)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
// These are the pins used for the Mega