This snippet reads several system variables pushes them onto an array. If the array contains more than one value, the two are compared. If there is more than a 10% difference between the two, a page is sent to a relevant individual. It runs every three hours. This works well for a lot of engineering applications.
#!/usr/local/bin/perl -w use diagnostics; my $test_st = qx(read_apt _test_status); chomp $test_st; print "$test_st\n"; #my $test_st = "Test running"; while ($test_st eq "Test running") { print "started\n"; my $lube1_mean = qx(read_apt LUBE1_STAT.statave); push @lube1_means, $lube1_mean; my $lube2_mean = qx(read_apt LUBE2_STAT.statave); push @lube2_means, $lube2_mean; my $lube3_mean = qx(read_apt LUBE3_STAT.statave); push @lube3_means, $lube3_mean; my $lube4_mean = qx(read_apt LUBE4_STAT.statave); push @lube4_means, $lube4_mean; my $speed1_mean = qx(read_apt SPEED1_STAT.statave); push @speed1_means, $speed1_mean; my $speed2_mean = qx(read_apt SPEED2_STAT.statave); push @speed2_means, $speed2_mean; my $speed3_mean = qx(read_apt SPEED3_STAT.statave); push @speed3_means, $speed3_mean; my $speed4_mean = qx(read_apt SPEED4_STAT.statave); push @speed4_means, $speed4_mean; my $a = @lube1_means; if ($a > 1) { compare($lube1_means[$a - 2], $lube1_means[$a-1]); compare($lube2_means[$a - 2], $lube2_means[$a-1]); compare($lube3_means[$a - 2], $lube3_means[$a-1]); compare($lube4_means[$a - 2], $lube4_means[$a-1]); compare($speed1_means[$a - 2], $speed1_means[$a-1]); compare($speed2_means[$a - 2], $speed2_means[$a-1]); compare($speed3_means[$a - 2], $speed3_means[$a-1]); compare($speed4_means[$a - 2], $speed4_means[$a-1]); } sleep 10800; } sub compare { my $a = abs($_[0]); my $b = abs($_[1]); if (($b > (1.1 * $a)) || ($b < (.9 * $a))) { system "msgto2 arcove - values are out of spec"; } }

In reply to data comparison by Lhamo_rin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.