Category Archives: Other

Hardware Monitoring: Syncing Drupal with Zenoss

Overview

One of the more daunting tasks of managing a larger network is keeping track of all your devices – both physically, and from a network monitoring perspective.  When I arrived on the job 3 years ago, the first major task I laid down for myself was implementing both an asset management system, as well as a network monitoring system, to ensure we always knew what we had, and if it was functioning properly.

I decided almost immediately that Drupal was the right candidate for the job of asset management.  There are a number of commercial IT/helpdesk systems out there which work great, but they are usually fairly expensive with recurring licensing costs, and my history with them has always been shaky.  Plus, I find myself not always using all the functionality I paid for.  I knew with my Drupal experience, I could get something comparable up in almost no time – this is not a discredit to IT packages, but moreso the power of the Drupal framework.

Network Monitoring – Cue Zenoss

Now that I had the hardware DB taken care of, I needed a NMS for monitoring.  Originally I was planning on Nagios, but a contractor who works for us (now friend) had introduced me to Zenoss, another open source alternative.  Zenoss is awesome – is absolutely has its quirks, and is not the most intuitive system to learn, but once things are up and running it’s great – and tremendously powerful.  So the choice was made.

Now – I had both pieces, but I absolutely hate entering data twice, and the interoperability guy in me loves integrating systems.  So I decided to write a script that would sync our Drupal database with Zenoss.  Drupal would serve as our master system, and any hardware we entered into it would automatically port over to Zenoss.  Any changes or deletions we made (IP address, location, name, etc) would sync over as well.

The below script performs this synchronization.  Some warnings up front – I’m not a Python guy by any means, I specifically learned it for this script, so I apologize for any slopping coding or obvious Python-y mistakes.  I’ve tried to thoroughly comment it to document how to use it and how it works.  Hopefully it can help some others out as well!

# Description: Sync devices to be monitored from Drupal to Zenoss
#
# Setup Work: Create a (or use an existing) content type that houses your hardware items to be monitored.
# They should have CCK fields for the IP address of the device, the name, and the type of
# device it is. The device type will determine the Zenoss class the script adds it to, and hence
# the kind of monitoring it will receive (e.g. Linux server, switch, ping only, etc)
#
# Additionally, in Zenoss, create a custom property field that will house the nid of the Drupal
# node. This serves as the foreign key and will be used to link the item in Drupal to its entry in Zenoss
#
# Usage: This script should be run from zendmd, and may be run once or periodically. We run it every 20 minutes from
# a cron job.
# It will create new entries in Zenoss for items not yet imported, delete ones that no longer exist in
# Drupal (it will only delete ones that were originally imported from Drupal), and will update ones that have
# been updated (type, IP, location, etc).
#
# Note: Excuse all the extra commits - we experienced some issues with data not being saved, and I threw some extra in
# there - they're almost definitely not necessaryimport MySQLdb

# Take a taxonomy term from Drupal identifying the type of monitoring to be done,
# and convert it to the appropriate Zenoss class path. Update these to whatever terms
# and Zenoss class paths that make sense for your environment. We setup ones for
# Linux and Windows servers, switches, waps, UPSes, PDUes, etc, as can be seen.
def getClassPath(passType):

if passType.lower() == "windows":
return "/Server/Windows"
elif passType.lower() == "linux":
return "/Server/Linux"
elif passType.lower() == "switch":
return "/Network/Switch"
elif passType.lower() == "mwap":
return "/Network/WAP/Managed"
elif passType.lower() == "uwap":
return "/Network/WAP/Unmanaged"
elif passType.lower() == "ups":
return "/Power/UPS"
elif passType.lower() == "pdu":
return "/Power/PDU"
elif passType.lower() == "camera":
return "/Camera"
elif passType.lower() == "cphone":
return "/Network/Telephone/Crash"
elif passType.lower() == "sphone":
return "/Network/Telephone/Standard"
elif passType.lower() == "printer":
return "/Printer"
elif passType.lower() == "converter":
return "/Network/Converter"
elif passType.lower() == "ping":
return "/Ping"
return "/Ping"

