Sunday, June 23, 2024

Running Powershell commands on a set of files


PS Microsoft.PowerShell.Core\FileSystem:: C:\PhD\Datasets\Astrometry\Set-146>  Get-ChildItem -File | ForEach-Object { file2pdfpsedit.exe $_.FullName --args xr }

Wednesday, November 16, 2022

Tmux : Create multiple windows to ssh to several servers



tmux new -s "${SESSION}" -d
tmux rename-window -t "${SESSION}.0" Main
tmux new-window -d -t "${SESSION}" -n Server1
tmux new-window -d -t "${SESSION}" -n Server2
tmux new-window -d -t "${SESSION}" -n Server3

# Run ssh command in each window
tmux send-keys -t "${SESSION}:1" 'ssh server1.mydomain' Enter
tmux send-keys -t "${SESSION}:2" 'ssh server2.mydomain' Enter
tmux send-keys -t "${SESSION}:3" 'ssh server3.mydomain' Enter

# To run command in a pane within a window, use:
# tmux send-keys -t "${SESSION}:1.<pane-position>" 'ssh server1' Enter
# tmux send-keys -t "${SESSION}" 'ssh server1' Enter

tmux attach-session -d -t "$SESSION"

Sunday, October 17, 2021

Creating a user service on Linux

 This is an example of running a local python script as a user service.

Most of this information was found  here.

Service location:


Service definition/contents of servicename.service

Description=Metriful User Service

ExecStart=/usr/bin/python3 /home/user/


Reload Systemd so it can find the new service

systemctl --user daemon-reload

Enable Service with

systemctl --user enable servicename.service

Let Service run even when all user sessions have expired

loginctl enable-linger <user>

Monday, October 11, 2021

ZSH First time run

These are the commands to re-run ZSH first time setup.

autoload -Uz zsh-newuser-install
zsh-newuser-install -f

Friday, March 27, 2020

Grafana is pretty awesome

It was so easy to setup.  Definitely needs more time spent with it.  But I have dashboards, alerting, and push notification thus far. Pretty sweet.

#monitoring #server #graphs

Wednesday, April 19, 2017

Replacing a failed hard drive in an (encrypted) ZFS Pool on FreeNAS

Disk Failure Email Alert

Device: /dev/ada5, failed to read SMART Attribute Data
Device: /dev/ada5, not capable of SMART self-check
Device: /dev/ada5, Read SMART Self-Test Log Failed
The volume tank (ZFS) state is DEGRADED: One or more devices could not be opened. Sufficient replicas exist for the pool to continue functioning in a degraded state.
Device: /dev/ada5, Read SMART Error Log Failed
Disk went to UNAVAIL on FreeNAS. It was a complete disk failure where the drive would not even turn on.

Checking status of zfs pools:

  pool: tank
 state: DEGRADED
status: One or more devices could not be opened.  Sufficient replicas exist for
 the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
  scan: scrub repaired 0 in 3h22m with 0 errors on Sat Mar 11 15:55:33 2017

 NAME                                                STATE     READ WRITE CKSUM
 tank                                                DEGRADED     0     0     0
   raidz1-0                                          DEGRADED     0     0     0
     gptid/2dc7c53c-2b99-11e6-94d8-0015177adaa2.eli  ONLINE       0     0     0
     gptid/2e7247c8-2b99-11e6-94d8-0015177adaa2.eli  ONLINE       0     0     0
     gptid/2f1f7b49-2b99-11e6-94d8-0015177adaa2.eli  ONLINE       0     0     0
     9773863262585734395                             UNAVAIL      0     0     0  was /dev/gptid/2fa84005-2b99-11e6-94d8-0015177adaa2.eli
     gptid/306d3755-2b99-11e6-94d8-0015177adaa2.eli  ONLINE       0     0     0

errors: No known data errors

 Here's how to replace the failed disk:
  1.  Offline the disk if you can by going to Storage > Volumes > Select your pool (e.g. tank) > Volume Status (on the status bar at the bottom).  I could not do this since the disk was already unavailable and hence offline
  2. NOTE the disk's name, like ada5xx
  3. Next, navigate to the Storage > View Disks and jot down the disk's serial number.  You will need this to physically identify the disk later.
  4. Shutdown your computer
  5. Physically remove the disk and replace it with a new one. 
  6. Boot up your machine
  7. Go back to  Storage > Volumes > Select your pool (e.g. tank) > Volume Status
  8. Select the defective disk's slot and click on Replace
  9. If it's an encrypted pool, enter your passphrase as well
  10. The resilvering process should start
For encrypted pools, once resilvering is completed do the following to avoid losing the pool on the next reboot. Go to Storage > Volumes > Select your pool containing the new disk

  1. Re-key your pool's encryption passphrase 
  2. Re-create a passphrase
  3. Download your key
  4. Add a recovery key.
For more detailed information, refer to the FreeNAS documentation.

 You can watch the pool rebuilding (resilvering) either on the GUI or on the CLI:

[root@freenas] ~# zpool status tank
  pool: tank
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Wed Apr 19 21:42:55 2017
        49.1G scanned out of 5.89T at 301M/s, 5h39m to go
        9.79G resilvered, 0.81% done

        NAME                                                STATE     READ WRITE CKSUM
        tank                                                ONLINE       0     0     0
          raidz1-0                                          ONLINE       0     0     0
            gptid/2dc7c53c-2b99-11e6-94d8-0015177adaa2.eli  ONLINE       0     0     0
            gptid/2e7247c8-2b99-11e6-94d8-0015177adaa2.eli  ONLINE       0     0     0
            gptid/2f1f7b49-2b99-11e6-94d8-0015177adaa2.eli  ONLINE       0     0     0
            gptid/c3e3e9d1-2583-11e7-8b27-0015177adaa2.eli  ONLINE       0     0     0  (resilvering)
            gptid/306d3755-2b99-11e6-94d8-0015177adaa2.eli  ONLINE       0     0     0

errors: No known data errors

Monday, April 29, 2013

Excellent read on cloud management

PCWorld: 21 tips for supercharging your cloud storage.