<?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>Linux &#8211; Everything is Broken</title>
	<atom:link href="https://play.datalude.com/blog/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://play.datalude.com/blog</link>
	<description>Efficiency vs. Inefficiency, in a no-holds barred fight.</description>
	<lastBuildDate>Wed, 22 Apr 2026 07:57:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Copy tmux Scroll Buffer to a File</title>
		<link>https://play.datalude.com/blog/2025/10/copy-tmux-scroll-buffer-to-a-file/</link>
					<comments>https://play.datalude.com/blog/2025/10/copy-tmux-scroll-buffer-to-a-file/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 10 Oct 2025 03:31:12 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=774</guid>

					<description><![CDATA[tmux is super handy for long running commands. Especially if you have a dodgy connection which is likely to break: the command will keep running and you can re-attach to the session to save the day. But as a dyed-in-the-wool bash user, I've kinda got used to being able to scroll up and down my ... <a title="Copy tmux Scroll Buffer to a File" class="read-more" href="https://play.datalude.com/blog/2025/10/copy-tmux-scroll-buffer-to-a-file/" aria-label="Read more about Copy tmux Scroll Buffer to a File">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">tmux is super handy for long running commands. Especially if you have a dodgy connection which is likely to break: the command will keep running and you can re-attach to the session to save the day.  </p>



<p class="wp-block-paragraph">But as a dyed-in-the-wool bash user, I've kinda got used to being able to scroll up and down my command history and copy items from there. But I always have to search the internet the exact commands I need in tmux. Here's an easy way to dump the whole tmux history buffer to a text file without complicated edit/scroll/copy start/copy end combinations. We'll assume your tmux prefix key is the default CTRL-B</p>



<pre class="wp-block-code"><code># default prefix key and colon. opens the command pane, at the bottom
CTRL-B  : 
# send whole history to tmux buffer
capture-pane -S -       
# get ready for another command, tmux
CTRL-B   : 
<code># self explanatory</code><code>save-buffer ~/tmux_output.txt       </code> </code></pre>



<p class="wp-block-paragraph">Now you can use your text editor to look at the command history, alerts, and outputs. I had to use this recently when I piped a long running script through tee -a but it failed to send any of the screen output to the specified text file. This was a lifesaver.</p>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2025/10/copy-tmux-scroll-buffer-to-a-file/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Advanced Bash logging to handle errors.</title>
		<link>https://play.datalude.com/blog/2025/09/advanced-bash-logging-to-handle-errors/</link>
					<comments>https://play.datalude.com/blog/2025/09/advanced-bash-logging-to-handle-errors/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 01 Sep 2025 07:27:41 +0000</pubDate>
				<category><![CDATA[Bash Script]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[script]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=759</guid>

					<description><![CDATA[So we've all done a quick log from a bash script, which looks like this That's great for small scripts. But sometimes you find that its not logging errors, which are also helpful, and you need to add those: And different commands behave differently, so it all starts to become complicated. But there's an easier ... <a title="Advanced Bash logging to handle errors." class="read-more" href="https://play.datalude.com/blog/2025/09/advanced-bash-logging-to-handle-errors/" aria-label="Read more about Advanced Bash logging to handle errors.">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">So we've all done a quick log from a bash script, which looks like this </p>



<pre class="wp-block-code"><code>LOGFILE="logs/$(date +%F)_backup.log"
# Append to the file
restic backup /etc/ &gt;&gt; $LOGFILE
find /root/scripts/ -type f -name "restic*.log" -mtime +14 -delete -print &gt;&gt; $LOGFILE</code></pre>



<p class="wp-block-paragraph">That's great for small scripts. But sometimes you find that its not logging errors, which are also helpful, and you need to add those:</p>



<pre class="wp-block-code"><code>LOGFILE="logs/$(date +%F)_backup.log"
# Append to the file
restic backup /etc/ 2&gt;&amp;1 &gt;&gt; $LOGFILE
find /root/scripts/ -type f -name "restic*.log" -mtime +14 -delete -print 2&gt;&amp;1 &gt;&gt; $LOGFILE</code></pre>



<p class="wp-block-paragraph">And different commands behave differently, so it all starts to become complicated. But there's an easier way. Two actually. The first is to use curly brackets to contain all the commands you want to log, and then pipe it through tee at the end. Commands after that block won't be logged. </p>



<span id="more-759"></span>



<pre class="wp-block-code"><code>LOGFILE="logs/$(date +%F)_backup.log"
{
echo "Starting Restic backup at $(date)"
restic backup /etc/
find /root/scripts/ -type f -name "restic*.log" -mtime +14 -delete -print
echo "Restic backup and maintenance completed"
} 2>&amp;1 | tee -a "${LOGFILE}"</code></pre>



<p class="wp-block-paragraph">And then there's the slightly less readable command substitution method. </p>



<pre class="wp-block-code"><code>exec &gt; &gt;(tee -a "${LOGFILE}") 2&gt;&amp;1
echo "Starting Restic backup at $(date)"
$RESTIC backup /etc/
find /root/scripts/ -type f -name "restic*.log" -mtime +14 -delete -print
echo "Restic backup and maintenance completed"</code></pre>



<h3 class="wp-block-heading">Comparison</h3>



<p class="wp-block-paragraph">Both methods will log all output of all commands, including errors. I find the curly brackets way slightly easier to read. It also allows you to select which commands are logged, but putting them inside the brackets or not. On the other hand, the exec method will log everything until the end of the script, which may or may not be desirable. Curly braces also seems to be more widely compatible. </p>



<p class="wp-block-paragraph">There may be other considerations, different performance considerations and buffering for heavy duty scripts, but that's beyond my regular use cases. </p>



<p class="wp-block-paragraph">Will just add a poor-man's log rotation trick for compleness, and so I can copy and paste it. </p>



<pre class="wp-block-code"><code># Start logging to rolling logfile
LOGFILE=/path/to.log
KEEPLINES=5000
{
            ### commands
} 2>&amp;1 | tee -a "${LOGFILE}"

# Keep last XXXX lines of rolling logfile, defined above in KEEPLINES
tail -n $KEEPLINES "$LOGFILE" > "$LOGFILE".tmp
mv -f "$LOGFILE".tmp "$LOGFILE"</code></pre>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2025/09/advanced-bash-logging-to-handle-errors/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Google Gemini bad qdrant systemd advice</title>
		<link>https://play.datalude.com/blog/2025/08/google-gemini-bad-qdrant-systemd-advice/</link>
					<comments>https://play.datalude.com/blog/2025/08/google-gemini-bad-qdrant-systemd-advice/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 06 Aug 2025 02:00:38 +0000</pubDate>
				<category><![CDATA[General IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=742</guid>

					<description><![CDATA[Sometimes I give AI a shot. This was one of the occasions where I did, and it ended up costing me more time that actually trying to solve the problem myself. I had a request to run qdrant database, and I didn't want to do it under docker, due to all the extra nonsense that ... <a title="Google Gemini bad qdrant systemd advice" class="read-more" href="https://play.datalude.com/blog/2025/08/google-gemini-bad-qdrant-systemd-advice/" aria-label="Read more about Google Gemini bad qdrant systemd advice">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Sometimes I give AI a shot. This was one of the occasions where I did, and it ended up costing me more time that actually trying to solve the problem myself. </p>



<p class="wp-block-paragraph">I had a request to run qdrant database, and I didn't want to do it under docker, due to all the extra nonsense that entails. So having installed it, basically just dropping a binary on the filesystem, I wanted to run it as a systemd service, under a specific user, qdrant. <br><br>On the qdrant site, they don't give an example, so I thought it would be quickest to ask Google Gemini, which quickly squirted out a reply. So I activated it and was confused when it wouldn't start. About an hour later, I figured out that the inline comments which Gemini had put in the systemd service files are not allowed. And when telling Gemini about this it cheerfully admitted that it knew about this all along:</p>



<figure class="wp-block-image size-full"><a href="https://play.datalude.com/blog/wp-content/uploads/2025/08/googleduh_16-50.jpg"><img fetchpriority="high" decoding="async" width="838" height="712" src="https://play.datalude.com/blog/wp-content/uploads/2025/08/googleduh_16-50.jpg" alt="" class="wp-image-743" srcset="https://play.datalude.com/blog/wp-content/uploads/2025/08/googleduh_16-50.jpg 838w, https://play.datalude.com/blog/wp-content/uploads/2025/08/googleduh_16-50-300x255.jpg 300w, https://play.datalude.com/blog/wp-content/uploads/2025/08/googleduh_16-50-768x653.jpg 768w" sizes="(max-width: 838px) 100vw, 838px" /></a></figure>



<p class="wp-block-paragraph">Even though I 'shared' the finding, I'm skeptical that Gemini will learn from it, so here is the working qdrant systemd file for anyone interested. </p>



<pre class="wp-block-preformatted"><code><code>[Unit]
Description=Qdrant Vector Database
After=network.target

[Service]
# sudo adduser --system --no-create-home --group qdrant
User=qdrant
Group=qdrant

ExecStart=/usr/bin/qdrant --config-path /etc/qdrant/config.yaml

# Put all data in here, please
WorkingDirectory=/qdrant

# Increase open file limit for better performance
LimitNOFILE=65536

Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target</code></code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2025/08/google-gemini-bad-qdrant-systemd-advice/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mysql 8 mysql_native_password deprecation error. MY-013360</title>
		<link>https://play.datalude.com/blog/2024/02/mysql-8-mysql_native_password-deprecation-error-my-013360/</link>
					<comments>https://play.datalude.com/blog/2024/02/mysql-8-mysql_native_password-deprecation-error-my-013360/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 14 Feb 2024 08:10:10 +0000</pubDate>
				<category><![CDATA[General IT]]></category>
		<category><![CDATA[error logs]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mysql]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=731</guid>

					<description><![CDATA[Checking in on a Mysql 8.x server the other day I found the following in the /var/log/mysql/error.log But not just one of them. Lots and lots of them, one a second, for the last few months. To be sure it didn't seem critical, but having lots of crap in your logs means its obscuring the really ... <a title="Mysql 8 mysql_native_password deprecation error. MY-013360" class="read-more" href="https://play.datalude.com/blog/2024/02/mysql-8-mysql_native_password-deprecation-error-my-013360/" aria-label="Read more about Mysql 8 mysql_native_password deprecation error. MY-013360">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Checking in on a Mysql 8.x server the other day I found the following in the /var/log/mysql/error.log </p>



<pre class="wp-block-code"><code>&#91;Warning] &#91;MY-013360] &#91;Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'</code></pre>



<p class="wp-block-paragraph">But not just one of them. Lots and lots of them, one a second, for the last few months. To be sure it didn't seem critical, but having lots of crap in your logs means its obscuring the really important bits, and making it hard to detect real problems. </p>



<p class="wp-block-paragraph">So how to get rid of them? Well not too hard as it happens. First option is to suppress them in your mysql config. I didn't know this was an option, but yes, you can add the following line to your mysqld config file and they don't get logged any more. </p>



<pre class="wp-block-code"><code>log_error_suppression_list='MY-013360'</code></pre>



<span id="more-731"></span>



<p class="wp-block-paragraph">And restart. This can also be set without restarting the server using SET GLOBAL:</p>



<pre class="wp-block-code"><code>mysql> set global log_error_suppression_list='MY-013360' ;<br>Query OK, 0 rows affected (0.00 sec)<br></code></pre>



<p class="wp-block-paragraph">Very useful if you just want to get rid of it while you're troubleshooting something. But now to get down to the root cause. How do we fix the error completely. Again not too hard. First of all we can take a look and see which user is the offender, and the default server policy. </p>



<pre class="wp-block-code"><code>mysql -e " show variables like 'default_authentication_plugin';"<br>  default_authentication_plugin = caching_sha2_password<br><br>mysql -e "select Host,User,plugin FROM  mysql.user;"<br>| Host      | User               | plugin                |<br>| localhost | guilty-user          | mysql_native_password |<br>| localhost | mysql.session    | caching_sha2_password |<br>| localhost | mysql.sys         | caching_sha2_password |<br>| localhost | root               | auth_socket             |<br></code></pre>



<p class="wp-block-paragraph">Well it was guilty-user, what a surprise. So lets fix that. The current password for guilty-user will be known to you &#8212; it'll be in the WP config file, or database connection string of whatever app is using it. Lets say its "F$ntasticPW", so we just ALTER the user using the same password:</p>



<pre class="wp-block-code"><code>mysql -e "ALTER USER 'guilty-user'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'F$ntasticPW';"</code></pre>



<p class="wp-block-paragraph">And there we have it. The app shouldn't even blink. And your monster db logs are gone. But as always, take a db backup before you try. </p>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2024/02/mysql-8-mysql_native_password-deprecation-error-my-013360/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Nice formatting for mysql show variables / show status</title>
		<link>https://play.datalude.com/blog/2024/02/nice-formatting-for-mysql-show-variables-show-status/</link>
					<comments>https://play.datalude.com/blog/2024/02/nice-formatting-for-mysql-show-variables-show-status/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 12 Feb 2024 08:20:22 +0000</pubDate>
				<category><![CDATA[General IT]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=727</guid>

					<description><![CDATA[Have you ever tried to get a variable out of mysql and your screen fills with dots and dashes from mysql's output? Turns out its pretty simple to get rid of with awk. That's all.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Have you ever tried to get a variable out of mysql and your screen fills with dots and dashes from mysql's output? Turns out its pretty simple to get rid of with awk. </p>



<pre class="wp-block-code"><code># Arrgh!<br>mysql -e "show variables" | grep innodb<br><br># Much better<br>mysql -e "show variables" | awk '{print $1 " = " $2}' | grep innodb</code></pre>



<p class="wp-block-paragraph">That's all. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2024/02/nice-formatting-for-mysql-show-variables-show-status/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>php-fpm monitoring for single domain</title>
		<link>https://play.datalude.com/blog/2023/06/php-fpm-monitoring-for-single-domain/</link>
					<comments>https://play.datalude.com/blog/2023/06/php-fpm-monitoring-for-single-domain/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 14 Jun 2023 10:05:35 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[script]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=709</guid>

					<description><![CDATA[Ran into this one recently and the solution came out of left field, so I thought I'd throw it out to the internet at large. I've got a server which is running php-fpm and nginx. However it has several websites running on it, each of which has its own php-fpm/pool.d/ profile. We were having a ... <a title="php-fpm monitoring for single domain" class="read-more" href="https://play.datalude.com/blog/2023/06/php-fpm-monitoring-for-single-domain/" aria-label="Read more about php-fpm monitoring for single domain">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Ran into this one recently and the solution came out of left field, so I thought I'd throw it out to the internet at large. I've got a server which is running php-fpm and nginx. However it has several websites running on it, each of which has its own php-fpm/pool.d/ profile. We were having a problem with one of the websites, which got a lot more traffic than the others, so we needed a way to monitor its php-fpm performance.<br><br>Setting up php monitoring is not hard. There are many guides around the internet. You put the line </p>



<pre class="wp-block-code"><code>pm.status_path = /status</code></pre>



<p class="wp-block-paragraph">in your fpm pool file, then add a block to your nginx config so that it can only be accessed by certain IP addresses. </p>



<span id="more-709"></span>



<pre class="wp-block-code"><code>        location ~ ^/status {
         access_log off;
         allow 127.0.0.1;    # localhost
         allow 12.23.34.45;   # my remote IP
         deny all;  
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         fastcgi_index index.php;
         include fastcgi_params;
         fastcgi_pass unix:/run/php/php-fpm-mysite.sock;
        }
</code></pre>



<p class="wp-block-paragraph">You access the URL mysite.com/status and all is good. </p>



<p class="wp-block-paragraph">Things get more complicated when you have a server where each domain has its own fpm pool file. The /status line in this case is just referring to that domain. If you access the mydomain.com/status URL from an external browser, the domain name resolves and nginx picks the correct php-fpm pool file, and you see the stats. </p>



<p class="wp-block-paragraph">Now consider using curl from localhost. </p>



<pre class="wp-block-code"><code> # On a server where there's only one pool file, this works. But when there are multiple pool files it doesn't know which one to use
curl http://127.0.0.1/status
# Can we resolve it with a Host header? No
 curl -H "Host: mysite.com" http://127.0.0.1/status
# Resolve looks hopeful, but actually it doesn't work with SSL
 curl --resolve 'mysite.com:443:127.0.0.1' https://127.0.0.1/status
# Maybe --insecure will help? No
 curl --resolve 'mysite.com:443:127.0.0.1' https://127.0.0.1/status --insecure
# Wait, maybe we can connect directly to the socket, and target the website that way! Nope.
curl --unix-socket /var/run/php/php-fpm-mysite.sock http://status/</code></pre>



<p class="wp-block-paragraph">After exhausting the Internet's wisdom on this, there didn't seem to be a way to get curl to fetch the information. It was needed locally so that it could be incorporated into a monitoring script, so allowing a remote IP to gather the info was not a desirable solution, although rapidly looking like the only option. </p>



<p class="wp-block-paragraph">Salvation came in the form of a program called cgi-fcgi which talks pure cgi-ese to the fpm socket. Or something like that. (apt install libfcgi-bin or yum install fcgi). Once installed, we can ask it for the information like this:</p>



<pre class="wp-block-code"><code>SCRIPT_NAME=/status SCRIPT_FILENAME=/status REQUEST_METHOD=GET cgi-fcgi -bind -connect /var/run/php/php-fpm-mysite.sock</code></pre>



<p class="wp-block-paragraph">So, incorporating that into a script we can monitor our website's fpm usage. I guess this could also be used in telegraf, zabbix and other monitoring solutions. And you can have a different status URL for each site/pool on the server. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2023/06/php-fpm-monitoring-for-single-domain/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Telegraf mysql monitor refuses to connect</title>
		<link>https://play.datalude.com/blog/2023/05/telegraf-mysql-monitor-refuses-to-connect/</link>
					<comments>https://play.datalude.com/blog/2023/05/telegraf-mysql-monitor-refuses-to-connect/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 16 May 2023 03:51:44 +0000</pubDate>
				<category><![CDATA[General IT]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=704</guid>

					<description><![CDATA[I'd set up a grafana server to collect some metrics from a few servers, and as part of that I wanted to get some Mysql data from a couple of them. Easy right? So on the first server I logged into mysql and set up a user for this: And the in /etc/telegraf/telegraf.conf I added: ... <a title="Telegraf mysql monitor refuses to connect" class="read-more" href="https://play.datalude.com/blog/2023/05/telegraf-mysql-monitor-refuses-to-connect/" aria-label="Read more about Telegraf mysql monitor refuses to connect">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">I'd set up a grafana server to collect some metrics from a few servers, and as part of that I wanted to get some Mysql data from a couple of them. Easy right? So on the first server I logged into mysql and set up a user for this:<br></p>



<span id="more-704"></span>



<pre class="wp-block-code"><code>CREATE USER 'telegraf-client'@'localhost' IDENTIFIED BY 'xxxxxxx';
GRANT REPLICATION CLIENT ON *.* TO 'telegraf-client'@'localhost' WITH MAX_USER_CONNECTIONS 5;
GRANT PROCESS ON *.* TO 'telegraf-client'@'localhost';
GRANT SELECT ON performance_schema.* TO 'telegraf-client'@'localhost';
FLUSH PRIVILEGES;</code></pre>



<p class="wp-block-paragraph">And the in /etc/telegraf/telegraf.conf I added:</p>



<pre class="wp-block-code"><code>&#91;&#91;inputs.mysql]]
  servers = &#91;"telegraf-client:xxxxxxxxxxx@tcp(127.0.0.1:3306)/"]</code></pre>



<p class="wp-block-paragraph">All good. Restart telegraf with systemctl and off we go: data flowed into grafana in a veritable torrent. </p>



<p class="wp-block-paragraph">On the second server, I did EXACTLY THE SAME THING, but all I could see in the mysql error log was [Warning] Access denied for user ' telegraf-client'@'127.0.0.1' (using password: YES)<br><br>I tried everything I could think of over several days. I tried localhost instead of the IP. I tried different quotes, I tried spaces in the brackets, I tried specifying information_schema database. I trawled forums. I tried deleting the user and recreating it as something else (maybe it didn't like the hyphen? getting desperate here). Nope. <br>I tried using the root user and deb-sys-maint. Nope. From the command line it would connect with 'localhost' but not 127.0.0.1. I checked the hosts file, the mysql config. Many many hours wasted. <br><br>Here is what worked. I have no idea why. The servers and setups were identical. This is the answer to one of the Mysteries of Linux: </p>



<pre class="wp-block-code"><code>servers = &#91;"telegraf-client:xxxxxxxxxx@unix(/var/run/mysqld/mysqld.sock)/"]</code></pre>



<p class="wp-block-paragraph">May it save you many hours. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2023/05/telegraf-mysql-monitor-refuses-to-connect/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>wp-cli &quot;Connection refused&quot; error</title>
		<link>https://play.datalude.com/blog/2022/11/wp-cli-connection-refused-error/</link>
					<comments>https://play.datalude.com/blog/2022/11/wp-cli-connection-refused-error/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 22 Nov 2022 08:11:08 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp-cli]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=690</guid>

					<description><![CDATA[Couldn't find anything about this with a few google searches so I decided to note it here. Weird problem: whenever I ran any wp-cli command, I'd get a list of 100+ lines of "Connection refused" before it actually did what I wanted. I tried a few things to figure it out, including So on a ... <a title="wp-cli &#34;Connection refused&#34; error" class="read-more" href="https://play.datalude.com/blog/2022/11/wp-cli-connection-refused-error/" aria-label="Read more about wp-cli &#34;Connection refused&#34; error">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Couldn't find anything about this with a few google searches so I decided to note it here. Weird problem: whenever I ran any wp-cli command, I'd get a list of 100+ lines of "Connection refused" before it actually did what I wanted. <br><br>I tried a few things to figure it out, including </p>



<ul class="wp-block-list">
<li>Searching the site for malware pointing to a blocked URL (no)</li>



<li>Checking the firewall logs (nothing)</li>



<li>Checking the db config, running performance tools on it to see that it wasn't exceeding max connections. (no) </li>



<li>Running tcpdump to see where wp-cli was trying to connect to (it wasn't)</li>



<li>Updating all plugins, themes,  (good to do anyway)</li>



<li>Checking db.php, which I found in wp-includes &#8230; which, hmmm, belongs to W3 Total Cache. </li>
</ul>



<p class="wp-block-paragraph">So on a hunch I tried </p>



<pre class="wp-block-code"><code>&gt; wp-cli plugin deactivate w3-total-cache 
Connection refused
Connection refused

... plus 200 more lines 

Connection refused
Connection refused
Connection refused
Plugin 'w3-total-cache' deactivated.

</code></pre>



<p class="wp-block-paragraph">&#8230; after which all wp-cli operations worked again. </p>



<p class="wp-block-paragraph">After some further digging, I enabled w3 Total Cache again, and found that it was configured to use redis, which wasn't running on the server. So the connection attempts were failing to connect to that. Pretty easy to sort out after that &#8230; </p>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2022/11/wp-cli-connection-refused-error/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Troubleshooting postfix using bcc to local user</title>
		<link>https://play.datalude.com/blog/2022/11/troubleshooting-postfix-using-bcc-to-local-user/</link>
					<comments>https://play.datalude.com/blog/2022/11/troubleshooting-postfix-using-bcc-to-local-user/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 17 Nov 2022 03:35:13 +0000</pubDate>
				<category><![CDATA[General IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[postfix]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=685</guid>

					<description><![CDATA[After routing mail through postfix to an external relay server (in this case gmail's smtp relay), all the mail from a server was routing correctly. Except after a couple of days I noticed a couple of strange bounces. Authentication at the gmail end was by IP address and domain, so any address xxxxx@domain.com could be ... <a title="Troubleshooting postfix using bcc to local user" class="read-more" href="https://play.datalude.com/blog/2022/11/troubleshooting-postfix-using-bcc-to-local-user/" aria-label="Read more about Troubleshooting postfix using bcc to local user">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">After routing mail through postfix to an external relay server (in this case gmail's smtp relay), all the mail from a  server was routing correctly. Except after a couple of days I noticed a couple of strange bounces. Authentication at the gmail end was by IP address and domain, so any address xxxxx@domain.com could be used to send email. But these were coming from yyyy@otherdomain.com so were being rejected with a helpful message by gmail. </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph"><code>The IP address you've 550-5.7.1 registered in your G Suite SMTP Relay service doesn't match domain of 550-5.7.1 the account this email is being sent from. If you are trying to relay 550-5.7.1 mail from a domain that isn't registered under your G Suite account 550-5.7.1 or has empty envelope-from, you must configure your mail server 550-5.7.1 either to use SMTP AUTH to identify the sending domain or to present 550-5.7.1 one of your domain names in the HELO or EHLO command. For more 550-5.7.1 information, please visit 550 5.7.1 <a rel="noreferrer noopener" href="https://support.google.com/a/answer/6140680#invalidcred" target="_blank">https://support.google.com/a/answer/6140680</a></code></p>
</blockquote>



<p class="wp-block-paragraph">Pretty helpful as messages go. Less helpful was the fact that there were several websites on the server and a couple of other apps, and I didn't have access to the admin panels of any of them. The mails, once bounced, were removed from postfix's queue, never to be seen again. Time for some detective work.  </p>



<span id="more-685"></span>



<p class="wp-block-paragraph">I found that the mails were heading for zzzz@domain.com so I figured if I could make those appear locally I'd be able to look at the source and see what had created them. This is not so hard to do in postfix. First of all you need a line in your main.cf </p>



<pre class="wp-block-code"><code># Added to troubleshoot rejection by gmail smtp           
# Need to add addresses to the file and run postmap on it 
recipient_bcc_maps = regexp:/etc/postfix/recipient_bcc_maps</code></pre>



<p class="wp-block-paragraph">Then  you need to add entries in your /etc/postfix/recipient_bcc_maps</p>



<pre class="wp-block-code"><code># run postmap recipient_bcc_maps after editing
/zzzz\@domain.com/  ubuntu
</code></pre>



<p class="wp-block-paragraph">After that run postmap recipient_bcc_maps and restart postfix for good measure. So now any mail headed to zzzz@domain.com will also be bcced to the local ubuntu user, were we can pick it up in /var/spool/mail/ubuntu </p>



<p class="wp-block-paragraph">All good. I waited. And waited. Then got bored of waiting and made a quick bash one liner to alert me when the ubuntu user's mail file changed. </p>



<pre class="wp-block-code"><code>while true; do if ls -hal "/var/spool/mail/ubuntu" | grep -q "Nov 15 07:14" ; then sleep 5 ; else mutt -s "changed" me@mydomain.com &lt;/dev/null ; break ; fi ; done
</code></pre>



<p class="wp-block-paragraph">So this is pretty crude but it works. Every 5 seconds it checks the date and time of the mail spool file (you'd need to change to the actual date of the file, of course), and if it changes it emails to me@mydomain.com. I ran that under 'screen' and two days later I got a notification, from which I was able to figure out which script on which domain had fired off the email. </p>



<p class="wp-block-paragraph">Maybe that one liner makes more sense as a script:</p>



<pre class="wp-block-code"><code>#!/bin/bash

FILE=/var/spool/mail/ubuntu
PATTERN="Oct 17 10:44"

while true;
do 
	if ls -hal "$FILE" | grep -q "$PATTERN" ; then 
		# Do nothing. 
		sleep 5
	else
		# echo "changed"
                # play fanfare.mp3
		mutt -s "changed" me@mydomain.com &lt;/dev/null
		break;
	fi 
done</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2022/11/troubleshooting-postfix-using-bcc-to-local-user/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Migrating from Notecase to CherryTree</title>
		<link>https://play.datalude.com/blog/2022/10/migrating-from-notecase-to-cherrytree/</link>
					<comments>https://play.datalude.com/blog/2022/10/migrating-from-notecase-to-cherrytree/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 10 Oct 2022 07:56:29 +0000</pubDate>
				<category><![CDATA[General IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://play.datalude.com/blog/?p=678</guid>

					<description><![CDATA[So I have a few documents which started life in TreePad. Then about 8 years ago I migrated them to Notecase, for reasons I don't remember. I hadn't opened them for a few months, but when I opened one in Notecase last week, I found out that they'd removed the everlasting Trial mode and they ... <a title="Migrating from Notecase to CherryTree" class="read-more" href="https://play.datalude.com/blog/2022/10/migrating-from-notecase-to-cherrytree/" aria-label="Read more about Migrating from Notecase to CherryTree">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">So I have a few documents which started life in TreePad. Then about 8 years ago I migrated them to Notecase, for reasons I don't remember. I hadn't opened them for a few months, but when I opened one in Notecase last week, I found out that they'd removed the everlasting Trial mode and they now have only a 30-day trial or paid modes. The prices are not unreasonable, but given that I hadn't opened any documents in the 6 months since they implemented the change, I decided to look for another Note Organizer. My search took me to CherryTree. </p>



<p class="wp-block-paragraph">CherryTree claims to be able to import from Notecase. However I tried various experiments, exporting to HTML, to Notecase HTML, plain text, MD, etc, but I couldn't get it to import any of the notes <em>nested</em> as originally intended. I could have sat there and dragged them around with the mouse until they were in the right place, and that would have been do-able, but a boring couple of hours. So I looked further. </p>



<p class="wp-block-paragraph">I found mention in the Github Issues page of <a rel="noreferrer noopener" href="https://github.com/giuspen/cherrytree" target="_blank">CherryTree</a> that the previous version of CherryTree was able to correctly import the notes structure from NoteCase. But that since the  developer is in the process of migrating the code from python to c++ (I think), then that functionality had been abandoned until he can re-implement it. I tried to find old versions of the app as flatpak, snap, and AppImage, but there weren't any.  So here's the convoluted story of how I got it to work. </p>



<ul class="wp-block-list">
<li>Download Ubuntu 16.04 Desktop and install it as a virtual machine in VirtualBox</li>



<li>Install the relevant CherryTree 0.34 version from <a href="https://launchpad.net/~giuspen/+archive/ubuntu/ppa/+packages" target="_blank" rel="noreferrer noopener">here</a>. </li>



<li>Export from the current NoteCase file as a notecase ncd. (ncdb and ncz formats don't work).  In order to get Notecase to start in 30 day trial mode I needed to first remove the ~/.notecase/ directory contents. </li>



<li>Open the ncd file in CherryTree 0.34 on Ubuntu 16. Save as CherryTree .ctb format. </li>



<li>Copy files back to main machine where they could be opened with a recent version of CherryTree. </li>
</ul>



<p class="wp-block-paragraph">OK, so now that's looking good, except all the notes are imported as rtf instead of plain text. Probably not a problem, but in my case it was, as I relied on monospace font for formatting in the originals, so I needed text format. The .ctb file format is in sqlite3, so I used dbeaver to examine it, and came up with the following SQL code to change all the rtf notes into txt notes. </p>



<pre class="wp-block-code"><code># Strip rtf header and footer from note
UPDATE node SET txt = REPLACE(txt,'&lt;?xml version="1.0" ?&gt;&lt;node&gt;&lt;rich_text&gt;','') WHERE is_richtxt = "1";
UPDATE node SET txt = REPLACE(txt,'&lt;/rich_text&gt;&lt;/node&gt;','') WHERE is_richtxt = "1";
# Set flags
UPDATE node SET syntax = "plain-text" WHERE is_richtxt = "1";
UPDATE node SET is_richtxt = "0" WHERE is_richtxt = "1";</code></pre>



<p class="wp-block-paragraph">And that was that. Probably more work than I initially intended, but the journey is part of the fun. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://play.datalude.com/blog/2022/10/migrating-from-notecase-to-cherrytree/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
