Showing off. [And now, tutorial too.]

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

helzerr
Cacti User
Posts: 54
Joined: Sun Feb 01, 2004 3:10 am
Location: Orlando, FL
Contact:

Showing off. [And now, tutorial too.]

Post by helzerr »

Here's a look at what I've done with Cacti on my small LAN. Granted, it's pretty vanilla. Maybe others can post their results too, and we can discuss how we've accomplished making our graphs.

http://s89822048.onlinehome.us/cacti/
Last edited by helzerr on Wed Feb 11, 2004 7:26 am, edited 1 time in total.
gmajor
Posts: 1
Joined: Tue Dec 16, 2003 1:24 pm
Location: Bristol, PA.

showing off

Post by gmajor »

Nice work, but how did you do it? I have been playing around with Cacti, in my spare time, since November. I can get hosts graphing all the stuff that's included with Cacti, but have had zero success getting Cacti to collect and graph on other SNMP OID's or data returned from scripts. I am discouraged by the lack of a tutorial or step-by-step guide on how to set up Cacti to gather and graph other data.
helzerr
Cacti User
Posts: 54
Joined: Sun Feb 01, 2004 3:10 am
Location: Orlando, FL
Contact:

Post by helzerr »

I am by no means a Cacti expert, I've only been using the software for about a week now... However, I will try to explain what I have done thus far. I will start with the weather script, as I have had better luck with gathering data from scripts. I did not use templates for this data source / graph (since only one host will be collecting weather data, no point in adding extra complexity of templates). My examples are based on Cacti 0.8.4.

** The script **

I began by modifying the weatherbug.pl script to reflect my zip code and station ID. I had to guess the station ID, as I could not find another means to obtain it. I have also modified the script to output gust wind speed data. It is also possible to change Units to 1 if you prefer metric units.

Code: Select all

#!/usr/bin/perl

$output = `/bin/bash -c 'wget --quiet -O - \"http:\/\/wisapidata.weatherbug.com\
/WxDataISAPI\/WxDataISAPI.dll?Magic=10991&RegNum=3647055&ZipCode=34475&StationID=
VNGRD&Units=0&Version=2.7&Fore=1&t=1015084854\/"'`;

$output =~ s/[^0-9|\|]*//gi;

@weather = split(/\|/, $output);

# docs
# [0] - ID?
# [1] - Current Time
# [2] - Current Date
# [3] - Current Temperature
# [5] - Wind Speed (MPH)
# [7] - Gust Wind Speed (MPH)
# [10] - Barometer (Moisture)
# [11] - Humidity (%)
# [12] - High Tempurature
# [13] - Low Temperature
# [14] - Dew Point
# [15] - Wind Chill

print "current_temp:" . $weather[3] . " wind_speed:" . $weather[5] . " gust_wind_
speed:" . $weather[7] . " barometer:" . $weather[10] . " humidity:" .
        $weather[11] . " high_temp:" . $weather[12] . " low_temp:" . $weather[13
] . " dew_point_temp:" .
        $weather[14] . " wind_chill_temp:" . $weather[15];
If I run the script, I get the following output:

Code: Select all

# perl ./weatherbug.pl
current_temp:63 wind_speed:6 gust_wind_speed:15 barometer:3017 humidity:55 high_
temp:68 low_temp:52 dew_point_temp:46 wind_chill_temp:63
The important lesson in this exmple is that, since this script returns more than one piece of data, each value returned by the script has a "tag" associated with it. We'll need to know these "tags" later when we define a data input method in Cacti.
helzerr
Cacti User
Posts: 54
Joined: Sun Feb 01, 2004 3:10 am
Location: Orlando, FL
Contact:

Post by helzerr »

** The Data Input Method **

Here is where we tell Cacti how to obtain the data we're interested in. Click Data Input Methods in the Management list. You should see several Data Input Methods that are included with Cacti. We need to add a method to get data from the weatherbug.pl script, so click Add in the upper right corner.

Now we're presented with the Data Input Methods [new] screen. The first thing it asks for is a Name. I followed the naming convention of the existing Data Input Methods provided with Cacti, and chose to call it "Unix - Weather", since it is a script that will run in Unix and get weather data.

The next field, Input Type, in this case is obviously Script/Command.

Finally, Input String is where we tell Cacti how to locate the script. Since this is a perl script, we need to specify perl as the command, followed by the script name. We can also use a variable, <path_cacti>, to save us the trouble of typing in a long path (or having to make changes should we move cacti later on). Also notice, the help text for Input String suggests we can include "input sources" in <> brackets. This was confusing to me at first. What it is really saying is that Cacti can send variables to the script, such as a grep string, or a device name, so we can use one script to gather data from more than one source. We don't need this for the weather script, unless you wanted to do something advanced like collect weather information for more than one location (in which case you'd have to modify the script to accept these variables). The Input String I used is : perl <path_cacti>/scripts/weatherbug.pl

