pgbadger监控安装和使用

pgbadger监控安装和使用 

https://github.com/dalibo/pgbadger/tree/v3.3   --安装包的下载地址,可以随意选择自己想要的版本 

1、解压下载的安装包 
drwxr-xr-x 3 root root   4096 May  5 08:19 pgbadger-5.1  --解压出来的目录 
-rw-r--r-- 1 root root 275644 Sep  3 03:21 pgbadger-5.1.zip 

2、安装 
[root@localhost ~]# cd pgbadger-5.1 
[root@localhost pgbadger-5.1]# ll 
total 1004 
-rw-r--r-- 1 root root  55530 May  5 08:19 ChangeLog 
-rw-r--r-- 1 root root    365 May  5 08:19 CONTRIBUTING.md 
drwxr-xr-x 2 root root   4096 May  5 08:19 doc 
-rw-r--r-- 1 root root    903 May  5 08:19 LICENSE 
-rw-r--r-- 1 root root   1399 May  5 08:19 Makefile.PL 
-rw-r--r-- 1 root root     81 May  5 08:19 MANIFEST 
-rw-r--r-- 1 root root    334 May  5 08:19 META.yml 
-rw-r--r-- 1 root root 873457 May  5 08:19 pgbadger 
-rw-r--r-- 1 root root  22729 May  5 08:19 README 
[root@localhost pgbadger-5.1]# perl Makefile.PL 
Checking if your kit is complete... 
Looks good 
Writing Makefile for pgBadger 

[root@localhost pgbadger-5.1]# make 
cp pgbadger blib/script/pgbadger 
/usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/pgbadger 
Manifying blib/man1/pgbadger.1 
[root@localhost pgbadger-5.1]# make install 
Installing /usr/share/man/man1/pgbadger.1 
Installing /usr/bin/pgbadger 
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/pgBadger/.packlist 
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod 

3、查看安装版本 
[root@testos ]# which pgbadger 
/usr/bin/pgbadger 
[root@testos ~]# pgbadger -V 
pgBadger version 5.1 

4、设置postgresql.conf 
log_line_prefix = '%t-%d-%h-%a :'   
                                        #   %a = application name 
                                        #   %u = user name 
                                        #   %d = database name 
                                        #   %r = remote host and port 
                                        #   %h = remote host 
                                        #   %p = process ID 
                                        #   %t = timestamp without milliseconds 
                                        #   %m = timestamp with milliseconds 
                                        #   %i = command tag 
                                        #   %e = SQL state 
                                        #   %c = session ID 
                                        #   %l = session line number 
                                        #   %s = session start timestamp 
                                        #   %v = virtual transaction ID 
                                        #   %x = transaction ID (0 if none) 
                                        #   %q = stop here in non-session 

5、网页查看 
http://192.168.10.173/out.html  --暂时打不开,还有没装完的。 

6、安装httpd、php 
yum install httpd      ---要先自己配置yum,才能使用yum install 进行安装 
chkconfig httpd on     --添加到自动启动 
service httpd start 
yum install php 

/var目录下就多了www目录 
[root@localhost www]# ll 
total 32 
drwxr-xr-x 2 root root 4096 Jul 15  2009 cgi-bin 
drwxr-xr-x 3 root root 4096 Sep  3 03:39 error 
drwxr-xr-x 2 root root 4096 Jul 15  2009 html 
drwxr-xr-x 3 root root 4096 Sep  3 03:39 icons 
[root@localhost www]# pwd 
/var/www 

7、在html下新建php文件,并测试http://192.168.10.173:/test.php能否正常打开 
网页显示如下: 
<? 
phpinfo(); 
?> 
---显示图形化界面才是正确的,而不是只读取文本内容 

8、安装apache 
>tar -zxvf httpd-2.2.11.tar.gz  
>cd httpd-2.2.11  
>./configure --prefix=/usr/local/apache 
make 
make install 

9、重启apache服务,再次验证 
vi /usr/local/apache/conf/httpd.conf 
找到"DirectoryIndex index.html在index.html 前添加 test.php 

service httpd restart 
http://192.168.10.173:/test.php --可以看到图形化界面 

