我们平时在使用zabbix的时候可能需要用到一些高级的trigger使用方法 例如:
1 |
{Template Docker:docker.memoryusage.rss.last()}>10737418240 |
这个意思是说,我们docker使用的内存过多的时候,就触发报警,但是什么时候接触呢?默认就是小于这个值就会接触,但是有时候,我们想要的并不是简单的小于这个值,我们需要更小的值 例如,使用的……
首先,jenkins是一个java程序,所以,我们要先安装java环境:
1 |
sudo yum install java-1.8.0-openjdk.x86_64 |
然后我们设置一下环境变量
1 2 3 4 |
sudo cp /etc/profile /etc/profile_backup echo 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' | sudo tee -a /etc/profile echo 'export JRE_HOME=/usr/lib/jvm/jre' | sudo tee -a /etc/profile source /etc/profile |
然后,我们更新一下repo
1 |
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo |
[crayon……
很多时候,我们都需要通过cli命令来获取volume信息,snapshots信息,但是,我们知道这些volume的name都是存在tags中的,例如:
1 |
aws ec2 describe-volumes |
我们得到的结果是:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
{ "Volumes": [ { "AvailabilityZone": "us-east-1a", "Attachments": [ { "AttachTime": "2013-12-18T22:35:00.000Z", "InstanceId": "i-1234567890abcdef0", "VolumeId": "vol-049df61146c4d7901", "State": "attached", "DeleteOnTermination": true, "Device": "/dev/sda1" } ], "VolumeType": "standard", "VolumeId": "vol-049df61146c4d7901", "State": "in-use", "SnapshotId": "snap-1234567890abcdef0", "CreateTime": "2013-12-18T22:35:00.084Z", "Size": 8 }, { "AvailabilityZone": "us-east-1a", "Attachments": [], "VolumeType": "io1", "VolumeId": "vol-1234567890abcdef0", "State": "available", "Iops": 1000, "SnapshotId": null, "CreateTime": "2014-02-27T00:02:41.791Z", "Size": 100 } ] } |
这个时候我们需要的信息可能需要过滤一……
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#!/usr/bin/env python # coding=utf-8 import urllib2 import xml.dom.minidom try: url="http://weather.yahooapis.com/forecastrss?u=c&w=2151330" request = urllib2.Request(url) response = urllib2.urlopen(request) print "Geting data from yahooapis...." data = response.read() #print data dom = xml.dom.minidom.parseString(data) root = dom.documentElement location = root.getElementsByTagName('yweather:location') city = location[0].getAttribute("city") weather_conditions=root.getElementsByTagName('yweather:condition') weather = weather_conditions[0].getAttribute('text') temp = weather_conditions[0].getAttribute('temp') print "City:",city print "weather:",weather print "temp:",temp except Exception: print("there is something wrong") |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#!/usr/bin/env python # coding=utf-8 import socket s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect(('www.sina.com.cn',80)) s.send('GET / HTTP/1.1\r\nHost:www.sina.com.cn\r\nConnection:close\r\n\r\n') buffer = [] while True: d=s.recv(1024) if d: buffer.append(d) else: break data = ''.join(buffer) s.close() header, html = data.split('\r\n\r\n', 1) #print header header_itesm = header.split('\r') #print header_itesm[0] header_stage = header_itesm[0].split(' ') print header_stage[1] website_stage = int(header_stage[1]) if website_stage != 200: print "ERROR" #发邮件 else: pass |
配合crontab 效果更佳