<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:schema="http://schema.org/" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" version="2.0" xml:base="https://www.linuxjournal.com/tag/graphing">
  <channel>
    <title>Graphing</title>
    <link>https://www.linuxjournal.com/tag/graphing</link>
    <description/>
    <language>en</language>
    
    <item>
  <title>Graph Any Data with Cacti!</title>
  <link>https://www.linuxjournal.com/content/graph-any-data-cacti</link>
  <description>  &lt;div data-history-node-id="1339370" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/12100f1.png" width="495" height="301" alt="" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/shawn-powers" lang="" about="https://www.linuxjournal.com/users/shawn-powers" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Shawn Powers&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;
For the past few years, I've been trying to understand how to make graphs using
RRDtool (Round-Robin Database tool) after failing miserably to understand MRTG
(Multi-Router Traffic Grapher) before that. The thing I like about RRDtool
is that it's newer and supports a wider variety of data sources. It's
still incredibly complicated though, and I've given up on learning how to use it
on multiple occasions. That's when I discovered Cacti.
&lt;/p&gt;

&lt;p&gt;
Cacti is not a new program. It's been around for a long time, and in its
own way, it's a complicated beast itself. I finally really took the time to figure
it out, however, and I realized that it's not too difficult to use. The cool
part is that Cacti makes RRDtool manipulation incredibly convenient. It
did take me the better part of a day to understand Cacti fully, so hopefully
this article will save you some time.
&lt;/p&gt;

&lt;h3&gt;
The Goal&lt;/h3&gt;

&lt;p&gt;
I want to create a graph that graphs something automatically and does
it using a bash script as the input as opposed to SNMP or anything like
that. I've been using bash for years, and I'm comfortable using the
command line to procure data. In fact, for this project, I'm going to
adapt a script I use for BirdTopia (my continual birdcam project for the
past few years) that will pull a temperature from the command line. I want
to pull the temperature from two different cities and graph them
together. For this example, I use Petoskey, Michigan (where I live), and Houston, Texas
(where &lt;em&gt;Linux Journal&lt;/em&gt; headquarters are located).
&lt;/p&gt;

&lt;p&gt;
Here's the script:

&lt;/p&gt;&lt;pre&gt;
&lt;code&gt;
#!/bin/bash
curl -s "http://api.wunderground.com/weatherstation/
 ↪WXCurrentObXML.asp?ID=$1" \
| grep temp_f | sed 's/.//' | sed 's/.//' | sed
 ↪'s/&lt;temp_f&gt;//' | sed 's/&lt;\/temp_f&gt;//'
&lt;/code&gt;
&lt;/pre&gt;


&lt;p&gt;
It looks complex, but really it just downloads the API information
from Weather Underground for the weather station given as an argument,
and then uses &lt;code&gt;sed&lt;/code&gt; (stream editor) to pare down the information to a
simple number—specifically, the numerical degrees in
Fahrenheit. If you
prefer Celsius, I applaud your country for adopting the metric system,
but sadly, my brain just can't relate Celsius to how warm the outdoor
temperature feels.
&lt;/p&gt;

&lt;p&gt;
One tricky part is figuring out what the proper weather station ID is
for your city. I wish you could just use a ZIP code, but I've been unable to
find a command-line weather API that will take a ZIP code. So if you're
following along, just head
over to &lt;a href="https://www.wunderground.com"&gt;Wunderground&lt;/a&gt; and load the page for your locale. Once there,
click on the link shown in Figure 1 (your text will be different, but the
location on the page should match). The next page will show the name of
your local weather station. You can see mine in Figure 2.
&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/graph-any-data-cacti" hreflang="und"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Thu, 27 Apr 2017 11:51:16 +0000</pubDate>
    <dc:creator>Shawn Powers</dc:creator>
    <guid isPermaLink="false">1339370 at https://www.linuxjournal.com</guid>
    </item>

  </channel>
</rss>
