I would like to propose one of the ways of monitoring of OS Windows server, which is installed on a Linux server as a virtual one. For this purpose, we will use Nagios and the program for Windows – NSClient++. First of all we need to install program NSClient++ on the virtual machine. During the…
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…
AWK: quick way to get squid users traffic usage
If you need quick and simple way to get squid users traffic usage you can use this script: #!/bin/bash awk ‘{ user = $8 traffic[user] += $5; } END { OFS = “tt” for (i in traffic) {printf “%s – tt size: %10.2f Mbn”, i, ( traffic[i] / (1024 * 1024 ) ) } }’…
RPM: Bulding Python package for Redis
To build RPM package for Python library is really easy task if developer has kindly included setup.py file in it. Let’s build RPM for redis-py package by Andy Mccurdy. First of all we need archive with last version of redis-py. [root@develop ~]# wget https://github.com/downloads/andymccurdy/redis-py/redis-2.4.9.tar.gz Unpack it. [root@develop ~]# tar xzvf redis-2.4.9.tar.gz [root@develop ~]# cd redis-2.4.9/…
AWK: getting last column value
If you need to get value of last column in awk you can use built-in variable NF which means the number of fields in record. awk ‘$(NF) !~ /-/ { print $0 }’ access_log Or next, if you need next to the last field. And so on. awk ‘$(NF-1) != /-/ { print $0 }’…
DRBD split-brain solution in primary/primary setup
Recently one of our customers DRBD cluster has detected split-brain: node2 kernel: block drbd1: Split-Brain detected, dropping connection! node2 kernel: block drbd1: helper command: /sbin/drbdadm split-brain minor-1 node2 kernel: block drbd1: helper command: /sbin/drbdadm split-brain minor-1 exit code 0 (0x0) This is primary/primary cluster. And to fix this issue we had to perform manual procedures…
RPM: last installed packages
1. To get list of last installed RPM packages you can simply use next command: rpm -qa –last | less 2. To get list of packages installed sorted by size use: rpm -qa –queryformat=”%{size} %{name}-%{version}-%{release}n” | sort -rn | less Didn’t find the answer to your question? Ask it our administrators to reply we will…
Bash: sort IP addresses
It’s very easy sorting IP-list. For example you have file ‘ip-list’. To sort IP’s redirect file contents to following sort command. Also collect only unique IP’s in yours list. cat ip-list | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 | uniq >> sorted-ips Didn’t find the answer to your question?…
How to exclude directories while using rsync
Sometimes when you copy a lot of data with rsync you may to exclude some sub-directories. You can do this by using –exclude. For instance, you want to copy files from /mnt to /home/destination_dir/, and you want to exclude directory /mnt/dir1/dir2/. rsync -az –exclude=’dir1/dir2/’ /mnt/ /home/destination_dir/ A lot of users do mistake when specifing path.…
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…