home *** CD-ROM | disk | FTP | other *** search
- Here are 2 library funtions that will allow non-setuid (or setgid)
- functions to check the load average. They are:
-
- getload(): A fast routine which will return only
- the 1, 5, or 15 minute average. It only returns
- 1 decimal place of accuracy (ie 3.1 instead of 3.08) and
- will only tell load averages below 25.0
- It requires a program installed on the system called
- "getld". This setgid program reads /dev/kmem and
- exits with information we need.
- ugetloads(): A much slower routine that will return all 3 load
- averages via an array passed to it. It just
- runs uptime(1) and captures the information it needs from
- there not requiring the external program getld.
-
-
- If getload() is usable (ie you install the program "getld")
- it is much faster than ugetloads() and can be called 3 times
- (to get the 3 load averages) in much less time than ugetloads()
- can be called once. The speed of getload() lies in the fact that "getld"
- exits() with the load average we want instead of printing
- it. This way getload() doesn't have to open a pipe to read what "getld" might
- otherwise print, it just has to look at the high byte of the exit status.
-
- The routine ugetloads() allows anyone to get the load averages
- without any extra programs on the system. It's good if you don't happen
- to be super-user and can let "getld" read /dev/kmem.
-
- A sample program example.c demonstrates the use of these routines.
-
- John Bien
- {ihnp4 | ucbvax | decvax}!trwrb!jsb
-
-