Jan 272011
 

Recently, I needed the ability to get a readout of the average bandwidth used on the server at one time. As many of you probably know, bandwidth is tough to measure for an instant. I could not find a tool or command that would allow me to get the data I wanted. So I decided to write one.

I write a perl script that uses the output from one invocation of ifconfig with a later invocation. The results are compared, and the total transferred, along with the average bps is extracted and printed.

Here is an example of printout:


thomas@thomas-desktop:~$ perl bandwidth-checker.pl -p -i=eth0 -t=5
Monitored traffic on interface eth0 for 5 seconds:
Incoming: 17.7109375 kbit (2.2138671875 KB) Average: 3.5421875 kbps (0.4427734375 KBps)
Outgoing: 2.109375 kbit (0.263671875 KB) Average: 0.421875 kbps (0.052734375 KBps)

I wrote a little page on the script, and have the source there as well. Hopefully it will help someone else out there: http://wiki.cornempire.net/scripts/bandwidth

If you have any use for it, on find any problems with the script, please comment below.

Dec 232010
 

Hello everyone,
I’ve been saying that I was going to post this for a long time, ever since my presentation at Fusion 2010: http://www.desire2learn.com/fusion/ and now I finally have.

I have written up two pages on code I developed for use with PHP and D2L’s web services. I have been using it at my work for the last year or so, and I finally polished it up a little, and created some installation and usage instructions. I’m not finished yet, but it is a start.

If you use D2L and want to extend it through Web Services (you need to purchase the web services package from D2L, and have it installed first), I encourage you to read over these pages:

If you have any comments, please post them below. Feel free to email me with any questions or problems you run into while working with the API or the testing framework. I’m eager to improve the code for everyone.

Oct 312010
 

Hello Folks,
Long time and no posting. I’ve been quite busy. So here are some updates:

Updates

MCPM

I’m currently completing a Masters Certificate in Project Management. It is a four month course that prepares you to be a professional project manager. It has been an interesting experience. The skills I’ve learned so far have already been put to good use both at work, and with my business on the side.

Project Work

My company has been awarded a contract to develop a Document Management System, as well as install servers and software to support this system. Work will be starting next week, and I will have very little free time to work on anything else during this. šŸ™ But, it will be a great experience and our first big project!

Server Hosting

In the last month or so, the company I had a VPS with http://www.webserve.ca (BBB Rating: C – 121 Complaints) was constantly attacked and hacked by outsiders. No matter what lengths I go to, somehow, someone was on the server sending mail and doing bad things. It seems that the company does very little intrusion detection, and the way in which the server was compromised, I suspect that the virtual hosts were actually the source. After 12 hour downtime with no answer from their 24/7 support, I decided to return to my former web host (http://www.canadianwebhosting.com BBB Rating: A+ – 0 complaints). Although more expensive, their support has been fantastic, and quality/value of service is good.

Software Plans

That last piece is a great segue into my software plan section. During my migration, I had to move my database (obviously). That experience has pushed me to develop a script that dumps commands to recreate all of your users and all of your grants in the event that you have to migrate your mysql database. By running this script, you will get all of the code you need to recreate all of your users and grants. Coupled with a mysql dump, you should be able to quickly copy an entire database! Hopefully I will find some time in the next few months to write the code.

I’m also planning to write a simple script that will aggregate our logwatch reports from our 15 servers into a single daily report. Instead of the default function, which is to email, the logwatch report will be scp’ed to a central server, and then a script will go over all of the reports, and put something together for all of the servers. I’ll make this available once it is written.

Gaming

I’ve been playing a bit of Civilization 5 lately. It is an ok game, but I find it is still very rough around the edges. Lots of bugs, incomplete features, and terrible AI. Although I really do enjoy the new combat engine.

I’ve also been playing a bit of Urban Terror. A free realistic FPS available for Linux.

Software

I’ve also run across a few nice software packages that I’d like to recommend:
Adminer: A great PHP script that you can upload to your site, and gain phpmyadmin type access to your databases. Supports a number of database types. Allows you to execute queries, create databases, backup databases and just browse your tables. It is a single file, so there is no installation, and I intend to use it for some light DB admin work.

Firewall Builder: I was looking for a program to help me manage iptables on linux. I’ve run firestarter in the past, but that is a gui app, and I wanted to configure the firewall for a server with no gui. I ran across Firewall Builder and gave it a try. It is dually licensed as commercial for Windows and Mac users and free for Linux users. Being a Linux user, I jumped at it to give it a try.