# Connect to Drupal's MySQL DB (Replace these values with the appropriate ones for your system)
imsConn = MySQLdb.connect(DRUPAL_MYSQL_SERVER, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB)
imsCursor = imsConn.cursor()

# Execute the query to grab all your items to be monitored. In our case, we have a node type called "hardware" that had CCK fields identifying the IP address,
# the type of hardware (a taxonomy term that dictated the Zenoss class of the item - see getClassPath above), a physical location, etc.
# You'll want to change the specific table/field names, but the inner join will probably stay, as you'll want to grab both the node and CCK fields that belong to it.
imsCursor.execute("""
SELECT node.nid, content_type_hardware.field_hardware_dns_value, content_type_hardware.field_hardware_location_value, content_type_hardware.field_hardware_ip_value, content_type_hardware.field_hardware_monitor_type_value, content_type_hardware.field_hardware_switchname_value, content_type_hardware.field_hardware_switchport_value
FROM node
INNER JOIN content_type_hardware ON node.nid = content_type_hardware.nid
""")

# Loop through all returned records - Check for additions, changes, and removals
while (1):
#tempRow is our current hardware item record
tempRow = imsCursor.fetchone()
if tempRow == None:
# No more entries, break out of loop
break
else:
# Search Zenoss records for the nid of the hardware item. A custom field will need to be created in Zenoss to serve
# as this foreign key. In our case, we used MHTIMSID - but you can use anything you'd like - just be sure to create the field in Zenoss.
found = False
for d in dmd.Devices.getSubDevices():
if d.cMHTIMSID != "":
if int(d.cMHTIMSID) == tempRow[0]:
found = True
break

if found == False:
# Hardware item not found, add it if it's monitored
if tempRow[4] != None:
dmd.DeviceLoader.loadDevice(("%s.yourdomain.com" % tempRow[1]).lower(), getClassPath(tempRow[4]),
"", "", # tag="", serialNumber="",
"", "", "", # zSnmpCommunity="", zSnmpPort=161, zSnmpVer=None,
"", 1000, "%s (%s - %s)" % (tempRow[2], tempRow[5], tempRow[6]), # rackSlot=0, productionState=1000, comments="",
"", "", # hwManufacturer="", hwProductName="" (neither or both),
"", "", # osManufacturer="", osProductName="" (neither or both).
"", "", "", #locationPath="",groupPaths=[],systemPaths=[],
"localhost", # performanceMonitor="localhost',
"none")
tempDevice = find(("%s.yourdomain.com" % tempRow[1]).lower())
tempDevice.setManageIp(tempRow[3])
commit()
# Save nid to Zenoss record (to serve as foreign key) for syncing
tempDevice._setProperty("cMHTIMSID","MHTIMS ID","string")
tempDevice.cMHTIMSID = tempRow[0];
commit()
else:
# Hardware item found - delete, update, or do nothing
if tempRow[4] == None:
# Delete if not set to monitor
dmd.Devices.removeDevices(d.id)
else:
# Update DNS and IP to current values
if d.getDeviceName() != ("%s.yourdomain.com" % tempRow[1]).lower():
d.renameDevice(("%s.yourdomain.com" % tempRow[1]).lower())
if d.getManageIp() != tempRow[3]:
d.setManageIp(tempRow[3])
commit()

# Change class if not set to "Manual" (We setup a taxonomy term called "Manual" that would turn off automatic Zenoss class selection during syncing
# and allow us to manually specificy the class of the device.
if tempRow[4] != "Manual":
d.changeDeviceClass(getClassPath(tempRow[4]))
commit()

# Update comments (location change)
d.comments = "%s (%s - %s)" % (tempRow[2], tempRow[5], tempRow[6])
commit()

# Save any missed changes
commit()

# Close connection to database
imsCursor.close()
imsConn.close()

Site Makeover

After finishing up phase 1 of SynthNet, I came to the conclusion that I really missed updating the blog.  When I get involved in a project, I tend to get wrapped up in it (more accurately – completely and ridiculously obsessed where it takes over my life) and other things drop off the radar.  However, I’ve decided I want to make a real effort to not get AS wrapped up in projects, and remember to give the blog some love.

New and Improved!