10、想办法把pg监控的log显示到这个界面 
vi  /etc/httpd/conf/httpd.conf    修改两处 
DocumentRoot "/var/www/"    --这样就可以读取www下面所有的目录和文件,因为我在/var/www下面新建了一个pgbadger子目录,out.html就放在下面 
                            如果不修改设置,就会提示找不到/pgbadger/out.html 

11、尝试手动执行 
cd /usr/bin 
[root@localhost bin]# pgbadger --prefix '%t-%d-%h-%a :' /pg/pg_log1/*.csv -o /var/www/pgbadger/out.html 
Can't locate Text/CSV_XS.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/bin/pgbadger line 1583. 
---看样子应该是没办法读取csv格式的文件 

修改配置文件,将日志文件改成log 
log_destination = 'csvlog'             # Valid values are combinations of  
                                        # stderr, csvlog, syslog, and eventlog, 
                                        # depending on platform.  csvlog 
                                        # requires logging_collector to be on. 

# This is used when logging to stderr: 
logging_collector = on          # Enable capturing of stderr and csvlog 
                                        # into log files. Required to be on for 
                                        # csvlogs. 
                                        # (change requires restart) 

# These are only used if logging_collector is on: 
log_directory = '/pg/pg_log1'           # directory where log files are written, 
                                        # can be absolute or relative to PGDATA 
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,  

12、再次执行 
[root@localhost bin]# pgbadger --prefix '%t-%d-%h-%a :' /pg/pg_log1/*.log -o /var/www/pgbadger/out.html 
FATAL: unable to detect log file format from /pg/pg_log1/postgresql-2014-09-03_193449.log, please use -f option.   ---无法检测格式 

需要指定格式 
[root@localhost pg_log1]# pgbadger --prefix '%t-%d-%h-%a :' /pg/pg_log1/*.csv -o /var/www/pgbadger/out.html -f csv    --报错 
Can't locate Text/CSV_XS.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/bin/pgbadger line 1583. 

[root@localhost pg_log1]# pgbadger --prefix '%t-%d-%h-%a :' /pg/pg_log1/*.csv -o /var/www/pgbadger/out.html -f stderr  --正确 
[========================>] Parsed 441 bytes of 441 (100.00%), queries: 0, events: 0 

或者 
pgbadger --prefix '%t-%d-%h-%a :' /pg/pg_log1/*.log -o /var/www/pgbadger/out.html -f csvlog  

13、验证成功 
http://192.168.12.173:/pgbadger/out.html 
可以打开监控页面,但是完全无数据 
[root@localhost bin]# pgbadger --prefix '%t-%d-%h-%a :' /pg/pg_log1/*.log -o /var/www/pgbadger/out.html  -不添加格式后,又可以了 
[========================>] Parsed 4303 bytes of 4303 (100.00%), queries: 8, events: 6 
LOG: Ok, generating html report... 

--Ok,搞定,可以在网页上面看到监控的数据了。 

14、定期执行命令 
[root@localhost ~]# cat run.sh 
#!/bin/bash 
/usr/bin/pgbadger --prefix '%t-%d-%h-%a :' /pg/pg_log1/*.log  -o /var/www/pgbadger/out.html 

vi /etc/crontab 
0 */1 * * * root /root/run.sh 

============================再次安装pgbadger==================== 
[root@pg pgbadger]# find / -name "pgbadger" 
/var/www/html/pgbadger 
/var/www/html/pgbadger/blib/script/pgbadger 
/var/www/html/pgbadger/pgbadger 
/usr/local/bin/pgbadger 

[root@pg pgbadger]# cat run.sh 
#!/bin/bash 
/usr/local/bin/pgbadger --prefix '%t-%d-%h-%a :' /home/pgsql/9.1/data/pg_log/postgresql-201* -o /var/www/html/pgbadger/out.html 

1、下载 
https://github.com/dalibo/pgbadger 
https://github.com/dalibo/pgbadger/releases 

2、安装 --192.168.12.29 
[root@antiywh-5NMQMH1 tmp]# tar -zxvf pgbadger-7.1.tar.gz 
pgbadger-7.1/ 
pgbadger-7.1/.gitignore 
pgbadger-7.1/.perltidyrc 
pgbadger-7.1/CONTRIBUTING.md 
pgbadger-7.1/ChangeLog 
pgbadger-7.1/LICENSE 
pgbadger-7.1/MANIFEST 
pgbadger-7.1/META.yml 
pgbadger-7.1/Makefile.PL 
pgbadger-7.1/README 
pgbadger-7.1/doc/ 
pgbadger-7.1/doc/pgBadger.pod 
pgbadger-7.1/pgbadger 
pgbadger-7.1/tools/ 
pgbadger-7.1/tools/README 
pgbadger-7.1/tools/pgbadger_tools 

