ssh tunneling

By | September 27, 2015

for some reason at some time you need tunnel to your home, work, server etc..
and the easiest way to build it – is ssh. There are a lot of manuals in internet how to do it, but here I will keep my useful examples with description

  • local port forwarding:
    ssh -2 -f -N -L local_port: user@host

    • 2 – Forces ssh to try protocol version 2 only
    • f – Requests ssh to go to background just before command execution
    • N – Requests ssh to go to background just before command execution
    • L – Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.
  • remote port forwarding:
    ssh -4 -N -f -R \*:remote_port: user@server

    • R – Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side.
    • \* – specify remote server listen on all interface
    • 4 – Forces ssh to use IPv4 addresses only
  • ssh vpn tunnel
    very good manual written on ubuntu help page: ssh_vpn tunnel

git commands

By | September 27, 2015
  • add new user in gitolite:
    * cd /tmp/
    * git clone git@git-host:gitolite-admin
    where: git - git-user, git-host - address or hostname of server, gitolite-admin - repo name
    * ssh-keygen -t rsa
    .pub - keep on server side.
    * cp /some/where/ /tmp/gitolite-admin/keydir
    * git add keydir
    * git commit
    * git push
  • create new repositories:
    * update file: gitolite-admin/conf/gitolite.conf
    * git add .
    * git commit -a -m "some comment"
    * git push

Conky config

By | September 27, 2015

My config which looks like:

