BaerConsulting LLC Blog

Tag: SSH

Network Media Player/Server How To

by BaerConsultLLC on Jan.13, 2010, under How To's, Server Configuration

Ok, so let’s start with the requirements.

First, you’ll need a physical machine or anything running Windows, Mac, or Ubuntu. It can even be a virtual machine! For all intensive purposes, we’ll go with Ubuntu since it’s free and downloadable. Second, you’ll need a Network Interface Card (NIC) for that machine. I recommend going with Intel Gigabit Pro GT/1000 cards. They’re a bit more expensive, but it’s all we use here at BaerConsulting and we’ve yet to have one fail on us. Even if you don’t run a gigabit network, I still recommend Intel Gigabit cards. Third, you’ll need something to play these media files on. At home, I have a D-Link DSM-520, a Buffalo Media Player, an XBox 360, and a Playstation 3. Out of these media players, a Playstation 3 seems to produce the best quality and is most compatible with codec types. Codecs are something that transcodes, recodes, or encodes a media file using it’s respective format, be it MP3, MP4, WMV, AVI, etc. Lastly, you’ll need some sort of network set up with the network media player and the server on that network. This will not work over the internet.

If you haven’t already started downloading Ubuntu, head on over to Ubuntu’s Home Page to download a copy. There are a variety of types and variety of ways to download Ubuntu. If you have a machine that’s a Core 2 Duo, Quad Core, Pentium Dual Core, or anything else that’s been made in the last 3-4 years, it’s probably a 64-bit processor, thus you’ll probably want to go with 64-bit Ubuntu Desktop. There are a lot of debates going on about the true advantage of 64-bit over 32-bit, but that’s a blog for a different day. If you have an older machine, such as a Pentium 4 or an Athlon XP, you’ll want to get the 32-bit version. Why Desktop you ask? Well it’s simple. First, I assume that you’re probably not proficient in Linux, and while some might argue that the best way to learn it is to jump in to server (no GUI, just command prompt), I figure I’ll be kind and give you something familiar. Next you get to search for ways to download this file. HTTP is the norm, but if you’re in to Torrenting and have a client, I suggest using that. It’s less strenuous on the Ubuntu servers and mirrors, plus, you’ll probably get the file faster.

Now you need a program to burn the ISO file. My personal favourite is MagicISO, but Roxio or Nero work just the same. Burn that file to a CD. If you got desktop, you’ll notice it’s a Live CD. This means that you can literally run the operating system off of the disc without it ever erasing files or touching the hard drive at all. It is the strong recommendation of BaerConsulting that you use a spare hard drive or one that contains no data that is valuable. If you don’t know what you’re doing, it’s probably best you don’t do it. Now, with that out of the way, and you being sure that you have a hard drive that you don’t mind wiping, let’s install Ubuntu.

Pop in the CD to your computer and boot it up. Select ‘Try Ubuntu without ant change to your computer’. Once it is booted up, you should be greeted with some peculiar sounds and a Desktop. Double click on ‘Install Ubuntu 9.10′. Select the appropriate language and click Forward. Select your appropriate Time Zone and click Forward. Select the appropriate keyboard layout and click Forward. On this screen you’ll see something similar to that of setting up Windows. This is where you partition your drive. For most users, using the default layout and simply clicking Forward will work best. WARNING: ONCE YOU CLICK FORWARD, ALL DATA ON YOUR DRIVE WILL BE LOST.. Pick you username, username again, type in your password, confirm it, and choose the name of this computer (otherwise known as hostname). Anything that autofills is probably safe. Once you’re sure about your settings, click Forward, then click Install. This can take up to 60 minutes depending on your system, so be patient. When it’s completely installed, go ahead and Restart Now. Take the disc out and close the tray, hit Enter as instructed by the splash screen.