As I went to write my first article after recording the SynthNet video, I also noticed the blog was looking a little tired.  They’d also made a number of improvements in WordPress since when I first installed everything, so I decided to take the leap, get a shiny new template, and put some new life into it.  I think it’s definitely an improvement – hope you enjoy it!

 

Spotlight: Leah Creates

One of the best things about being involved in the world of technology, besides getting a front row seat to all the amazing advancements made every day, is meeting and talking with the creative people who make the magic happen. I think I’m especially lucky, having strong ties to a range of different areas such as networking and development, to have met a diverse mix of very talented people.

Web Developer Extraordinaire

To say business exists in a social media world where online presence and reputation is important would be the understatement of the century. Companies today live and die by their ability to harness the power of the web. And while there are many developers out there, a true burden lies in finding talented and experienced ones. Not only does Leah fall into this camp, combining expert design skill with seasoned web development knowledge, but she possesses something that many in the industry don’t – a real love and respect for what her customers are trying to accomplish with their website. This truly shines through both in her work, and how she treats her clients. It translates into a special website that speaks its goals and connects to its visitors like no other site could. It is the difference between a good looking site and a truly powerful site.

The Proof is in the Pudding

I’ve known Leah for a number of years, having had the privilege of working with her on a number of projects professionally – and her sites continue to really impress me. Some excellent examples of recent projects: Be Irreplaceable | Donna Heart.

I love these examples, as they show how she has taken a general framework like WordPress, and turned it into a beautiful site that really communicates the site’s message. They feel personable and comfortable when you visit them, unlike a lot of cold and bland sites out there. They have that truly personal touch which is key to connecting with the audience.

For even more examples of her work, check out her online portfolio.

So if you’re looking to build a new website for your business, or need to re-imagine the one you already have, I really suggest keeping Leah Creates in mind. She is amazing at both what she does, and how she does it – something setting her apart from so many other development houses out there.

LeahCreates

Congratulations and Website Updates!

First off, big congratulations to @merman1974, the winner of the Synthetic Dreams Spooktacular Giveaway Contest! We got lots of turnout and made a number of cool, new retro-friends on Twitter.

Next, speaking of Twitter, some website news. I’ve cleaned some clutter off the front page a bit, and added a Twitter feed as well. I’m pretty active with my tweets these days, so I figured it would be nice to carry that over onto the website.

Thanks again everyone!

Win a Free PSX64 Interface and Help a Great Cause!

If you’ve been following along on the blog, you’ll know that I recently got a Twitter account. Yeah – I was definitely one of the hold outs. But – I wanted a place to post little tidbits that weren’t really blog worthy, but were interesting none-the-less, and Twitter is the perfect place for that. Plus, I’ve already met some pretty groovy people through it – and it’s a great place to get news out fast. However, Twitter is definitely a more-the-merrier kind of thing, so along that vein, presenting:

The Synthetic Dreams Spooktacular Giveaway!

First, the prize: we’ll be giving away a free PSX64 Interface, along with a copy of Shredz64 to the lucky winner. Additionally, we’ll be donating $50.00 to one of the charities below – to which is by choice of the winner.

Heart to Heart International – Disaster Response and Medical Aid
Global Links – Medical Aid and Health Education
Vitamin Angels – Nutrients for Infants and Children
Books for Africa – Literature and Education for Africa

Not only do you get to rock out to your favorite SID tunes Guitar Hero style and reinvigorate your old C64, Amiga, and Atari games with a Playstation controller – but you also get to help out those less fortunate who could really use a hand.

The Rules

The rules are simple! Follow me, @ToniWestbrook, on Twitter between now and Halloween (October 31st). Once you’re following me, send me a tweet saying you’d like to participate in the contest – and your name will be entered into the drawing! (And I’ll follow you back!)

You can even double your chances to win – after tweeting the above to me, if you then tweet to all your followers:

“RT: @ToniWestbrook Win a free PSX64 to play Guitar Hero on your Commodore 64 while helping those in need! Details: http://bit.ly/cK1YKF”

You’ll be entered twice!

Keep following along, and at midnight (EST) at October 31st, the winner will be announced.

More on the Charities

