1 <?xml version=
"1.0" encoding=
"ISO-8859-1"?>
2 <rss version='
2.0' xmlns:lj='http://www.livejournal.org/rss/lj/
1.0/'
>
4 <title>Petter Reinholdtsen - Entries from March
2024</title>
5 <description>Entries from March
2024</description>
6 <link>http://www.hungry.com/~pere/blog/
</link>
10 <title>Plain text accounting file from your bitcoin transactions
</title>
11 <link>http://www.hungry.com/~pere/blog/Plain_text_accounting_file_from_your_bitcoin_transactions.html
</link>
12 <guid isPermaLink=
"true">http://www.hungry.com/~pere/blog/Plain_text_accounting_file_from_your_bitcoin_transactions.html
</guid>
13 <pubDate>Thu,
7 Mar
2024 18:
00:
00 +
0100</pubDate>
14 <description><p
>A while back I wrote a small script to extract the Bitcoin
15 transactions in a wallet in the
16 <ahref=
"https://plaintextaccounting.org/
">ledger plain text accounting
17 format
</a
>. The last few days I spent some time to get it working
18 better with more special cases. In case it can be useful for others,
19 here is a copy:
</p
>
21 <p
><blockquote
><pre
>
23 # -*- coding: utf-
8 -*-
24 # Copyright (c)
2023-
2024 Petter Reinholdtsen
26 from decimal import Decimal
33 def format_float(num):
34 return numpy.format_float_positional(num, trim=
'-
')
37 u
'amount
' :
'Assets:BTC:main
',
41 '<some address
>' :
'Assets:bankkonto
',
42 '<some address
>' :
'Assets:bankkonto
',
46 proc = subprocess.Popen(cmd,stdout=subprocess.PIPE)
47 j = json.loads(proc.communicate()[
0], parse_float=Decimal)
51 # get all transactions for all accounts / addresses
56 cmd = [
'bitcoin-cli
',
'listtransactions
',
'*
', str(limit)]
58 txs.extend(exec_json(cmd))
60 # Useful for debugging
61 with open(
'transactions.json
') as f:
62 txs.extend(json.load(f, parse_float=Decimal))
64 for tx in sorted(txs, key=lambda a: a[
'time
']):
65 # print tx[
'category
']
66 if
'abandoned
' in tx and tx[
'abandoned
']:
68 if
'confirmations
' in tx and
0 >= tx[
'confirmations
']:
70 when = time.strftime(
'%Y-%m-%d %H:%M
', time.localtime(tx[
'time
']))
71 if
'message
' in tx:
72 desc = tx[
'message
']
73 elif
'comment
' in tx:
74 desc = tx[
'comment
']
75 elif
'label
' in tx:
76 desc = tx[
'label
']
79 print(
"%s %s
" % (when, desc))
80 if
'address
' in tx:
81 print(
" ; to bitcoin address %s
" % tx[
'address
'])
83 print(
" ; missing address in transaction, txid=%s
" % tx[
'txid
'])
84 print(f
" ; amount={tx[
'amount
']}
")
85 if
'fee
'in tx:
86 print(f
" ; fee={tx[
'fee
']}
")
87 for f in accounts.keys():
88 if f in tx and Decimal(
0) != tx[f]:
90 print(
" %-
20s %s BTC
" % (accounts[f], format_float(amount)))
91 if
'fee
' in tx and Decimal(
0) != tx[
'fee
']:
92 # Make sure to list fee used in several transactions only once.
93 if
'fee
' in tx and tx[
'txid
'] in txidfee \
94 and tx[
'fee
'] == txidfee[tx[
'txid
']]:
97 fee = tx[
'fee
']
98 print(
" %-
20s %s BTC
" % (accounts[
'amount
'], format_float(fee)))
99 print(
" %-
20s %s BTC
" % (
'Expences:BTC-fee
', format_float(-fee)))
100 txidfee[tx[
'txid
']] = tx[
'fee
']
102 if
'address
' in tx and tx[
'address
'] in addresses:
103 print(
" %s
" % addresses[tx[
'address
']])
105 if
'generate
' == tx[
'category
']:
106 print(
" Income:BTC-mining
")
108 if amount
< Decimal(
0):
109 print(f
" Assets:unknown:sent:update-script-addr-{tx[
'address
']}
")
111 print(f
" Assets:unknown:received:update-script-addr-{tx[
'address
']}
")
115 print(
"# Found %d transactions
" % c)
117 print(f
"# Warning: Limit {limit} reached, consider increasing limit.
")
123 </pre
></blockquote
></p
>
125 <p
>It is more of a proof of concept, and I do not expect it to handle
126 all edge cases, but it worked for me, and perhaps you can find it
127 useful too.
</p
>
129 <p
>To get a more interesting result, it is useful to map accounts sent
130 to or received from to accounting accounts, using the
131 <tt
>addresses
</tt
> hash. As these will be very context dependent, I
132 leave out my list to allow each user to fill out their own list of
133 accounts. Out of the box,
'ledger reg BTC:main
' should be able to
134 show the amount of BTCs present in the wallet at any given time in the
135 past. For other and more valuable analysis, a account plan need to be
136 set up in the
<tt
>addresses
</tt
> hash. Here is an example
137 transaction:
</p
>
139 <p
><blockquote
><pre
>
140 2024-
03-
07 17:
00 Donated to good cause
141 Assets:BTC:main -
0.1 BTC
142 Assets:BTC:main -
0.00001 BTC
143 Expences:BTC-fee
0.00001 BTC
144 Expences:donations
0.1 BTC
145 </pre
></blockquote
></p
>
147 <p
>It need a running Bitcoin Core daemon running, as it connect to it
148 using
<tt
>bitcoin-cli listtransactions *
100000</tt
> to extract the
149 transactions listed in the Wallet.
</p
>
151 <p
>As usual, if you use Bitcoin and want to show your support of my
152 activities, please send Bitcoin donations to my address
153 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
158 <title>RAID status from LSI Megaraid controllers using free software
</title>
159 <link>http://www.hungry.com/~pere/blog/RAID_status_from_LSI_Megaraid_controllers_using_free_software.html
</link>
160 <guid isPermaLink=
"true">http://www.hungry.com/~pere/blog/RAID_status_from_LSI_Megaraid_controllers_using_free_software.html
</guid>
161 <pubDate>Sun,
3 Mar
2024 22:
40:
00 +
0100</pubDate>
162 <description><p
>The last few days I have revisited RAID setup using the LSI
163 Megaraid controller. These are a family of controllers called PERC by
164 Dell, and is present in several old PowerEdge servers, and I recently
165 got my hands on one of these. I had forgotten how to handle this RAID
166 controller in Debian, so I had to take a peek in the
167 <a href=
"https://wiki.debian.org/LinuxRaidForAdmins
">Debian wiki page
168 "Linux and Hardware RAID: an administrator
's summary
"</a
> to remember
169 what kind of software is available to configure and monitor the disks
170 and controller. I prefer Free Software alternatives to proprietary
171 tools, as the later tend to fall into disarray once the manufacturer
172 loose interest, and often do not work with newer Linux Distributions.
173 Sadly there is no free software tool to configure the RAID setup, only
174 to monitor it. RAID can provide improved reliability and resilience in
175 a storage solution, but only if it is being regularly checked and any
176 broken disks are being replaced in time. I thus want to ensure some
177 automatic monitoring is available.
</p
>
179 <p
>In the discovery process, I came across a old free software tool to
180 monitor PERC2, PERC3, PERC4 and PERC5 controllers, which to my
181 surprise is not present in debian. To help change that I created a
182 <a href=
"https://bugs.debian.org/
1065322">request for packaging of the
183 megactl package
</a
>, and tried to track down a usable version.
184 <a href=
"https://sourceforge.net/p/megactl/
">The original project
185 site
</a
> is on Sourceforge, but as far as I can tell that project has
186 been dead for more than
15 years. I managed to find a
187 <a href=
"https://github.com/hmage/megactl
">more recent fork on
188 github
</a
> from user hmage, but it is unclear to me if this is still
189 being maintained. It has not seen much improvements since
2016. A
190 <a href=
"https://github.com/namiltd/megactl
">more up to date
191 edition
</a
> is a git fork from the original github fork by user
192 namiltd, and this newer fork seem a lot more promising. The owner of
193 this github repository has replied to change proposals within hours,
194 and had already added some improvements and support for more hardware.
195 Sadly he is reluctant to commit to maintaining the tool and stated in
196 <a href=
"https://github.com/namiltd/megactl/pull/
1">my first pull
197 request
</A
> that he think a new release should be made based on the
198 git repository owned by hmage. I perfectly understand this
199 reluctance, as I feel the same about maintaining yet another package
200 in Debian when I barely have time to take care of the ones I already
201 maintain, but do not really have high hopes that hmage will have time
202 to spend on it and hope namiltd will change his mind.
</p
>
204 <p
>In any case, I created
205 <a href=
"https://salsa.debian.org/debian/megactl
">a draft package
</a
>
206 based on the namiltd edition and put it under the debian group on
207 salsa.debian.org. If you own a Dell PowerEdge server with one of the
208 PERC controllers, or any other RAID controller using the megaraid or
209 megaraid_sas Linux kernel modules, you might want to check it out. If
210 enough people are interested, perhaps the package will make it into
211 the Debian archive.
</p
>
213 <p
>There are two tools provided, megactl for the megaraid Linux kernel
214 module, and megasasctl for the megaraid_sas Linux kernel module. The
215 simple output from the command on one of my machines look like this
216 (yes, I know some of the disks have problems. :).
</p
>
220 a0 PERC H730 Mini encl:
1 ldrv:
2 batt:good
221 a0d0
558GiB RAID
1 1x2 optimal
222 a0d1
3067GiB RAID
0 1x11 optimal
223 a0e32s0
558GiB a0d0 online errs: media:
0 other:
19
224 a0e32s1
279GiB a0d1 online
225 a0e32s2
279GiB a0d1 online
226 a0e32s3
279GiB a0d1 online
227 a0e32s4
279GiB a0d1 online
228 a0e32s5
279GiB a0d1 online
229 a0e32s6
279GiB a0d1 online
230 a0e32s8
558GiB a0d0 online errs: media:
0 other:
17
231 a0e32s9
279GiB a0d1 online
232 a0e32s10
279GiB a0d1 online
233 a0e32s11
279GiB a0d1 online
234 a0e32s12
279GiB a0d1 online
235 a0e32s13
279GiB a0d1 online
240 <p
>In addition to displaying a simple status report, it can also test
241 individual drives and print the various event logs. Perhaps you too
242 find it useful?
</p
>
244 <p
>In the packaging process I provided some patches upstream to
245 improve installation and ensure
246 <ahref=
"https://github.com/namiltd/megactl/pull/
2">a Appstream
247 metainfo file is provided
</a
> to list all supported HW, to allow
248 <a href=
"https://tracker.debian.org/isenkram
">isenkram
</a
> to propose
249 the package on all servers with a relevant PCI card.
</p
>
251 <p
>As usual, if you use Bitcoin and want to show your support of my
252 activities, please send Bitcoin donations to my address
253 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>