Skip to content

Instantly share code, notes, and snippets.

View discarn8's full-sized avatar

discarn8 discarn8

View GitHub Profile
@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_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_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_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_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 / 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 / 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 / install_mysql_pi.sh
Last active June 7, 2022 15:49
BASH: Install MYSQL On Raspberry Pi
#!/bin/bash
# *********************************************
# FILENAME: install_mysql_pi.sh
# DATE: Sep 2021
# AUTHOR: RCombs
#
# PURPOSE: Install mysql Client on Raspberry Pi
# *********************************************
@discarn8
discarn8 / install_UFW_pi.sh
Created February 7, 2022 04:47
BASH: Automate UFW installation on Raspberry Pi
#!/bin/bash
# **************************************************
# FILENAME: install_UFW.sh
# DATE: DEC 2021
# AUTHOR: RCombs
#
# PURPOSE: Install UFW on Raspberry Pi
# **************************************************
@discarn8
discarn8 / stock_to_mysql.sh
Created February 4, 2019 06:26
Bash script to pull stock price and drop it to mysql table
#!/bin/bash
#The mysql connection string shown, assumes you are using a .cnf file in your home directory
# Set set -xv to enable script debugging
#set -xv
ds=0
i=0
#Pull the current stock price from the nasdaq site