There are a lot of future scientists, doctors, and engineers waiting to soar, but they may never get the chance without food, medicine, or education. This blog, and Synthetic Dreams as a whole, is about letting people achieve their dreams – but before you can do that, you need your basic needs met – and sometimes you need a helping hand to meet them.

Each of the charities above has been verified with Charity Navigator.

Good Luck Everyone!

My Newest Robotic Buddy, Vincent (CompuRobot)

It’s not uncommon if you love programming, computers, tinkering, and all things electronic, that you also have a love for robots. I am not unique in this regard! I’m a fan of programmable bots in general (I have a few of the Lego mindstorm robots, including the newer NXT). Recently, my friend Ryan gave me this little guy:

He bears the name “COMPUROBOT”, and as can be seen, shows a striking resemblance to Vincent from Disney’s The Black Hole. For this reason, that’s the name I’ve chosen for him.At first glance, Vincent looks like a simple toy – he has a fun shape, features LEDs for eyes, flashing bulb in his belly, colorful stickers, and a sturdy design. He is driven by two independent wheels below and supported in the front by two smaller wheels. However, there is quite a bit more at play than a simple toy that runs around the room. Examining the top of Vincent reveals a 5×5 Matrix of buttons, each with an icon indicating its function. It turns out Vincent, the Compurobot, is a programmable robot!

Though some of the icons seem to suggest movement, I wasn’t quite sure what all of them meant, or in what the protocol for using them was, so I luckily was able to find the manual online.

Capabilities

Vincent features a 4-bit processor and a small amount of RAM that can hold up to 48 commands. Though its volatile and erases after turning him off, the procedure is very simple for programming. Simply hit the button of the action (forward, backward, turn, play noise, etc), and then the number of seconds you wish him to perform it. E.g. hitting FORWARD, 4, LEFT, 3, BACK, 6 and then START (green) would cause him to go forward for 3 seconds, turn left for 3 seconds, then back for 6 seconds. Sound can be played simultaneously (you turn it on and off with 1 and 3, respectively), so Vincent can make cool noises while charging along. He even features a 3-gear module with a 9400 RPM motor, which can be programmed as well (icon with the circle and 3 connected lines).

Though the CPU appears to be very simple without the ability to perform conditional processing (which also leaves out the possibility of looping), a neat little feature it does have is the ability to multiply time amounts. The X button on the control panel is multiplication – so if you’d like Vincent to go forward 48 seconds, you can hit 6 X 8. Just a nice little added feature!

The Atari Connection

What could be most neat of all about this little guy? He was produced by Axlon – which you may not have heard of. But Axlon was a company created by Nolan Bushnell, founder of Atari. Axlon had produced a few such robots, but they never took off like his earlier company did.

All in all, a very cool present! Thanks Ryan!

Shredz64 at the Portland Retro Gaming Expo

Just a heads up, if you’re around the Portland, OR area this weekend (September 18-19), stop by the Portland Retro Gaming Expo. Not only does it promise to have TONS of retro games, hardware, and general awesomeness to play and buy, but the Commodore Computer Club and Users Group of Vancouver, WA will be at the Expo demonstrating Shredz64 and the PSX64 in action! They’ll also have lots of other Commodore goodness to check out.

The expo is located at:

Portland Crowne Plaza
1441 NE 2nd Avenue
Portland, OR
503-233-2401

And full details can be obtained on the website. Personally I’m very jealous of everyone who gets to attend, I wish I could be there myself – it looks like its going to be a blast! Check it out if you can!

10 Reasons the Commodore 64 Will Never Die

As some of you might have guessed by now, I’m pretty heavily into retro computers. I love them all in different ways, but the C64 holds a very special place in my heart in particular. It was my very first computer (and my only machine for 8 years) – and it introduced me into a world which I never escaped. I learned how to program on it, played my first computer game on it, and spent a great deal of my childhood on it. So while I might be biased as I write this, I’ll try to be as objective as possible.

1. The Game Library