[root@antiywh-5NMQMH1 pgbadger-7.1]# make && make install   --直接安装报错 
make: *** 没有指明目标并且找不到 makefile。 停止。 

[root@antiywh-5NMQMH1 pgbadger-7.1]# perl Makefile.PL 
Checking if your kit is complete... 
Looks good 
Writing Makefile for pgBadger 
[root@antiywh-5NMQMH1 pgbadger-7.1]# make && make install 
cp pgbadger blib/script/pgbadger 
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/pgbadger 
Manifying blib/man1/pgbadger.1p 
Installing /usr/local/share/man/man1/pgbadger.1p 
Installing /usr/local/bin/pgbadger 
Appending installation info to /usr/lib64/perl5/perllocal.pod 

root@antiywh-5NMQMH1 pgbadger-7.1]# which pgbadger 
/usr/local/bin/pgbadger 
[root@antiywh-5NMQMH1 ~]# pgbadger -V 
pgBadger version 7.1 

3、安装php和httpd依赖包 
yum install -y  httpd  httpd-devel php  php-devel  
chkconfig httpd on 
[root@antiywh-5NMQMH1 ~]# service httpd start 
正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using 220.250.64.18 for ServerName 
                                                           [确定] 
[root@antiywh-5NMQMH1 data]# service httpd restart 
停止 httpd:                                               [确定] 
正在启动 httpd:                                           [确定] 
                                                         
                                                          
4、安装apache 
>tar -zxvf httpd-2.2.11.tar.gz  
>cd httpd-2.2.11  
>./configure --prefix=/usr/local/apache 
make && make install 

5、修改一些pg库的参数 
logging_collector = on 
#log_destination = 'stderr' 
#log_directory = 'pg_log' 
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' 
log_line_prefix = '%t-%d-%h-%a :' 

6、修改参数 
vi  /etc/httpd/conf/httpd.conf 
DocumentRoot "/var/www/"     --这样就可以读取www下面所有的目录和文件,因为我在/var/www下面新建了一个pgbadger子目录,out.html就放在下面 
                            如果不修改设置,就会提示找不到/pgbadger/out.html 
ServerName  127.0.0.1:80 
<Directory "/var/www/pgbadger">   --指定具体目录 
Options Indexes FollowSymLinks 
Order allow,deny 
Allow from all 
AllowOverride All 
</Directory> 
                           
vi /usr/local/apache/conf/httpd.conf 
写一个网页验证: 
[root@antiywh-5NMQMH1 pgbadger]# pwd 
/var/www/pgbadger 
[root@antiywh-5NMQMH1 pgbadger]# cat test.php 
<?php 
echo "tina's website"; 
?> 

7、重启apache服务,再次验证 
service httpd restart 
http://192.168.12.29:/pgbadger/test.php 

若是启动报错,说端口占用,就先kill掉 
[root@antiywh-5NMQMH1 html]# netstat -lnp|grep 80 
tcp        0      0 :::80                       :::*                        LISTEN      16634/httpd         
[root@antiywh-5NMQMH1 html]# ps 16634 
  PID TTY      STAT   TIME COMMAND 
16634 ?        Ss     0:00 /usr/local/apache/bin/httpd -k start 

kill -9 16634  

8、启动pgbadger的 
/usr/local/bin/pgbadger --prefix '%t-%d-%h-%a :' /home/pgsql/9.1/data/pg_log/postgresql-201* -o /var/www/html/pgbadger/out.html 

----------- 
[root@localhost mha4mysql-node-0.52]#  perl Makefile.PL;make;make install 
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: inc /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at inc/Module/Install/Makefile.pm line 4. 
BEGIN failed--compilation aborted at inc/Module/Install/Makefile.pm line 4. 
Compilation failed in require at inc/Module/Install.pm line 307. 
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: inc /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at inc/Module/Install/Can.pm line 6. 
BEGIN failed--compilation aborted at inc/Module/Install/Can.pm line 6. 
Compilation failed in require at inc/Module/Install.pm line 307. 
Can't locate ExtUtils/MM_Unix.pm in @INC (@INC contains: inc /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at inc/Module/Install/Metadata.pm line 316. 
make: *** 没有指明目标并且找不到 makefile。 停止。 
make: *** 没有规则可以创建目标“install”。 停止。 

