Puppetdb Report to Csv

Query puppetdb for the last report of this node, and convert the returned json document to csv with the help of jq:

curl \
	-s -G \
	--cert /etc/puppetlabs/puppet/ssl/certs/$(hostname -f).pem \
	--key /etc/puppetlabs/puppet/ssl/private_keys/$(hostname -f).pem \
	--cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem  \
	https://puppetdb:8081/pdb/query/v4 \
	--data-urlencode 'query=[
		"from", "reports",
		["=", "certname", "'$(hostname -f)'"],
		["order_by", [["end_time", "desc"]]],
		["limit", 1]
	]' | jq -r ' .[] |
		[
			.certname,
			.status,
			.end_time,
			( .metrics.data[] | select(.name == "total") | select(.category == "time") | .value | tostring )
		] | @csv'

This will result in something like this

"Foo","unchanged","2019-04-05T18:26:00.866Z","10.1234"

Mutt Segfault when piping message

mutt 1.7.2-1+deb9u1 from Debian stretch segfaults when piping a message? Turns out to be related to 860176, at least for me.

The following patch on top of the 1.7.2-1+deb9u1 source package fixes the segfault for me:

Index: mutt-1.7.2/imap/message.c
===================================================================
--- mutt-1.7.2.orig/imap/message.c
+++ mutt-1.7.2/imap/message.c
@@ -508,7 +508,7 @@ int imap_fetch_message (CONTEXT *ctx, ME
	  }
	  else
	    pbar = NULL;
-	  if (imap_read_literal (msg->fp, idata, bytes, &progressbar) < 0)
+	  if (imap_read_literal (msg->fp, idata, bytes, pbar) < 0)
	    goto bail;
	  /* pick up trailing line */
	  if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)

Goodby Octopress, Welcome Hugo

Migrated from Octopress to Hugo with the help of octohug. It went quite well, with a couple of problems due to multiline titles, or a literal . written as dot by octopress.

I chose the Hugo Flex theme, since it uses no javascript and is quite tiny. To use more screen space, I changed this:

diff --git a/assets/css/base.css b/assets/css/base.css
index 93ee10c..da5a2d1 100644
--- a/assets/css/base.css
+++ b/assets/css/base.css
@@ -104,7 +104,6 @@ code {
 }

 .u-wrapper {
-  max-width: 42rem;
   margin: auto;
 }

Disabled tags and categories in config.yaml:

disableKinds: ["taxonomy", "taxonomyTerm"]

find jenkins jobs for email address

import hudson.tasks.Mailer
import hudson.plugins.emailext.ExtendedEmailPublisher

def mail = 'foo@bar.com'

Jenkins.instance.getAllItems(AbstractItem.class).collect{ Jenkins.instance.getJob( it.fullName ) }.findAll { job ->
  job?.getPublishersList()?.any {
    (it instanceof Mailer && it.recipients =~ mail) || (it instanceof ExtendedEmailPublisher && it.recipientList =~
mail)
  }
}.collect{ it.fullName }

skype and dbus

Is Skype crashing with

Thread 1 "skypeforlinux" received signal SIGSEGV, Segmentation fault.
0x00007ffff49085d0 in _dbus_header_get_byte_order () from /lib/x86_64-linux-gnu/libdbus-1.so.3

Try stopping dbus:

systemctl stop dbus.socket dbus.service

icinga2

Run a command through sudo:

object CheckCommand "sudo_mailq" {
	import "mailq"

	command = [
		"/usr/bin/sudo",
		"/usr/lib/nagios/plugins/check_mailq"
	]
}

immediate shutdown after boot

Is your linux configured to shut down on power button press and immediately shuts down after the next boot?

Use acpi_listen to check if you are getting two events for each button press:

button/power PBTN 00000080 00000000
button/power LNXPWRBN:00 00000080 0000001c

Hack around it by passing the event information to your script /etc/acpi/events/powerbtn:

...
action=../../etc/acpi/powerbtn.sh %e

And reacting only on one /etc/acpi/powerbtn.sh:

...
[ "$2" == "PBTN" ] || exit 0

bash

Is Bash matching lower- and uppercase files seemingly not caring about shopt -u nocaseglob, e.g.:

$ touch foo FOO
$ echo [a-z]*
foo FOO

then set LC_COLLATE to C, see man bash / Pattern Matching / LC_COLLATE:

The sorting order of characters in range expressions is determined by the current locale and the values of the LC_COLLATE or LC_ALL shell variables, if set. To obtain the traditional interpretation of range expressions, where [a-d] is equivalent to [abcd], set value of the LC_ALL shell variable to C, or […]

apt secure and stretch

Has your own repository stopped working for stretch with something like this:

W: GPG error ... Release: The following signatures were invalid: ...
W: The repository ... Release' is not signed.

Check that your Release.gpg files contain sha256 signatures (Hint: --cert-digest-algo,), not sha1.