OpenVMS Source-Code Demos

ENV_CHECK_100.com

$!===========================================================================
$! Program: ENV_CHECK.COM
$!
$! Purpose:  Gathers and displays the state of the internal Fans/Temperature/
$! Thermal/Power Supplies of the system.  Not all systems are capable of
$! reporting this information so the output will be different for each type.
$! Some systems can't report any.
$!
$! History:
$! ver who           when       what
$! 100 Scott Belviso 02/07/03   - Original Creation
$! 101 Neil Rieck    2007-06-26 - added alarm severity prefixes + statistics
$!
$! Paramaters:
$!      none
$!
$! Run instructions:
$!      @env_check
$!
$!===========================================================================
$ error_count = 0		! init
$ warn_count  = 0		! init
$ say :== write sys$output
$ ask :== inquire/nopunct
$ bel[0,8]==7
$ say "ENV_CHECK.COM"
$ say "============="
$ set proc/priv=all
$ thermal_ctr = 0
$ thermal_size = 2
$ thermal_length = 32
$ fan_ctr = 0
$ fan_size = 2
$ fan_length = 32
$ temp_ctr = 0
$ temp_size = 2
$ temp_length = 32
$ power_ctr = 0
$ power_size = 2
$ power_length = 32
$ tv = f$getsyi("thermal_vector")
$ fv = f$getsyi("fan_vector")
$ temp_v = f$getsyi("temperature_vector")
$ pv = f$getsyi("power_vector")
$!
$!	Main
$!
$main:
$ gosub thermal_loop
$ gosub fan_loop
$ gosub temp_loop
$ gosub power_loop
$ goto done
$!
$!	Thermal subroutine
$!
$thermal_loop:
$ thermal_ctr = thermal_ctr + 1
$ if thermal_ctr * thermal_size .gt. thermal_length then return
$ thermal'thermal_ctr = f$extract(thermal_length - (thermal_size * thermal_ctr),thermal_size,tv)
$ if thermal'thermal_ctr .eqs. "01" then write sys$output "-i- Thermal ''thermal_ctr' is Good"
$ if thermal'thermal_ctr .eqs. "00"
$ then
$	write sys$output "-e- Thermal ''thermal_ctr' is BAD",bel
$	error_count = error_count + 1
$ endif
$! if thermal'thermal_ctr .eqs. "FF" -
$!      then write sys$output "Thermal ''thermal_ctr' is Not Present"
$ goto thermal_loop
$!
$!	Fan subroutine
$!
$fan_loop:
$ fan_ctr = fan_ctr + 1
$ if fan_ctr * fan_size .gt. fan_length then return
$ fan'fan_ctr = f$extract(fan_length - (fan_size * fan_ctr),fan_size,fv)
$ if fan'fan_ctr .eqs. "01" then write sys$output "-i- FAN ''fan_ctr' is Good"
$ if fan'fan_ctr .eqs. "00"
$ then
$	write sys$output "-e- FAN ''fan_ctr' is BAD",bel
$	error_count = error_count + 1
$ endif
$! if fan'fan_ctr .eqs. "FF" -
$!      then write sys$output "FAN ''fan_ctr' is Not Present"
$ goto fan_loop
$!
$!	temperature subroutine
$!
$temp_loop:
$ temp_ctr = temp_ctr + 1
$ if temp_ctr * temp_size .gt. temp_length then return
$ temp'temp_ctr = f$extract(temp_length - (temp_size * temp_ctr),temp_size,temp_v)
$ if temp'temp_ctr .nes. "FF"				!
$    then						!
$       actual_temp = temp'temp_ctr			!
$       actual_temp = %x'actual_temp			!
$	prefix = "-i-"					! default
$	if actual_temp .ge. 30 then prefix = "-w-"	! >  86 F (losing our A/C ?)
$	if actual_temp .ge. 35 then prefix = "-e-"+bel	! >  95 F (lost our A/C ?)
$	if actual_temp .le.  5 then prefix = "-e-"+bel	! <  41 F (faulty reading?)
$       write sys$output prefix," Temp ''temp_ctr' is ''actual_temp' Celsius"
$	if prefix .eqs. "-e-" then error_count = error_count + 1
$	if prefix .eqs. "-w-" then warn_count  = warn_count  + 1
$ endif							!
$ goto temp_loop					!
$!
$power_loop:
$ power_ctr = power_ctr + 1
$ if power_ctr * power_size .gt. power_length then return
$ power'power_ctr = f$extract(power_length - (power_size * power_ctr),power_size,pv)
$ if power'power_ctr .eqs. "01" then write sys$output "-i- Power Supply ''power_ctr' is Good"
$ if power'power_ctr .eqs. "00"				!
$ then							!
$	write sys$output "-e- Power Supply ''power_ctr' is BAD",bel
$	error_count = error_count + 1			!
$ endif							!
$! if power'power_ctr .eqs. "FF" -
$!      then write sys$output "Power Supply ''power_ctr' is Not Present"
$ goto power_loop					!
$!
$done:
$ if (error_count .gt. 0) .or. (warn_count .gt. 0)
$ then
$	say "-i- Problem statistics:"
$	if (error_count .gt. 0) then say "-i- total error count: ",error_count
$	if (warn_count  .gt. 0) then say "-i- total warn  count: ",warn_count
$	ask junk "Hit <enter> to confirm then continue..."
$ endif
$ say "-i- exiting ENV_CHECK.COM"
$ exit					!