Operations 13 min read

Why Python 2 Still Matters and How to Build a Simple DevOps Monitoring Platform

This article explains the reasons Python 2 remains dominant, compares Python 2 and 3 features, offers guidance on learning Python via the __future__ library, and provides a step‑by‑step tutorial for building a lightweight DevOps monitoring platform using Django, MongoDB, ECharts and Psutil.

Efficient Ops
Efficient Ops
Efficient Ops
Why Python 2 Still Matters and How to Build a Simple DevOps Monitoring Platform

How to Choose a Python Version

Python has two main versions, 2 and 3, both still maintained but incompatible.

Differences between Python 2 and Python 3

Print statement vs function: print "abc" vs print("abc") Class model: old‑style and new‑style classes vs only new‑style classes

Division: 1/2 == 0 in 2, 1/2 == 0.5 in 3

String formatting: % vs format() Range functions: xrange vs range Long type renamed to int Import style: relative imports vs absolute imports

Source file encoding: ASCII vs UTF‑8

Officially Python 2 support ends in 2020, but most existing projects still run on 2.7, so learning 2 first can ease migration.

Download statistics from 2016 show Python 2.6/2.7 dominate, explaining continued use.

Technology evolves fast, but production adoption is slow.

If Python 2 works, there is little incentive to upgrade.

Python 3 is not the default interpreter on many OSes, making migration costly.

How to Learn Python

Use the __future__ library in Python 2 to access many Python 3 features, start with Python 2.7, and write code compatible with both versions.

Key recommendations:

Start with Python 2.7, avoid earlier 2.x releases.

Avoid deprecated Python 3 syntax and packages.

Do not use Python versions earlier than 3.5.

Prefer syntax that works on both 2 and 3.

Familiarize yourself with the __future__ library.

DevOps engineers should primarily use Python 2.7.

Application developers can use Python 3.5 or newer.

Develop a Simple Monitoring Platform

Why Monitoring Matters for Operations

Monitoring is the eyes of a DevOps engineer; a good system quickly detects and locates issues, reducing downtime and easing workload.

Server Side

Use the AdminLTE front‑end framework (based on Bootstrap) for UI, ECharts for charts, and Django for the backend. Store monitoring data in MongoDB for scalability; MySQL can be used for asset information.

Provide an API that receives JSON payloads from clients, timestamps them, and inserts them into MongoDB, partitioned by host.

Client Side

The client uses requests for HTTP, schedule for periodic tasks, and psutil to collect CPU, memory, network, and disk metrics.

Collected metrics are packaged as JSON and posted to the server API.

Further Development

Hardware monitoring via Linux commands (smartctl, dmidecode).

Use psutil for NPM, CPU, memory, disk, network, process metrics.

Monitor middleware (MySQL, Nginx) via CLI or built‑in interfaces.

Custom monitoring via shell scripts.

Application performance monitoring via instrumentation or JVM sniffing.

Alerting via email, WeChat, etc.

Building your own platform gives full control and enhances your Python and software engineering skills.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonDevOpsDjangoMongoDB
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.