1 00:00:07,050 --> 00:00:08,520 - All right, so we need to make sure 2 00:00:08,520 --> 00:00:11,280 that we have full sysrq functionality. 3 00:00:11,280 --> 00:00:16,280 That was in /proc/sys/kernel/sysrq. 4 00:00:18,270 --> 00:00:21,603 And we can see "1", and 1 is exactly what we need. 5 00:00:22,650 --> 00:00:26,100 Next, we need sysrq to trigger a full OOM kill. 6 00:00:26,100 --> 00:00:28,200 I would always advise, before you do that, 7 00:00:28,200 --> 00:00:29,160 use echo h 8 00:00:29,160 --> 00:00:31,931 even if you're sure about what you want to do. 9 00:00:31,931 --> 00:00:34,530 /proc/sysrq-trigger, 10 00:00:34,530 --> 00:00:36,030 and then dmesg 11 00:00:36,030 --> 00:00:38,250 to check what it is telling you. 12 00:00:38,250 --> 00:00:41,793 And there we can see memory-full-oom-kill is f. 13 00:00:43,140 --> 00:00:44,760 The reason you need to check it out 14 00:00:44,760 --> 00:00:48,630 is that these sysrq-triggers can do pretty nasty stuff 15 00:00:48,630 --> 00:00:49,980 on your system. 16 00:00:49,980 --> 00:00:52,020 Like, if by accident you type c, 17 00:00:52,020 --> 00:00:53,700 then you crash your system. 18 00:00:53,700 --> 00:00:55,140 And then it's gone. 19 00:00:55,140 --> 00:00:57,540 So you better be sure that you know 20 00:00:57,540 --> 00:00:59,970 what it is that you are going to do. 21 00:00:59,970 --> 00:01:04,970 So echo f > /proc/sysrq-trigger. 22 00:01:05,220 --> 00:01:08,190 And there we go, and again it is killing the GDM, 23 00:01:08,190 --> 00:01:10,773 GNOME graphical Display Manager. 24 00:01:14,970 --> 00:01:17,610 Right. So now we are back. 25 00:01:17,610 --> 00:01:22,610 Let's have a look at journalctl | grep -A 10 OOM, 26 00:01:25,950 --> 00:01:28,207 which is showing us, right here, 27 00:01:28,207 --> 00:01:32,160 "process of the unit has been killed by the OOM killer." 28 00:01:32,160 --> 00:01:33,750 So we are running out of memory, 29 00:01:33,750 --> 00:01:35,010 and then the essence is 30 00:01:35,010 --> 00:01:37,470 that a process will be killed. 31 00:01:37,470 --> 00:01:39,540 And here you can see the information 32 00:01:39,540 --> 00:01:41,850 that was printed right after it. 33 00:01:41,850 --> 00:01:46,290 I have used -A on my grep, -A for "after." 34 00:01:46,290 --> 00:01:49,920 Maybe you wanna do minus uppercase C for after and before. 35 00:01:49,920 --> 00:01:52,663 There's -A for after, -B for before, 36 00:01:52,663 --> 00:01:55,590 and -C for after and before, 37 00:01:55,590 --> 00:01:58,230 so that you can see exactly what has been going on 38 00:01:58,230 --> 00:02:03,180 and get more information about the process that was killed. 39 00:02:03,180 --> 00:02:05,760 In this case, by the way, that was pretty obvious 40 00:02:05,760 --> 00:02:09,750 because we were kicked out of the graphical Display Manager. 41 00:02:09,750 --> 00:02:13,380 In some other cases it might not be that obvious. 42 00:02:13,380 --> 00:02:15,750 Hey, shall I show you something fun? 43 00:02:15,750 --> 00:02:20,613 Let's get back to this echo h > /proc/sysrq-trigger, 44 00:02:21,840 --> 00:02:24,120 and dmesg. 45 00:02:24,120 --> 00:02:26,280 Because what else can we do? 46 00:02:26,280 --> 00:02:29,790 Well, we can do pretty dramatic stuff, 47 00:02:29,790 --> 00:02:34,790 like echo c > /proc/sysrq-trigger 48 00:02:38,580 --> 00:02:39,900 What is going to happen? 49 00:02:39,900 --> 00:02:42,390 Oh no, my system isn't doing anything anymore. 50 00:02:42,390 --> 00:02:43,560 It crashes. 51 00:02:43,560 --> 00:02:45,720 That's what is going to happen. 52 00:02:45,720 --> 00:02:47,790 Now, you might wonder, why is this useful? 53 00:02:47,790 --> 00:02:49,770 Well, this is useful if you want to test 54 00:02:49,770 --> 00:02:54,000 what your system is doing in specific cases. 55 00:02:54,000 --> 00:02:56,370 Maybe you have configured some high availability, 56 00:02:56,370 --> 00:02:59,430 and you want stuff to be started again automatically. 57 00:02:59,430 --> 00:03:02,070 Then isn't it cool that you can test what is happening 58 00:03:02,070 --> 00:03:03,660 if your system is crashing. 59 00:03:03,660 --> 00:03:06,810 echo c > /proc/sysrq-trigger, 60 00:03:06,810 --> 00:03:08,970 and you got yourself a crash. 61 00:03:08,970 --> 00:03:11,550 And that is how cool, and at the same time, dangerous 62 00:03:11,550 --> 00:03:13,323 the sysrq-triggers can be.