Now it's time to create our Data Input Method, click the create button.
Last edited by helzerr on Tue Feb 10, 2004 7:44 pm, edited 2 times in total.
helzerr
Cacti User
Posts: 54
Joined: Sun Feb 01, 2004 3:10 am
Location: Orlando, FL
Contact:

Post by helzerr »

** Input and Output Fields **

Now we are presented with the ability to add Input and Output Fields. Once again, this was somewhat confusing to me at first, I expected Input to mean data coming into Cati, and Output to mean data going out of Cacti. However, this is not the case. Input and Output refer to the script instead of Cacti.

Since our weatherbug.pl script takes no input, I'll ignore the Input portion for now, and focus on the Output portion. This is where Cacti picks up the data from our script's output. Click add to get started adding an Output Field.

The first thing we are prompted for is a "[Field] Output". This is where we match up the "tags" I mentioned earlier with "friendly names" in Cacti. I'll begin with the first "tag" returned from the weatherbug.pl script, current_temp. I type "current_temp" (minus quotes, of course) for the [Field] Output. For "Friendly Name", I choose to call this Output Field "Current Temperature", so once again, I type that in (minus quotes). I leave the check box "Update RRD File" enabled, as I want to record this data in the RRD file. Click create to complete the Output Field definition.

We repeat this process for each value returned from our script that we want to have access to in Cacti. However, you don't have to add an Output Field for all the "tags" your script returns, it is safe to ignore some. For example, my weatherbug.pl script returns 9 results, but I've only created 7 Output Fields. I ignore the high_temp and low_temp values weatherbug.pl provides. When you've created all your Output Fields, click save.
helzerr
Cacti User
Posts: 54
Joined: Sun Feb 01, 2004 3:10 am
Location: Orlando, FL
Contact:

Post by helzerr »

** Data Sources **

Data Sources is where we associate our new Data Input Method with a RRD. Once again, I initially found this name, Data Sources, confusing. We're actually putting data into the data source... However, later on we will be using this facility as the source of data for our graphs, so I suppose the name makes sense. Lets click the add button in the upper right to get started.

** Data Template Selection **

Here we are given two options, Selected Data Template and Host. Since we're not using templates for this example, we can leave this set to None. I also chose to leave Host set to None, since the weather isn't specific to any particular host on my small LAN. We'll click create to move on.

Here is where it all begins to come together. I'll go over each of the options.

** Data Source **

Name: First we have to pick a name for the data source. I simply used "Weather", since the source isn't associated with a host. If you have chosen to associate the data source with a host, you can use the variable |host_description| in the name, in which case the name might look like "|host_description| - Weather". The list of Cati variables is available here.

Data Source Path: This is where we tell Cacti what RRD file to use. Since we're making a new RRD file, leave it blank and Cacti will set this for us. If we were using an existing RRD file (from some other monitoring application, maybe), we could use that as our data source instead. [Note: If you specify an RRD file that is managed by some means other than Cacti here, you wouldn't create a Data Input Method in Cacti for it, either]

Data Input Source: We pick the "Unix - Weather" Data Input Method we created earlier from the drop-down list.

Associated RRA's: Like it says, you probably want to select all of these. Click Daily, hold the <shift> key, and click Yearly to select them all. I have missed this step before, causing me a lot of frustration trying to figure out what I had done wrong.

Step: This is how often the RRD expects to be updated. I stuck with the default of 300 seconds (5 minutes)

Data Source Active: I left this in its default state, enabled.
Last edited by helzerr on Wed Feb 11, 2004 7:44 am, edited 2 times in total.
User avatar
jcullen
Posts: 24
Joined: Fri Sep 05, 2003 10:50 pm

web hits; lodgged in users; disk temps; load average;weather

Post by jcullen »

Hello,

Impressive graphs, nice coloring :P . If you do not mind could you share with me the templates you used for these grpahs listed below you had displayed. Cacti is great unfortunately I sitll have much learning to do. Also if you could specify weather it is for linux or the other OS that would be great. Thanks for your time.

web hits; lodgged in users; disk temps; load average;weather


JCullen
JCullen@triad.rr.com
Last edited by jcullen on Wed Feb 11, 2004 7:13 am, edited 1 time in total.
helzerr
Cacti User
Posts: 54
Joined: Sun Feb 01, 2004 3:10 am
Location: Orlando, FL
Contact:

Post by helzerr »

** Data Source Item **

Here is where we determine what gets stored in our new RRD file. Initially, Cacti only asks us for a single Data Source Item, we'll be presented with the opportunity to add more later.

Internal Data Source Name: This is the name used to identify this Data Source in your RRD file. Once again, using the current temperature example, for the sake of consistency I named mine current_temp.

