Skip to content

Instantly share code, notes, and snippets.

Avatar

Troy Anderson theinventor

View GitHub Profile
View memory-usage.py
#!/usr/bin/python
import subprocess
import re
# Get process info
ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0].decode()
vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0].decode()
# Iterate processes
@theinventor
theinventor / bad-events.txt
Created Feb 22, 2018
Things you might want to watch for in windows eventlog
View bad-events.txt
EventID,Source,LogName,EventType,Message,Severity
9,%,%,0,%did not respond within the timeout period%,High
11,%,%,0,%controller error%,High
1000,%Microsoft-Windows-DHCP-Server%,%,0,%The DHCP service received the unknown option%,Critical
1064,%Microsoft-Windows-DHCP-Server%,%,0,%There are no IP addresses available for BOOTP clients%,Critical
1069,%Microsoft-Windows-DHCP-Server%,%,0,%Iashlpr cannot contact the NPS service%,Critical
1070,%Microsoft-Windows-DHCP-Server%,%,0,%Iashlpr initialization failed%,Critical
1142,%Microsoft-Windows-DHCP-Server%,%,0,%The DHCP server is unable to reach the NPS server%,Critical
3,%Microsoft-Windows-DNS-Server-Service%,%,0,%The DNS server has shut down%,Critical
10,%Microsoft-Windows-DNS-Server-Service%,%,0,%The DNS server could not start because it is dependent on the NTDS service which is not started%,Critical
@theinventor
theinventor / rc-car-highbeams.c
Created Feb 22, 2018
Simple arduino code to handle pwm and drive rc car headlights (LEDs) from a receiver (power and signal)
View rc-car-highbeams.c
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
To upload to your Gemma or Trinket:
1) Select the proper board from the Tools->Board Menu
2) Select USBtinyISP from the Tools->Programmer
3) Plug in the Gemma/Trinket, make sure you see the green LED lit
@theinventor
theinventor / syncro-sample-rest-api.ps1
Last active Aug 30, 2020
A sample powershell script with some functions to work with the SyncroMSP HTTP REST API
View syncro-sample-rest-api.ps1
Import-Module $env:SyncroModule
###########################################################################################
# First, some functions, these are just declarations that get used lower down the script. #
###########################################################################################
function Query-Syncro-Tickets ($SyncroSubdomain,$SyncroAPIKey,$Query) {
$uri = "https://$SyncroSubdomain.syncromsp.com/api/v1/tickets?api_key=$SyncroAPIKey&query=$Query"
$response = Invoke-RestMethod -Uri $uri
$response
@theinventor
theinventor / syncro-install.ps1
Created Jan 15, 2018
Download Syncro agent and install it from command line
View syncro-install.ps1
# Download the installer
$source = "https://rmm.syncromsp.com/GetThisURLfromYourCustomerDetailPageAndPutItHere.exe"
$destination = "C:\temp\syncro-installer.exe"
# Check if Invoke-Webrequest exists otherwise execute WebClient
if (Get-Command 'Invoke-Webrequest'){
Invoke-WebRequest $source -OutFile $destination
} else {
$WebClient = New-Object System.Net.WebClient
View laundry-monitor.groovy
import groovy.time.*
definition(
name: "Laundry Monitor II", namespace: "HDFLucky", author: "Mr. Lucky",
description: "This application is a modification of the SmartThings 'Laundry Monitor' SmartApp. Instead of using a vibration sensor, it utilizes Power (wattage) sensing.",
category: "My Apps",
iconUrl: "https://dl.dropboxusercontent.com/u/52901840/laundry.png",
iconX2Url: "https://dl.dropboxusercontent.com/u/52901840/laundry@2x.png",
iconX3Url: "https://dl.dropboxusercontent.com/u/52901840/laundry@3x.png")
View monitor-backup-exec.ps1
Import-Module $env:SyncroModule
# this depends on bemcli being installed!
#Setting default CLI
import-module bemcli
#Getting Alerts
$Alerts = Get-BEAlert
#Looping through the alerts and setting them.
View monitor-windows-server-backup.ps1
Import-Module $env:SyncroModule
$Date=Get-Date; $Date=$Date.AddDays(-1).ToShortDateString()
$WBS=Get-WBSummary
$LastBackupResult=$WBS.LastBackupResultDetailedHR
$LastSuccessfulBackup=$WBS.LastSuccessfulBackupTime.ToShortDateString()
$LastBackup=$WBS.LastBackupTime
$Versions=$WBS.NumberOfVersions
$ErrorDesc=Get-WBJob -Previous 1; $ErrorDesc=$ErrorDesc.ErrorDescription
@theinventor
theinventor / veeam_backup_monitor.ps1
Created Dec 1, 2017
Sample powershell for Syncro to get event viewer data (for last 1 day, so make this a daily script) and create an alert in your Syncro account if it finds issues.
View veeam_backup_monitor.ps1
Import-Module $env:SyncroModule
# Create RMMAlerts when a backup fails
$event = Get-EventLog "Veeam Backup" -newest 1 -After (Get-Date).AddDays(-1)| Where-Object {$_.EventID -eq 0}
if($event.entrytype -eq "Error") {
write-host "We got an event that is an error from Veeam Backup!"
Rmm-Alert -Category "veeam_backup_failed" -Body "Veeam Backup Failed on $(%computername%) - message: $($event.message)"
} else {
@theinventor
theinventor / install-and-run-ccleaner.ps1
Created Nov 28, 2017
Powershell to install and run ccleaner. In Syncro set this up to run as System, Powershell.
View install-and-run-ccleaner.ps1
Import-Module $env:SyncroModule
# Silent Install CCleaner
# http://www.piriform.com/ccleaner/download
# Path for the workdir
$workdir = "c:\temp\"
$sixtyFourBit = Test-Path -Path "C:\Program Files (x86)"
You can’t perform that action at this time.