perf
August 23, 2017 — 16:45

Author: silver  Category: linux  Comments: Off

perf – performance analysis tools for Linux

Start with:

perf top
perf bench all

Example:

To find out why “kworker” process (kernel per-cpu threads) has high CPU usage:

  • record 10 seconds of backtraces on all CPUs to perf.data:
    perf record -g -a sleep 10
  • analyse recording:
    perf report

More info:
https://www.brendangregg.com/perf.html
https://askubuntu.com/questions/33640/kworker-what-is-it-and-why-is-it-hogging-so-much-cpu

Debian
August 23, 2017 — 15:37

Author: silver  Category: linux  Comments: Off

Remote upgrade using aptitude:

  1. echo “defscrollback 10000” >>/root/.screenrc
  2. screen
  3. /etc/sysctl.conf:
    # on kernel panic reboot after 60s
    kernel.panic = 600
    # enable magic sysrq key
    kernel.sysrq=1</pre>
  4. In /etc/apt/sources.list: change old to new dist (or “stable” etc)
    ( if needed: apt-get install debian-archive-keyring )
  5. aptitude update
  6. aptitude safe-upgrade
    ( optionally/if needed: full-upgrade, dist-upgrade )

Change default editor:

sudo update-alternatives --config editor

Install build tools:

apt-get install build-essential

pkg install dates:

for file_list in `ls -rt /var/lib/dpkg/info/*.list`; do \
  stat_result=$(stat --format=%y &quot;$file_list&quot;); \
  printf &quot;%-50s %s\n&quot; $(basename $file_list .list) &quot;$stat_result&quot;; \
done

backports:

apt-get -t stretch-backports install “package”
aptitude -t stretch-backports install “package”

/etc/apt/preferences:

Package: *
Pin: release a=stable
Pin-Priority: 900

Package: *
Pin: release o=Debian
Pin-Priority: -10

“testing” packages:

install a pkg from testing:
sudo apt-get -t testing install tmux
show all testing pkgs:
aptitude search -F "%p %V %v" '?narrow(~i, ~Atesting)
( stable, unstable, oldstable, etc )

apt-get install package=version

Windows 10 Licensing
August 23, 2017 — 14:40

Author: silver  Category: windows  Comments: Off

Product Key can now be a “Digital License”. This seems to be true for upgraded Windows 7 keys.
To prevent activation issues after hardware changes: link MS account to digital license asap (Settings > Accounts).

View current license:

slmgr.vbs /dlv
wmic path softwarelicensingservice get OA3xOriginalProductKey

powershell "(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey"

Update product key:

run slui.exe or goto Settings > Activation

MS Activation servers:

activation-v2.sls.microsoft.com
validation-v2.sls.microsoft.com

More info:

https://support.microsoft.com/en-us/help/20530/windows-10-reactivating-after-hardware-change

Windows Uptime
August 23, 2017 — 14:07

Author: silver  Category: windows  Comments: Off

How to find out Windows Uptime?

Using PowerShell:

powershell ((Get-Date) - (gcim Win32_OperatingSystem).LastBootUptime).ToString('g')
powershell ((Get-Date) - ([wmi]'').ConvertToDateTime((Get-WmiObject win32_operatingsystem).LastBootUpTime)).ToString("dd' days 'hh\:mm\:ss")

Also, I cobbled together this little script that looks like the Linux uptime cmd. It’s embedded in a batch file so for ease of running (https://blogs.msdn.microsoft.com/jaybaz_ms/2007/04/26/powershell-polyglot/ for more info). Gist: https://git.io/v5tx0.

@PowerShell -ExecutionPolicy RemoteSigned -Command Invoke-Expression $('$args=@(^&{$args} %*);'+[String]::Join(';',(Get-Content -LiteralPath '%~f0') -notmatch '^^@PowerShell.*EOF$')) & goto :EOF

$d = Get-Date
$upTime = (($d) - ([wmi]'').ConvertToDateTime((Get-WmiObject win32_operatingsystem).LastBootUpTime)).ToString("d' days,  'h\:mm")
$ActiveUsers = @()
foreach($User in (Get-WmiObject Win32_LoggedOnUser).Antecedent) { $ActiveUsers += $User.Substring($User.LastIndexOf('=') + 2, $User.Length - $User.LastIndexOf('=') -3) }
$UserText = "$($ActiveUsers.Count) user"
if ( $ActiveUsers.Count -gt 1 ) { $UserText += "s" }
$TotalProcTime = (Get-Counter "\Processor(_total)\% Processor Time") | foreach {$_.CounterSamples[0].CookedValue}

Write-Host -NoNewLine (" {0}, up {1},  {2},  total proctime: {3}%" -f $d.toString("HH:mm:ss"), $upTime, $UserText, [math]::Round($TotalProcTime,2))

Output looks like this:

C:\Users\silver>uptime
 14:45:41, up 5 days,  20:15,  3 users,  total proctime: 2,26%

 

GUI (Windows 10):

Task Manager (taskmgr) > More details > Performance tab > CPU

Boot Time:

net stats <workstation/server>
systeminfo | findstr "System Boot Time"








We use Matomo free and open source web analytics
We also use Jetpack WordPress.com Stats which honors DNT