thorko.deLinux / Unix systems administrator

Latest SysadminDB entries


MySQL - truncate all tables of database

echo "set foreign_key_checks=0;" >> /tmp/truncate.sql
mysql -Nse "show tables" <database> | while read table; do echo "truncate table $table;" >> /tmp/truncate.sql; done
echo "set foreign_key_checks=1;" >> /tmp/truncate.sql
mysql -u root <database> < /tmp/truncate.sql



Zabbix - Triggers stuck on dashboard

If there are triggers schown on dashboard which are nowhere else seen in Zabbix you can release them if you set the value in database to 0.

Get the triggerid with this query

mysql> SELECT t.triggerid,t.expression,t.description,t.url,t.priority,t.lastchange,t.comments,t.error,t.state FROM triggers t \
WHERE NOT EXISTS (SELECT NULL FROM functions f,items i,hosts h WHERE t.triggerid=f.triggerid AND f.itemid=i.itemid \
AND i.hostid=h.hostid AND (i.status<>0 OR h.status<>0)) \
AND t.status=0 AND NOT EXISTS (SELECT NULL FROM functions f,items i,hosts h WHERE t.triggerid=f.triggerid \
AND f.itemid=i.itemid AND i.hostid=h.hostid AND h.maintenance_status=1)\
AND t.priority IN ('0','2','3','4','5') AND t.value='1' AND t.flags IN ('0','4')\
ORDER BY t.lastchange DESC LIMIT 100 OFFSET 0;

update these triggers

mysql> update triggers set value=0 where triggerid = '<your triggerid>';



Zabbix - ugrade of database failed

Zabbix error message: Lost connection to MySQL server during query

Solution: Check your timeout settings on the mysql database. And also check your devices (firewalls, loadbalancers) between your zabbix server and database server.
In some cases there can be a device which has a low idle timeout on connections. This device is dropping the connection if there is no traffic. 




Scan your documents and archiv as a searchable PDF

Install packages

~$ apt-get install sane sane-utils ghostscript netpbm pdftk pdfocr tesseract-ocr-deu tesseract-ocr

Now make sure your scanner got detected

~$ scanimage -L
device `genesys:libusb:001:049' is a Canon LiDE 220 flatbed scanner

Scan your document and create a PDF

~$ scanimage --format pnm --resolution 1200 > /tmp/test.pnm
~$ pnmtops /tmp/test.pnm > /tmp/test.ps
~$ ps2pdf /tmp/test.ps /tmp/test.pdf

Once you created the PDF you can run OCR on it

~$ pdfocr -i /tmp/test.pdf -o /tmp/scan.pdf -L -t -l deu



RPM sign packages without passphrase

To sign a package without a passphrase do

~$ expect -c 'set timeout 3600; spawn rpmbuild -bb --sign /tmp/package.spec; expect -exact "Enter pass phrase: " { 
send -- "\r" }; expect eof'



(c) 2014 by thorko.de