Minimum Value: The smallest value we want the RRD file to store. If our data input method returns a value smaller than this setting, it is stored as Unknown (U). This facility can help prevent spikes in your graphs. I used 0 for this setting, since I'm gathering temperature data in Farenhight from central Florida. I don't expect valid data that says it's colder than 0 degrees F.

Maximum Value: Just like Minimum Value, sets a limit on the largest value you can store in the RRD file. I set mine to 120.

Data Source Type: I selected Gauge, since my data input is a temperature gauge. See the RRD Tool create documentation for descriptions of the other data source types.

Heartbeat: Just like it says, I kept the default of 600.

Now we can actually create our new Data Source. Click create to continue. You will notice you have returned to the Data Source screen. We are now given the opportunity to associate an Output Field (from our Data Input Method) with our newly created Data Source Item. In this case, we pick "current_temp - Current Temperature" from the drop-down list. Click save to save the change, and Cacti returns us to the Data Source list.

Since we have additional items to associate with this data source, we have to open it to add more. Click on your weather data source in the list, scroll down to Data Source Item, and click New. Cacti creates a new Data Source Item tab, ready to be configured for our next item. We repeat these steps for each data source item we want stored in the RRD file. In my case I went on to create items for wind chill temp (min 0, max 120), dew point temp (min 0, max 120), barometer (min 100, max 5000), humidity (min 0, max 100), wind speed (min 0, max 100), and gust wind speed (min 0, max 120), all of type Gauge and Heartbeat of 600.

Now we have completed the Data Source and are ready to begin graphing!
helzerr
Cacti User
Posts: 54
Joined: Sun Feb 01, 2004 3:10 am
Location: Orlando, FL
Contact:

Post by helzerr »

** Graph Management **

Click Graph Management and Add to get started creating a new graph. We'll begin with the current temperature graph. The first option we have is template and host selection. Since I chose not to use a template for my weather graph, and have not associated weather with a particular host, I've left both of these set to their default value, none. Lets click create to move on to Graph Configuration.

Title: This is the title that will be shown in the "header" of the graph, and also determines how graphs are sorted in the tree or export. I used "Weather - Temperatures - Current" for this graph.

Image Format: I stuck with the default, PNG, because I like PNG files better than GIF. If you need to support older browsers, you might want to change this to GIF for compatibility's sake.

Height and Width: I used the default values, for no particular reason.

--> to be continued...
helzerr
Cacti User
Posts: 54
Joined: Sun Feb 01, 2004 3:10 am
Location: Orlando, FL
Contact:

Post by helzerr »

jcullen: Here is an archive to whet your appetite. I'm running Cacti on Linux, and all the scripts and graphs you requested are for Linux hosts as well.

My weather graphs are not defined as templates, so I couldn't include them in the export right now. I'll try to migrate them to templates so I can export them. The colors I chose are copied from the first site in the "Sites that use Cacti" list.

I did not include logged in users or load average, as I'm using the "built-in" default Cacti templates for those functions.

The hdd_temperature.md0 script gathers temperature data from the 6 drives that make up my md0 software RAID array. I have defined the members of this array in the script itself. Maybe one day I will make it smart enough to parse /etc/mdadm.conf instead.
Attachments
cacti_templates.zip
Graph and Data templates, Scripts.
(14.61 KiB) Downloaded 1633 times
barkeep8
Posts: 3
Joined: Wed Mar 10, 2004 10:41 pm

nice work!

Post by barkeep8 »

Really enjoyed the tutorial, helped put it all together for me! Thanks for taking the extra time and effort to put it togethe!
Guest

Post by Guest »

Looking at the cpu use of your graphs, I would say its time to get a bigger processor. :)

Very nice work on the tutorial, thanks a lot!
nitio

Post by nitio »

at first I could make the graph shows...
but no values were shown even if the updater showed that the values were taken
I've just modified the unix_sensors and the template to get sensors values from kernel 2.6.x that works on /sys now and have separated values for actual/max/min

it shouldn't be a matter for the graph not to work... any ideas?

btw: I can't see the graphics now, apparently it updates the right rrd but get the wrong file to make the graph...

[]'s
nitio
shorvath

Weather [NON US]

Post by shorvath »

Does anyone have any scripts for anywhere other than the US??
The UK for example?
Peer
Posts: 4
Joined: Thu Mar 25, 2004 11:17 am
Location: Netherlands

Post by Peer »

Hi,
I was trying out the howto to get the weather graph's, from helzerr, but i got stuck.
My RRD seems not to get updated, no error's in the log file.
I keep comming up with several blank graph's :cry:

Anny idea of what i am doing wrong, or should i wait until helzerr finishes the howto.

<edit> 28-03-2004

Shoot me it is working ????????????
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests