Saturday, September 6, 2008

Using Cacti to Monitor Server Uptime

Using Cacti to Monitor Server Uptime

Cacti really appears to be the simplest and nicest damn way to drive RRDToolfor server monitoring. If you don't know about Cacti, you may find it here

I assume cacti is already installed on your server and you are now in admin control panel.

This Quick Tutorial will Show you the Way to Monitor Uptime of any Host on Network

1.1.1 Creating A Template for Uptime Monitoring:

Monitoring server uptime is a fairly simple task, it would seem, but it's more complex than you might think, and it provides some interesting background in issues for setting up Cacti.

This tutorial will work through creating a template and then creating an instance of that template for a particular host:

1. Create a data template
2. Create a CDEF formula
3. Create a graph template
4. Create a graph for a particular host

Information that you need to know before starting is that uptime is available through SNMP as ticks (we assume here they are 100ths of a second) and the MIB to request is "HOST-RESOURCES-MIB::hrSystemUptime.0". YMMV, especially if you're not looking at a Linux system...

1.1.2 Creating a Data Template:

Click on "Data Templates". At the RHS of the header above the list that comes up, click on "Add".

Give it a title, like "ucd/net - Uptime (ticks)". You should also use that for the "Name" field. Source:

The option to "Use per data source value" lets you ultimately override this for each individual data source that this is used as a template for. We ain't going to need that for _any_ of these fields, so ignore all of them.

The "Data Input Method" we are going to use is to "Get SNMP Data". We only want a single value, so we don't want the "... (indexed)" alternative which is used for (e.g.) getting the traffic across all network interfaces.

The default is for all RRAs to be selected. You probably want to leave it that way, to leave you with appropriately degrading-over-age data.

The "Step" is the frequency of each data point. For Uptime I think 300 seconds is OK, but it could perhaps be higher. Each data collection point is some overhead, and they all add up, so you should think hard before reducing this below five minutes.

"Data Source Active" should be checked. You can use this inidvidually on host data sources templated from this to disable collection for some reason, but it's silly to template it to anything other than "Active" :-) Data Source Item:

We are only going to have a single Data Source Item in this source. Other sources may return multiple values, ordered according to some sort of index field, but that isn't appropriate for this.

So the item needs a name - we'll call it "uptime".

The uptime can't be negative, so the lowest reasonable value is 0. Anything less than that will be considered bogus data and will be ignored.

We would like to believe our uptime can be pretty large. Hopefully an unsigned int4, so we'll set the maximum to a rather optimistic 4000000000.

The data source type in this case is a GAUGE. We don't measure the difference from one query to the next (which is what COUNTER) would give us, and we're not going to derive something else from it (although maybe that's an alternative way to do what we're going to do in a minute...). Custom Data:

The only field we need to enter anything into here is the "OID" field because we expect all of the other fields to be provided from the host information. We don't need to say to use a per data-source item either, because it will use the _host_ data, not a per data source customisation.

The OID in this case should be the one we mentioned above: HOST-RESOURCES-MIB::hrSystemUptime.0

1.1.3 Creating a CDEF Formula:

Since the uptime is measured in ticks, and while that's really interesting, we want to see it in decimal days because it's generally more useful to us. For Linux this means dividing the number by 8640000, so we will create a formula to do this.

For some reason, known only to the Cricket developers, these are available in a sub-menu that expands when we click on "Graph Management". Click on "CDEFs" and then "Add". First we have to give it a name, so we'll call ours "Ticks to Days" and then click "Create" to get the record there.

The formula is stack based, so we will add three "CDEF items":

1. The current database value.
2. A constant 8640000.
3. The division operator.

Well, go on and do it then...

1.1.4 Creating a Graph Template:

Right, now you've done the formula that we will use in the graph, you can create the graph.

Choose "Graph Templates" and click on "Add" (top right) again.

We'll need a name, so lets call this "ucd/net - Uptime". Graph Template:

The title should be something like "|host_description| - Uptime" so that the host description gets stuffed in there when it is instantiated.

