Over a million developers have joined DZone.

Comparing the Difference Between Two Environments

Everyone's heard ''your app doesn't work on my machine,'' and there are tons of variables that can contribute to why something is broken. Here's a way to quickly find out what the differences are.

· DevOps Zone

The DevOps zone is brought to you in partnership with Sonatype Nexus. The Nexus suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

Why is this working on my server, but fails on yours? This kind of question is quite common. After careful checks and side-by-side tests, we may or may not find the difference. The root cause may be a packages conflict, mismatched versions, corrupted files, or something magical.

How we can quickly detect the noticeable differences between two servers?


 Let's examine the common differences:

  1. OS flavor. The OS version may be different. Say, the system may work on Ubuntu 14.04 64-bit, but fails on Ubuntu 12.04 32-bit. The server may have less memory than we expect, etc.
  2. Software Packages. Missing packages, extra packages installed which cause conflicts, wrong installation versions, etc.
  3. Libraries. Wrong JDK version, some .jar libraries are missing, etc.
  4. Config files. Incorrect setting in config files.

Luckily all this information can be discovered by using multiple existing commands. For example, we can get all OS details by probing  /proc filesystem  or commands like  free/df/lscpu , etc. All software installed after OS installation can be found like this. Jar libraries usually are placed under the $CLASSPATH folder, etc.

Apparently it demands a lot of learning and experience to get familiar with all these tools. Furthermore, humans are slow and error-prone.

What if we design a command-line tool to automate the check and compare process?

We need it to:

  • Dump detailed information into txt files.
  • Categorize different checks into typical scenarios, like OS, Java, Python, etc.
  • Diff the generated list by category.

Based on this idea, here comes list_os_packages cli tool in Github.


For better user experience, we can wrap up it as a Jenkins job: CompareMachinesReport.



Like our blog posts? Discuss with us on LinkedIn, Wechat, or NewsLetter.

The DevOps zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today


Published at DZone with permission of Denny Zhang, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}