When it boots back up, go ahead and log in based on the credentials you entered during the installation. Click on Applications>Accessories>Terminal. Type “sudo apt-get update”, hit enter, enter your password, hit enter. From here on, please assume that “hit enter” comes after every command. Once that’s completed, type “sudo apt-get upgrade”. When it prompts you, select yes. While it’s downloading updates, go back to Applications>Accessories and right click on Terminal. Click Add To Panel… This will put a shortcut icon on the top bar of your screen. This will give you quicker access to the terminal. It is the definitive administration tool under Linux. While the command is downloading and installing updates, go to System>Preferences>Remote Desktop. Click the “Allow other users to view your desktop” checkbox. Select the checkbox that says “Require the user to enter this password:” and enter a password. This will allow VNC remote access to this machine. This is where the hostname comes in handy, which you should see in the form of “username”@”hostname” in the terminal window at the beginning of the command prompt. Download Real, Tight, or Ultra VNC Viewer. That is quite simple, open it, enter the hostname, and click connect. If you’ve done everything right, you should be prompted for a password. Enter the password and you should now be seeing the Desktop of the Ubuntu machine. You can now put this machine in a remote location, provided the VNC connection worked, and remove the monitor, keyboard, mouse, etc. Just a network cable, a power cable, and of course, the machine itself.

After the update of Ubuntu, you should reboot and run those two commands again, just in case. We’re not dealing with Windows, so you’ll usually get all updates in one shot. Open up the terminal again. Enter “sudo apt-get install ssh”. This will install and SSH server so you can use an application like PUTTY for Windows to use the command line. If you’re proficient in command line, this will be very familiar to you.

Let’s open up terminal again, if it’s not already open. Type “sudo apt-get install mencoder ffmpeg mplayer vlc sun-java6-jre”. Note the spaces in between each application or package, as they’re referred to in Linux. Accept the license terms.

Go to PS3MediaServer.blogspot.com and download the newest Playstation Media Server. Choose to save to the Desktop. Right click and choose to extract here. There should be a new folder on the Desktop. Open up the terminal again and type “cd /home/[username]/Desktop/pm[tab]“. The tab key should autocomplete the folder as necessary. You should now be in the same folder as the files you just downloaded. Type “chmod +x PM[tab]“. Unlike Windows command line, Linux’s command line is case sensitive, so PM is not interpreted the same as pm. Then type “chmod +x linux/ts[tab]“. This makes the necessary files executable, just like a shortcut icon on the desktop of Windows.

With your mouse, go in to the folder that you just extracted to your Desktop. Double click on the PMS.sh file. If prompted, choose run in terminal. This should open up a new window. This is the main configuration console of the Playstation Media Server. This is where you can select the folders to be shared across the network. To add files to this server, you’ll need to set up Samba, which is a blog for another day. By default, the server shares all files and folders, which can be risky, but if you’re network is secure, it should be fine. Now that you have SSH set up, you could use Samba, or you could use WinSCP. For now, Google and download WinSCP. You’ll log in with the same username, password, and hostname that you entered during your initial setup of Ubuntu. Once logged in, you can see the layout of your local machine and the remote machine. Seeing as how Linux/Ubuntu is very secure operating system based mostly on permissions, you’ll want to put the files under /home/[username] on the Ubuntu machine. That will make them available to your media player. Also a note about permission; you’ll notice I used “sudo” quite a bit in the commands above. This stands for “superuserdo”. The superuser is the ultimate in permissions. It allows you to modify the system wherever you need to. Do NOT provide your password or any credentials to that machine to anyone you do not trust.

Why Playstation Media Server you ask? Because it plays mostly anything you like. As you can already guess, it is mostly compatible with the Playstation 3, but I have yet to meet anything that it will play on the Playstation 3 that you cannot play on the XBox 360 for example.

You now have a fully functional media server that can be detected by media players. You can also use this media server as anything else Ubuntu based that you like, such as a network grapher, network monitor, or a NAS. Again, you’ll probably want some extra storage on this machine. We’ll eventually post some instructions on setting up a NAS at a later time, but this should get you streaming your media files in the meantime.

Leave a Comment :, , , , , , , , , , more...

Nagios

by BaerConsultLLC on Aug.25, 2009, under News, Server Configuration

