分类:乱七八糟日期:2018-06-09 - 19:30:46评论:14条作者:老谢
自h入手顶配X220以来,深深爱上了X系带来的便携性,1366*768的分辨率外出应用一下没问题,但是长时间使用分辨率太低实在影响效率,所以一直使用外接的显示器,但是最近把外接显示器搬走以后,普分的屏用着实在太难受了,于是折腾一波!
改造项目:
- 屏幕:夏普W23 IPS 1920*1080
- 网卡:BCM94360HMB (1300m 蓝牙4.0)
- 白名单BIOS屏蔽LVSD实现单屏模式
- 蓝牙接口转USB内置无线鼠标适配器
继续阅读…
分类:运维技术日期:2018-05-16 - 15:13:15评论:0条作者:老谢
zabbix_proxy编译安装
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
yum -y install net-snmp net-snmp-devel curl curl-devel perl-DBI net-snmp-utils
wget https://netix.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.11/zabbix-3.2.11.tar.gz
tar -zxf zabbix-3.2.11.tar.gz
mysql -uroot -proot -e "create database zabbix_proxy character set utf8"
cd zabbix-3.2.11
./configure --prefix=/usr/local/zabbix \
--enable-proxy \
--enable-agent \
--with-mysql=/usr/bin/mysql_config \
--with-net-snmp \
--with-libcurl \
--with-libxml2 \
--with-openssl
make install
mysql -uroot -proot zabbix_proxy < database/mysql/schema.sql |
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
yum -y install net-snmp net-snmp-devel curl curl-devel perl-DBI net-snmp-utils
wget https://netix.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.11/zabbix-3.2.11.tar.gz
tar -zxf zabbix-3.2.11.tar.gz
mysql -uroot -proot -e "create database zabbix_proxy character set utf8"
cd zabbix-3.2.11
./configure --prefix=/usr/local/zabbix \
--enable-proxy \
--enable-agent \
--with-mysql=/usr/bin/mysql_config \
--with-net-snmp \
--with-libcurl \
--with-libxml2 \
--with-openssl
make install
mysql -uroot -proot zabbix_proxy < database/mysql/schema.sql
修改/usr/local/zabbix/etc/zabbix_proxy.conf配置文件
Server=IP # zabbix服务端IP
Hostname=wyy_proxy # 必须和WEB页面添加代理时设置的名称一致
LogFile=/tmp/zabbix_proxy.log # 日志文件
DBHost=IP # 数据库IP
DBName=zabbix_proxy # 数据库名
DBUser=user # 数据库用户名
DBPassword=password # 数据库密码 |
Server=IP # zabbix服务端IP
Hostname=wyy_proxy # 必须和WEB页面添加代理时设置的名称一致
LogFile=/tmp/zabbix_proxy.log # 日志文件
DBHost=IP # 数据库IP
DBName=zabbix_proxy # 数据库名
DBUser=user # 数据库用户名
DBPassword=password # 数据库密码
启动proxy服务
/usr/local/zabbix/sbin/zabbix_proxy |
/usr/local/zabbix/sbin/zabbix_proxy
iptables开放端口
iptables -A INPUT -p tcp --dport 10050 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 10050 -j ACCEPT
iptables -A INPUT -p tcp --dport 10051 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 10051 -j ACCEPT
/etc/init.d/iptables save |
iptables -A INPUT -p tcp --dport 10050 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 10050 -j ACCEPT
iptables -A INPUT -p tcp --dport 10051 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 10051 -j ACCEPT
/etc/init.d/iptables save
修改/usr/local/zabbix/etc/zabbix_agentd.conf配置文件
Server=proxyIP #proxyIP为proxy服务器IP
#重启agent端,使配置生效
service zabbix_agentd start |
Server=proxyIP #proxyIP为proxy服务器IP
#重启agent端,使配置生效
service zabbix_agentd start
zabbix_agentd及zabbix_proxy的主机名要与zabbix_server中添加的主机名一致,zabbix_agent的server地址填proxy的地址。
下面是重点
ConfigFrequency=60 #zabbix proxy从zabbix server取得配置数据的频率(秒),默认1小时同步一次!
分类:linux日期:2018-05-08 - 19:39:15评论:0条作者:老谢
在配置zabbix主机的时候,有个items抓snmp的oid输出的是字符串,zabbix3.4可以直接通过正则处理snmp抓到的数据,但是为了oneoaas已经降级到了zabbix 3.2,经过一番搜索可以通过外部脚本来处理抓到的字符串,首先编辑vim /usr/local/zabbix/etc/zabbix_server.conf,关掉externalscripts的注释,然后修改为正确路即可。
snmpwalk -v 2c -c public 192.168.1.1 1.3.6.1.4.1.35047.2.10.7.0抓取到的值为SNMPv2-SMI::enterprises.35047.2.10.7.0 = STRING: “35 loginned users in all”,处理脚本如下:
#!/bin/bash
test=$(snmpwalk -v 2c -c public 192.168.1.1 1.3.6.1.4.1.35047.2.10.7.0)
#test1=`$test | grep '"\d+'`
echo $test | awk '
{
string=$0
len=length(string)
for(i=50; i<=len; i++)
{
tmp=substr(string,i,1)
if(tmp ~ /[0-9]/)
{
str=tmp
str1=(str1 str)
}
}
print str1
}' |
#!/bin/bash
test=$(snmpwalk -v 2c -c public 192.168.1.1 1.3.6.1.4.1.35047.2.10.7.0)
#test1=`$test | grep '"\d+'`
echo $test | awk '
{
string=$0
len=length(string)
for(i=50; i<=len; i++)
{
tmp=substr(string,i,1)
if(tmp ~ /[0-9]/)
{
str=tmp
str1=(str1 str)
}
}
print str1
}'
分类:网络技术日期:2018-05-05 - 11:37:31评论:1条作者:老谢
测试3.2和3.4均可用,通知媒介里面,给三个参数,顺序为:{ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE}
#!/usr/bin/python
#coding:utf-8
import smtplib
from email.mime.text import MIMEText
import sys
defaultencoding = 'utf-8'
if sys.getdefaultencoding() != defaultencoding:
reload(sys)
sys.setdefaultencoding(defaultencoding)
mail_host = 'smtp.xxx.cn'
mail_user = 'xxx'
mail_pass = 'xxx'
mail_postfix = 'xxx.cn'
def send_mail(to_list,subject,content):
me = mail_user+"@"+mail_postfix
msg = MIMEText(content, 'plain', 'utf-8')
msg["Accept-Language"]="zh-CN"
msg["Accept-Charset"]="ISO-8859-1,utf-8"
if not isinstance(subject,unicode):
subject = unicode(subject)
msg['Subject'] = subject
msg['From'] = me
msg['to'] = to_list
try:
s = smtplib.SMTP()
s.connect(mail_host)
s.login(mail_user,mail_pass)
s.sendmail(me,to_list,msg.as_string())
s.close()
return True
except Exception,e:
print str(e)
return False
if __name__ == "__main__":
send_mail(sys.argv[1], sys.argv[2], sys.argv[3]) |
#!/usr/bin/python
#coding:utf-8
import smtplib
from email.mime.text import MIMEText
import sys
defaultencoding = 'utf-8'
if sys.getdefaultencoding() != defaultencoding:
reload(sys)
sys.setdefaultencoding(defaultencoding)
mail_host = 'smtp.xxx.cn'
mail_user = 'xxx'
mail_pass = 'xxx'
mail_postfix = 'xxx.cn'
def send_mail(to_list,subject,content):
me = mail_user+"@"+mail_postfix
msg = MIMEText(content, 'plain', 'utf-8')
msg["Accept-Language"]="zh-CN"
msg["Accept-Charset"]="ISO-8859-1,utf-8"
if not isinstance(subject,unicode):
subject = unicode(subject)
msg['Subject'] = subject
msg['From'] = me
msg['to'] = to_list
try:
s = smtplib.SMTP()
s.connect(mail_host)
s.login(mail_user,mail_pass)
s.sendmail(me,to_list,msg.as_string())
s.close()
return True
except Exception,e:
print str(e)
return False
if __name__ == "__main__":
send_mail(sys.argv[1], sys.argv[2], sys.argv[3])
分类:linux日期:2018-04-10 - 10:45:17评论:0条作者:老谢
请优先参考:LNMP安装配置Zabbix搭建企业级监控平台
安装zabbix(CentOS 6.9 X64)
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
yum -y install net-snmp net-snmp-devel curl curl-devel perl-DBI net-snmp-utils
wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.8/zabbix-3.4.8.tar.gz
tar -zxf zabbix-3.4.8.tar.gz
mysql -uroot -proot -e "create database zabbix character set utf8"
cd zabbix-3.4.8
mysql -uroot -proot zabbix < database/mysql/schema.sql
mysql -uroot -proot zabbix < database/mysql/images.sql
mysql -uroot -proot zabbix < database/mysql/data.sql
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-openssl
make install
vim /etc/services
#添加下面的字段
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
#修改 zabbix server 配置文件
#注意:DBUser和DBPassword请自行根据实际情况填写数据库用户名及密码
vim /usr/local/zabbix/etc/zabbix_server.conf
DBUser=zabbix
DBPassword=zabbix
cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd
chmod +x /etc/init.d/zabbix_server
chmod +x /etc/init.d/zabbix_agentd
#添加mysql client库到系统默认库中:
vim /etc/ld.so.conf
#添加:
/usr/local/mysql/lib
#启动
/etc/init.d/zabbix_server start
mkdir /home/wwwroot/zabbix
cp -r -a frontends/php/* /home/wwwroot/zabbix |
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
yum -y install net-snmp net-snmp-devel curl curl-devel perl-DBI net-snmp-utils
wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.8/zabbix-3.4.8.tar.gz
tar -zxf zabbix-3.4.8.tar.gz
mysql -uroot -proot -e "create database zabbix character set utf8"
cd zabbix-3.4.8
mysql -uroot -proot zabbix < database/mysql/schema.sql
mysql -uroot -proot zabbix < database/mysql/images.sql
mysql -uroot -proot zabbix < database/mysql/data.sql
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-openssl
make install
vim /etc/services
#添加下面的字段
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
#修改 zabbix server 配置文件
#注意:DBUser和DBPassword请自行根据实际情况填写数据库用户名及密码
vim /usr/local/zabbix/etc/zabbix_server.conf
DBUser=zabbix
DBPassword=zabbix
cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd
chmod +x /etc/init.d/zabbix_server
chmod +x /etc/init.d/zabbix_agentd
#添加mysql client库到系统默认库中:
vim /etc/ld.so.conf
#添加:
/usr/local/mysql/lib
#启动
/etc/init.d/zabbix_server start
mkdir /home/wwwroot/zabbix
cp -r -a frontends/php/* /home/wwwroot/zabbix
配置fping
yum install epel-release.noarch
yum update
yum install fping
chown root:zabbix /usr/sbin/fping
chmod 710 /usr/sbin/fping
chmod ug+s /usr/sbin/fping
#修改/usr/local/zabbix/etc/zabbix_server.conf,删除FpingLocation=/usr/sbin/fping前的注释。 |
yum install epel-release.noarch
yum update
yum install fping
chown root:zabbix /usr/sbin/fping
chmod 710 /usr/sbin/fping
chmod ug+s /usr/sbin/fping
#修改/usr/local/zabbix/etc/zabbix_server.conf,删除FpingLocation=/usr/sbin/fping前的注释。
分类:网络技术日期:2018-04-09 - 19:23:01评论:6条作者:老谢
需求说明
由于设备量较大,如何有效的备份交换机设备配置文件就成了问题,经过一番搜索和对比,最终决定使用上传配置文件到tftp的方式进行备份,下面的脚本使用telnetlib库进行操作,感谢大D牛倾情技术支持,再次谢过大D神犇。
修改说明
Guge上传的V3.0源码仅支持Cisco的交换机,在大D牛的技术支持下,增加了H3C的支持(部分老版本的H3C可能会备份失败),同时也会按照时间自动分目录进行备份,下一步的想法会加入json的支持以及GUI。
main.py V4.0(测试环境Python 2.7.14)
#!/usr/bin/python
#by Kuhn 2014-03-29
#Updata by Derek.s && Jason 2018-04-09
import sys
import os
import telnetlib
import getpass
import datetime
import pexpect
import re
host = ""
user = "123"
password = "123"
#password = "123"
enpw = "123"
h3cpw = "123"
tftpserver = "8.8.8.8"
now = datetime.datetime.now()
def main():
for host in open("sw.txt", "r").readlines():
dsthost = host.strip('\n')
try:
tn = telnetlib.Telnet(dsthost,port=23,timeout=10)
except:
print "Can't connection %s"%dsthost
continue
#tn.read_until("Username:")
#tn.write(user+"\n")
try:
tn.read_until("Password:")
tn.write(password+"\n")
result = tn.read_some()
rex_h3c_bin_1 = r'%Wrong password'
login_Failed_H3C_1 = re.search(rex_h3c_bin_1, result)
rex_h3c_bin_2 = r'%Username or password is invalid.'
login_Failed_H3C_2 = re.search(rex_h3c_bin_2, result)
except:
print "Connection error %s"%dsthost
continue
#print(login_Failed_H3C_1, login_Failed_H3C_2)
if((login_Failed_H3C_1 is None) and (login_Failed_H3C_2 is None)):
#print("cisco")
try:
tn.write("en\n")
tn.read_until("Password:")
tn.write(enpw+"\n")
tn.read_until("#")
tn.write("copy running-config tftp:\n")
tn.write(tftpserver+"\n")
tn.write(now.strftime("%Y/%m/%d")+"/"+host+"\n")
tn.read_until("#")
tn.close
print now.strftime("%Y/%m/%d") + " " + dsthost + " Backup successful."
except:
print "Connection error %s"%dsthost
continue
else:
#print("H3c")
try:
tn.write(h3cpw+"\n")
tn.read_until(">")
tn.write("tftp "+tftpserver+" put flash:/startup.cfg"+" "+now.strftime("%Y/%m/%d")+"/"+host+"\n")
tn.read_until(">")
tn.close
print now.strftime("%Y/%m/%d") + " " + dsthost + " Backup successful(h3c)."
except:
print "Connection error %s"%dsthost
continue
if __name__=="__main__":
main() |
#!/usr/bin/python
#by Kuhn 2014-03-29
#Updata by Derek.s && Jason 2018-04-09
import sys
import os
import telnetlib
import getpass
import datetime
import pexpect
import re
host = ""
user = "123"
password = "123"
#password = "123"
enpw = "123"
h3cpw = "123"
tftpserver = "8.8.8.8"
now = datetime.datetime.now()
def main():
for host in open("sw.txt", "r").readlines():
dsthost = host.strip('\n')
try:
tn = telnetlib.Telnet(dsthost,port=23,timeout=10)
except:
print "Can't connection %s"%dsthost
continue
#tn.read_until("Username:")
#tn.write(user+"\n")
try:
tn.read_until("Password:")
tn.write(password+"\n")
result = tn.read_some()
rex_h3c_bin_1 = r'%Wrong password'
login_Failed_H3C_1 = re.search(rex_h3c_bin_1, result)
rex_h3c_bin_2 = r'%Username or password is invalid.'
login_Failed_H3C_2 = re.search(rex_h3c_bin_2, result)
except:
print "Connection error %s"%dsthost
continue
#print(login_Failed_H3C_1, login_Failed_H3C_2)
if((login_Failed_H3C_1 is None) and (login_Failed_H3C_2 is None)):
#print("cisco")
try:
tn.write("en\n")
tn.read_until("Password:")
tn.write(enpw+"\n")
tn.read_until("#")
tn.write("copy running-config tftp:\n")
tn.write(tftpserver+"\n")
tn.write(now.strftime("%Y/%m/%d")+"/"+host+"\n")
tn.read_until("#")
tn.close
print now.strftime("%Y/%m/%d") + " " + dsthost + " Backup successful."
except:
print "Connection error %s"%dsthost
continue
else:
#print("H3c")
try:
tn.write(h3cpw+"\n")
tn.read_until(">")
tn.write("tftp "+tftpserver+" put flash:/startup.cfg"+" "+now.strftime("%Y/%m/%d")+"/"+host+"\n")
tn.read_until(">")
tn.close
print now.strftime("%Y/%m/%d") + " " + dsthost + " Backup successful(h3c)."
except:
print "Connection error %s"%dsthost
continue
if __name__=="__main__":
main()
参考:http://mybeibei.net/157.html
分类:网络技术日期:2018-04-02 - 21:03:59评论:0条作者:老谢
EVE-NG(全称Emulated Virtual Environment – NextGeneration),继Unetlab 1.0后的Unetlab的2.0新版本,改了名字,原名是UnifiedNetworking Lab统一网络实验室。笔者觉得名字改的非常合理,这款模拟器已经不仅可以模拟网络设备,也可以运行一切虚拟机。理论上,只要能将虚拟机的虚拟磁盘格式转换为qcow2都可以在EVE-NG上运行。所以,EVE-NG可以算得上是仿真虚拟环境。EVE-NG是国外大神们开发的,融合了dynamips,IOL,KVM。它是深度定制的Ubuntu操作系统,可以直接把它安装在x86架构的物理主机上。它也有ova版本,可以导入到VMware等虚拟机软件中运行。EVE-NG在交互模式上更加具有优势,与GNS3截然不同。GNS3更像是用户使用的软件,只有GNS3支持的 OS才能使用;而EVE-NG更像是CS模型,EVE-NG是服务端,用户端可以是支持http/https的任意OS。
EVE-NG模拟器的安装配置
可以在EVE-NG官网下载到ova格式的虚拟机文件,在VMware Workstation Pro或VSPHERE等虚拟机中导入即可,root的默认密码是eve,老版本可能是unl,第一次进入系统会进入初始化配置界面,按照向导进行设置即可,之后会自动进行重启,再次进入系统可以使用apt-get update获取更新列表,然后使用apt-get install eve-ng安装eve-ng的更新版本。
使用vim将下面的python脚本写到文件,然后使用命令pydoc3 文件名执行后即可进行破解并自动写入序列号。
CiscoIOUKeygen.py
#! /usr/bin/python
print("*********************************************************************")
print("Cisco IOU License Generator - Kal 2011, python port of 2006 C version")
print("Modified to work with python3 by c_d 2014")
import os
import socket
import hashlib
import struct
# get the host id and host name to calculate the hostkey
hostid=os.popen("hostid").read().strip()
hostname = socket.gethostname()
ioukey=int(hostid,16)
for x in hostname:
ioukey = ioukey + ord(x)
print("hostid=" + hostid +", hostname="+ hostname + ", ioukey=" + hex(ioukey)[2:])
# create the license using md5sum
iouPad1 = b'\x4B\x58\x21\x81\x56\x7B\x0D\xF3\x21\x43\x9B\x7E\xAC\x1D\xE6\x8A'
iouPad2 = b'\x80' + 39*b'\0'
md5input=iouPad1 + iouPad2 + struct.pack('!I', ioukey) + iouPad1
iouLicense=hashlib.md5(md5input).hexdigest()[:16]
print("\nAdd the following text to ~/.iourc:")
print("[license]\n" + hostname + " = " + iouLicense + ";\n")
print("You can disable the phone home feature with something like:")
print(" echo '127.0.0.127 xml.cisco.com' >> /etc/hosts\n")
lic = ["[license]\n" + hostname + " = " + iouLicense + ";" + "\n"]
f = open('/opt/unetlab/addons/iol/bin/iourc','w')
f.writelines(lic)
f.close() |
#! /usr/bin/python
print("*********************************************************************")
print("Cisco IOU License Generator - Kal 2011, python port of 2006 C version")
print("Modified to work with python3 by c_d 2014")
import os
import socket
import hashlib
import struct
# get the host id and host name to calculate the hostkey
hostid=os.popen("hostid").read().strip()
hostname = socket.gethostname()
ioukey=int(hostid,16)
for x in hostname:
ioukey = ioukey + ord(x)
print("hostid=" + hostid +", hostname="+ hostname + ", ioukey=" + hex(ioukey)[2:])
# create the license using md5sum
iouPad1 = b'\x4B\x58\x21\x81\x56\x7B\x0D\xF3\x21\x43\x9B\x7E\xAC\x1D\xE6\x8A'
iouPad2 = b'\x80' + 39*b'\0'
md5input=iouPad1 + iouPad2 + struct.pack('!I', ioukey) + iouPad1
iouLicense=hashlib.md5(md5input).hexdigest()[:16]
print("\nAdd the following text to ~/.iourc:")
print("[license]\n" + hostname + " = " + iouLicense + ";\n")
print("You can disable the phone home feature with something like:")
print(" echo '127.0.0.127 xml.cisco.com' >> /etc/hosts\n")
lic = ["[license]\n" + hostname + " = " + iouLicense + ";" + "\n"]
f = open('/opt/unetlab/addons/iol/bin/iourc','w')
f.writelines(lic)
f.close()
继续阅读…
分类:乱七八糟日期:2018-03-25 - 22:14:31评论:5条作者:老谢
本来屏幕上有个坏点,电池循环次数700+,本来想走AC+免费把电池和屏幕换掉,然后最后一次摔手机,在屏幕和壳的链接处凹进去了一块,被拒保了…所以干脆走AC+意外险换了新机..无锡恒隆广场的直营店,总体感觉一般,预约检测完机器一个小时后拿到新机,然后付款就可以走人了。
最新评论
Andy烧麦:这些大厂都能提供必要的售后
王光卫博客:小米生态还是比较丰富
空空裤兜:在天猫买的利维斯顿,阿里智能APP...
林羽凡:我突然发现,你也记录了很多博文了。
菊座:小米的东西还行
zwwooooo:一般电器产品都jd,就是想售后身心
zwwooooo:能随便搞个公司玩玩也算是实力选手
大D:坚持就是胜利哈哈哈
老麦:看着那一排日志存档,老前辈了啊。
大峰:这售后可以嘛~