1 $!# Check_MK Agent for OpenVMS
2 $!# +------------------------------------------------------------------+
3 $!# | ____ _ _ __ __ _ __ |
4 $!# | / ___| |__ ___ ___| | __ | \/ | |/ / |
5 $!# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
6 $!# | | |___| | | | __/ (__| < | | | | . \ |
7 $!# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 $!# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
10 $!# +------------------------------------------------------------------+
12 $!# This file is part of Check_MK.
13 $!# The official homepage is at http://mathias-kettner.de/check_mk.
15 $!# check_mk is free software; you can redistribute it and/or modify it
16 $!# under the terms of the GNU General Public License as published by
17 $!# the Free Software Foundation in version 2. check_mk is distributed
18 $!# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
19 $!# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
20 $!# PARTICULAR PURPOSE. See the GNU General Public License for more de-
21 $!# tails. You should have received a copy of the GNU General Public
22 $!# License along with GNU Make; see the file COPYING. If not, write
23 $!# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
24 $!# Boston, MA 02110-1301 USA.
26 $!# Author: Paul Aebersold, netPuls info@netpuls.info
27 $if p1 .nes. "" then set verify
28 $msgOff := set message/nofacility/noseverity/noidentification/notext
29 $msgOn := set message/facility/severity/identification/text
34 $cmdProcedure = f$environment("procedure")
35 $actlDirectory = f$parse(cmdProcedure,,,"device") + -
36 f$parse(cmdProcedure,,,"directory")
37 $if f$search("''f$trnlnm("sys$scratch")'tmp.dir") .eqs. ""
39 $tmpDirectory = f$trnlnm("sys$scratch")
41 $tmpDirectory = f$trnlnm("sys$scratch")-"]"+".tmp]"
43 $errFile = "''tmpDirectory'VMSagent.err"
44 $cacheFile = "''actlDirectory'VMSagent.cache"
46 $sampleFile = "''actlDirectory'myMon.lis"
47 $tempFile = "''tmpDirectory'outFile.tmp"
48 $tmpCMS = "''tmpDirectory'tmp.CMS"
49 $tmpDisksm = "''tmpDirectory'tmp.mDk"
50 $tmpDisks = "''tmpDirectory'tmp.Dsk"
51 $tmpNetif = "''tmpDirectory'tmp.nif"
52 $tmpQueues = "''tmpDirectory'tmp.Que"
53 $tmpUsr = "''tmpDirectory'tmp.Usr"
54 $say = "write sys$output"
55 $modeNet = f$edit(f$mode(),"lowercase,trim") .eqs. "network"
56 $modeDirect = f$environment("interactive") .and. "true"
57 $if .not. modeNet then define/nolog sys$error 'errFile'
66 $if f$search("''cacheFile'") .nes. ""
68 $if (f$cvtime(f$time(),,"secondofyear")-f$cvtime( -
69 f$file("''cacheFile'","rdt"),,"secondofyear") -
70 ) .le. 'cacheMaxAge' then useCacheFile="true"
71 $if f$getjpi("","prcnam") .nes. "VMSagnt$collect"
73 $type/nohead 'cacheFile'
78 $if (.not. useCacheFile) .and. (f$search("''cacheFile'_new") .eqs. "")
80 $run sys$system:loginout.exe /detached/noswap/authorize -
81 /input='cmdProcedure'/process_name="VMSagnt$collect" -
82 /uic='f$getjpi("","uic")'/output=nl:/error='errFile'
88 $create/protection=(g:r,w) 'cacheFile'_new
89 $HWinfo = f$edit(f$getsyi("arch_name"),"trim")
90 $numCPU = f$getsyi("activecpu_cnt")
91 $MEMtotal = f$getsyi("memsize")
92 $PGinfo = f$getsyi("page_size")
93 $SWinfo = f$edit(f$getsyi("version"),"trim")
94 $if sampleInterval .gt. samplePeriod then sampleInterval=samplePeriod/5
95 $if (samplePeriod .gt. 600) .or. (samplePeriod .lt. 10) then -
97 $if (sampleInterval .gt. 60) .or. (sampleInterval .lt. 1) then -
100 $sSec=samplePeriod-sMin*60
101 $monitor/nodisplay/interval='sampleInterval'/summary='sampleFile' -
102 /ending="+0-0:''sMin':''sSec'" system/all, -
103 disk/all/item=operation_rate
105 $gosub create_tmpFiles
108 $if .not. modeNet then deassign sys$error
109 $if f$search("''errFile'") .nes. "" then purge/nolog/keep=2 'errFile'
110 $if f$search("''sampleFile'") .nes. "" then -
111 delete/noconfirm/nolog 'sampleFile';*
112 $if f$search("''tmpDirectory'tmp.*") .nes. "" then -
113 delete/noconfirm/nolog 'tmpDirectory'tmp.*;*
114 $pipe delete/noconfirm/nolog 'cacheFile';* && -
115 rename/nolog/noconfirm 'cacheFile'_new 'cacheFile' || -
116 rename/nolog/noconfirm 'cacheFile'_new 'cacheFile'
119 $search/nowarnings/noheading/format=nonull/exact/output='tmpCMS' -
120 'sampleFile' "Interrupt State","MP Synchronization","User Mode", -
121 "Idle Time","Free List Size","Process Count","Direct I/O Rate", -
123 $search/nowarnings/noheading/format=nonull/exact/output='tmpDisks' -
124 'sampleFile' "$DK","DSA","$1$DG"
125 $if f$extract(1,1,"''SWinfo'") .ge. 8
127 $pipe tcpip netstat -in | search/wild/output='tmpNetif' -
128 sys$pipe *.*.*.*,127.0.0./match=xor
131 $show system/batch/noheading/output='tmpQueues'
132 $show users/interactive/subprocess/batch/network/nohead/output='tmpUsr'
135 $open/read inFile 'tmpCMS'
137 $read/end_of_file=CMSdone/error=CMSdone inFile line
138 $cLine = f$edit(line,"compress,trim")
139 $if f$element(0," ",cLine) .eqs. "Interrupt" then -
140 wt0 = f$element(3," ",cLine)
141 $if f$element(1," ",cLine) .eqs. "Synchronization" then -
142 wt1 = f$element(3," ",cLine)
143 $if f$element(0," ",cLine) .eqs. "User" then -
144 cpu3 = f$element(3," ",cLine)
145 $if f$element(0," ",cLine) .eqs. "Idle" then -
146 cpu2 = f$element(3," ",cLine)
147 $if f$element(0," ",cLine) .eqs. "Free" then -
148 freeMem = f$element(0,".",f$element(4," ",cLine))
149 $if f$element(0," ",cLine) .eqs. "Process" then -
150 sys3 = f$element(3," ",cLine)
151 $if f$element(0," ",cLine) .eqs. "Direct" then -
152 sys1 = f$element(4," ",cLine)
153 $if f$element(0," ",cLine) .eqs. "Buffered" then -
154 sys2 = f$element(4," ",cLine)
160 $if f$search("''cacheFile'_new") .nes. "" then -
161 delete/noconfirm/nolog 'cacheFile'_new;*
163 $define sys$output "''cacheFile'_new"
164 $on error then goto WCFdone
165 $say "<<<check_mk>>>"
166 $say "Version: 1.6.0i1"
167 $say "AgentOS: openvms"
168 $say "Nodename: ",f$getsyi("nodename")
169 $say "Architecture: ''HWinfo'"
170 $say "SWversion: ''SWinfo'"
172 $say "''numCPU' ''cpu2' ''cpu3' ''wt0' ''wt1'"
174 $say "MemTotal: ",'MEMtotal'*('PGinfo'/1024)
175 $say "MemFree: ",'freeMem'*('PGinfo'/1024)
176 $say "SwapTotal: ",f$getsyi("swapfile_page")*('PGinfo'/1024)
177 $say "SwapFree: ",f$getsyi("swapfile_free")*('PGinfo'/1024)
178 $say "<<<vms_system>>>"
179 $say "''sys1' ''sys2' ''sys3'"
180 $say "<<<vms_diskstat>>>"
184 $say "<<<vms_queuejobs>>>"
186 $say "<<<vms_users>>>"
193 $open/read inFile 'tmpDisks'
195 $read/end_of_file=DSKdone/error=DSKdone inFile line
196 $cLine = f$edit(line,"compress,trim")
197 $Dname = f$element(0," ",cLine)
198 $if f$extract(0,1,f$element(1," ",cLine)) .nes. "("
200 $say f$element(0," ",cLine)," ",f$element(1," ",cLine)," ", -
201 f$getdvi("''Dname'","maxblock")," ", -
202 f$getdvi("''Dname'","freeblocks")," ",f$element(5," ",cLine)
204 $say f$element(0," ",cLine)," ",f$element(2," ",cLine)," ", -
205 f$getdvi("''Dname'","maxblock")," ", -
206 f$getdvi("''Dname'","freeblocks")," ",f$element(6," ",cLine)
213 $if f$extract(1,1,"''SWinfo'") .lt. 8 then return
214 $open/read inFile 'tmpNetif'
216 $read/end_of_file=NIFdone/error=NIFdone inFile line
217 $cLine = f$edit(line,"compress,trim")
218 $say f$element(0," ",cLine)," ",0," ",f$element(4," ",cLine)," ", -
219 0," ",0," ",0," ",f$element(5," ",cLine)," ",0," ", -
220 f$element(6," ",cLine)," ",0," ",0," ",0," ",f$element(7," ",cLine)
226 $open/read inFile 'tmpUsr'
228 $read/end_of_file=USRdone/error=USRdone inFile line
229 $cLine = f$edit(line,"compress,trim")
230 $say f$element(0," ",cLine)," ",f$element(1," ",cLine)," ", -
231 f$element(2," ",cLine)," ",f$element(3," ",cLine)," ", -
232 f$element(4," ",cLine)
238 $open/read inFile 'tmpQueues'
240 $read/end_of_file=QUEdone/error=QUEdone inFile cLine
241 $say f$extract(0,8,cLine)," ", -
242 f$edit(f$extract(9,15,cLine),"trim")," ", -
243 f$edit(f$extract(25,4,cLine),"trim")," ", -
244 f$edit(f$extract(45,15,cLine),"trim")," ", -
245 f$edit(f$extract(35,10,cLine),"trim")," ", -
246 f$edit(f$extract(60,10,cLine),"trim")
251 $!######################[:END: check_mk_agent.com :END:]######################