RRDtool is a great facility which aims to replace MRTG and was written by Tobias Oetiker. RRDtool provides powerful features for collecting and visualizing various system metrics like network traffic, MySQL counters or whatever you want. It’s always good idea to know what is going on under the hood of your server. Managing servers we…
All posts tagged python
Python: sorting dict by value
Probably one of the most often task while working with dictionaries in Python is sorting by value. That is how it can be done: >>> d = {‘Canada’: 513, ‘Sao Tome and Principe’: 3, ‘Fiji’: 1, ‘Montenegro’: 12, ‘Lithuania’: 47} >>> sorted_list = sorted(d, key=d.get, reverse=True) >>> for i in sorted_list: … print i, d[i]…
Python: distribution systems world
At the very beginning Python packaging world may seem too confusing. But only at first sight. There are a lot of different packages package formats, libraries and tools for distributing and packages management in Python world. There is also PyPI – the Python Package Index is a repository of software for the Python. Most often…
Python: how to get list of listen sockets in Linux
Here is an example of Python code to get listen socket from Python: def listen_sockets(): listens = [] lines = open(“/proc/net/tcp”).readlines() for l in lines: ls = l.split() if ls[3] == ‘0A’: lp = ls[1].split(‘:’) ip = str(lp[0]) pair = “%s.%s.%s.%s:%s” %( int(ip[6:8], 16), int(ip[4:6], 16), int(ip[2:4], 16), int(ip[0:2], 16), int(lp[1], 16)) listens.append(str(pair)) return listenslistens…