mirror of
https://github.com/paradizelost/Linux-Scripts.git
synced 2024-11-25 02:44:44 -06:00
Initial Commit
This commit is contained in:
parent
5d747da34f
commit
4c6efb2896
12
docast.py
Normal file
12
docast.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
import time
|
||||||
|
import pychromecast
|
||||||
|
exroom=pychromecast.Chromecast('192.168.1.123')
|
||||||
|
lroom=pychromecast.Chromecast('192.168.1.107')
|
||||||
|
home=pychromecast.Chromecast('192.168.1.103')
|
||||||
|
emc=exroom.media_controller
|
||||||
|
lmc=lroom.media_controller
|
||||||
|
hmc=home.media_controller
|
||||||
|
home.wait()
|
||||||
|
time.sleep(5)
|
||||||
|
hmc.play_media('http://192.168.1.14/doorbell.mp3','audio/mpeg')
|
72
logwatch.sh
Normal file
72
logwatch.sh
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
function procaplog(){
|
||||||
|
while IFS=, read -r date mac; do
|
||||||
|
HOSTNAME=$(checkmac "$mac")
|
||||||
|
if [ "$HOSTNAME" ]; then
|
||||||
|
case $HOSTNAME in
|
||||||
|
AMAZON_IOT_BUTTON)
|
||||||
|
/root/bin/sheet.py "$date" "Diaper Change"
|
||||||
|
alert_dan "$date The button was pushed"
|
||||||
|
python /root/bin/docast.py
|
||||||
|
;;
|
||||||
|
DAN_PIXEL)
|
||||||
|
alert_alli "Dan is home at $date"
|
||||||
|
/root/bin/sheet.py "$date" $HOSTNAME
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
/root/bin/sheet.py "$date" $HOSTNAME
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
alert_dan "$NOW - Unknown host $mac connected at $date"
|
||||||
|
/root/bin/sheet.py "$date" $mac
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
};
|
||||||
|
function procswitchlog(){
|
||||||
|
while IFS=, read -r date device port state; do
|
||||||
|
if [ "$state" == "Up:" ]; then
|
||||||
|
alert_dan "Port $port on switch $device came up at $date"
|
||||||
|
else
|
||||||
|
alert_dan "Port $port on switch $device went down at $date"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
function checkmac(){
|
||||||
|
LINE=$(grep $1 /root/bin/test.txt )
|
||||||
|
if [ "$LINE" ]; then
|
||||||
|
read -r mac hostname <<< $LINE
|
||||||
|
echo $hostname
|
||||||
|
fi
|
||||||
|
};
|
||||||
|
function alert_alli(){
|
||||||
|
nail -s "$1" -S from="Alerts@hamik.net" "$PHONE2" <<<"."
|
||||||
|
};
|
||||||
|
function alert_dan(){
|
||||||
|
nail -s "$1" -S from="Alerts@hamik.net" "$PHONE1" <<<"."
|
||||||
|
nail -s "$1" -S from="Alerts@hamik.net" "$PHONE3" <<<"."
|
||||||
|
};
|
||||||
|
LOG="/var/log/logs/192.168.1.113.log"
|
||||||
|
LOG2="/var/log/logs/192.168.1.104.log"
|
||||||
|
LOG3="/var/log/logs/192.168.1.252-1.log"
|
||||||
|
EVT="$(comm --nocheck-order -23 "$LOG" "$LOG.old" | wc -l)"
|
||||||
|
EVT2="$(comm --nocheck-order -23 "$LOG2" "$LOG2.old" | wc -l)"
|
||||||
|
EVT3="$(comm --nocheck-order -23 "$LOG3" "$LOG3.old" | wc -l)"
|
||||||
|
PHONE1="15555555555@vtext.com"
|
||||||
|
PHONE2="15555555555@vtext.com"
|
||||||
|
PHONE3="15555555555@vtext.com"
|
||||||
|
|
||||||
|
if [ "$EVT" != "0" ]; then
|
||||||
|
cp "$LOG" "$LOG.old"
|
||||||
|
tail -n "$EVT" "$LOG" | awk '/WPA: pairwise key handshake completed/ {print $1 " " $2 " " $3 ", " $9 }'|procaplog
|
||||||
|
fi
|
||||||
|
if [ "$EVT2" != "0" ]; then
|
||||||
|
cp "$LOG2" "$LOG2.old"
|
||||||
|
tail -n "$EVT2" "$LOG2" | awk '/WPA: pairwise key handshake completed/ {print $1 " " $2 " " $3 ", " $9 }'|procaplog
|
||||||
|
fi
|
||||||
|
if [ "$EVT3" != "0" ]; then
|
||||||
|
cp "$LOG3" "$LOG3.old"
|
||||||
|
tail -n "$EVT3" "$LOG3" | awk '/Link Up:/ {print $1 " " $2 " " $3 "," $4 "," $11 "," $10 }'|procswitchlog
|
||||||
|
tail -n "$EVT3" "$LOG3" | awk '/Link Down:/ {print $1 " " $2 " " $3 "," $4 "," $11 "," $10}'|procswitchlog
|
||||||
|
fi
|
||||||
|
|
12
sheet.py
Normal file
12
sheet.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import gspread
|
||||||
|
import sys
|
||||||
|
toadd=sys.argv
|
||||||
|
toadd.pop(0)
|
||||||
|
from oauth2client.service_account import ServiceAccountCredentials
|
||||||
|
scope = "https://spreadsheets.google.com/feeds"
|
||||||
|
credentials = ServiceAccountCredentials.from_json_keyfile_name('/root/bin/credentials.json', scope)
|
||||||
|
gs = gspread.authorize(credentials)
|
||||||
|
gsheet = gs.open("testsheet")
|
||||||
|
wsheet = gsheet.worksheet("Sheet1")
|
||||||
|
wsheet.insert_row(toadd,index=2)
|
Loading…
Reference in New Issue
Block a user