{"id":2804,"date":"2017-03-06T00:00:12","date_gmt":"2017-03-06T08:00:12","guid":{"rendered":"http:\/\/192.168.3.4\/?p=2804"},"modified":"2018-01-09T06:51:27","modified_gmt":"2018-01-09T14:51:27","slug":"cacti-and-custom-data-source-monitoring-part-1-of-2","status":"publish","type":"post","link":"https:\/\/www.cloudacm.com\/?p=2804","title":{"rendered":"Cacti and Custom Data Source Monitoring Part 1 of 2"},"content":{"rendered":"<p><strong>Introduction and Background<\/strong><\/p>\n<p>I had posted about Cacti and setting up graphing from unorthodox data sources before.\u00a0 When I stepped back through those documented steps, I didn&#8217;t get the expected results.\u00a0 The inaccurate and vague information on that post prompted me to take a hard top to bottom look at the process.\u00a0 For anyone that had viewed that post and become confused by it, I do apologize.\u00a0 I dedicate this post to you as a humble attempt to right my wrong on the subject of Cacti.<\/p>\n<p>On the Raspberry Pi, I&#8217;ll be creating a completely new system that will start with the installation of the OS.\u00a0 The OS that I&#8217;ll be working with is MATE, but you can do the same with any other supported flavor of Linux.\u00a0 From there I&#8217;ll go on to install the dependencies required for Cacti to run.\u00a0 Next, we&#8217;ll cover the steps of installing Cacti and some basic configuration.\u00a0 Once that is done, we will have a working Cacti platform from which we can start with.<\/p>\n<p>The native data sources supported by Cacti will be covered and I&#8217;ll step through how to setup those.\u00a0 Next, we&#8217;ll cover how to create custom data sources.\u00a0 This will allow Cacti to be used as a tracking mechanism for any number of applications.<\/p>\n<p>Once we have Cacti recording our data values from various sources, I&#8217;ll cover the graphing functions.\u00a0 Next I&#8217;ll cover some additional plug ins supported by Cacti and how to install them.<\/p>\n<p>When all is said it done, you should have an extensive picture of Cacti.\u00a0 With that knowledge I hope you will be able to do some advanced tasks with Cacti.\u00a0 Let&#8217;s begin.<\/p>\n<p><strong>Installing the MATE Operating System on the Raspberry Pi<\/strong><\/p>\n<p>The distro I&#8217;ll be using is Ubuntu MATE 16.04.2 LTS for Raspberry Pi 2 and 3 systems.\u00a0 The website for the OS can be found here, https:\/\/ubuntu-mate.org\/raspberry-pi\/.\u00a0 I suggest reading the details about the distro as it points out some items that will make your experience a better one.\u00a0 Speaking of making things better, consider making a donation to the development team.\u00a0 In their words, &#8220;If everyone who downloaded Ubuntu MATE donated $2.50 it would fund the full-time development of Ubuntu MATE and MATE Desktop.&#8221;<\/p>\n<p>It&#8217;s good practice to checksum your download.\u00a0 The Ubuntu MATE site provides a hash for the download.\u00a0 Mine happens to be this string &#8220;dc3afcad68a5de3ba683dc30d2093a3b5b3cd6b2c16c0b5de8d50fede78f75c2&#8221;.\u00a0 To verify that download is valid, use this command against the downloaded file.<\/p>\n<p>[bash]<br \/>\nsha256sum ubuntu-mate-16.04.2-desktop-armhf-raspberry-pi.img.xz<br \/>\n[\/bash]<\/p>\n<p>The Raspberry Pi uses microSDHC media as its &#8220;hard drive&#8221;.\u00a0 You&#8217;ll need to take additional steps to prepare the media so the Raspberry Pi can boot MATE from it.\u00a0 The Ubuntu MATE site suggests a few different methods on how to load the distro image onto the microSDHC media.\u00a0 I&#8217;m working from a Linux system, so I&#8217;ll use steps based on that OS.\u00a0 If you have a Windows or Apple platform, choose steps in accordance to those operating systems.<\/p>\n<p>From the Linux terminal window, enter this command<\/p>\n<p>[bash]<br \/>\nunxz ubuntu-mate-16.04.2-desktop-armhf-raspberry-pi.img.xz<br \/>\n[\/bash]<\/p>\n<p>Then I use the GUI version of DDRescue and choose the media to work with.\u00a0 This has been a good way for me to avoid imaging a drive on my computer, versus my intended target.\u00a0 I like to pause and double check.\u00a0 Remember to measure twice and cut once.<\/p>\n<p>Once the image has been copied, insert it in the Raspberry Pi.\u00a0 Connect the Raspberry Pi to a network connection, a KVM (keyboard, video monitor, and mouse), and a power source.\u00a0 From there you will see the OS start to load.<\/p>\n<p>My system did a file system resize to take up the remaining free space on my 32GB microSD card.\u00a0 When it finished, the Raspberry Pi rebooted.<\/p>\n<p>Following the reboot, I got the usual prompts to finish up the installation.\u00a0 I selected the pertinent information for my system.<\/p>\n<ul>\n<li>Language<\/li>\n<li>Time Zone<\/li>\n<li>Keyboard Layout<\/li>\n<li>User Account and login preferences<\/li>\n<\/ul>\n<p>When all was said and done, my MATE operating system was done.\u00a0 Next I ran updates, removed old items, and rebooted by issuing these commands.<\/p>\n<p>[bash]<br \/>\nsudo apt-get update<br \/>\nsudo apt-get upgrade<br \/>\nsudo apt-get autoremove<br \/>\n[\/bash]<\/p>\n<p>It&#8217;s good practice to do a reboot following any update, even if the system doesn&#8217;t prompt to do a reboot.\u00a0 I ensures that processes run with the newer code instead of the old code still occupying memory.<\/p>\n<p><strong>Settings On Firefox<\/strong><\/p>\n<p>One other thing I like to do with my MATE install is to set Firefox to preferences that I find personally favorable.<\/p>\n<p>On the new tab option I choose show blank page.\u00a0 The reset of these options are set in the Preferences section.<\/p>\n<p>Under General:<br \/>\nWhen Firefox starts: Show a blank page<br \/>\nUnder Search:<br \/>\nDuckDuckGo only &#8211; remove all others<br \/>\nuncheck &#8211; provide search suggestions<br \/>\nUnder Security:<br \/>\nUncheck &#8211; Remember logins for sites<br \/>\nUnder Advanced:<br \/>\nUnder General:<br \/>\nCheck &#8211; Warn me when websites try to redirect or reload the page<br \/>\nUnder Data Choices:<br \/>\nUncheck &#8211; Enable Firefox Health Report<br \/>\nUnder Update:<br \/>\nUncheck &#8211; Auto Update Search Engines<br \/>\nClose Firefox and reboot<\/p>\n<p><strong>Apache Web Server Install<\/strong><\/p>\n<p>Now it&#8217;s time to complete the AMP of our LAMP setup.\u00a0 In case you didn&#8217;t know it, LAMP stands for Linux Apache MySQL PHP.\u00a0 It&#8217;s going to be a requirement for us to operate Cacti on the Raspberry Pi.<\/p>\n<p>Here are the steps I found and worked for my instance.\u00a0 First I installed the Apache web server by issuing this command in the terminal window.<\/p>\n<p>[bash]<br \/>\nsudo apt-get install apache2<br \/>\n[\/bash]<\/p>\n<p>I then tested the install by opening firefox and going to this URL, http:\/\/localhost, yes it worked.\u00a0 Next, I installed PHP by issuing this command in the terminal window.<\/p>\n<p><strong>Installing PHP<\/strong><\/p>\n<p>[bash]<br \/>\nsudo apt-get install php libapache2-mod-php<br \/>\n[\/bash]<\/p>\n<p>This loaded version 7.0.\u00a0 A lot of &#8220;how-to&#8221; instructions I found online used a version of PHP that has since been superseded.\u00a0 For some reason this information remains when doing searches for instructions on how to install PHP on Linux.\u00a0 Anyway, my command worked.\u00a0 Next, I created a test PHP page for me to verify that my install worked.\u00a0 I like to use nano, but you can use any text editor so as long as you run it as super user.<\/p>\n<p>[bash]<br \/>\nsudo nano \/opt\/bitnami\/apps\/wordpress\/htdocs\/testphp.php<br \/>\n[\/bash]<\/p>\n<p>I then entered this code in the new file.<\/p>\n<p>[php]<br \/>\n&lt;?php phpinfo(); ?&gt;<br \/>\n[\/php]<\/p>\n<p>I then saved it and did a test by going to the URL, http:\/\/localhost\/testphp.php.\u00a0 Sure as anything, it worked.\u00a0 Next up I installed my last component for our Cacti requirements and that is MySQL.\u00a0 I issued this command in a terminal.<\/p>\n<p><strong>Installing MySQL Database Server<\/strong><\/p>\n<p>[bash]<br \/>\nsudo apt-get install mysql-server<br \/>\n[\/bash]<\/p>\n<p>When you do, you&#8217;ll get a prompt for the DB root password.\u00a0 Be sure you remember it, you&#8217;ll need it later.\u00a0 Safegaurd it and don&#8217;t use something simple.\u00a0 Next I installed MySQL management tools that run ontop of PHP, this was my logic behind installing PHP before MySQL.\u00a0 I issued these commands in the terminal.<\/p>\n<p>[bash]<br \/>\nsudo apt-get install php-mysql phpmyadmin<br \/>\n[\/bash]<\/p>\n<p>I selected apache2.\u00a0 Next I configured the phpmyadmin database and set the password for DB.\u00a0 Next I restarted my Apache webserver service using this command.<\/p>\n<p>[bash]<br \/>\nsudo \/etc\/init.d\/apache2 restart<br \/>\n[\/bash]<\/p>\n<p>After the service restarted, I checked that I could access MySQL using the PHP admin site with this URL, http:\/\/localhost\/phpmyadmin, all worked nicely.<\/p>\n<p>I then rebooted again for good measure.<\/p>\n<p><strong>Installing Webmin<\/strong><\/p>\n<p>Now, I also installed WEBMIN because managing a Linux system through command line is a pain.\u00a0 Also, since this system will be mounted inside an enclosure, it&#8217;s going to be running headless.<\/p>\n<p>I did my setup using these commands at the terminal.<\/p>\n<p>[bash]<br \/>\ncd Downloads<br \/>\nwget http:\/\/prdownloads.sourceforge.net\/webadmin\/webmin_1.831_all.deb<br \/>\nsudo dpkg &#8211;install webmin_1.831_all.deb<br \/>\n[\/bash]<\/p>\n<p>My system complained about missing dependencies.\u00a0 I used this command to get past that problem.<\/p>\n<p>[bash]<br \/>\nsudo apt-get -f install<br \/>\n[\/bash]<\/p>\n<p>By the graces, my WEBMIN install continued on as if no problem had occurred.<\/p>\n<p>Setting up webmin (1.831) &#8230;<\/p>\n<p>The WEBMIN install completed and I tested teh site by going to the URL, https:\/\/localhost:10000.\u00a0 Firefox warned me that the connection was not secure.\u00a0 I logged in using my MATE operating system user name and password.\u00a0 It was a nice surprise to see that the WEBMIN interface has been updated with some nice aesthetics.\u00a0 The real treat about WEBMIN is it tells you about pending updates.\u00a0 Sure as anything, I had several to apply.<\/p>\n<p>After installing the updates, I rebooted.<\/p>\n<p><strong>Installing Cacti<\/strong><\/p>\n<p>Now we are finally able to start with the installation of CACTI.\u00a0 Since we covered so much material, I&#8217;m going to break this post up into 2 sections.\u00a0 I&#8217;ll at least get you up and running with CACTI in this post.\u00a0 We&#8217;ll cover all the custom data source stuff on the next post.<\/p>\n<p>Installing Cacti was done using this command at the terminal.<\/p>\n<p>[bash]<br \/>\nsudo apt-get install cacti<br \/>\n[\/bash]<\/p>\n<p>I entered the password for DB then selected apache2 from the list.\u00a0 That was it, it was done installing.\u00a0 I tested the site by going to the URL, http:\/\/localhost\/cacti.<\/p>\n<p>Next, I stepped through the initial configuration.\u00a0 During the Cacti Installation Guide I selected New Install.\u00a0 During the first login admin\/admin is used and you&#8217;ll be prompted to change the password.<\/p>\n<p>That was it, the site came up with the following preloaded data sources that were being graphed.<\/p>\n<p>Localhost &#8211; Load Average<br \/>\nLocalhost &#8211; Logged in Users<br \/>\nLocalhost &#8211; Memory &#8211; Free<br \/>\nLocalhost &#8211; Memory &#8211; Free Swap<br \/>\nLocalhost &#8211; Processes<\/p>\n<p>Under Management \/ Devices \/ Localhost \/ Create Graphs for this host, I decided to add the media partitions size and use from Data Query list.\u00a0 This lets me know if I&#8217;m running out of space on my boot and main partitions.\u00a0 Running out of space on the boot partition can be a update nightmare.\u00a0 I&#8217;ve been though this and it&#8217;s best to avoid.<\/p>\n<p>Next, Under Management \/ Graph Tree \/ Default Tree, I added Tree Items types for each graph and removed header and host.\u00a0 Tree view doesn&#8217;t work for some reason, but preview view does.\u00a0 I&#8217;m thinking this has something to do with Linux.\u00a0 If I view the cacti site from another system it displays correctly.<\/p>\n<p><strong>Some Basic Cacti Preferences<\/strong><\/p>\n<p>The last thing I&#8217;ll cover in this post is changing the graph appearance.\u00a0 Under Settings tab I changed the graph settings as such.<\/p>\n<p>Default Graph View Timespan &#8211; 6 hours<br \/>\nThumbnail Height &#8211; 210<br \/>\nThumbnail Width &#8211; 460<\/p>\n<p>That&#8217;s it for now.\u00a0 My Cacti site is now graphing some basic metrics of my Raspberry Pi.\u00a0 Also, I&#8217;m able to do patch management easily with Webmin and perform other functions that I&#8217;ll cover in more detail in my next post.\u00a0 Thank you for joining me again.\u00a0 I hope this has been informative and useful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction and Background I had posted about Cacti and setting up graphing from unorthodox data sources before.\u00a0 When I stepped back through those documented steps, I didn&#8217;t get the expected results.\u00a0 The inaccurate and vague information on that post prompted me to take a hard top to bottom look at the process.\u00a0 For anyone that had viewed that post and become confused by it, I do apologize.\u00a0 I dedicate this post to you as a humble attempt to right my&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.cloudacm.com\/?p=2804\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-2804","post","type-post","status-publish","format-standard","hentry","category-data-mining"],"_links":{"self":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2804"}],"version-history":[{"count":9,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2804\/revisions"}],"predecessor-version":[{"id":2806,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2804\/revisions\/2806"}],"wp:attachment":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}