#!/usr/bin/perl -w
# Copyright © 2021 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
#

=head1 check_qemu_oom

check_qemu_oom - check if qemu is killed due to system being out of memory

=head1 SYNOPSIS

check_qemu_oom qemu_pid

=cut

use Mojo::Base -strict;

my $qemu_pid = $ARGV[0];

eval { use Pod::Usage; pod2usage(1); } unless $qemu_pid;

exit 0 if (index(qx{dmesg}, "Out of memory: Killed process $qemu_pid") != -1);
exit 1;