The interface is a bit daunting for the first time user, I strongly recommend you watch the intro video (and hopefully you already know what a firewall does. ;)) This program lets you use drag and drop to configure rules for your firewall. It creates the rules in a custom format, and then compiles them into a number of different formats for various firewall programs and devices. It even goes a step further and lets you remotely install the firewall on the remote servers. A very nice touch.

I’ve only tried iptables configuration so far, but it ran very well. I intend to use it for all of our servers, and put the configuration files under revision management. So I can manage all versions of our firewall configs from a single box.

That’s all for now.

Jul 312010
 

I’ve ported my popular (that means more than one person is using it. ;)) hacks from version 2.1 of Hesk to the new 2.2. You can read the whole tutorial on my wiki: http://wiki.cornempire.net/hesk/hesk22/

For those upgrading, you will need to reapply the hack to the new files. The differences were pretty minor between 2.1 and 2.2. I’ll outline the differences here:

  • The line numbers are different for the files
  • The function print_add_ticket_start that you need to add needs a few additional lines to bring in the global stylesheets. This was not required in 2.1
  • I also made a small tweak to this function so that there is no category selected by default, allowing you to select the default category via the dropdown box. Previously, this would have been unselectable.

I’m working on a screencast of applying this hack for those who are more visual learners. So stay tuned for that.

To take a look back at my previous post, and learn more about Hesk, click here.

Jul 292010
 

I recently decided to get back into desktop applications. Since about 2000 I’ve focused on developing for the web using Perl and PHP (mostly PHP). But sometimes it is nice to write a desktop app, instead of having to write a web app for everything. I’ve written some applications using the PHP CLI option, but that isn’t quite the same as a gui. My motivation was to write a GUI that controlled ffmpeg and would allow me to capture screen casts for tutorials I needed to make.

I started my adventure looking at a GUI frontend for PHP. And ran across PHP-GTK+. I installed it, and looked at some tutorials on it, but the more I looked, the more it looked like the community was inactive and stale. I also couldn’t find any way to package my application to share with others. They would need to install PHP, compile GTK+ (which wasn’t all that easy), reconfigure PHP and then run my application. Although most of the programs would be for my eyes only, it would be nice to have the option to share from time to time. So that was the end of the road for my PHP adventure.

I then decided to look at other languages for developing the application. I considered some of the options out there, Java, C, Ruby, Python, but decided to give Python a try. I’ve coded Java before, and I wasn’t a fan. Always seemed like overkill for everything I wanted to do. I’ve heard lots of good stuff about Python, and it is usually installed with most Linux installations, so this was my language of choice.

I then began looking for a good IDE for Python. Being a big fan of Eclipse, I ran across pydev for Ecplise. A simple install into the software manager in Eclipse, and I was off to the races. You will need to configure the location to your python binary, which for me (Ubuntu 9.10) was in /usr/bin/python2.6 Enabling this, gives you all the fancy code completion which I love so much. If you need to set it up, you need to visit (In Eclipse) Window -> Preferences -> Pydev -> Interpreter – Python -> New… and browse to your python binary. (If you do not have python available, you may need to install it first using apt-get or Synaptic Package Manager. Just search for python, and it should install everything you need to get started.) Here are some tutorials for getting started with Python:

I’ve used Glade once before, very briefly just to figure out what it was. It is a GUI drawer. Similar to the GUI drawer in Visual Basic, it allows you to layout your interface without using code. It creates XML files which can be imported by your application (and it has bindings for many languages) that create your interface. You just need to connect your code to the signals in the GUI, and you can make magic happen. You will need to install Glade via Synaptic Package Manager. The current version is the 3.6 series. Here are some great tutorials to get you started with Glade:

So, my first dabble in GUI desktop programming in a decade, and my first taste of python. About 5 hours later I had written the application I wanted. It is an 84 line python script binding to one glade file for the interface. It allows me to select a window, and using a pre-set configuration, launch ffmpeg and record a screencast. Still a lot of work to do before it is ready to be shared, but it is a great start. Using pydev via Eclipse for the Python coding, and Glade for the interface design, you should be able to turn out some simple desktop apps in a matter of hours.

This is probably just the beginning of my python coding, so you may see more here on that in the future.

Jun 292010
 

Announcement

At long last, The Director! is complete. This is the URL redirection php/apache script that I mentioned early last month. Had a few minor things to fix up, which I finally did last night, and now it is available to all.

It is a very rough looking piece of software, true to my views that admins shouldn’t care what the software looks like, provided it works correctly, and it looks pretty to the public. Since I suck at UI, AND The Director! has no public face, this is the perfect project for me!

So what does The Director! do?