Oooo such a dirty word. In all actuality, Nagios is only intimidating. Once you find the right walkthrough and decide for or against compiling from source, you’re already through most of the battle. We decided that a free Windows based monitoring system that had device and probe limitations just wasn’t going to cut it anymore. Since we have a very beautiful 5TB total available storage NAS with a dual-core processor and 2GB of RAM sitting there just storing data, we figure we might as well use it for some monitoring. We went through Zabbix and determined that it was going to take longer to get it set up than most of the server would even be in production. Not to mention SNMP based monitoring of system resources can be a security risk as well as difficult to troubleshoot. Nagios has a very comprehensive support base out there. It has been customized and modified to do just about anything that is desired, so we opted for Nagios.

As previously stated, the NAS is a Ubuntu 9.04 desktop with the hardware specs above. Luckily, Nagios and most plugin packages are in the repositories, meaning that can be downloaded and install using your favorite package manager, on Ubuntu, by default, it’s apt. From there, it’s quite simple to figure out how to monitor things. We did print outs of all the commands that were available in the /etc/nagios-plugins directory with (while in /etc/nagios-plugins) ‘cat *.cfg > all.txt’. Marked each one that we’d like to use and started making our host .cfg files. Whenever you make a change to the Nagios configuration files (any of them), you have to restart Nagios for the change to take effect. This is where Nagios can get somewhat tedious. We highly recommend doing one host at a time. Do a few hosts one at a time, restarting after each one. When Nagios catches an error, it won’t restart successfully and it will usually tell you why. Go back in to the config file and make the necessary changes. Once you’ve mastered hosts, you should start adding services to the host files. You can do your file structure however you like. We used one .cfg file for the mail server, one for the web server, so on and so forth. This way, if you take that server out of production, you can just remove the file or move it to another file with another extension. Also, if something goes wrong, you’ll know exactly where to start looking.

Also, there is a Nagios ‘agent’ called NRPE that is used to monitor system resources on the local machine and sends them back to Nagios. The nice thing is that NRPE uses one single port and utilizes SSL so it’s pretty secure. Those commands are defined in the nrpe.cfg file. We have ours running under xinetd which means we can modify commands as much as we want without having to restart NRPE, although you will have to restart Nagios when you add your check_nrpe command. It’s basically a beefier version of SNMP. We’ve only had one hiccup where NRPE failed SSL handshakes for about an hour, but we believe it was due to an NTP misconfiguration. Time is very important when dealing with secure connections. Right now, we’re experimenting with adding some extensive Zimbra monitoring utilizing NRPE. We just altered some perl paths to get Nagios monitoring the postfix mail queue on the Zimbra server, letting us know whenever it reaches a certain point. This tells us that it is possible to do some very interesting things with Nagios. We’ll post the most interesting parts.

We have not and will not post anything pertaining to the actual set up of Nagios such as a walkthrough. Honestly, it took about 15-25 hours to get it successfully monitoring 52 different services, but that includes setting up NSClient++ (basically NRPE for Windows), NRPE on the Mail Server (CentOS) and the Web Server (Ubuntu), importing all publicly available and privately available services such as POP, SMTP, IMAP, HTTP, etc., public IP addresses, private IP addresses, and domains. We went through and used at least a dozen walkthroughs. At some point, we may set up an additional box just to do the walkthrough, but don’t hold your breath. Nagios documentation is pretty thorough. Google NRPE documentation in order to find the best document for the job. It’s posted by Nagios but couldn’t be readily found on the site. Nagios mailing lists are great resources when all else fails. Also, don’t forget your notification profiles. IT IS HIGHLY ADVISED THAT YOU USE THE ‘NEVER’ NOTIFICATION PROFILE OR CREATE ONE IF YOUR SPECIFIC INSTALL DOESN’T HAVE ONE ON EACH AND EVERY HOST/SERVICE UNTIL IT IS UP, RUNNING, AND STABLE. I’D SAY ONCE EVERYTHING IS GREEN, LET IT RUN FOR A WEEK, THEN YOU’LL KNOW YOU CAN TURN ON NOTIFICATIONS. OTHERWISE, YOUR INBOX WILL FILL QUICKLY WHILE YOU WORK OUT THE BUGS.

Leave a Comment :, , , , , , , , , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...