The C64 has always been known as a gaming machine, and for good reason. While the computer has been used across all areas of computing, from music composition and graphic design to business management and financial accounting, its library of games is MASSIVE. Estimates come in at over 21,000 titles, and new titles are still being developed all the time (Check out the most comprehensive database at GB64). And like any media, from music to movies, just because the title is older doesn’t mean it’s not still enjoyable – there are some simply great games for the C64 that are still lots of fun to play.

2. Quantity Produced

The Commodore 64 is still the best selling computer to this day – and most likely will be forever. Saying it sold well would be a gross understatement – it crushed the home computer market. Jack Tramiel, founder of Commodore, did a lot of things right in his day, and one was the price point of the machine. While it started at $595, it eventually dropped to $200, and estimates of units sold range from 17 to 30 MILLION. Even with a large portion of owners throwing their machine away over time, 30 million computers simply don’t disappear. It is still extremely easy to pick up a C64 off of eBay, Craigslist, or other online sites.

3. The Community

While this is true of a lot of the classic computers, it is especially true of the Commodore line – there is still a huge following for this machine. It’s likely if you look enough online, you’ll still find a user’s group, yearly convention, or informal get-together that includes, or even focuses on, the C64. I’ve personally attended a couple conferences (TPUG‘s World of Commodore and ECCC), and have been in close contact with other groups (Commodore Computer Club and Users Group in Vancouver, WA) – and they’re all friendly guys and gals who have a common love for all things Commodore (and Amiga, and Apple, and Atari, etc…). They are the true heart that continues to drive the C64 onward!

4. The SID Chip

The MOS 6581/8580 SID is arguably one of the greatest sound chips to ever be produced. During its time, there was no other 8-bit computer that had the sound capabilities of the C64. Even in contemporary times, the unique sound quality of the SID is still a desired effect that modern musicians seek to take advantage of. Newer dedicated hardware, such as the SIDStation, has been used by groups such as Timbaland and Machinae Supremacy to produce the sweet C64-style synth sounds that can’t be gotten anywhere else.

5. Hackability

While computers today can render 3D worlds while playing a 20 part symphony and downloading a set of encyclopedias, this comes at a cost – and that cost is complexity. The beauty of a machine like the C64 is a hardware or software developer’s ability to interact directly with the machine. You can read and write directly from/to memory, tie into the system bus, and do a whole other array of low level things that 62 layers of hardware and operating system don’t allow you to do on a new PC. For those who love to tinker, this is a dream.

6. New Capabilities

Due in large part to #2 and #5, new hardware still being made constantly, which breathes incredible new life into the machine. From SD/CF card readers and Ethernet adapters, to mp3 players and accelerators, the Commodore 64 of today is a different beast than in its 80s heyday. When a machine with a 1 MHz processor and 64K of RAM can surf the web, tweet on Twitter, and can access files on an 160GB IDE hard drive, that’s truly amazing.

7. Strong Emulator Support

Using a Commodore 64 doesn’t necessarily mean you need the hardware anymore. Since the advent of faster machines with emulation capabilities, many developers have been working on virtual versions of the hardware counterpart. Many years have passed, and these are now solid, amazing, and free applications that allow you to use a C64 on a variety of devices, from computers and laptops to PSPs and iPhones. Even if all the hardware one day disappeared, emulators never will. Two of the most popular ones are VICE and CCS64).

8. FPGA Implementations

In the same vein as #7, some hardware wizards have gone the emulation route, but instead of producing a software version, have reimplemented the machine in FPGA hardware. In this manner, the C64 exists as firmware on a programmable chip, which allows for smaller, cheaper, and easily upgradable/hackable versions of the C64. And since the machine exists as firmware, many of these devices have different models of computers on the same device – flip the switch and go from using a C64 to an Amiga 500. Examples include Jeri Ellsworth’s DTV and the MCC (Multiple Classic Computer).

9. The Scene

Since the beginning, due to its powerful sound and graphics capability, the C64 has been used to demonstrate elite programming skills through dazzling shows of animation and music. While it started in large part as intros to software cracks, the demo scene grew into a beast all of itself. Some of the greatest artistic, musical, and programming talent to ever hit a computer has gone into software demos. And to this day, programming gurus continue to show off their talents on the C64 – not only because it’s a great platform to program for, but feats are all the more impressive when accomplished in minimal space/computation. A list of upcoming Demo parties can be found at Demo Party.net