# Use Xft?
use_xft yes
xftfont OFL Sorts Mill Goudy:size=8
xftalpha 0.8
text_buffer_size 2048
# Update interval in seconds
update_interval 1
# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0
max_specials 1024
max_user_text 18384
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_transparent yes
#own_window_type override
own_window_class conky
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
background no
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# Minimum size of text area
minimum_size 200 0
#maximum_width 250
# Draw shades?
draw_shades no
# Draw outlines?
draw_outline no
# Draw borders around text
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
#border_inner_margin 5
#border_width 1
# Default colors and also border colors
default_color white
default_shade_color white
default_outline_color white
own_window_colour white
color1 white
# Text alignment, other possible values are commented
alignment bottom_left
# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 10
gap_y 20
# Subtract file system buffers from used memory?
no_buffers yes
# set to yes if you want all text to be in uppercase
uppercase no
# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2
# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2
# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes
# Add spaces to keep things from moving about? This only affects certain objects.
use_spacer none
${font Goudy Bookletter 1911:style=Bold}System Info${font} ${hr 2}
${font}CPU temp.: ${alignr}${color #FF0000}${hwmon 1 temp 1}°C${color0}
${font}MotherBoard temp.: ${alignr}${color #FF0000}${hwmon 1 temp 2}°C${color0}
${font}GPU temp.: ${alignr}${color #FF0000}${execpi 10 nvidia-settings -q GPUCoreTemp|grep :0|cut -d ')' -f2|cut -d : -f2|tr -d .}°C${color0}
${font}CPU fan speed: ${alignr}${color #FF0000}${hwmon 1 fan 1}${color0}
#${font}Video fan speed: ${alignr}${color #FF0000}${hwmon 1 fan 2}${color0}
#${font}Power fan speed: ${alignr}${color #FF0000}${hwmon 1 fan 3}${color0}

${font Goudy Bookletter 1911:style=Bold}Processors ${hr 2}
${font}CPU summary: ${color #FF0000}${cpu}% ${color0}
${font}core1: ${alignr}${cpubar cpu1 8,60}
${font}core2: ${alignr}${cpubar cpu2 8,60}
${font}core3: ${alignr}${cpubar cpu3 8,60}

${font Goudy Bookletter 1911:style=Bold}Memory ${hr 2}
${font}RAM: ${color #FF0000}$memperc%${color0} ${alignr}${membar 8,60}
${font}SWAP: ${color #FF0000}$swapperc%${color0} ${alignr}${swapbar 8,60}
#${font StyleBats:size=16}q${font} Uptime: ${alignr}${uptime}

${font Goudy Bookletter 1911:style=Bold}HD info${font} ${hr 2}
${font}Root dir:
${voffset -4}${color #FF0000}${fs_free /}${color0} / ${fs_size /} ${alignr}${fs_bar 8,60 /}
${voffset -4}${color #FF0000}${fs_free /media/D}${color0} / ${fs_size /media/D} ${alignr}${fs_bar 8,60 /media/D}

#${font Goudy Bookletter 1911:style=Bold}NETZWERK${font} ${hr 2}
#${voffset 4}${font PizzaDude Bullets:size=14}O${font} Up: ${upspeed eth0} ${alignr}${upspeedgraph eth0 8,60 000000 000000}
#${voffset 4}${font PizzaDude Bullets:size=14}U${font} Down: ${downspeed eth0} ${alignr}${downspeedgraph eth0 8,60 000000 000000}
#${voffset 4}${font PizzaDude Bullets:size=14}N${font} Upload: ${alignr}${totalup eth0}
#${voffset 4}${font PizzaDude Bullets:size=14}T${font} Download: ${alignr}${totaldown eth0}
#${voffset 4}${font PizzaDude Bullets:size=14}a${font} Local Ip: ${alignr}${addr eth0}
#${voffset 4}${font PizzaDude Bullets:size=14}a${font} Public Ip: ${alignr}${execi 1800}
${font Goudy Bookletter 1911:style=Bold}Top processes${font} ${hr 2}
NAME $alignr PID CPU
${top name 1} $alignr ${top pid 1} ${top cpu 1}
${top name 2} $alignr ${top pid 2} ${top cpu 2}
${top name 3} $alignr ${top pid 3} ${top cpu 3}
#${top name 4} $alignr ${top pid 4} ${top cpu 4}
#${top name 5} $alignr ${top pid 5} ${top cpu 5}
#${font Goudy Bookletter 1911:style=Bold}WETTER${font} ${hr 2}
#Station: ${execi 3600 conkyForecast --location=GMXX0018 --datatype=CN}
#Wetterlage: ${execi 3600 conkyForecast --location=GMXX0018 --datatype=CC}
#${font ConkyWeather:size=34}${execi 3600 conkyForecast --location=GMXX0018 --datatype=WF}${font}
#Temp: ${execi 3600 conkyForecast --location=GMXX0018 --datatype=HT}
#${voffset 4}${font ConkyWeather:size=34}${execi 3600 conkyForecast --startday=1 --endday=3 --location=GMXX0018 --spaces=2 --datatype=WF}${font}
#${voffset 4}${execi 3600 conkyForecast --location=GMXX0018 --startday=1 --endday=3 --spaces=16 --datatype=HT}
#${voffset 4}${execi 3600 conkyForecast --location=GMXX0018 --startday=1 --endday=3 --spaces=5 --datatype=DW}

nagios3 as website

By | September 8, 2015

by default it’s alias: and to do it standalone site follow below instruction:

  • a2disconf nagios3
  • ln -s /etc/nagios3/apache2.conf /etc/apache2/sites-enabled/
  • modify this file to look like:
    <VirtualHost *:80>
            ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3/
            Alias /stylesheets /etc/nagios3/stylesheets/
            Alias / /usr/share/nagios3/htdocs/
            DocumentRoot /usr/share/nagios3/htdocs/
            <DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
                    Options FollowSymLinks
                    DirectoryIndex index.php index.html
                    AllowOverride AuthConfig
                    Order Allow,Deny
                    Allow From All
                    AuthName "Nagios Access"
                    AuthType Basic
                    AuthUserFile /path/to/nagios3/htpasswd.users
                    require valid-user
            <Directory /usr/share/nagios3/htdocs>
                    Options +ExecCGI
            ErrorLog ${APACHE_LOG_DIR}/
            LogLevel warn
            CustomLog ${APACHE_LOG_DIR}/ combined
  • in file /etc/nagios3/cgi.cfg change url_html_path from /nagios3 to /
  • service apache2 restart

backup mysql databases

By | September 8, 2015
steps to perform mysql databases backup:
  • put the server  in a read-only state:
    SET GLOBAL read_only = ON;
  • backup data via this script or:
    mysqldump -h host_name --user=user_name --password=password --events --opt --single-transaction db_for_backup | gzip > backup_name.gz
  • turn off read-only mode:
    SET GLOBAL read_only = OFF;
to restore db from backup:
  • you can use this script
  • or:  mysql -u user "db_name" < backup_name
  • or: gunzip < backup_name.gz | mysql -u user -p password db_name