解决办法:        yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker 

CPAN(Comprehensive Perl Archive Network)是internet上Perl模块最大的集散地,包含了现今公布的几乎所有的perl模块, 
通过上面的例子,可以获知利用这个格式,可以到CPAN上安装需要的模块。 

到CPAN的官方站点下载CPAN模块 
   http://search.cpan.org/~andk/CPAN-1.9301/lib/CPAN.pm 

解压,编绎,安装 
    $tar zxvf CPAN-1.9301.tar.gz 
    $cd CPAN-1.9301 
    $perl Makefile.PL 
    ImportingPAUSE public key into your GnuPG keychain... done! 
    (Youmay wish to trust it locally with 'gpg --lsign-key 450F89EC') 
    WARNING:SIGN is not a known parameter. 
    Checkingif your kit is complete... 
    Looksgood 
    Warning:prerequisite Test::Harness 2.62 not found. We have 2.56. 
    Warning:prerequisite Test::More 0 not found. 
    'SIGN'is not a known MakeMaker parameter name. 
    WritingMakefile for CPAN 
    
    
    http://search.cpan.org/~andk/ 
    
  CPAN-2.10.tar.gz 
  
[root@pgtina CPAN-2.10]# perl Makefile.PL 
Importing PAUSE public key into your GnuPG keychain... gpg: new configuration file `/root/.gnupg/gpg.conf' created 
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run 
done! 
(You may wish to trust it locally with 'gpg --lsign-key 450F89EC') 
Checking if your kit is complete... 
Looks good 
Warning: prerequisite CPAN::Meta::Requirements 2.121 not found. 
Warning: prerequisite HTTP::Tiny 0.005 not found. 
Warning: prerequisite Test::More 0 not found. 
Writing Makefile for CPAN 
make && make install 

依然去http://search.cpan.org/~andk/  查找这个CPAN::Meta::Requirements  HTTP::Tiny 

装了两个之后再检测就差一个 
[root@pgtina CPAN-2.10]# perl Makefile.PL 
Importing PAUSE public key into your GnuPG keychain... done! 
(You may wish to trust it locally with 'gpg --lsign-key 450F89EC') 
Warning: prerequisite Test::More 0 not found. 
Writing Makefile for CPAN 

yum install perl-Time-HiRes 

http://192.168.12.29/pgbadger/out.html   7.1版本的 
http://192.168.12.250/pgbadger/out.html   3.3版本的  这个版本的看着舒服些 

          

---前段部分我是个外行,只能简单的实现下我想要的效果~大家可以忽略以下内容---------- 

怎么添加首页面    
[root@pg html]# pwd 
/var/www/html 
[root@pg html]# cat index.php 
<html> 
<head> 
<title>数据库监控工具</title> 
</head> 
<body> 
<br/></br/> 
<h1 align='center'>欢迎使用数据库监控系统</h1> 
<p align='center'> 
&nbsp;&nbsp;&nbsp;&nbsp;<a href='pgbadger/out.html'>主库日志监控(20服务器)</a> <br/> 
<br/> 
&nbsp;&nbsp;&nbsp;&nbsp;<a href='pgbadger/out_18.html'>从库日志监控(18服务器)</a> 
</p> 
<p align='center'> 
<font color='red'>备注:日志分析结果2小时更新一次</font> 
</p> 
<p> 
20数据库运维日志<br> 
<?php 
$file = fopen("log.txt","r"); 
while(!feof($file)) 

    echo fgets($file). "<br />"; 

fclose($file); 
?> 
</p> 
</body> 
</html> 

[root@antiywh-5NMQMH1 www]# vi getdata.sh 
#!/bin/bash 
su -  postgres -c "psql -d tm_samples" <<EOF 
\o /var/www/html/log.txt 
SELECT * FROM ( 
SELECT RELNAME ,pg_relation_size(RELNAME::regclass )/1024/1024 tabMB FROM PG_STAT_USER_TABLES 
)AA where tabMB > 10 
ORDER BY tabMB DESC; 
\q 
EOF 
echo "日志文件数(保存四天日志):" >> /var/www/html/log.txt 
ls /home/pgsql/9.1/data/pg_log/|wc -l >> /var/www/html/log.txt 

尽量配置到/var/www/html目录下 
[root@pgtina html]# ll 
total 24 
-rwxr-xr-x. 1 root     root      376 Dec  7 10:57 getdata.sh 
-rw-r--r--. 1 root     root      525 Dec  7 10:21 index.php 
-rw-rw-r--. 1 postgres postgres 6691 Dec  7 10:57 log.txt 
drwxrwxrwx. 2 root     root     4096 Dec  7 10:10 pgbadger 
-rw-r--r--. 1 root     root       32 Dec  4 15:48 test.php 
[root@pgtina html]# 

/////////////////////////////////////////////////////////////新的监控页面(表大小+表行数)/////////////////////////////////////////////////// 

如果在字符才中有双引号的话,可以使用反斜杠"\"来进行转义 

10 */2 * * *  root sh /tmp/run.sh 

pgbadger监控页面的数据 
[root@antiywh-5NMQMH1 pg_log]# cat /tmp/run.sh 
#!/bin/bash 
/usr/local/bin/pgbadger --prefix '%t-%d-%h-%a :' /home/pgsql/9.1/data/pg_log/postgresql-201* -o /var/www/html/pgbadger/out.html 

[root@pgtina html]# pwd 
/var/www/html 
[root@pgtina html]# ll 
total 24 
-rw-r--r--. 1 root root  172 Dec  8 15:08 db_jk.log 
drwxr-xr-x. 2 root root 4096 Dec  8 15:18 file 
-rwxrwxrwx. 1 root root 2741 Dec  8 15:39 getdata.sh 
-rwxr-xr-x. 1 root root  864 Dec  8 14:18 index.php 
drwxrwxrwx. 2 root root 4096 Dec  8 14:10 pgbadger 
-rw-r--r--. 1 root root   32 Dec  4 15:48 test.php 

主页面(展示数据库的名字跟表个数),子页面(表大小+表行数) 

[root@pgtina html]# cat getdata.sh 
#!/bin/bash 
#2015-12-8 tina 
date=`date +"%Y-%m-%d %H:%M:%S"` 
rm -f /var/www/html/db_jk.log 
rm -f /var/www/html/file/*.php 
rm -f /var/www/html/file/*.txt 
rm -f /tmp/pg250_*.log 
num1=`ls /home/pgsql/9.1/data/pg_log/|wc -l` 

databases=$(psql -U postgres -c "select datname from pg_database where datname not like 'temp%' and datname not like 'postgres' order by datname;" |grep -v "datname" |grep -v "row"|grep -v "-") 
for db in $databases 
do 
num2=$(psql -U postgres -d $db -c "select count(*) from pg_tables where schemaname='public';"|grep -v "count" |grep -v "row"|grep -v "-") 
echo "$db  $num2">>/var/www/html/db_jk.log 
done 

for db in $databases 
do 
tables=$(psql -U postgres -d $db -c "select tablename from pg_tables where  schemaname='public' order by tablename;"|grep -v "tablename" |grep -v "row"|grep -v "\-") 

for table in $tables 
    do 
       echo $table >>/tmp/pg250_$db.log 
       psql -U postgres -d $db  -c "select count(*) from $table;" |grep -v "count" |grep -v "row"|grep -v "\-">>/tmp/pg250_$db.log 
    done 
cat /tmp/pg250_$db.log|awk 'NF==1{printf "%s   ", $1;next}1'>>/var/www/html/file/$db.txt 

echo "<html>" >/var/www/html/file/$db.php 
echo "<body>">>/var/www/html/file/$db.php 
echo '<div style="position:absolute;width:100%;height:100%;z-index:-1"> 
<img src="./3.jpg" width="100%" height="100%" /> 
</div>' >>/var/www/html/file/$db.php 
echo "<br/></br/>" >>/var/www/html/file/$db.php 
echo "<h1 align='center'>欢迎使用数据库监控系统</h1>" >>/var/www/html/file/$db.php 
echo "最近一次更新时间:$date <br/>">>/var/www/html/file/$db.php 
echo "<br/></br/>" >>/var/www/html/file/$db.php 
echo "日志文件数(保存四天日志):$num1" >>/var/www/html/file/$db.php 
echo "<br/></br/>">>/var/www/html/file/$db.php 
echo "表名     表大小(mb):<br/>" >>/var/www/html/file/$db.php 
data=$(psql -U postgres -d $db -c "SELECT * FROM (SELECT RELNAME ,pg_relation_size(RELNAME::regclass )/1024/1024 tabMB FROM PG_STAT_USER_TABLES )AA ORDER BY tabMB DESC;"|grep -v "relname" |grep -v "-"| awk '{print $0,"<br/>"}') 
echo $data >> /var/www/html/file/$db.php 
echo "<br/>">>/var/www/html/file/$db.php 
echo "表名     表行数:" >>/var/www/html/file/$db.php 
echo "<br/>">>/var/www/html/file/$db.php 
echo "<?php" >>/var/www/html/file/$db.php 
echo "\$file = fopen(\"/var/www/html/file/$db.txt\",\"r\");" >>/var/www/html/file/$db.php 
echo "while(!feof($file))" >>/var/www/html/file/$db.php 
echo "{" >>/var/www/html/file/$db.php 
echo 'echo fgets($file). "<br />";' >>/var/www/html/file/$db.php 
echo "}" >>/var/www/html/file/$db.php 
echo "fclose($file);" >>/var/www/html/file/$db.php 
echo "?>" >>/var/www/html/file/$db.php 
echo "</body>" >>/var/www/html/file/$db.php 
echo "</html>" >>/var/www/html/file/$db.php 
done 

[root@pgtina html]# cat index.php 
<html> 
<head> 
<title>数据库监控工具</title> 
</head> 
<body> 
<div style="position:absolute;width:100%;height:100%;z-index:-1"> 
  <img src="./file/4.jpg" width="100%" height="100%" /> 
</div> 
<br/></br/> 
<h1 align='center'>欢迎使用数据库监控系统</h1> 
<p align='center'> 
&nbsp;&nbsp;&nbsp;&nbsp;<a href='pgbadger/out.html'>主库日志监控(250测试服务器)</a> <br/> 
<br/> 
</p> 
<p align='center'> 
<font color='red'>备注:日志分析结果2小时更新一次</font> 
</p> 
服务器IP:192.168.12.250 
<br/></br/> 
服务器角色:测试库 
<br/></br/> 
数据库列表(数据库名 表个数): 
<br/> 
<?php 
$file = fopen("/var/www/html/db_jk.log","r"); 
while(!feof($file)) 

    $str = trim(fgets($file)); 
    $arr = strstr($str,' ',TRUE); 
    echo '<a href="/file/'.$arr.'.php">'. $str. "</a><br />"; 

fclose($file); 
?> 
</p> 
</body> 
</html> 

[root@pgtina html]# cat db_jk.log 
devops       1 
dw_report      16 
dynfarming       6 
engine      15 
mongo_statistic       5 
t_url       4 
test      11 
tm_exchange      11 
tm_samples     311 
yunwei      64 

[root@pgtina file]# cat devops.php 
<html> 
<body> 
<div style="position:absolute;width:100%;height:100%;z-index:-1"> 
<img src="./3.jpg" width="100%" height="100%" /> 
</div> 
<br/></br/> 
<h1 align='center'>欢迎使用数据库监控系统</h1> 
最近一次更新时间:2015-12-08 15:08:54 <br/> 
日志文件数(保存四天日志):8 
<br/></br/> 
表名     表大小(mb):<br/> 
t_test_wubao | 14 <br/> (1 row) <br/> <br/> 
<br/> 
表名     表行数: 
<br/> 
<?php 
$file = fopen("/var/www/html/file/devops.txt","r"); 
while(!feof()) 

echo fgets($file). "<br />"; 

fclose(); 
?> 
</body> 
</html> 

访问:http://192.168.12.20 
      http://192.168.12.20/pgbadger/out.html 
      http://192.168.12.20/file/devops.php 

时间: 2024-10-27 23:01:19

pgbadger监控安装和使用的相关文章

centos6系统snmp监控安装配置与使用示例

  简单网络管理协议(SNMP),由一组网络管理的标准组成,包含一个应用层协议(application layer protocol).数据库模型(database schema)和一组资源对象,下文一起来和111cn小编看看centos6系统snmp监控安装配置与使用. 安装 Net-SNMP CentOS及其它RedHat系列产品提供了net-snmp的二进制包.我们可以直接从源里安装. Example yum install net-snmp net-snmp-devel net-snmp

Cacti监控安装完成后导入Nginx监控模板发生的问题

环境: Ubuntu server 12.04 x64 Cacti-0.8.8a 今天安装了Cacti监控,安装完成后,导入Nginx监控模板,发现监控的时候,一直不出图,很是郁闷.结果在系统时面直接调用监控Nginx状态的pl脚本,发现报错 cactiuser@00098:/var/tmp/cacti/cacti/rra$ /usr/bin/perl /var/tmp/cacti/cacti-0.8.8a/scripts/get_nginx_clients_status.pl   http:/

Panabit监控安装教程

Panabit,一款网络监控软件,在精确识别协议即对应用分类的基础上,根据用户自定义策略,提供灵活方便的流量管理机制:带宽限速.带宽保证.带宽预留,并可基于协议/协议组.IP/IP组进行参数化的策略设置. 下载地址:http://forum.panabit.com/forum.php?mod=attachment&aid=NTY4MXxkZmE5Zjk4ZHwxNDEzMzYzNzM0fDB8MTAyMTc= 安装需求:服务器最少3块网卡,512MB内存. 下载后,刻成光盘,使用光盘启动,对Pa

centos系统上Munin监控安装教程

I. 安装 在安装之前请确保已安装EPEL,如果没有,你可以参考centos安装EPEL来安装Munin yum --enablerepo=epel install munin munin-common munin-node rrdtool 通过安装提示我们可以发现,munin主要依靠perl来工作. 安装完毕后系统会有如下改变: /etc/munin/munin.conf : Munin master(服务器端) 配置文件. /etc/cron.d/munin : Munin 设置cronta

Nagios远程监控安装与配置详解图文第1/3页_组网教程

作为系统管理员,我最担心那些重要的在线系统在我不知情的情况下停机或者停止网络服务,而且那些发生故障的服务或主机有时候可能要好长一段时间才知道.尤其是遇到节假日,系统管理员就很紧张.要改变这种被动局面,这里我推荐网络监控软件Nagios,个人认为它最大的好处是可以发故障报警短信-只要Nagios监控的对象发生故障,系统就会自动发送短信到手机上.下面摘录Nagios官方网站的描述: Nagios is an open source host, service and network monitori

linux中zabbix监控安装与配置详解

在安装客户端的时候,软件包和服务器是同一个,只是configure 的配置参数不同而已. 添加用户,用户组,解压包  代码如下 复制代码 [root@logsec /usr/local/src] #groupadd zabbix -g 201 [root@logsec /usr/local/src] #useradd -g zabbix -u 201 -m zabbix [root@logsec /usr/local/src] #tar -xvf zabbix-2.0.5.tar.gz 编译安装

百度杀毒的实时监控是什么

  百度杀毒的实时监控安装后,百度杀毒软件会对个人设备进行实时监测,出现病毒威胁时,会根据设置,自动删除病毒文件,或者锁定病毒文件禁止其运行,等待处理.

命令行下的抗毒精英

  一.TASKLIST--火眼金睛 如今的病毒越来越狡猾,常常不见首也不见尾.但许多病毒往往在进程这一环节中露出狐狸尾巴,因而查看进程是查杀病毒的一个重要的方法.命令行提供了进程查看的命令工具--Tasklist(Windows XP或更新版本).此命令与任务管理器一样可以显示活动进程的列表.但通过使用参数,可以看到任务管理器查看不到的信息,可以实现更强大的功能.使用参数"/M",运行"Tasklist /M"将显示每个任务加载的所有的DLL模块;使用参数&quo

微服务框架和工具大全

在<Java微服务>一书中,我们使用 Spring Cloud,它提供使微服务非常容易地开发所需的所有工具和平台.Spring Cloud使用 Netflix开放源码软件( OSS).让我们探讨 Netflix OSS--一个完整的软件包. Netflix开放源码软件(OSS) Netflix开放源码软件中心是基于 Java的微服务开放源码项目最流行和最广泛使用的开放源码软件.世界上最成功的视频租赁服务依赖于它.Netflix已经有超过 4000万用户,他们在全球各地使用其服务.Netflix