分类: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()
继续阅读…
最新评论
老何:不至于跌得这么狠吧
Andy烧麦:这些大厂都能提供必要的售后
王光卫博客:小米生态还是比较丰富
空空裤兜:在天猫买的利维斯顿,阿里智能APP...
林羽凡:我突然发现,你也记录了很多博文了。
菊座:小米的东西还行
zwwooooo:一般电器产品都jd,就是想售后身心
zwwooooo:能随便搞个公司玩玩也算是实力选手
大D:坚持就是胜利哈哈哈
老麦:看着那一排日志存档,老前辈了啊。