Skip to content

Instantly share code, notes, and snippets.

View discarn8's full-sized avatar

discarn8 discarn8

View GitHub Profile
@discarn8
discarn8 / 4-square_heatmap.py
Last active February 28, 2022 17:14
Python: Create a live-update 4-square_heatmap.py
import plotly.graph_objects as go
import dash
from dash import dcc, html
import requests
from dash.dependencies import Input, Output
app = dash.Dash(__name__)
app.layout = html.Div([
#Display the graph - specify the callback to call on
dcc.Graph(id='live-update-graph'),
@discarn8
discarn8 / bollies.sh
Last active January 6, 2024 22:10
Bash One-line-lovelies
# Remove blank lines from a text file
sed -i '/^$/d' file.txt
# Delete line 7000 with sed
sed -i '7000d' file.txt
# Replace 'Earth' with 'Globe' "globally"
sed -i 's/Earth/Globe/g' file.txt
# Replace 'Earth' with 'Globe' "globally" in multiple files
@discarn8
discarn8 / check_nfs.sh
Last active March 21, 2022 04:28
Nagios Check NFS
/usr/lib/nagios/plugins/check_nfs.sh
----------------------------------------------------------------
#!/bin/sh
RC=0
NAGIOS_CRIT=2
NAGIOS_OK=0
NAGIOS_WARN=1
FS="/NFS"
# Main
@discarn8
discarn8 / check_hw
Last active March 21, 2022 04:52
Nagios Check Hardware
/usr/lib/nagios/plugins/check_hw
------------------------------------------------------
#!/bin/sh
HW=$(cat /proc/device-tree/model | tr '\0' '\n')
echo $HW
exit 0
------------------------------------------------------
/etc/nagios/nrpe.cfg | egrep -v '#|^$'
@discarn8
discarn8 / check_os
Created March 21, 2022 04:35
Nagios Check Operating System
/usr/lib/nagios/plugins/check_os
------------------------------------------------------------
#!/bin/sh
OS=$(cat /etc/os-release | grep PRETTY_NAME | awk -F"=" '{print $2}' | sed -s 's/"//g')
echo $OS
exit 0
------------------------------------------------------------
/etc/nagios/nrpe.cfg | egrep -v '#|^$'
------------------------------------------------------------
command[check_users]=/usr/lib/nagios/plugins/check_users -w 3 -c 4
@discarn8
discarn8 / check_throttled
Last active June 7, 2022 15:46
Nagios Check Raspberry Pi If Throttled
/usr/lib/nagios/plugins/check_throttled
---------------------------------------------------------------------
#!/bin/sh
OS=$(cat /etc/os-release | grep PRETTY_NAME | awk -F"=" '{print $2}' | sed -s 's/"//g')
echo $OS
exit 0
pi@livingtemp:~ $ cat /usr/lib/nagios/plugins/check_throttled
#!/bin/sh
throttled="$(vcgencmd get_throttled)"
@discarn8
discarn8 / check_voltage
Last active June 7, 2022 15:46
Nagios Check Raspberry Pi Voltage
/usr/lib/nagios/plugins/check_voltage
-----------------------------------------------------
#!/bin/sh
voltage=$(for i in core sdram_c sdram_i sdram_p ; do echo $i `/opt/vc/bin/vcgencmd measure_volts $i`; done)
echo $voltage | awk -F"V " '{print $1"V\n"$2"V\n"$3"V\n"$4}'
exit 0
------------------------------------------------------------
/etc/nagios/nrpe.cfg | egrep -v '#|^$'
------------------------------------------------------------
command[check_users]=/usr/lib/nagios/plugins/check_users -w 3 -c 4
@discarn8
discarn8 / check_rasp_temp
Created March 21, 2022 04:51
Nagios Check Raspberry Pi Temperature
/usr/lib/nagios/plugins/check_rasp_temp
---------------------------------------------------------
#!/bin/bash
# Adapted from check_nagios_latency
VCGENCMD="/opt/vc/bin/vcgencmd"
# Prints usage information
usage() {
@discarn8
discarn8 / d3-diagram.html
Created March 22, 2022 05:06
Simple D3.js Example
d3-diagram.html
--------------------------------------------------------------------
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<style>
body {font-family: 'Arial';
background: #000000;}
</style>
<svg width="960" height="600"></svg>
@discarn8
discarn8 / DS18B20_fetch-temp.py
Last active March 25, 2022 09:51
Python script to get temperature reading from DS18B20 sensor
#!/usr/bin/python
import os
import time
if os.path.isdir('/sys/bus/w1/devices/28-011111ffffff/'):
os.system('/sbin/modprobe w1-gpio')
os.system('/sbin/modprobe w1-therm')
temp_sensor = '/sys/bus/w1/devices/28-011111ffffff/w1_slave'