thorko.deLinux / Unix systems administrator

Latest SysadminDB entries


Linux using find in an advanced way

find directories matching n characters long

~$ find . -type d -regextype posix-extended -regex "./[0-9a-zA-Z]{10}" -maxdepth 1 -exec rm -rf {} \;



Salt - use a local state file of last run

write that file /usr/lib/python2.7/site-packages/salt/returners/file.py

# Import Salt libs
import salt.utils
def _get_conn():
if 'config.option' in __salt__:
statefile = __salt__['config.option']('returner.file.file')
else:
cfg = __opts__
statefile = cfg.get('returner.file.file', None)

return statefile

def returner(ret):
statefile = _get_conn()
f = open(statefile, 'w')
for obj in ret['return'].iteritems():
(key, value) = obj
for a, b in value.iteritems():
f.write(a + ": " + str(b) + "\n")
f.write("--------------------\n")
f.close()

and add this to your /etc/salt/minion config

returner.file.file: /var/log/salt/state.log



Zabbix - get statistics about items

If you want to graph the statistics from zabbix items add these to your zabbix_agentd.conf

UserParameter=zabbix.unsupported_items=/usr/bin/mysql -u root zabbix -BNe "select count(i.itemid) from items i 
inner join hosts h on i.hostid=h.hostid where h.status=0
and i.flags in (0x0,0x4) and i.type<>9 and i.status=0 and i.state=1;"

UserParameter=zabbix.items=/usr/bin/mysql -u root zabbix -BNe "select count(i.itemid) from items i inner join hosts h
on i.hostid=h.hostid where h.status=0 and i.flags in (0x0,0x4) and i.type<>9;"

UserParameter=zabbix.items_enabled=/usr/bin/mysql -u root zabbix -BNe "select count(i.itemid) from items i
inner join hosts h on i.hostid=h.hostid where h.status=0 and i.flags in (0x0,0x4) and i.type<>9 and i.state=0 and i.status=0;"

UserParameter=zabbix.items_disabled=/usr/bin/mysql -u root zabbix -BNe "select count(i.itemid) from items i
inner join hosts h on i.hostid=h.hostid where h.status=0 and i.flags in (0x0,0x4) and i.type<>9 and i.status=1;"



If you want to use a NFS server behind a firewall you need to open some ports

in /etc/default/nfs-kernel-server

PCMOUNTDOPTS="--manage-gids -p 32767"

in /etc/default/nfs-common

STATDOPTS="--port 32765 --outgoing-port 32766"

in /etc/default/quota

RPCRQUOTADOPTS="-p 32769"

if you are using ufw put that in before.rules

-A INPUT -p udp --dport 2049 -j ACCEPT
-A INPUT -p tcp --dport 2049 -j ACCEPT
-A OUTPUT -p tcp --sport 2049 -j ACCEPT
-A OUTPUT -p udp --sport 2049 -j ACCEPT
-A INPUT -p udp --dport 111 -j ACCEPT
-A INPUT -p tcp --dport 111 -j ACCEPT
-A OUTPUT -p tcp --sport 111 -j ACCEPT
-A OUTPUT -p udp --sport 111 -j ACCEPT
-A INPUT -p tcp --dport 32764:32769 -j ACCEPT
-A INPUT -p udp --dport 32764:32769 -j ACCEPT



Enable touch events in chromium / chrome

To enable touch events in chromium / chrome browsers open the chrome://flags page and search for "touch" and "pinch" and switch the dropdown menu to enable. Close your browser and start it again and you will see you can touch and zoom on your screen (of course only if you have a touchscreen).




(c) 2014 by thorko.de