Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Saturday, May 30, 2015

Updating Ubuntu for the Unexperienced and

Time has come to update one of our Ubuntu boxes.  I can never remember how to do it and always have to go lookup the commands.  Maybe if I write them down here it'll help me remember them for next time.

I started with a lsb_release -a to see what version I was on.  Which happened to be 12.0.4.5 so I wasn't too far out of date.

Then I ran sudo apt-get update and then sudo apt-get upgrade to update all the packages that were available on the current version.  That brings me up to a fully patched system that needs to be upgraded to the latest LTS version (this is a production box running applications so I like to stick with LTS versions, I've never had a need to utilize the long term part, but it makes me feel better).

Next step I did was sudo apt-get dist-upgrade.  I'm no expert and I probably could have skipped this step and it's possible this step caused my later troubles.  Hind sight is 20/20 they say.

Now I just need to make the plunge and upgrade to the next release.  That's pretty easy,  sudo do-release-upgrade handles that.  And then the fun started.

Part way through this it prompts me because some of the apache configuration files have been modified from their originals.  I look through these changes and it really doesn't seem to like too big of a deal, but I don't want to stumble into something since most of these tweaks were done 2 years ago so I make a backup.  This machine is virtual and I didn't have the machine integration plugin installed so I couldn't switch between consoles there.  No problem though, I just SSH'd back into the machine and made a quick copy of the config file in question and then told the updater to replace it.  

The update gets done, I give the box a reboot, it seems to come back up normally and I think all is right in the world.  Then I pull up one of the websites hosted on the box and it just displays the content of the php file rather than processing the php file.  Maybe it's just this one site, nope, all the sites are equally broken.

No sweat, I've got a backup of that configuration file.   So I compare my "custom" file to the new file and don't see anything obviously wrong with it.  Obviously some of my tweaks are gone, but those wouldn't affect php not running.  I try restarting apache and it complains about a line in a configuration file (if I had noted the file I would have shared it here), that line looks like it has sometihng to do with php.  I did a bit of Googling and came across a reference to enabling php module with this command sudo a2enmod php5.  No luck, restarted apache, still no luck, same error and web pages still aren't right.

I find the command apt --installed list to show which packages are installed. I see a lot of php5-something else packages, but no php5 package.  I run sudo apt-get install php5 and let it install (it doesn't complain that it's already installed).  I restart apache and it works.  No error.  My web pages are back to normal.

I run apt --installed list again and it shows php5 is now installed.


In hind sight I think maybe the apt-get dist-upgrade may have been what did me in.  I'm not sure why, but none of the other commands should have removed any packages.  I guess if I had paid more attention to those apt-get message about packages being updated and being removed I would have been on top of this.  Lesson learned.

Thursday, October 24, 2013

My Aventures in Installing Cacti (Part 2)

This is a continuation of my first post about installing Cacti.  You can find that post here

Now that I've got this new Cacti server up and running we need to get some data collection setup so we can get some of those pretty graphs.

But first things first.  Out of the box this install is setup for DHCP.  We'll need to change that to a static IP address so it doesn't go jumping around on the network.  Now that I'm done with all the console part I'm going to remove the keyboard, mouse, and monitor and I don't want to lose it on the network somewhere.

Configuring an IP address from the console on a Ubuntu box is pretty easy.   There are just a couple of changes that need to be made to a configuration text file.  That file is /etc/network/interfaces.  To edit that use the command sudo nano /etc/network/interfaces  All we going to do there is change the iface eth0 inet dhcp line to iface eth0 inet static and then add a couple of lines for the actual static address.  It should look similar to this when you get finished:

auto eth0
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
gateway 10.0.0.1
dns-server 10.0.0.2

Once those changes have been made we'll need to restart the network interfaces to make those go into affect.  To restart the network interfaces just use sudo /etc/init.d/networking restart

Easy enough, right?  Now we know which IP address our server will be using and we wont be at the mercy of our DHCP server.

Now let's log back into our Cacti server and get to setting that up.  You'll need to use the IP address that you configure to access the server, but it will look something like http://10.0.0.100/cacti  You'll log in with the username/password that you setup earlier when you went through the initial setup wizard.

Once logged into Cacti you'll want to add a new device. Just click on Devices on the left side and then click on Add over on the right side.  You'll want to type in a description that's useful for you.  This is what's going to show up in all the lists in Cacti.  For the hostname I just entered the IP address of the switch I wanted to monitor.  For host template, it defaults to None, but if you'll go ahead and select something here it'll make things a little easier later on.  For me, I'm monitoring a Cisco 3750 switch so I just picked the "Generic SNMP-enabled Host" template.  I left the next bit on the defaults.  I did have to change the SNMP Community string.  I couldn't remember what it was setup to on the switch so I had to go look through my documentation, but after I found it entered that in there.  If you're not sure just stick with "public", a lot of equipment comes with that by default so it may work for you.  Once you've got that in there, just click Create and then you'll be done with that page.

Your page now should have "Save Successful" at the top.  Below that it shows my SNMP info from my switch.  Over on the right there's a link for "Create Graphs for this Host."  Go ahead and click on that.  There should be a new page up that lists all of the interfaces on available on your switch.  If you don't see that, go back to the last screen and check that your Host Template is set correctly (mine is Generic SNMP-enabled Host).  Now for my switches I see all of my interfaces that are configured on the switches, the ports, and the stacking ports too.  If you've configured descriptions on your ports those will show up too.  For my interests I wanted to see how much traffic was coming and going on the WAN. So I picked the interface  (by checking the box at the right-hand side of the column) that I have setup as the "outside" of my site. Then down at the bottom I picked the graph type out of the drop down box.  For right now I picked "In/Out Bits with Total Bandwidth".  At some point in the future I may change that to one of the bytes graphs but for now I just went with the bits graph.  Now just click on Create and you'll have created your first graph in Cacti.

Wait, you just clicked Create and it doesn't look like it did anything right?  Check up at the very top, you should see a line that says "Create graph: blah blah blah"  I guess you want to see your graph now, right?  Well, I don't want to disappoint you, so I'll tell you how to get there.  Click on Devices on the left, then click on the Device that you added earlier, and then click on Graph List (toward the top right).  Then just click on the graph that you just created.  VoilĂ !  It's blank, right?  Well that's because we just set it up and there's no data yet.  By default it polls every 5 minute, so it's going to take a while to get some data.  Go do something else for a little and then come back.  Really, watching it doesn't make it go any faster.  Trust me.  I've tried.

While you wait, you can go ahead and add the graph to the "Tree".  This way you can just use the "graphs" link at the top to see your.... empty... graphs.  Don't worry, the data will start coming in eventually.  But let's pass this time productively and add it to the Tree already.  Go back to your Graph List.  You can do that the same way I listed earlier, or here's a different way.  Just click on Graph Management on the right, pick your host out of the drop down and you graphs should be listed there.  Now we want to pick one (check the box on the right side), then select the "Place on Tree (Default: Tree)" action out of the bottom drop down list, and then click on Go.  It asks for a Destination Branch, but right now we've only got one, the [root], so we're going to use it and click on Continue.

Now if you click on graphs at the top it'll take you to the graphs view (obviously, right?).  It defaults to the Tree view, but I don't have a lot in there so I click on the icon at the top on the far right.  I know it's a graph, but it looks like mountains to me.  Since there are not many graphs setup yet, I like this view better.  Later on I'll probably prefer one of the other ones, but for now I'll just stick with this one.

Still waiting for the data to show up?  Let's get rid of the localhost device and graph that came with the installation.  I don't really have any interesting in watching the machine that's watching everything else, so I just deleted that device.  To do that go back to the console and then click on Devices.  Check the box by your localhost and then select the Delete action at the bottom and click Go.  Click to confirm that you want to get rid of it and then it'll be gone.

By now you might have a single column on your chart.  It's not much to look at right?  Well, tomorrow it will be more impressive.  In the mean time you'll have to find something else to do.  How about reading some of my other blog posts?  That sounds like fun, right?



My Aventures in Installing Cacti (Part 1)

I wanted to do some logging of network interface usage on some of our switches so I thought I'd setup Cacti and give it a try.  Why Cacti, well I had used it before (years ago) and thought I'd use it again.

Where did I start?  I thought a linux box my be the easiest way to get it going.  I also thought if I ran into problems help would be easier to find for a linux box than a Windows box also.  So I went to Ubuntu's website and grabbed the latest LTS Server iso (which happens to be 12.04 Precise Pangolin).  Then I picked up a flash drive and used unetbootin to load the iso on the drive.  Waited for it to finish, then pulled the drive out and attempted to boot the system from the flash drive.

I noticed the boot loader mentioned loading some BSD files which I thought was rather odd, but I went on working on something else and waited for it to finish booting up.  I checked the boot screen and it wasn't a Ubuntu install, it was an install screen for an appliance that I had recently updated using that same flash drive.  Apparently UNetbootin didn't overwrite the other installer correctly.  The plan was to just format the drive and try again.  It seems nothing goes as easily as it should.  Windows only recognizes the 4gb flash drive as a 28mb drive.  Great, the appliance installer must have partitioned the drive and Windows can't read it correctly.  So I downloaded BOOTICE from http://bbs.ipauly.com/ to clear off the partitions and reformat the drive.

After doing that I, I then re-ran UNetbootin and loaded the iso back on the drive.  Did I mention that nothing seems to go as easy as it should?  I picked USB Boot out of the boot menu on the computer and bam, an immediate "Boot Failed" message.  Great...what's wrong now?  The drive had been a little slow to write to, maybe it had finally died.  Being in the computer business it seems there's always another flash drive lying around so I looked until I found a 1gb drive.  That doesn't sound like much but it's plenty for a Ubuntu installation.

Third time's the charm, right?  Run through UNetbootin to copy the iso to the flash drive, then boot the computer, and finally... a Ubuntu install screen.

This is all pretty basic stuff on the Ubuntu install.  I went through and did pick to use the entire drive and install LVM.  When it asked about what applications to installed I picked the LAMP option (that's Linux Apache MySQL PHP in case you wondered).  There are more guides for installing Ubuntu than you can shake a stick at so I wont cover that here.

After a couple of false starts there I finally got Ubuntu installed on the machine.  To get Cacti installed is pretty easy.  I did a sudo apt-get install cacti and it installed cacti and all the dependencies and loaded right into the cacti setup.

Setting up cacti is pretty straight forward.  Here's a link install-and-configure-cacti-monitoring-tool-in-ubuntu-9-10-karmic-server.html to a guide that's complete with screenshots.  This one's pretty close to what I saw.  The only difference I found is that the RRDTools version that comes with Ubuntu 12.04 is 1.4 instead of version 1.3 as indicated in the guide.  Also, I haven't gotten around to chance the Spine setup as indicated towards the end of the guide and so far mine is working fine.

At this point you should have your Ubuntu server up and running with Cacti installed and also running.

Since it seems this post is getting a little long, I think I'll break it into two posts.  Check back in for the second part.

Here's the link for that second part.
 http://practicalschooltech.blogspot.com/2013/10/my-aventures-in-installing-cacti-part-2.html