Skip to content

Instantly share code, notes, and snippets.

View eksiscloud's full-sized avatar

Jakke Lehtonen eksiscloud

View GitHub Profile
@eksiscloud
eksiscloud / monitrc
Last active October 28, 2019 18:45
Starting point for new install of Monit server monitoring
set daemon 60 #check services every 60 seconds
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
#Event queue
set eventqueue
basedir /var/lib/monit/events # set the base directory where events will be stored
slots 100 # optionally limit the queue size
@eksiscloud
eksiscloud / site.mon
Last active October 21, 2019 01:52
Monit conf for a host/domain/site
### example.tld
check host example.tld with address www.example.tld
# ICMP check
if failed icmp type echo
for 2 times within 2 cycles
then alert
# HTTP check
if failed port 80 protocol http
@eksiscloud
eksiscloud / lamp.mon
Last active October 22, 2019 21:54
Monit: Apache2, MySQL and PHP-FPM
# Apache2
check process apache2 with pidfile /var/run/apache2/apache2.pid
group www-data
start program = "/bin/systemctl start apache2" with timeout 30 seconds
stop program = "/bin/systemctl stop apache2"
if failed host localhost port 80 with protocol http
and request "/server-status" for 2 times within 2 cycles then restart
depend apache_bin
depend apache_rc
@eksiscloud
eksiscloud / worpdress-site.mon
Created October 21, 2019 07:32
Monit conf for a host/domain/site with Wordpress
### example.tld
check host example.tld with address www.example.tld
# ICMP check
if failed icmp type echo
for 2 times within 2 cycles
then alert
# HTTP check
if failed port 80 protocol http
@eksiscloud
eksiscloud / services.mon
Last active January 9, 2021 07:32
Monit conf for Varnish, Redis, Hitch and Postfix
# Varnish
check program varnishpanic with path "/bin/varnishadm panic.show"
if status != 1 then alert
check process varnish with pidfile /var/run/varnish.pid
#start program = "/etc/init.d/varnish start" with timeout 30 seconds
#stop program = "/etc/init.d/varnish stop"
start program = "/usr/bin/systemctl start varnish" with timeout 30 seconds
stop program = "/usr/bin/systemctl stop varnish"
if failed host 127.0.0.1 port 80 protocol http
@eksiscloud
eksiscloud / wp-plugins.sh
Last active March 19, 2021 12:06
WP CLI + Bash: Batch installer of Wordpress plugins
#!/usr/bin/env bash
## WordPress Plugin Installer using BASH and WP-CLI
# Make executable: chmod u+x wp-plugins
# remember change WPPATH
# array of plugin slugs to install
WPPLUGINS=(
advanced-database-cleaner basepress categorytinymce classic-editor code-snippets change-last-modified-date disqus-comment-system
@eksiscloud
eksiscloud / wpcli.sh
Created October 23, 2019 14:29
WP CLI without root/sudo
#!/usr/bin/env bash
#
# install WP CLI at your home-dir. Change if you want something else
# make executable: chmod u+x wpcli.sh
# use ./wpcli.sh
#
mkdir ~/wp-cli
wget -q https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O ~/wp-cli/wp
chmod 755 ~/wp-cli/wp
export PATH="$PATH:~/wp-cli"
@eksiscloud
eksiscloud / wp_widget_backup
Created October 23, 2019 19:26
Wordpress: Backup active widgets and locations
#!/usr/bin/env bash
#
# Backup your widgets before you give a try to new theme
#
# https://guides.wp-bullet.com/using-wp-cli-backup-restore-wordpress-widgets/
#
# create array of all widgets in the wp_options table
WIDGETSARRAY=($(wp db query "SELECT option_name FROM $(wp db prefix --allow-root)options WHERE option_name LIKE 'widget\_%'" --skip-column-names --allow-root))
# loop through widgets
@eksiscloud
eksiscloud / wp_widget_restore
Created October 23, 2019 19:30
Wordpress: Restore active widgets and locations
#!/usr/bin/env bash
#
# Restore your widgets after tried new theme
#
# https://guides.wp-bullet.com/using-wp-cli-backup-restore-wordpress-widgets/
#
# loop through widget backups
for WIDGETBACKUP in /tmp/widgets/*.txt
do
# extract filename
@eksiscloud
eksiscloud / policy
Last active October 26, 2019 18:12
AWS Lambda: Custom IAM user policy for SES forwarding
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],