Perform Informix performance monitoring with the shell

Source: Internet
Author: User
Tags header informix mkdir printf resource time interval

The use of the shell to achieve Informix performance monitoring, and output in HTML format, intuitive and convenient. It is suitable for monitoring system performance when Informix system is first built. This example is designed according to the cron mechanism, which is scheduled to be monitored every day when the system is busy, in order to analyze and rationalize the resource allocation and parameter settings of the system.

#!/bin/ksh
#ScriptName: Getgloinfo
#定义环境变量
Informixdir=/usr/informix
Informixserver=server0
Onconfig=onconfig.server0
Path= $PATH: $INFORMIXDIR/bin
Exportinformixdirinformixserveronconfigpath
logg= $INFORMIXDIR/log
#建立数据存放目录
Yue= ' Date+%y%m '
If[!-d${logg}/${yue}]
Then
Mkdir${logg}/html/${yue}>/dev/null2>&1
Mkdir${logg}/data/${yue}>/dev/null2>&1
Fi
#准备临时数据目录
Tmp=/tmp/glo;mkdir$tmp
#数据文件名: Format mmdd-hhmm
D= '/bin/date+%m%d-%h%m '
Glodat=${logg}/data/${yue}/${d}.glo
Tdir=${logg}/html/${yue}
Bname= '/bin/basename$glodat '
umask133
#采集数据
GetData () {
#提取统计项目
Onstat-gglo|awk ' {print$3} ' |sed-e ' 1,/^class/d '-e '/^$/d ' |sed ' $d ' >${tmp}/glotmp
#采集数据: time interval 100 seconds
foriin1234567
Todo
Onstat-gglo|awk ' {print$6} ' |sed-e ' 1,/total/d '-e '/^$/d ' ' >${tmp}/glo '. $i
paste${tmp}/glotmp${tmp}/glo.${i}>${tmp}/glo.$$
Mv${tmp}/glo.$$${tmp}/glotmp
[$i-lt7]&&sleep100
Done
awk ' {printf '%s ', $1;for (i=2;i<9;printf "%.2f", $i + +);
for (i=3;i<9;i++) printf "%.2f" ($i-$ (i-1));
for (i=4;i<9;i++) printf "%.2f", ($i-$2);p rintf "\ n"} ' ${tmp}/glotmp
}
Body () {
Cat$glodat|whilereadline
Todo
printf "<tralign=\" Center\ "valign=\" middle\ "><fontsize=\" 1\ ">\n"
Set$line
J=0
foriin$*
Todo
if["$j"!= "0"]
Then
printf "<td>%.2f</td>\n" $i
Else
printf "<td>%s</td>\n" $i
Fi
J=j+1
Done
printf "</tr>\n"
Done
}
Header () {
cat-<<!
<body>
<tablewidth= "1" "Border=" align= "center" bordercolorlight= "#FFCCCC" bordercolordark= "#FF6633" >
<CAPTION><FONTSIZE=+2><b>${bname}</b></FONT></CAPTION>
<tralign= "center" valign= "Middle" ><fontface= "song Body" >
<tdrowspan=2><fontsize=2>VPS</font></td>
<tdcolspan=7><fontsize=+2> raw Data (Onstat-gglo) </font></td>
<tdcolspan=6><fontsize=+2> resource Utilization (%) </font></td>
<tdcolspan=5><fontsize=+2> Cumulative Utilization (SEC) </font></td>
</tr>
<tralign= "center" valign= "Middle" ><fontsize= "1" >
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
<td>G</td>
<td> Session One </td>
<td> Session Two </td>
<td> session Three </td>
<td> session Four </td>
<td> Session Five </td>
<td> session Six </td>
<td>200 sec </td>
<td>300 sec </td>
<td>400 sec </td>
<td>500 sec </td>
<td>600 sec </td>
</tr>
!
}
Tailer () {
D= ' Date+%y/%m/%d-%h:%m '
cat-<<!
</table>
<p><fontsize= "1" >ReportDate:${D}</font></p>
!
}
#programmainbody
GetData > $GLODAT
Header > $tdir/$bname. html
Body >> $tdir/$bname. html
Tailer >> $tdir/$bname. html
RM-RF${TMP}

Output Sample:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.