Skip to content

Instantly share code, notes, and snippets.

View koy1619's full-sized avatar
🎯
Focusing

Chris koy1619

🎯
Focusing
View GitHub Profile
@koy1619
koy1619 / mysql_master_slave_monitor.sh
Last active December 17, 2015 12:39
mysql服务&主从监控脚本 将此脚本放于mysql从库上,设置crontab -e */10 * * * * root /bin/sh /home/mysqld_monitor.sh 每十分钟跑一次,检测到mysqld服务或者是主从宕掉之后会发送邮件(只发一次)!
#!/bin/bash
mysql_status=`netstat -nl | awk 'NR>2{if ($4 ~ /.*:3306/) {print "Yes";exit 0}}'`
PortNum=`netstat -lnt|grep 3306|wc -l`
if [ "$mysql_status" == "Yes" ];then
slave_status=`mysql -uroot -p123456 -e"show slave status\G" | grep "Running" | awk '{if ($2 != "Yes") {print "No";exit 1}}'`
if [ "$slave_status" == "No" ];then
echo "slave is not working!"
[ ! -f "/tmp/slave" ] && echo "Slave is not working!" | mail -s "Warn!MySQL Slave is not working" monitor@test.me
@koy1619
koy1619 / DropboxBackup.sh
Last active December 17, 2015 12:39
参考http://davehope.co.uk/Blog/backup-your-linux-vps-to-dropbox/ 备份数据到Dropbox,可能因为中国大陆网络环境受影响
#!/bin/bash
DROPBOX_USER="xxx@xxx.com" //Dropbox的账号
DROPBOX_PASS="12345678" //Dropbox的密码
DROPBOX_DIR="/backups" //Dropbox中的文件夹名称
BACKUP_SRC="/home/wwwroot /data" //需要备份的文件夹路径,可以同时指定多个中间用空格隔开
BACKUP_DST="/home/backup" //用来存放备份的文件夹路径
MYSQL_SERVER="127.0.0.1" //连接本地MySQL
MYSQL_USER="root" //本地MySQL的用户
MYSQL_PASS="12345678" //本地MySQL的密码
@koy1619
koy1619 / hosts_deny.sh
Last active December 17, 2015 12:39
shell脚本防止暴力破解SSH服务 crontab */30 * * * * root sh /home/hosts_deny.sh
#! /bin/bash
cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' > /home/black.txt
DEFINE="5"
for i in `cat /home/black.txt`
do
IP=`echo $i |awk -F= '{print $1}'`
@koy1619
koy1619 / dnspodsh.sh
Created May 20, 2013 08:51
在bash中使用DNSPod的API接口实现DDNS客户端
#!/bin/bash
##############################
# dnspodsh v0.3
# 基于dnspod api构架的bash ddns客户端
# 作者:zrong(zengrong.net)
# 详细介绍:http://zengrong.net/post/1524.htm
# 创建日期:2012-02-13
# 更新日期:2012-03-11
##############################
@koy1619
koy1619 / ddns.go
Last active December 17, 2015 12:39 — forked from hugozhu/ddns.go
go实现dnspod的ddns
package main
import (
"io/ioutil"
"log"
"net"
"net/http"
"net/url"
"strings"
"time"
@koy1619
koy1619 / pypod.py
Last active December 17, 2015 13:29 — forked from chuangbo/README.md
python脚本实现dnspod的ddns
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#替换上你的Email,密码,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。
#获得domain_id可以用curl curl -k https://dnsapi.cn/Domain.List -d "login_email=xxx&login_password=xxx"
#获得record_id类似 curl -k https://dnsapi.cn/Record.List -d "login_email=xxx&login_password=xxx&domain_id=xxx"
import httplib, urllib
import socket
import time
@koy1619
koy1619 / dnspod_ddns.php
Last active December 17, 2015 14:39
PHP脚本实现DNSPOD动态域名解析 crontab -e 1 * 1 * * * php /home/dnspod_ddns.php 设置为1小时运行一
<?php
header("Content-type: text/html; charset=utf8");
class Dns
{
#Dnspod账户
private $dnspod_user = 'user@example.com';
#Dnspod密码
#!/bin/bash
BACKUP_SRC="/home/wwwroot"
BACKUP_DST="/home/backup"
#MYSQL_SERVER="localhost"
#MYSQL_USER="root"
MYSQL_PASS="123456"
@koy1619
koy1619 / nginx-vhost.conf
Created April 2, 2014 07:36
nginx-vhost.conf
server {
listen 8080;
server_name test.com;
index index.html index.htm index.php;
root /home/wwwroot/test;
location /test2 {
auth_basic "pd";
auth_basic_user_file /usr/local/nginx/conf/vhost/pd.passwd;
allow 114.112.113.111;
@koy1619
koy1619 / ntp.conf
Last active October 27, 2015 03:07
ntp.conf
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# 允许本地所有操作
restrict 127.0.0.1
restrict -6 ::1
# 允许的局域网络段或单独ip
#restrict 127.0.0.1   
#restrict 192.168.10.2  # 指定某台机器时间同步