IdleResonance has asked for the wisdom of the Perl Monks concerning the following question:
This is by far the simplest yet most terrifying Perl solution that I have ever developed. I have written entire mod_perl websites and associated toolsets used by several fortune 100 companies but I can't bring myself to implement this on one of my own personal systems.
This system is booted (/boot, /, /var, /usr, etc...) off of an OCZ PCI-Express SSD card. Unfortunately every 1-3 months the card locks up resulting in I/O errors. In this case, even if I have an open shell on the system I am only able to run programs that are currently in disk cache in memory. Attempting to exec all other processes will result in I/O errors until a reset. There are usually no direct hands near the box and unfortunately I do not have access to out of band management of any kind to reset the box (IPMI, BMC, iLO, RSA, DRAC, PDU, eRIC, ATEN IP8000, etc...). I feel that my only option is to attempt to read a few KB from one of the ~4K files in /usr/bin and do an immediate (or postponed) reset if I get an EIO error back from sysread. I need to be able to reset the box immediately if I cannot read from one of the logical volumes on the SSD.
Keep in mind this is a very preliminary rough draft and I do not take posting to perlmonks lightly. However, I would appreciate any input on the logic.
#!/usr/bin/perl use strict; use Errno; # 3740 files, 3739 max index my @files = glob("/usr/bin/*"); my $range = $#files; #scalar(@files)-1; while (1) { my $random = int(rand($range)); my $filename = $files[$random]; my $buffer; print STDERR "Checking $filename - ( $random / $range )\n"; #my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$c +time,$blksize,$blocks) = stat($filename); open(FILE, "< $filename") or next; my $retval = sysread(FILE, $buffer, 8192); if (!defined $retval) { if ($!{EIO}) { print STDERR "I/O Error on $filename. Resetting.\n"; #system("/var/tmpfs/reboot -nf"); -- MUST BE IN MEMORY FS +AND STATICALLY LINKED. system calls /bin/sh but should be cached in m +emory #exec {'/var/tmpfs/reboot'} '-nf'; -- MUST BE IN MEMORY FS + AND STATICALLY LINKED } } close(FILE); sleep(15); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I/O Watchdog Daemon
by aitap (Curate) on Aug 22, 2012 at 07:35 UTC | |
by IdleResonance (Acolyte) on Aug 22, 2012 at 15:40 UTC | |
|
Re: I/O Watchdog Daemon
by GlitchMr (Sexton) on Aug 22, 2012 at 09:25 UTC | |
by IdleResonance (Acolyte) on Aug 22, 2012 at 15:34 UTC | |
|
Re: I/O Watchdog Daemon
by flexvault (Monsignor) on Aug 22, 2012 at 13:37 UTC | |
by IdleResonance (Acolyte) on Aug 22, 2012 at 15:54 UTC | |
by flexvault (Monsignor) on Aug 22, 2012 at 17:05 UTC | |
by Anonymous Monk on Aug 22, 2012 at 13:42 UTC | |
by flexvault (Monsignor) on Aug 22, 2012 at 13:52 UTC | |
|
Re: I/O Watchdog Daemon
by CountZero (Bishop) on Aug 22, 2012 at 16:13 UTC | |
by IdleResonance (Acolyte) on Aug 22, 2012 at 16:26 UTC | |
by CountZero (Bishop) on Aug 22, 2012 at 17:17 UTC | |
|
Re: I/O Watchdog Daemon
by runrig (Abbot) on Aug 22, 2012 at 17:18 UTC |