<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Alonso.ch &#187; paste.bin</title>
	<atom:link href="http://blog.alonso.ch/category/paste-bin/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.alonso.ch</link>
	<description>Nonsport Blog</description>
	<lastBuildDate>Wed, 01 Feb 2012 08:33:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Howto: SNMP(D) unter Debian Squeeze</title>
		<link>http://blog.alonso.ch/paste-bin/howto-snmpd-unter-debian-squeeze/</link>
		<comments>http://blog.alonso.ch/paste-bin/howto-snmpd-unter-debian-squeeze/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 00:06:45 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[Cacti]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[snmp]]></category>
		<category><![CDATA[Squeeze]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=141</guid>
		<description><![CDATA[Dieses Howto soll ein kleiner Quickstart in den &#8220;neuen&#8221; SNMPD-Deamon unter Debian Squeeze sein. In diesem Fall soll der Dienst so konfiguriert werden, dass Systeminformationen über SNMP (z.B. Nagios,Cacti) abgefragt werden können. Installation der Pakete: apt-get install snmp Wer auch zukünftig seine OID&#8217;s auflösen möchte, muss sich nun neu im Non-Free Repository bedienen. Dort steht [...]]]></description>
			<content:encoded><![CDATA[<p>Dieses Howto soll ein kleiner Quickstart in den &#8220;neuen&#8221; SNMPD-Deamon unter Debian Squeeze sein. In diesem Fall soll der Dienst so konfiguriert werden, dass Systeminformationen über SNMP (z.B. <a href="http://blog.alonso.ch/tag/nagios/">Nagios</a>,<a href="http://blog.alonso.ch/tag/cacti/">Cacti</a>) abgefragt werden können.</p>
<p>Installation der Pakete:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> snmp</pre></div></div>

<p>Wer auch zukünftig seine OID&#8217;s auflösen möchte, muss sich nun neu im Non-Free Repository bedienen. Dort steht das entsprechende Paket &#8220;<em>snmp-mibs-downloader</em>&#8221; bereit.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> snmp-mibs-downloader</pre></div></div>

<p>Das wars, der SNMPD-Deamon müsste mal &#8220;laufen&#8221;. Test mittels dem entsprechenden init.d Script möglich</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>snmpd status</pre></div></div>

<p>Dort müsste man den Erfolg der bisher äussert komplexen Installation nun mittels &#8220;<em>snmpd is running</em>&#8221; bestätigt kriegen.</p>
<p><strong>Weiter gehts mit der Konfiguration:</strong><br />
<span id="more-141"></span></p>
<p>Offiziell steht das Tool <em>snmpconf</em> bereit, mit welchem man per Wizzard den Dienst konfigurieren kann. Ich pers. finde dieses Tool allerdings eher verwirrend und ineffizient. In diesem Beispiel sollen lediglich die Systeminformationen plus ein paar &#8220;externe&#8221; Scripts auf Distanz mittes SNMP v1/v2 abgefragt werden können, daher reicht eine recht magere Konfiguration. </p>
<p>/etc/snmp/snmpd.conf</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># Netzwerk
agentAddress  udp:161
&nbsp;
#Zugriffsteuerung
rocommunity public nagioshost.hallo.welt
&nbsp;
# Kontaktinformationen
syslocation Ich bin hier
syscontact ich@hallo.welt
&nbsp;
# Systemchecks
includeAllDisks  10%
load   12 10 5
&nbsp;
#Erweiterungen
exec meintest   /usr/local/bin/meintest.sh</pre></div></div>

<p>Erwähnenswert ist hier der &#8220;neue&#8221; Parameter <em>agentAddress</em> , welcher den Deamon standartmässig nur auf localhost (udp:127.0.0.1:161) bindet. Hier wahlweise die gewünschte Interface-Adresse verwenden, oder wie in meinem Beispiel auf allen IP&#8217;s des Systems horchen lassen. Alle übrigen Parameter haben sich bei Squeeze wenig verändert. Die Zugriffsteuerung wurde sogar wesentlich vereinfacht über ein view konzept &#8211; welches im aufgezeigten Beispiel allerdings komplett weggelassen wurde. Die definierte Host/Community Kombination hat so einen kompletten Lesezugriff.</p>
<p>Den Deamon neu starten &#8211; fertig:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>snmpd restart</pre></div></div>

<p>Auch hier lohnt es sich danach ein weiteres mal den &#8220;status&#8221; abzufragen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>snmpd status</pre></div></div>

<p>Sofern vorhanden, müssen nun noch die entsprechenden Regeln in der Firewall ergänzt werden (TCP/UDP Port 161), damit der Zugriff auf Distanz auch wirklich klappt.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/howto-snmpd-unter-debian-squeeze/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Courier SSL Zertifikate erneuern (Debian)</title>
		<link>http://blog.alonso.ch/paste-bin/courier-ssl-zertifikate-erneuern-debian/</link>
		<comments>http://blog.alonso.ch/paste-bin/courier-ssl-zertifikate-erneuern-debian/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 23:58:59 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Courier]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=136</guid>
		<description><![CDATA[Wenn der Courier IMAP und/oder POP3 Server unter Debian als Paket installiert wird, erstellt selbiges automatisch die selbstsignierten SSL-Zertifikate. Diese haben per default eine Laufzeit von 1 Jahr und müssen entsprechend erneuert werden. Unter Debian gibts dazu direkt passende Werkzeuge.. Alte Zertifikate sichern: cd /etc/courier/ mv imapd.pem imapd.pem.old mv pop3d.pem pop3d.pem.old Neue Zertifikate erstellen: mkimapdcert [...]]]></description>
			<content:encoded><![CDATA[<p>Wenn der Courier IMAP und/oder POP3 Server unter Debian als Paket installiert wird, erstellt selbiges automatisch die selbstsignierten SSL-Zertifikate. Diese haben per default eine Laufzeit von 1 Jahr und müssen entsprechend erneuert werden. Unter Debian gibts dazu direkt passende Werkzeuge..</p>
<p>Alte Zertifikate sichern:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>courier<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> imapd.pem imapd.pem.old
<span style="color: #c20cb9; font-weight: bold;">mv</span> pop3d.pem pop3d.pem.old</pre></div></div>

<p><span id="more-136"></span><br />
Neue Zertifikate erstellen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mkimapdcert
mkpop3dcert</pre></div></div>

<p>Courier-SSL Dienste neu starten:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>courier-pop-ssl restart <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>courier-imap-ssl restart</pre></div></div>

<p>So &#8211; schon hat man wieder 1 Jahr lang Ruhe.. <img src='http://blog.alonso.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/courier-ssl-zertifikate-erneuern-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mySQL Information Schema: Tables</title>
		<link>http://blog.alonso.ch/paste-bin/mysql-information-schema-tables/</link>
		<comments>http://blog.alonso.ch/paste-bin/mysql-information-schema-tables/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 23:22:48 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[mySQL]]></category>
		<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[Query]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=117</guid>
		<description><![CDATA[Die Information Schemas unter mySQL liefern praktisch alle relevanten Informationen über die DB und deren Inhalt. Besonders praktisch für Anwender welche kein UI (z.B. phpmyadmin) zur Verfügung haben und mit der mySQL-Konsole arbeiten müssen (dürfen/können!). Sehr informativ sind die Table Schemas. Folgendes Query listet alle Tabellen, deren Storage Engine, Kollation und die Anzahl Datensätze zurück: [...]]]></description>
			<content:encoded><![CDATA[<p>Die <a href="http://dev.mysql.com/doc/refman/5.1/de/information-schema.html">Information Schemas</a> unter mySQL liefern praktisch alle relevanten Informationen über die DB und deren Inhalt. Besonders praktisch für Anwender welche kein UI (z.B. <a href="http://www.phpmyadmin.net">phpmyadmin</a>) zur Verfügung haben und mit der mySQL-Konsole arbeiten müssen (dürfen/können!). </p>
<p>Sehr informativ sind die <a href="http://dev.mysql.com/doc/refman/5.1/de/tables-table.html">Table Schemas</a>.</p>
<p>Folgendes Query listet alle Tabellen, deren <a href="http://blog.alonso.ch/tech/database/mysql/vergleich-der-wichtigsten-storage-engines-memory-innodb-und-myisam/">Storage Engine</a>, Kollation und die Anzahl Datensätze zurück:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> table_schema<span style="color: #000033;">,</span> table_name<span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">engine</span><span style="color: #000033;">,</span> table_collation<span style="color: #000033;">,</span> table_rows 
<span style="color: #990099; font-weight: bold;">from</span> information_schema.<span style="color: #990099; font-weight: bold;">tables</span> 
<span style="color: #990099; font-weight: bold;">where</span> table_schema <span style="color: #CC0099; font-weight: bold;">like</span> <span style="color: #008000;">'mydb<span style="color: #008080; font-weight: bold;">%</span>'</span><span style="color: #000033;">;</span></pre></div></div>

<p><span id="more-117"></span></p>
<p>Resultat (z.B. WordPress Blog DB):</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">select</span> table_schema<span style="color: #000033;">,</span> table_name<span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">engine</span><span style="color: #000033;">,</span> table_collation<span style="color: #000033;">,</span> table_rows 
<span style="color: #990099; font-weight: bold;">from</span> information_schema.<span style="color: #990099; font-weight: bold;">tables</span> 
<span style="color: #990099; font-weight: bold;">where</span> table_schema <span style="color: #CC0099; font-weight: bold;">like</span> <span style="color: #008000;">'mydb<span style="color: #008080; font-weight: bold;">%</span>'</span><span style="color: #000033;">;</span>
<span style="color: #CC0099;">+--------------+-----------------------+--------+-----------------+------------+</span>
<span style="color: #CC0099;">|</span> table_schema <span style="color: #CC0099;">|</span> table_name            <span style="color: #CC0099;">|</span> <span style="color: #990099; font-weight: bold;">engine</span> <span style="color: #CC0099;">|</span> table_collation <span style="color: #CC0099;">|</span> table_rows <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+--------------+-----------------------+--------+-----------------+------------+</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_commentmeta        <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">0</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_comments           <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">3</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_contact_form_7     <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_links              <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">2</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_options            <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>        <span style="color: #008080;">269</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_postmeta           <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>         <span style="color: #008080;">69</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_posts              <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>        <span style="color: #008080;">103</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_prli_clicks        <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_prli_groups        <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">0</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_prli_link_metas    <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">0</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_prli_links         <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_term_relationships <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>        <span style="color: #008080;">163</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_term_taxonomy      <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>         <span style="color: #008080;">56</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_terms              <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>         <span style="color: #008080;">50</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_usermeta           <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>         <span style="color: #008080;">16</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> mydb1  <span style="color: #CC0099;">|</span> wp_users              <span style="color: #CC0099;">|</span> MyISAM <span style="color: #CC0099;">|</span> utf8_general_ci <span style="color: #CC0099;">|</span>          <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+--------------+-----------------------+--------+-----------------+------------+</span>
<span style="color: #008080;">16</span> rows <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.74</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div>

<p>Natürlich sind hier auch weitere Informationen abrufbar. Erste Hilfe bietet hier einmal mehr die <a href="http://dev.mysql.com/doc/refman/5.1/de/tables-table.html">mySQL Dok</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/mysql-information-schema-tables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t: Produktive Datenbankabfragen mit Select * from &#8230;</title>
		<link>http://blog.alonso.ch/tech/database/dont-produktive-datenbankabfragen-mit-select-from/</link>
		<comments>http://blog.alonso.ch/tech/database/dont-produktive-datenbankabfragen-mit-select-from/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 15:34:08 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Datenbanken]]></category>
		<category><![CDATA[Dos & Don'ts]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=111</guid>
		<description><![CDATA[Mittels Cacti konnten wir einen beachtlichen Anstieg des mySQL Traffics auf einem Shared Hosting Server feststellen &#8211; welcher langsam aber sicher die Performance des Servers beeinträchtigte. Ein einfaches SHOW FULL PROCESSLIST; auf der mySQL-Konsole dieses Servers brachte folgendes Query mit sehr kurzen Intervallen und einer grossen Laufzeit zum vorschein: SELECT * FROM hits ORDER by [...]]]></description>
			<content:encoded><![CDATA[<p>Mittels <a href="http://www.cacti.net">Cacti</a> konnten wir einen beachtlichen Anstieg des mySQL Traffics auf einem Shared Hosting Server feststellen &#8211; welcher langsam aber sicher die Performance des Servers beeinträchtigte.</p>
<p>Ein einfaches</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SHOW</span> <span style="color: #990099; font-weight: bold;">FULL</span> PROCESSLIST<span style="color: #000033;">;</span></pre></div></div>

<p> auf der mySQL-Konsole dieses Servers brachte folgendes Query mit sehr kurzen Intervallen und einer grossen Laufzeit zum vorschein:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> hits <span style="color: #990099; font-weight: bold;">ORDER by</span> userid <span style="color: #990099; font-weight: bold;">DESC</span></pre></div></div>

<p>Somit war auch die verdächtige Datenbank &#8211; und dadurch auch der verantwortliche Account erruiert. Ein kurzer Blick auf das Schema dieser Datenbank/Tabelle zeigte folgendes:</p>
<ul>
<li>> 1&#8217;000&#8217;000 Datensätze!</li>
<li>Kein Index auf userid!</li>
</ul>
<p><span id="more-111"></span></p>
<p>Als erstes wurde mal userid indexiert, was zwar die Queryperformance deutlich verbesserte &#8211; aber die Last des Servers immernoch überdurchschnittlich beanspruchte.</p>
<p>Ich konnte mir spontan nicht erklären, wesshalb jemand den kompletten Inhalt dieser Tabelle auslesen sollte. Alleine der fehlende Index und das &#8220;Select *&#8221; waren für mich ein Indiz, dass hier KEIN Profi am Werk war. Mich packte der Ergeiz und ich warf einen Blick auf den PHP-Code der entsprechenden Applikation. Es handelte sich dabei um ein gut frequentiertes Toplisten-Script. Irgendwo im Code fand ich folgendes:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">..</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$useridgen</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM hits ORDER BY userid DESC&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$idgenaray</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$useridgen</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$userid</span><span style="color: #339933;">=</span><span style="color: #000088;">$idgenaray</span><span style="color: #009900;">&#91;</span>userid<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">..</span></pre></div></div>

<p>Toll, diese Funktion macht also nichts anderes als die nächste ID für einen Datenbankeintrag zu ermitteln. <img src='http://blog.alonso.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
<a href="http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html">Auto_Increment</a> war hier offenbar ein Fremdwort..</p>
<p>Nach einer Rücksprache mit dem betroffenen Kunden wurde die Applikation so minimal wie möglich angepasst.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$useridgen</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT max(userid) as userid FROM hits&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$idgenaray</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$useridgen</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$userid</span><span style="color: #339933;">=</span><span style="color: #000088;">$idgenaray</span><span style="color: #009900;">&#91;</span>userid<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Das neue Query liefert durch den SELECT max() nur noch genau 1 Datensatz zurück (statt > 1&#8217;000&#8217;000 vorher)! &#8211; erfüllt aber genau dieselbe Funktion innerhalb dieses Scriptes. Das Script selbst musste somit nicht weiter angepasst werden.</p>
<p>Die Auswirkung dieses Korrektur lässt sich auf folgenden Graphen auf beeindruckende Art und Weise erkennen:<br />
<a href="http://blog.alonso.ch/wp-content/uploads/cacti1.png"><img src="http://blog.alonso.ch/wp-content/uploads/cacti1.png" alt="" title="cacti" width="587" height="223" class="aligncenter size-full wp-image-113" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/tech/database/dont-produktive-datenbankabfragen-mit-select-from/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Querys so kompakt wie möglich halten</title>
		<link>http://blog.alonso.ch/tech/database/mysql/sql-querys-so-kompakt-wie-moglich-halten/</link>
		<comments>http://blog.alonso.ch/tech/database/mysql/sql-querys-so-kompakt-wie-moglich-halten/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 12:45:52 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Dos & Don'ts]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=98</guid>
		<description><![CDATA[Setzten sie keine SELECT * FROM Statements ein wenn sie nicht zwingend ALLE informationen benötigen! Natürlich sollten auch unnötigen keine JOINS erstellt werden. Praxisbeispiel: Ein Kundenserver viel immer wieder durch schlechte Performance auf. Es handelte sich dabei um eine Forensoftware von Woltlab, welche mit ein paar Hacks erweitert wurde. Insgesammt umfasst die Datenbank an die [...]]]></description>
			<content:encoded><![CDATA[<p>Setzten sie keine SELECT * FROM Statements ein wenn sie nicht zwingend ALLE informationen benötigen! Natürlich sollten auch unnötigen keine JOINS erstellt werden.</p>
<p>Praxisbeispiel:<br />
Ein Kundenserver viel immer wieder durch schlechte Performance auf. Es handelte sich dabei um eine Forensoftware von Woltlab, welche mit ein paar Hacks erweitert wurde. Insgesammt umfasst die Datenbank an die 1.5 Millionen Posts in 300&#8217;000 Threads. Das Datenvolumen der Datenbank lag zu diesem Zeitpunkt bei rund  1.4GB. Zu Stosszeiten waren jeweils an die 250 User und Bots unterwegs..</p>
<p><span id="more-98"></span></p>
<p>Ein einfaches</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SHOW</span> <span style="color: #990099; font-weight: bold;">FULL</span> PROCESSLIST<span style="color: #000033;">;</span></pre></div></div>

<p> auf der mySQL-Konsole brachte folgendes Query mit einer sehr grossen Laufzeit zum vorschein:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span>
bb2_threads.<span style="color: #CC0099;">*</span><span style="color: #000033;">,</span>
bb2_icons.<span style="color: #CC0099;">*</span><span style="color: #000033;">,</span>
bb2_boards.<span style="color: #CC0099;">*</span><span style="color: #000033;">,</span>
bb2_users.username <span style="color: #990099; font-weight: bold;">as</span> lastposter
<span style="color: #990099; font-weight: bold;">FROM</span> bb2_threads
<span style="color: #000099;">LEFT</span> <span style="color: #990099; font-weight: bold;">JOIN</span> bb2_icons <span style="color: #990099; font-weight: bold;">USING</span> <span style="color: #FF00FF;">&#40;</span>iconid<span style="color: #FF00FF;">&#41;</span>
<span style="color: #000099;">LEFT</span> <span style="color: #990099; font-weight: bold;">JOIN</span> bb2_boards <span style="color: #990099; font-weight: bold;">ON</span> <span style="color: #FF00FF;">&#40;</span>bb2_threads.boardid<span style="color: #CC0099;">=</span>bb2_boards.boardid<span style="color: #FF00FF;">&#41;</span>
<span style="color: #000099;">LEFT</span> <span style="color: #990099; font-weight: bold;">JOIN</span> bb2_users <span style="color: #990099; font-weight: bold;">ON</span> <span style="color: #FF00FF;">&#40;</span>bb2_threads.lastposterid<span style="color: #CC0099;">=</span>bb2_users.userid<span style="color: #FF00FF;">&#41;</span>
<span style="color: #990099; font-weight: bold;">WHERE</span> bb2_threads.closed<span style="color: #CC0099;">!=</span><span style="color: #008080;">3</span> 
<span style="color: #990099; font-weight: bold;">ORDER BY</span> bb2_threads.lastposttime <span style="color: #990099; font-weight: bold;">DESC</span> <span style="color: #990099; font-weight: bold;">LIMIT</span> <span style="color: #008080;">0</span><span style="color: #000033;">,</span> <span style="color: #008080;">5</span></pre></div></div>

<p>Dieses Query ermittelt also die 5 aktuellsten Threads sammt Titel, Author und die entsprechenden ID&#8217;s für die Verlinkung und zeigt diese infos auf der Startseite an. Das Query hatte unverändert auf der Konsole trotz allen notwendigen Indexen eine Laufzeit von gut 3s &#8211; verursacht durch die gigantische Datenmenge und den notwendigen Filesort.</p>
<p>Nachdem ich mich in das Datenbankschema eingearbeitet habe &#8211; konnte ich das Query &#8220;etwas&#8221; bereinigen:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span>
bb2_threads.threadid<span style="color: #000033;">,</span>
bb2_threads.views<span style="color: #000033;">,</span>
bb2_threads.lastposterid<span style="color: #000033;">,</span>
bb2_threads.topic<span style="color: #000033;">,</span>
bb2_threads.lastposter
<span style="color: #990099; font-weight: bold;">FROM</span> bb2_threads
<span style="color: #000099;">LEFT</span> <span style="color: #990099; font-weight: bold;">JOIN</span> bb2_boards <span style="color: #990099; font-weight: bold;">ON</span> <span style="color: #FF00FF;">&#40;</span>bb2_threads.boardid<span style="color: #CC0099;">=</span>bb2_boards.boardid<span style="color: #FF00FF;">&#41;</span>
<span style="color: #990099; font-weight: bold;">WHERE</span> bb2_threads.closed<span style="color: #CC0099;">!=</span><span style="color: #008080;">3</span> 
<span style="color: #990099; font-weight: bold;">ORDER BY</span> bb2_threads.lastposttime <span style="color: #990099; font-weight: bold;">DESC</span> <span style="color: #990099; font-weight: bold;">LIMIT</span> <span style="color: #008080;">0</span><span style="color: #000033;">,</span> <span style="color: #008080;">5</span></pre></div></div>

<p>Der Output ist 100% identisch zum Original. Die Abfrage dauert jetzt allerdings nur noch knapp 0.2s!</p>
<p>Nur diese eine Anpassung hatte folgende Auswirkung auf die Serverlast (Ab KW51):<br />
<a href="http://blog.alonso.ch/wp-content/uploads/cacti.png"><img src="http://blog.alonso.ch/wp-content/uploads/cacti-300x129.png" alt="Cacti mySQL Graph" title="cacti" width="300" height="129" class="aligncenter size-medium wp-image-101" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/tech/database/mysql/sql-querys-so-kompakt-wie-moglich-halten/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mySQL Tuning Primer</title>
		<link>http://blog.alonso.ch/paste-bin/mysql-tuning-primer/</link>
		<comments>http://blog.alonso.ch/paste-bin/mysql-tuning-primer/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 12:40:58 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[mySQL]]></category>
		<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Tool]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=96</guid>
		<description><![CDATA[Der mySQL Tuning Primer ist ein kleines Shellscript welches die mySQL-Statusinformationen (&#8220;SHOW STATUS&#8221;, &#8220;SHOW VARIABLES&#8221;) analysiert und in einen übersichtlichen Report mit Optimierungstips umwandelt. Ein gutes und effizientes Hilfsmittel zur Optimierung der Serverkonfiguration (my.cnf). Hilft beim optimieren von: Slow Query Log Max Connections Worker Threads Key Buffer Query Cache Sort Buffer Joins Temp Tables Table [...]]]></description>
			<content:encoded><![CDATA[<p>Der mySQL Tuning Primer ist ein kleines Shellscript welches die mySQL-Statusinformationen (&#8220;SHOW STATUS&#8221;, &#8220;SHOW VARIABLES&#8221;) analysiert und in einen übersichtlichen Report mit Optimierungstips umwandelt. Ein gutes und effizientes Hilfsmittel zur Optimierung der Serverkonfiguration (my.cnf).<br />
<span id="more-96"></span><br />
Hilft beim optimieren von:</p>
<ul>
<li>Slow Query Log</li>
<li>Max Connections</li>
<li>Worker Threads</li>
<li>Key Buffer</li>
<li>Query Cache</li>
<li>Sort Buffer</li>
<li>Joins</li>
<li>Temp Tables</li>
<li>Table (Open &#038; Definition) Cache</li>
<li>Table Locking</li>
<li>Table Scans (read_buffer)</li>
<li>Innodb Status </li>
</ul>
<p>Kompatibel mit allen gängigen mySQL Versionen.</p>
<p>Bereitgestellt wird der Tuning Primer von <a href="http://www.day32.com/MySQL/">Day32.com</a>. Download: <a href="http://www.day32.com/MySQL/tuning-primer.sh">mySQL Tuning primer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/mysql-tuning-primer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gezieltes entpacken von grossen TAR&#8217;s</title>
		<link>http://blog.alonso.ch/paste-bin/gezieltes-entpacken-von-grossen-tars/</link>
		<comments>http://blog.alonso.ch/paste-bin/gezieltes-entpacken-von-grossen-tars/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 19:55:31 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Tar]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=82</guid>
		<description><![CDATA[Um einzelne Dateien und Ordner aus einem TAR zu extrahieren muss nicht das komplette Archiv entpackt werden. Das spart gerade bei grösseren Archiven nicht nur Speicherplatz &#8211; sondern auch meist wertvolle Zeit und Systemresourcen. Folgende Beispiele dienen dazu als Lösungsansatz. Archivinhalt auflisten &#8211; ohne entpacken Inhalt komplett auflisten: tar -tvf MEINTAR.tar.gz Inhalt auflisten und filtern: [...]]]></description>
			<content:encoded><![CDATA[<p>Um einzelne Dateien und Ordner aus einem TAR zu extrahieren muss nicht das komplette Archiv entpackt werden. Das spart gerade bei grösseren Archiven nicht nur Speicherplatz &#8211; sondern auch meist wertvolle Zeit und Systemresourcen. Folgende Beispiele dienen dazu als Lösungsansatz.</p>
<p><strong>Archivinhalt auflisten &#8211; ohne entpacken</strong></p>
<p>Inhalt komplett auflisten:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-tvf</span> MEINTAR.tar.gz</pre></div></div>

<p>Inhalt auflisten und filtern:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-tvf</span> MEINTAR.tar.gz <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> suchwort</pre></div></div>

<p><span id="more-82"></span><br />
Diese Information ist eine gesunde Basis für die nächsten Schritte <img src='http://blog.alonso.ch/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><strong>Einzelne Dateien entpacken</strong></p>
<p>Einzelne Datei aus einem TAR entpacken:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zxvf</span> MEINTAR.tar.gz ordner1<span style="color: #000000; font-weight: bold;">/</span>ordner2<span style="color: #000000; font-weight: bold;">/</span>datei1.jpg</pre></div></div>

<p>Einzelne Ordner/Pfade rekursiv aus einem TAR entpacken:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zxvf</span> MEINTAR.tar.gz ordner1<span style="color: #000000; font-weight: bold;">/</span>ordner2<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Richtig flexibel wird das entpacken mit Wildcard-Filtern:</p>
<p>Rekursiv aus TAR mit Wildcard-Filter entpacken:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> xfv MEINTAR.tar.gz  <span style="color: #660033;">--wildcards</span> <span style="color: #660033;">--no-anchored</span> <span style="color: #ff0000;">'settings*'</span></pre></div></div>

<p>Einzelne Dateitypen aus TAR mit Wildcard-Filter entpacken:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> xfv MEINTAR.tar.gz  <span style="color: #660033;">--wildcards</span> <span style="color: #660033;">--no-anchored</span> <span style="color: #ff0000;">'*.jpg'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/gezieltes-entpacken-von-grossen-tars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ByeBye Port 25</title>
		<link>http://blog.alonso.ch/paste-bin/byebye-port-25/</link>
		<comments>http://blog.alonso.ch/paste-bin/byebye-port-25/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 02:36:07 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[Sicherheit]]></category>
		<category><![CDATA[E-Mail]]></category>
		<category><![CDATA[SMTP]]></category>
		<category><![CDATA[Swisscom]]></category>
		<category><![CDATA[TLS]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=70</guid>
		<description><![CDATA[Viele DSL/Cable Provider neigen momentan mehr oder weniger berechtigterweise dazu den normalen SMTP Port 25 für ausgehende Mails zu sperren. Ein aktuelles Beispiel wäre momentan gerade Swisscom/Bluewin, wie Inside-IT berichtet. Im aktuellen Fall erhällt der heimische Nutzer folgende Zustellmeldung per E-Mail zurückgeschickt: Ihre Nachricht hat einige oder alle Empfänger nicht erreicht. Betreff: ***** Gesendet am: [...]]]></description>
			<content:encoded><![CDATA[<p>Viele DSL/Cable Provider neigen momentan mehr oder weniger berechtigterweise dazu den normalen SMTP Port 25 für ausgehende Mails zu sperren. Ein aktuelles Beispiel wäre momentan gerade Swisscom/Bluewin, wie <a href="http://www.inside-it.ch/frontend/insideit?_d=_article&#038;site=ii&#038;news.id=20588">Inside-IT</a> berichtet.<br />
<span id="more-70"></span><br />
Im aktuellen Fall erhällt der heimische Nutzer folgende Zustellmeldung per E-Mail zurückgeschickt:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Ihre Nachricht hat einige oder alle Empfänger nicht erreicht.
      Betreff:  ***** 
      Gesendet am:      dd.mm.yyyy HH:MM
Folgende(r) Empfänger kann/können nicht erreicht werden:
'*****' am dd.mm.yyyy HH:MM
573 573  
Authentifizierte Verbindungen nicht moeglich. Bitte nutzen Sie den Port 587 oder kontaktieren Sie uns unter 0800 800 800. 
Connexions authentifiees pas possible. Veuillez utiliser le port 587 ou nous appeler au 0800 800 800.
Collegamenti autenticati non possibili. Prego voi uso la porta 587 oppure contattare il numero 0800 800 800.
Authenticated connections not possible. Please use port 587 or contact us on 0800 800 800.</pre></div></div>

<p>Offenbar hat dieser Schritt bei vielen Providern erheblichen Supportaufwand produziert. Zumindest eröffneten <a href="http://support.hostpoint.ch/index.php?page=DefconDetailPage&#038;defcon=455">Hostpoint</a> und <a href="http://www.cyon.ch/status/statusentry.php?id=365">Cyon</a> Statustickets zu dieser Problematik. Ebenfalls wurde auf der <a href="http://www.mail-archive.com/swinog@lists.swinog.ch/msg04276.html">Swinog Mailingliste</a> ordentlich darüber diskutiert.</p>
<p>Offiziell will man dadurch das versenden von Spam über Mailserver ohne Authentifizierung/Verschlüsselung unterbinden (z.B. durch Viren). Ob die entsprechenden Mailserver unter Port 587 (Submission) aber sicherer konfiguriert sind bezweifle ich. Zumal auch hier eine Verschlüsselung (TLS) nicht zwingend erforderlich ist.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/byebye-port-25/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cowsay &#8211; Ascii Spass für die Konsole</title>
		<link>http://blog.alonso.ch/paste-bin/cowsay-ascii-spass-fur-die-konsole/</link>
		<comments>http://blog.alonso.ch/paste-bin/cowsay-ascii-spass-fur-die-konsole/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 00:55:56 +0000</pubDate>
		<dc:creator>Alonso</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[paste.bin]]></category>
		<category><![CDATA[ASCII]]></category>
		<category><![CDATA[Lenny]]></category>

		<guid isPermaLink="false">http://blog.alonso.ch/?p=57</guid>
		<description><![CDATA[Cowsay (bzw. Cowthink) erstellt ein paar simple ASCII-Grafiken auf der Konsole mit einem beliebigen Textinhalt. Könnte man z.B. benutzen um MOTD-Banner zu erstellen, oder die Benutzer über die .bashrc auf eine spezielle Art und Weise zu begrüssen. Installation unter Debian Lenny: apt-get install cowsay ln -s /usr/games/cowsay /usr/bin/cowsay Das wars eigentlich schon. Ein erster Test: [...]]]></description>
			<content:encoded><![CDATA[<p>Cowsay (bzw. Cowthink) erstellt ein paar simple ASCII-Grafiken auf der Konsole mit einem beliebigen Textinhalt. Könnte man z.B. benutzen um MOTD-Banner zu erstellen, oder die Benutzer über die .bashrc auf eine spezielle Art und Weise zu begrüssen.<br />
<span id="more-57"></span><br />
Installation unter Debian Lenny:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> cowsay
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>games<span style="color: #000000; font-weight: bold;">/</span>cowsay <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>cowsay</pre></div></div>

<p>Das wars eigentlich schon.</p>
<p>Ein erster Test:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">cowsay <span style="color: #ff0000;">&quot;blog.alonso.ch&quot;</span></pre></div></div>

<p>Müsste zu folgendem Resultat führen:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"> ________________
&lt; blog.alonso.ch &gt;
 ----------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||</pre></div></div>

<p>Unter <em>/usr/share/cowsay/cows/</em> sind ausserdem diverse Templates vorhanden, welche alternativ über den Parameter -f verwendet werden können.</p>
<p>Ein weiteres Beispiel:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">cowsay <span style="color: #660033;">-f</span> bunny <span style="color: #ff0000;">&quot;blog.alonso.ch&quot;</span></pre></div></div>

<p>Müsste zu folgendem Resultat führen:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"> ________________
&lt; blog.alonso.ch &gt;
 ----------------
  \
   \   \
        \ /\
        ( )
      .( o ).</pre></div></div>

<p>Natürlich kann die Kuh auch über die Pipe gefüttert werden.</p>
<p>Ein letztes Beispiel:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>meminfo <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> MemFree <span style="color: #000000; font-weight: bold;">|</span> cowsay <span style="color: #660033;">-f</span> tux</pre></div></div>

<p>Müsste zu folgendem Resultat führen:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">  ____________________
&lt; MemFree: 369624 kB &gt;
 --------------------
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/</pre></div></div>

<p>Natürlich kann die Kuh noch viel mehr, siehe Manpage</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alonso.ch/paste-bin/cowsay-ascii-spass-fur-die-konsole/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