The Director! is a URL shortening/redirection service similar to tinyurl and others that allow you to point one web address to another (presumably a short one to a longer one). Currently it does some simple stat tracking (if you want) on the URLs, and allows you to manage your redirects. More information and a download can be found here: http://www.cornempire.net/go/director (this shows The Director! in action as I have it installed on my site now).

Requirements and Cost

The Director! is a free download, available under an undetermined licence at this time. You are free to use it, just don’t take the code and sell it. If you make any modifications, feel free to share them back to us (submit an issue to the bug tracker and attach your code). We provide no support or guarantees/warranty for the code, if you choose to use it, you are on your own. Later, I’ll enumerate that into some sort of formal licence.

In order to make use of The Director! you will need:

  • A webserver
  • PHP running on the webserver
  • A domain name of some sort
  • A rewrite module for fancy redirects (instructions provided for apache and mod_rewrite)

You will need access to edit your webserver config, or .htaccess file if you are on shared hosting.

If you run into any issues, make a note below and I’ll do my best to help. But again, no formal guarantees or warranty come with the application.

Screenshots

Certainly nothing to be proud of…but here are some screenshots of The Director! in all of it’s ugly orange glory:

Credits

Other then me, many thanks to Pat for his help in writing The Director!. As well as credit to Mark James for the Silk Icons which I don’t think I’ve actually put to use yet, but when I redesign the GUI, I will.

May 072010
 

Just a quick announcement that I’m working on a new programming project called The Director!. It is essentially a url redirection/shortening service written in PHP and utilizing the apache rewrite module to do the really cool stuff.

Those in the know realize that creating such a service is just a few lines of code in the vhost entry for apache, and then a few lines of code in a php script to do the redirection, but the goal here is to make it easy to use management interface with a bit of simple stat tracking.

Hoping to have version 0.1 out this weekend (depending on how my fence construction goes this weekend).

You can view more information here: http://wiki.cornempire.net/thedirector/start

Apr 152010
 

So, you have a nice new database table, and you forgot (or couldn’t) add comments to the columns when you created it. I recently ran into this problem, and my usual internet searches didn’t turn up much.Ā  One would expect a statement similar to this:
ALTER COLUMN `columnname` ADD COMMENT 'a comment'
However, that statement doesn’t exist.

If you have gotten to my post, you probably realize that there is no easy way to add comments (unless you have a nice application that does it for you). The real statement is something along the lines of this:
ALTER TABLE `courses` CHANGE `courseid` `courseid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'a new comment'

Which means you need to know the table definition, and restate it every time you want to change the comment. If you are doing this in bulk, that is a pain in the butt.

So, I wrote this little script that will take a create table definition, and turn it into Alter Table commands, that will add comments to each of your columns.

All you need to do is run ‘SHOW CREATE TABLE `tablename`’ on your database table, and insert that definition into my script here, and it will spit out a series of Alter Table calls with a space for a comment appended to the end.

The script is very basic at this point, and expects the formatting as shown in the example. The GUI I use, DbVisualizer, as well as the mysql command line client spit this out. So hopefully yours will to.

If you find this useful, or run into any problems with the script, please let me know.

Edit (April 15, 2010): Uploaded v0.2. Small mistake that was placing the column name in place of the table name. Sorry to anyone that was used it before and noticed it.
Edit (November 17, 2013): You can download the php script here for running on your own server.

Dec 062009
 
Edit: I’ve made a new post regarding Hesk and these enhancements for the new version 2.2. You can read it here: http://cornempire.net/2010/07/31/hesk-enhancements-for-version-2-2/

I came across the free, open source Hesk Helpdesk (http://www.hesk.com) while I was looking for a light weight help system for a project that was starting up. The project has since been put on hold, but Hesk is still a great application for a helpdesk/knowledge base. Hesk is offered as a free downloadable PHP script, as well as a Hosted Version if you do not have a server. The hosted version will cost you $20 US a month. You can also by a license for the downloadable version for $39.95 US to remove the Hesk branding.

While this application is great…

  1. Allows unlimited staff
  2. Granular permissions to the system and help desk categories
  3. Excellent knowledge base built in
  4. Innovative system that doesn’t require user accounts for clients

It is lacking a few features. I plan to use this application to respond to clients from a number of different projects. As such, it would be nice if they didn’t see ALL of the problem types when submitting tickets. Because Hesk is open source, we can make a few tweaks to get directly to a specific problem type.

Hesk also allows custom fields for your tickets, but it shows all custom fields on all problem types. This can get confusing for users in a multi-project environment. I’m developing a little hack to get around this limitation.

I’ve outlined both of these changes required on my wiki, you can take a look here.