apcupsd монитор (ups example)
Ключевые слова: ups, example, (найти похожие документы)
_ RU.LINUX (2:5077/15.22) ___________________________________________ RU.LINUX _
From : Boris Tobotras 2:5020/510 Sat 11 Jul 98 09:02
Subj : apcupsd монитор
________________________________________________________________________________
Если кто юзает APCшный UPS с apcupsd, то вот к нему ценный
программный продукт :-)
#! /usr/bin/wish
set timeout 5000
set statusFile "/etc/apcupsd.status"
#
frame .f -relief ridge -border 2
label .f.l -text "Util: " -font
-adobe-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-*
label .f.s -foreground blue -font
-adobe-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*
pack .f.l .f.s -side left
frame .s -relief ridge -border 2
label .s.l -text "Batt: " -font
-adobe-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-*
label .s.s -foreground blue -font
-adobe-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*
pack .s.l .s.s -side left
frame .v -relief ridge -border 2
label .v.l -text "Volt: " -font
-adobe-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-*
label .v.s -foreground blue -font
-adobe-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*
pack .v.l .v.s -side left
frame .e -relief ridge -border 2
label .e.l -text "Event: " -font
-adobe-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-*
label .e.s -foreground blue -font
-adobe-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*
pack .e.l .e.s -side left
pack .f .s .v .e -side left
wm title . "APC UPS status"
set entered 0
set mTime 0
bind . <Enter> {
set entered 1
set mTime 0
doUpdate
}
bind . <Leave> {
set entered 0
set mTime 0
doUpdate
}
proc doUpdate {} {
global mTime statusFile timeout
after $timeout doUpdate
set currentTime [file mtime $statusFile]
if { $currentTime <= $mTime } {
return
}
set mTime $currentTime
set f [open $statusFile "r"]
# APC : Jul 09 09:11:22
# CABLE : APC Cable 940-0095A
# UPSMODEL : BackUPS Pro
# UPSMODE : Stand Alone
# LINEFAIL : OK
# BATTSTAT : OK
# LINEVOLT : OK
# LASTEVNT : LINE VOLTAGE INCREASE
global eventTime
gets $f; gets $f; gets $f; gets $f
foreach entry {f s v} {
.${entry}.s configure -text "N/A"
}
while { 1 } {
parseLine [gets $f]
if { [eof $f] } break
}
close $f
}
proc now {} {
return [clock format [clock seconds]]
}
set lastValue ""
set eventTime [now]
proc parseLine { line } {
set l [split $line]
set keyword [lindex $l 0]
set value [getValue $l]
switch $keyword {
"LINEFAIL" {
setValue .f.s $value
}
"BATTSTAT" {
setValue .s.s $value
}
"LINEVOLT" {
setValue .v.s $value
}
"LASTEVNT" {
global entered
if { $entered == 1 } {
global eventTime
setValue .e.s $eventTime
} else {
setValue .e.s $value
}
global lastValue
if { "$value" != "$lastValue" } {
global eventTime
set eventTime [now]
set lastValue $value
}
}
}
}
proc setValue { widget text } {
$widget configure -text $text
foreach pattern { fail off down } {
if { [regexp ".*${pattern}.*" [string tolower $text]] } {
$widget configure -foreground red
return
}
}
$widget configure -foreground blue
}
proc getValue { line } {
return [string range $line [expr [string first ":" $line] + 2] end]
}
doUpdate
--
Best regards, -- Boris.
Any sufficiently advanced operating system is indistinguishable from Unix.
--- Gnus v5.5/XEmacs 20.3 - "London"
* Origin: Linux inside (2:5020/510@fidonet)