Here, I will explain the difference between him and cacti nagios ~ And why should we use him ~
Cacti Uses snmp to capture data. Of course, you can use snmp to execute exec to retrieve the data in the script.
Nagios is used to monitor various Server statuses. Of course, you can also use pnp to draw images.
But why should I use graphite? In fact, it is just a function that shows the received data to the page ~
I think this function is enough ~
Requirements:
Script Execution Efficiency
System log analysis result
Online users
To the quality and delay of each network node
Company developers want to see the number of api calls
Number of calls to a program
Latency statistics for each process
These images can be well drawn, which is more convenient than drawing with rrdtool ~
Http://graphite.readthedocs.org/en/latest/index.html
1. Graphite Project Overview
Graphite is an enterprise-level monitoring tool that can run on cheap machine hardware.
Ii. Graphite Functions
Graphite is a drawing tool that displays data graphically. It mainly performs two tasks:
- Store time series data
- Displays data graphs as needed
Graphite does not collect data. Some tools know how to send data to Graphite. A little code is required, but it is very simple.
Iii. Simple Architecture
Graphite consists of three software components:
- Carbon-A Twisted daemon monitors time series data
- Whisper-A simple database used to store time series data, designed similar to RRD
- Graphite webapp-Django webapp: Uses Cairo to present images as needed
Architecture diagram: 650) this. length = 650; "class =" size-large wp-image-3294 "title =" Graphite High Level "alt =" Graphite High Level "width =" 458 "height =" 600 "style =" margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; background-position: initial; background-repeat: initial; "src =" http://www.bkjia.com/uploads/allimg/131227/1U23W126-0.png "/>
Graphite High Level
In this figure, we can see that Carbon first writes data to the Whisper database file, then Graphite Webapp reads the data, and then displays the image. But in fact, this system uses cache. Data may first go to the cache, and then the Webapp reads the data to display the image. This is why the web app graphics can still be displayed in near real-time mode when the host I/O response fails.
Data feed is quite simple, and most of the effort is usually spent on data collection. When you send data points to Carbon, they can draw images in the webapp immediately. Webapp provides several ways to create and display images, including simpleURL APIIn this way, you can easily embed images into other Web pages.
Iv. Effects
Is the effect in the browser:
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131227/1U23S233-1.jpg "/>
Shell example
- ORT=2003
- SERVER=graphite.your.org
- echo "local.random.diceroll 4 `date +%s`" | nc ${SERVER} ${PORT};
Python example
- #!/usr/bin/python
- import sys
- import time
- import os
- import platform
- import subprocess
- from socket import socket
-
- CARBON_SERVER = '127.0.0.1'
- CARBON_PORT = 2003
-
- delay = 60
- if len(sys.argv) > 1:
- delay = int( sys.argv[1] )
-
- def get_loadavg():
- # For more details, "man proc" and "man uptime"
- if platform.system() == "Linux":
- return open('/proc/loadavg').read().strip().split()[:3]
- else:
- command = "uptime"
- process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
- os.waitpid(process.pid, 0)
- output = process.stdout.read().replace(',', ' ').strip().split()
- lenlength = len(output)
- return output[length - 3:length]
-
- sock = socket()
- try:
- sock.connect( (CARBON_SERVER,CARBON_PORT) )
- except:
- print "Couldn't connect to %(server)s on port %(port)d, is carbon-agent.py running?" % { 'server':CARBON_SERVER, 'port':CARBON_PORT }
- sys.exit(1)
-
- while True:
- now = int( time.time() )
- lines = []
- #We're gonna report all three loadavg values
- loadavg = get_loadavg()
- lines.append("system.loadavg_1min %s %d" % (loadavg[0],now))
- lines.append("system.loadavg_5min %s %d" % (loadavg[1],now))
- lines.append("system.loadavg_15min %s %d" % (loadavg[2],now))
- message = '\n'.join(lines) + '\n' #all lines must end in a newline
- print "sending message\n"
- print '-' * 80
- print message
- print
- sock.sendall(message)
- time.sleep(delay)
This article is from "Fengyun, it's her ." Blog, please be sure to keep this source http://rfyiamcool.blog.51cto.com/1030776/1184015