Data Filtering

[posted 1999/12/07]

After I had modified our configuration to support AIX and IRIX, I was surprised to start receiving DfChkEmergency alerts from the IRIX test host.  After looking at the input data, I readily saw the problem.

Here is the =dfl display for a Solaris system:

Filesystem         1024-blocks  Used Available Capacity Mounted on
/dev/dsk/c0t3d0s0      38383   17797    16748     52%   /
/dev/dsk/c0t3d0s6     554054  469940    28709     94%   /usr
/dev/dsk/c0t3d0s3      61615   11032    44422     20%   /var
/dev/dsk/c0t3d0s5     122727    6913   103542      6%   /export/home

And here is a similar display for an IRIX system:

Filesystem             Type  blocks     use     avail  %use Mounted on
/dev/root               xfs   208700    45852   162848  22  /
/dev/usr                xfs  7646759  6851025   795734  90  /usr
/dev/dsk/dks0d3s7       xfs 17755328 17594424   160904 100  /nfs/shanghai/s2
/dev/dsk/dks0d2s7       xfs 17755328  5744104 12011224  33  /nfs/shanghai/s1

Spot the difference? Under Solaris (and all the other supported non-IRIX OSes), the "Capacity" or "%use" figures are all displayed as percents (e.g., "52%"), while in IRIX alone the trailing percent sign (%) is missing (e.g., "22").

This causes problems further down, because a rule reads:

        rule
                if #cap >= 100%
                ...
                        output mail "Filesystem $mount on $fsname is
                                     $text(100*#cap,0)% full,
                                           $text(#avail) Kb left"
                        ...
                endif

So, the #cap for /dev/root was "22", that is, 2200%, and the alarm got triggered.

Here was my initial, incorrect fix, applied as the first rule:

// this won't work, because we can't set a dat value; so we apply the filter
// trick above
//#if irix
//      rule    // irix displays "100", not "100%"
//              set #cap /= 100
//#endif

As the comment says, this won't work, because I am trying to set anew a fixed dat value, which to pikt is a no-no.

I thought to set a new variable,

#if irix
       rule
                set #usage = #cap/100
#endif

then refer to #usage, not #cap, in all subsequent rules.

Then I thought of a better solution:

                input proc "=dfl | =grep '^/'"
#if irix        // irix displays "100", not "100%"
                filter "=awk '{printf("%s %s %s %s %s %s%% %s\n",
                              $1, $2, $3, $4, $5, $6, $7)}'"
#endif
                =dfdata

With that data filtering in place, the /dev/root line on the IRIX machine becomes

/dev/root               xfs   208700    45852   162848  22%  /

with the "%" now consistently applied.

After that, the rest of the alarm worked as is.  And no more erroneous alerts!

For more examples, see Developer's Notes.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
Learn new
techniques for
alert e-mail routing