10. The Shameless Plug

And the C64 is the only place to find Shredz64 (Guitar Hero for the C64)! 😉 It’s just fun to show your friends that a machine made in 1982 can do the same things that a new PS3 or Wii can do. (Sorry, had to do it)

So if you’ve never tried a C64, or haven’t touched one for a long time – find an emulator, pick one up off eBay, or borrow a friend’s – and find out for yourself why it’s still the most amazing computer ever made!

Fun Ways to Sharpen Your CS Skills

If you’re anything like me, once you learned how to code, you would take any chance you could get to write little programs for fun. I remember once I finally “got” BASIC on my Commodore 64 growing up, I would spend hours writing the cheeziest (looking back) programs. A favorite of mine was writing countless “Question and Answer” programs, where the computer would ask “How are you?” and depending on your answer, the program would issue a different (and probably inappropriate given my age at the time) response.

Time Marches On

As time went on though, and I got better at programming, learned the fundamentals, studied Computer Science – things started to change. I still loved to program, but my goals became larger and more complex. Pet projects would take days to complete, then weeks, then months. Once I started doing it professionally, that added a whole new level, where the projects were for money, and project management, sustainability, fiscal viability, etc, all became factors. I had to specialize and focus on specific areas to remain competitive. And the technology changed – whereas once I was communicating directly with the processor and memory I/O, now I was communicating 17 levels up to a a COM object or framework API. It was just a different ballgame – which isn’t necessarily a bad thing, but sometimes working at such a high level for different purposes can make you lose site of the underlying CS. Sometimes it’s important to keep your CS skills as fresh and sharp as your software engineering ones.

Some Fun Ways to Up Your CS Game

Luckily, there are some sites out there that are awesome for keeping those little grey CS cells active in your head.

Project Euler
This is by far my favorite one. Euler offers a large number of problems (currently 300) that require a computer program to solve. They are generally geared toward mathematics of different levels and areas (generally the higher the problem, the more difficult it is), and you can solve them using any method or programming language you wish. The website keeps track of how many you’ve solved and how you’re faring with the rest of the members, but really you’re competing with yourself to write the best program you can. As you get into later problems, even your efficiency matters, as your first solution might take 3 days to complete, whereas the better one takes .25 seconds. They have discussion forums for each problem as well (once you’ve solved it), where people show their solutions and help each other out. Some example problems on the site:

1. Add all the natural numbers below one thousand that are multiples of 3 or 5.
7. Find the 10001st prime.
15. Starting in the top left corner in a 20 by 20 grid, how many routes are there to the bottom right corner?
109. How many distinct ways can a player checkout in the game of darts with a score of less than 100?
157. Solving the diophantine equation 1/a+1/b= p/10n

As you can see, there are a large range of problems targeting different areas and algorithms. I’ve solved 34 to date – sometimes I’ll spend a lunch hour working on a problem, they’re great fun and you can do them at your own pace – and learn new techniques in the process.

Hack This Site!
No, that wasn’t an invitation! Hack This Site . Org is an interesting site that offers a number of security, reverse engineering, and application development missions. While I’m actually against the practice of unauthorized computer access (especially being a IT Manager by day) – penetration testing is a great thing for a network administrator to know, and reverse engineering is a fantastic thing for a programmer to know. In the high-level development world we now live in, getting back to the processor and memory level is definitely a plus – and studying the binary structure of an executable certainly achieves that. Not only does it strengthen your machine language skills, but it also gives you great insight into how compilers work, how operating systems link DLLs, management memory, and achieve IPC.

Many More

Project Euler and Hack This Site are the two I focus on (and between the two of them, there are enough problems to keep me busy for years), but if they aren’t your cup of tea, here are a list of other programming problem related sites:

Bright Shadows
Electrica
Programming Challenges
Python Challenge
TopCoder

Have fun, and get your CS in shape!

Follow Along On Twitter!

For those interested, I finally bit the bullet and created a Twitter account. Follow all the programming, retrocomputer, and engineering madness!

@ToniWestbrook
http://www.twitter.com/ToniWestbrook