Skip to main content

Posts

Showing posts from 2017

Postgresql partituoning (few simple steps)

History I created a simple application for logistic purpose based on Django, PostgresSQL, and Postgis.  This is a service receiving a position of a truck and place it on the map. Service is really simple and uses a virtual machine with small performance.  The main problem of the current solution is a small performance of this cloud server.  Most of the cloud providers use LAN for attaching virtual server's drives. As result speed of disk I/O is really small.   root@sergiy:/home/serg# fdisk -l Disk /dev/xvda1: 20 GiB, 21474836480 bytes, 41943040 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/xvda2: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes root@sergiy:/home/serg# hdparm -tT /dev/xvda1 /dev/xvda1: Timing cache

Upgrade postgres 9.4 to 9.6 at Debian linux

I'm using virtual server based on Debian Linux for some my free projects.  One of them is based on Postgres with PostGIS extension.   This windy rainy day is a good time for executing some upgrade. Also I would like to add partman extension for partituoning. Checking new version.  Update package list : aptitude update Get: 1 http://ftp.debian.org/debian jessie-updates InRelease [145 kB] Get: 2 http://security.debian.org stretch/updates InRelease [62.9 kB] Get: 3 http://security.debian.org jessie/updates InRelease [63.1 kB]  Check for new version: dpkg-query -l postgresql* Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name V

checking host hardware using linux kernel

How to collect information about  host without trivial system command   I'm using a lot of hardware boxes with no limit on distro types and versions.  In this case using system command such as ifconfig has a limited usage.  Also,  system config files have a different path and best way for me is getting information from the kernel. Of course,  I'm using cat command for doing this. Next table has information about hardware. Let me know if something is interesting for you and you know something interesting hardware information in the linux kernel file path information /proc/cpuinfo CPU /proc/meminfo memory /sys/block List of block devices. HDD has sd or hd at the beginning /sys/class/block/{digit}/device/model HDD drive and vendor /sys/block/{digit}/size HDD size  /sys/block List of block devices. HDD has sd or hd at the beginning /sys/bus/pci/devices/0000:{digit}/net System name of the network card /sys/devices/virtual/dmi/id/board_*

Postfix can not start via systemd (simple fix)

Solving problem related to systemd process I like postfix.   This is really smart and secure mail server. I'm helping above  dozen clients around the world and  tunning  postfix is really fun task. This morning I was downgrading postfix  to the stable version for one of the my friends and come across interesting issue.  root@newserver:/etc/init.d# systemctl status postfix ● postfix.service Loaded: masked (/dev/null; bad) Active: inactive (dead) since вт 2017-06-13 14:35:41 EEST; 1h 48min ago Main PID: 25145 (code=exited, status=0/SUCCESS) чер 13 14:47:09 newserver systemd[1]: Stopped postfix.service. чер 13 14:47:29 newserver systemd[1]: Stopped postfix.service. чер 13 14:58:22 newserver systemd[1]: Stopped postfix.service. чер 13 14:58:23 newserver systemd[1]: Stopped postfix.service. чер 13 15:05:20 newserver systemd[1]: Stopped postfix.service. чер 13 15:29:06 newserver systemd[1]: Stopped postfix.service. чер 13 15:29:06 newserver systemd[1]: Stopp

Another one MySQL monitor

Detecting MySQL loading I've seen strange and randomize increasing  of the  MySQL db loading but mytop did not help to sorted out with this issue. I'm not Mike Tyson and my reaction is more slow then CPU. If I don't catch this dynamically I will catch this statistically.  Main idea Select active request by cron and write it ti file. After this statistic analyze for long period of time sort  this problem out.  Selecting information  from  MySQL  Please add python mod MySQLdb  and set correct credentials up. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 import os , MySQLdb def main (): """ checking process list and save it to file""" LOGFILENAME = 'dbusage.log' MYSQLUSERNAME = 'root' MYSQLPASSWORD = 'password' MYSQLHOST = 'localhost' logfile = open (LOGFILENAME, 'a' ) mydb = MySQLdb . connect(host = MYSQLHOST,

Sending request using request library

Using request library for Pirates  Few years ago using urllib2 was a simplest way for sending and receiving  HTTP Request. But now I'm using  Request library . This  is more simple and powerful. Unfortunately Request is not include in default install and Pip  should be used .  Installation  Procedure is really simple  and near to standard : MacBook-Pro-Hohlov:pirates skhohlov $ virtualenv ./env New python executable in ./env/bin/python2.7 Also creating executable in ./env/bin/python Installing setuptools, pip, wheel...done. MacBook-Pro-Hohlov:pirates skhohlov $ source ./env/bin/activate ( env ) MacBook-Pro-Hohlov:pirates skhohlov $ ( env ) MacBook-Pro-Hohlov:pirates skhohlov $ ( env ) MacBook-Pro-Hohlov:pirates skhohlov $ pip install requests Collecting requests Using cached requests-2.13.0-py2.py3-none-any.whl Installing collected packages: requests Successfully installed requests-2.13.0 You are using pip version 7.1.2, however version 9.0.1 is available. You sho

Starting python programming

Programming is easy. Really easy. Many years ago programming requires good skills in hardware and software. "How computers works" was really important question 30 years ago. Cracking Enigma computer or first computer at a nuclear submarine were more simplest the modern cell phone.  This is a reason why building mathematical solution requires perfect engineering skill. Computer is more powerful now and  tarting programming does not requires long term eduction. For example: driving car does not requires deep knowing in  engines and physics, you are driver not mechanics. Downloading software.  First  download  python. python   Also text editor  or powerful IDE is needed. I like Emacs but a lot of peoples love pycharm. You can download it  from  PyCharm . Python is really popular and a lot of system have it included. I'm planning  to use some additional libraries  for our application. It is good idea do not touch your original software. Correct  way is virtual envir

Plarium part two. Working with swf

Flash is old but still usable.  Flash is very old  but still  usable. Few year ago I was sure that this product be killed by WebGL or other modern technology. Now Flash is alive and  very popular for some application.  Flash  contains not only sprites and images ,  actionscript code is also included in swf file. By running  this code flsdh has ability to  work with  user control and send command via network.  Start JPEXS Free Decompiler  and open previous downloaded swf file. Navigate to script section:   Unfortunately my Imac has problem with text searhing(searching is stopped with 'out of memory' error). In this case I'm looking  for potential file using personal meaning. File which has "sign-code" reference is placed at next path: scripts-> model-> logic->server->commands->JsonCallCmd Function name is call() and contain  another one fuction generateRequestSignature(data,paramTextForSignatureCalculation) where  data are data which are s

Plarium again. How to start programming due to game playing.

Plarium again. How to start programming due to game playing.  I would like to say that writing a small script which is helping to have advantages against other peoples is not good. Writing  this post I have a goal to prepare a way to the fanny world of the programming.  I hope this article helps to use computer not a game machine only.  Previous article related to this one  is placed at : old script Requirements Internet browser with developer tools. Firefox or chrome are a good choice.  Both of them can be installed at the any popular operations system.  Download links are there:  https://www.mozilla.org/uk/firefox/new/ and https://www.google.com/chrome/browser/desktop/index.html. Also developer extension is needed: this is for firefox Plarium company uses flash and flash decompiler (in some case debugger) is required. I've used   JPEXS Free Flash Decompiler . Download link is here : https://www.free-decompiler.com/flash/download/    I've used  python for writing s