www.thorko.de Thorsten Kohlhepp - Systems administrator | Thorko.de

 

 

Latest SysadminDB entries


Modx Manager - Annoying "Leave Page" popup

In Modx Manager starting with 2.2.12 every time you leave a resource you'll get an annoying  popup which says "You have unsaved changes" and if you really want to leave the page.

I've created a simple patch which disables this popup

--- modx-2.2.13-pl/manager/assets/modext/widgets/resource/modx.panel.resource.js.bck 2014-04-03 20:24:59.014434002 +0200
+++ modx-2.2.13-pl/manager/assets/modext/widgets/resource/modx.panel.resource.js 2014-04-03 20:25:28.714434010 +0200
@@ -65,12 +65,12 @@
}

// Prevent accidental navigation when stuff has not been saved
- if (MODx.config.confirm_navigation == 1) {
+ /*if (MODx.config.confirm_navigation == 1) {
var panel = this;
window.onbeforeunload = function() {
if (panel.warnUnsavedChanges) return _('unsaved_changes');
};
- }
+ }*/

if (this.config.record.deleted) {
this.handlePreview('hide');
~



Zabbix: useful database queries

show the size of tables in MB

SELECT table_name AS "Table", round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" 
FROM information_schema.TABLES WHERE table_schema = "zabbix";

show all foreign key constraints

use INFORMATION_SCHEMA;
select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME,REFERENCED_TABLE_NAME,
REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE;

cleanup unused items in history

select distinct(itemid) from history left join items using (itemid) where items.itemid IS NULL;

some scripts to cleanup the zabbix database

https://github.com/mattiasgeniar/zabbix-orphaned-data-cleanup




Screen is a terminal multiplexer.

It is likely if you run multiple terminals in one window. To start a new screen session type 'screen' in your terminal session. You will get an information message which you can just skip. You have now one open terminal.

To create a new one in screen press CTRL-a and after releasing those buttons c
CTRL-a c     This creates a new window.

CTRL-a 0     jump to screen window 0

CTRL-a 1     jump to screen window 1

CTRL-a n     jump to next window

CTRL-a p     jump to previous window

CTRL-a d     detach terminal window from screen

CTRL-a A     rename the window

CTRL-a ESC scroll back in screen

CTRL-a H     begin logging of the current window to screenlog.n

screen -x     join a running screen session (Multi display mode), shows output on all screens

Fancy status line at the end of screen terminal

Add these line to your .screenrc file or global wide in /etc/screenrc

# hardstatus lastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<%=%m/%d %c"
# hardstatus on
# hardstatus alwayslastline

It will display the name of each window and mark the active one as blue.

enable logging of current window

CTRL-a :
:logfile <name>
:log on

 

enable PgDn and PgUp to enter copy mode

figure out which key combination is sent to the terminal when you hit PgDn and PgUp
type cat and hit Enter. Now hit PgUp and PgDn and check what characters you'll get.

Create a .screenrc file in your home directory and add the lines below to it (replace the characters after "bindkey" by the characters you got on the terminal).

bindkey ^5~ eval "copy" "stuff \"^u\"" # alt-page-up goes to copy mode
bindkey ^6~ eval "copy" # alt-page-down goes to copy mode
bindkey -m ^5~ stuff "^u" # alt-page-up sends page-up in copy mode
bindkey -m ^6~ stuff "^d" # alt-page-down sends page-down in copy mode

send a command to several windows

CTRL-a :
:at bash# stuff "echo hello\015"




Rename files recursively

Find files which contain "something" in filename and rename "something" to "else"

~$ find . -name '*something*' -exec bash -c 'mv $0 ${0/something/else}' {} \;



Set country code for your WLAN card

check which country code you have set

~$ iw reg get

To set it permanent to your country add the following line to your /etc/rc.local file

/sbin/iw reg set DE