Everything else is pretty much the defaults. Override the size if you prefer them larger or smaller (but you can tweak this stuff later, so don't get too fussy at this point).

You might like to set the vetical label to "days", since that's what we're hoping to have displayed there...

Save what you have so far, and then two new sections appear at the top called "Graph Template Items" and "Graph Item Inputs". Graph Template Items:

We'll add two of these:

1. The actual uptime, as a plotted value.

2. The current value, as text at the bottom of the graph.

You can also get bonus points for adding the average and maximum at the bottom too.

Click "Add". Choose the data source template that we added above from the drop-down list.

Pick a colour.

The "Graph Item Type" is going to be "AREA", although it could be "LINE" if you prefer.

The "Consolidation Function" is going to be "AVERAGE". This is true in almost all cases, and it defines how the values in a range of time periods will get squished together when we are displaying wider and wider time periods and so we are losing detail.

The "CDEF Function" will be the one we just created earlier...

And we ignore the remaining fields and click "Save".

We're now back at the graph template page, so we click "Add" again.

We again choose the data source template that we added above from the drop-down list.

The "Graph Item Type" is going to be "GPRINT".

The "Consolidation Function" in this case is going to be "LAST" because in any resolution loss we will still want to be displaying the most recent value.

The "CDEF Function" will again be the "Ticks to Days" one we created earlier.

The "Text Format" field should be "Current:".

Click "Save" to save it.

Now we are back in the Graph Template and we can click "Save" to save that as well, since we are basically completed. Remember, we can come back later and tweak colours and so forth and it will apply across all graphs that use this template. Cool.

1.1.5 Using Our Template

Odds are if you have fiddled with Cacti enough to be able to get to the start of this tutorial that you already know all this, but it's included here for completeness...

Assuming that you already have a host, and all of their SNMP stuff is working, lets add a new graph to that host for their uptime.

Go to the "Devices" section and choose the server you want to add the Uptime graph to.

On that server, in the "Associated Graph Templates", choose the "ucd/net - Uptime" option that we have added and click the "Add" button. The graph will now appear in the list as "Not being graphed".

Click on the "Create Graphs for this Host" link at the top of the page and the Graph Templates will then be listed with a checkbox next to the ones that are not currently being graphed. Check the box and click "Create" to create them.

Now wait.

Wait a bit longer.

After about 10 minutes you should be able to go to the graphs for your host and see the uptime there.

Be happy!

Thanks you and good night...

Quick Note: This Quick Tutorial is not Originally Written by Me. I Found it Somewhere else in Internet. Written by:

Andrew McMillan


Cacti Support said...

I'm delighted that I have observed this weblog. Finally anything not a junk, which we go through incredibly frequently. The website is lovingly serviced and kept up to date. So it need to be, thank you for sharing this with us.

Rackmount LCD said...

The each part in your information is quite impressive. First time i see the article which cover
1. Create a data template
2. Create a CDEF formula
3. Create a graph template
4. Create a graph for a particular host

such type of information with separate details.


Other Posts

Labels / Category

2013 (1) 3G (4) Adsense (2) AKTEL (2) Amateur Radio (3) APNIC (5) Bajaj Discovery (1) Bajaj Pulsar (1) Bangla News (5) Bangladesh (29) Bangladesh Computer Market (1) Bangladesh Cricket (2) Bangladesh earthquake (3) Bangladesh Educational Board (1) Bangladesh Energy (4) Bangladesh ICT (15) Bangladesh Internet Service (15) Bangladeshi Credit Card (3) Bangladeshi News Site (3) Bank in Bangladesh (7) Bank of Bangladesh (10) Banking in Bangladesh (10) BGMEA Bulding (1) Big File Download (3) blackhat (1) BLOG (6) Bogon (3) bot (2) BTCL (3) BTRC (14) BTTB Internet (10) BTTB Submarine Cable (9) Byke Hijack (1) Cacti (1) Call Block (1) Carbon Credit (1) CentOs (2) CentOs Bangladesh (2) Charity (2) Chrome (2) Computer Booting (1) Credit Card (10) Credit Card in Bangladesh (8) Crime (3) CyberCrime (11) Cyclon (1) DDoS (8) Dengue (1) Denmark (1) Dhaka earthquake (5) DNS (3) DNSSEC (2) Domain (9) DoS (4) dot bd domain (3) Dot CO.CC (2) Download (4) Drive not opening on click (1) DV Lottery 2010 (2) E-Learning (1) earthquake (5) EARTHQUAKE BANGLADESH (2) EARTHQUAKE DHAKA (2) earthquake in Bangladesh (5) earthquake in Dhaka (5) Email (7) Email Full Header (3) Email Sender Identify (4) Entertainment (2) Fake Email Sender (5) Firefox (8) FTP (1) Funny (4) GMail (4) Google (18) GPRS Settings (1) GrameenPhone (1) HAM (4) Health (3) Hobby (1) IGW (3) IIG (3) India (1) Indian ICT (1) Indian IT (1) Internet (19) Internet Mail (1) Internet Security (9) iPhone (3) iPhone Bangla (2) iPhone Bangladesh (2) iPhone in Dhaka (2) iPod (1) IPv4 Allocation (8) ipv6 (10) islam (4) ISOC (3) Linux Articles (6) Metal News (1) Microsoft (4) Microsoft buy Yahoo (1) Mirror Server (1) Mobile Phone (3) Mobile Phone Internet (1) Mobile Phone News (3) Mobile Phone Operator (6) Mobile Phone User (3) Mozilla (8) Mozilla Firefox (8) Myself (1) Mystery (1) Netcraft (4) Network Monitoring (4) neverBot (2) News Site (1) Nokia (3) Oil Price (2) Online Security (7) Paypal in Bangladesh (6) Personal View (1) Phishing (2) Pigeons (1) Postfix (7) PSTN (2) RANGS Bulding (1) Relay Host (2) robot.txt (1) robots.txt (2) Scour (2) (2) Second submarine cable (3) Sendmail (4) Share Market (4) Smart Relay (3) SSC Result (1) SSC Result 2008 (1) Stock Market (3) Technology (1) Ubuntu (4) UCB (5) UCBL (5) URL Redirect (2) Virus (3) Virus Infected Windows (3) Virus Information (3) Warid (2) Web Spider (3) Webhosting (6) Wimax (4) Windows (1) Windows Problems (1) Wireless Internet in Bangladesh (5) Yahoo (4) Yahoo Sold (1)

Share it