Skip to content

Instantly share code, notes, and snippets.

@bensig
Created March 4, 2023 20:51
Show Gist options
  • Save bensig/acca752aa490826266e2df87c7f5066d to your computer and use it in GitHub Desktop.
Save bensig/acca752aa490826266e2df87c7f5066d to your computer and use it in GitHub Desktop.
Unpack ubuntu oom killer output
#!/bin/bash
# may need to specify a diff path to syslog if you want older log files
cat /var/log/syslog | grep kernel | rev | cut -d"]" -f1 | rev | awk '{ print $3, $4, $5, $8 }' | grep '^[0-9].*[a-zA-Z]' | perl -MData::Dumper -p -e 'BEGIN { $db = {}; } ($total_vm, $rss, $pgtables_bytes, $name) = split; $db->{$name}->{total_vm} += $total_vm; $db->{$name}->{rss} += $rss; $db->{$name}->{pgtables_bytes} += $pgtables_bytes; $_=undef; END { map { printf("%.1fG %s\n", ($db->{$_}->{rss} * 4096)/(1024*1024*1024), $_) } sort { $db->{$a}->{rss} <=> $db->{$b}->{rss} } keys %{$db}; }' | tail -n 10 | tac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment