zabbix监控AIX DB2数据库
程序员文章站
2022-09-04 18:24:35
记一次工作中使用zabbix监控aix db2数据库的经历。 记忆要点: 1.使用自定义perl脚本; 2.由于zabbix用户权限的原因,无法调用db2用户获取数据库的数据,所以在zabbix配置文件中设置已root用户启动 2.然后根据快照中的数据按照zabbix的格式定义键值,数据格式,以下面 ......
记一次工作中使用zabbix监控aix db2数据库的经历。
记忆要点:
1.使用自定义perl脚本;
2.由于zabbix用户权限的原因,无法调用db2用户获取数据库的数据,所以在zabbix配置文件中设置已root用户启动
- 首先,创建脚本,我这里的名称为db2stat.pl,脚本权限为755,确保有可执行权限
#!/usr/bin/perl -wt use file::spec; # set this to path of db2 executable $env{'path'} = "/opt/ibm/db2/v9.7/bin"; #db2可执行文件的路径 $dbuser = 'db2inst'; #定义db2数据库的用户 # directory where snapshots are cached. my $snapshot_dir = file::spec->tmpdir(); # get database name and timeout args my $timeout = shift @argv; my $dbname = shift @argv; # untaint if ($dbname =~ /^([-\w.]+)$/) { $dbname = $1; } else { die "bad dbname argument"; } if ($timeout =~ /^(\d+)$/) { $timeout = $1; } else { die "bad timeout value"; } # generate stat file name my $statfile = "$snapshot_dir/$dbname.txt"; my $tmpstatfile = "$snapshot_dir/$dbname.txt.tmp"; # regenerate stats if file too old if (! -f $statfile or (time - (stat($statfile))[10]) > $timeout) { # first touch file to prevent another perform in next moment system("/usr/bin/touch $statfile"); system("/usr/bin/su - $dbuser -c 'db2 update monitor switches using bufferpool on lock on sort on statement on table on uow on' >/dev/null 2>$1"); # 开启db2快照开关 #then generate tmp data system("/usr/bin/su - $dbuser -c 'db2 get snapshot for database on $dbname' >$tmpstatfile"); # 将获取的快照数据保存到本地 #finally swap files system("/usr/bin/cp -p $tmpstatfile $statfile"); } # generate regular expressions to match from args while (@argv) { my $key = shift(@argv); my $value = shift(@argv); if (defined $value) { # add preceding line match push(@re, qr/\s*\q$key\e\s*=\s*\q$value\e\s*/); } else { # add stat line match push(@re, qr/\s*\q$key\e\s*=\s*(.+)\s*/); } } # try to find value with preceding line matches and stat line match my $idx = 0; open(data, "<$statfile"); while (<data>) { my $line = $_; if ($line =~ $re[$idx]) { my $match = $1; # return the match if all expressions have been matched $idx++; if ($idx == scalar @re) { print "$match\n"; exit 0; } } # reset matches if empty line if ($line eq "") { $idx = 0; } }
2.然后根据快照中的数据按照zabbix的格式定义键值,数据格式,以下面为例
# user parameters for db2 snapshot statistics # simple statistics userparameter=db2stat.database_status[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "database status" userparameter=db2stat.apps_connected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "applications connected currently" userparameter=db2stat.apps_executing[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "appls. executing in db manager currently" userparameter=db2stat.locks_held[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "locks held currently" userparameter=db2stat.deadlocks_detected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "deadlocks detected" userparameter=db2stat.lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock escalations" userparameter=db2stat.excl_lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "exclusive lock escalations" userparameter=db2stat.agts_waiting_on_locks[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "agents currently waiting on locks" userparameter=db2stat.lock_timeouts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock timeouts" userparameter=db2stat.log_space_used[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "log space used by the database (bytes)" userparameter=db2stat.package_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache inserts" userparameter=db2stat.package_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache overflows" userparameter=db2stat.catalog_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache inserts" userparameter=db2stat.catalog_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache overflows" userparameter=db2stat.commit_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "commit statements attempted" userparameter=db2stat.rollback_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rollback statements attempted" userparameter=db2stat.dynamic_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "dynamic statements attempted" userparameter=db2stat.static_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "static statements attempted" userparameter=db2stat.failed_statement_operations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "failed statement operations" userparameter=db2stat.select_sql_statements_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "select sql statements executed" userparameter=db2stat.xquery_statements_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "xquery statements executed" userparameter=db2stat.updates_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "update/insert/delete statements executed" "db2stat.conf" 56 lines, 5523 characters # user parameters for db2 snapshot statistics # simple statistics userparameter=db2stat.database_status[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "database status" userparameter=db2stat.apps_connected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "applications connected currently" userparameter=db2stat.apps_executing[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "appls. executing in db manager currently" userparameter=db2stat.locks_held[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "locks held currently" userparameter=db2stat.deadlocks_detected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "deadlocks detected" userparameter=db2stat.lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock escalations" userparameter=db2stat.excl_lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "exclusive lock escalations" userparameter=db2stat.agts_waiting_on_locks[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "agents currently waiting on locks" userparameter=db2stat.lock_timeouts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock timeouts" userparameter=db2stat.log_space_used[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "log space used by the database (bytes)" userparameter=db2stat.package_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache inserts" userparameter=db2stat.package_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache overflows" userparameter=db2stat.catalog_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache inserts" userparameter=db2stat.catalog_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache overflows" userparameter=db2stat.commit_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "commit statements attempted" userparameter=db2stat.rollback_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rollback statements attempted" userparameter=db2stat.dynamic_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "dynamic statements attempted" userparameter=db2stat.static_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "static statements attempted" userparameter=db2stat.failed_statement_operations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "failed statement operations" # user parameters for db2 snapshot statistics # simple statistics userparameter=db2stat.database_status[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "database status" userparameter=db2stat.apps_connected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "applications connected currently" userparameter=db2stat.apps_executing[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "appls. executing in db manager currently" userparameter=db2stat.locks_held[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "locks held currently" userparameter=db2stat.deadlocks_detected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "deadlocks detected" userparameter=db2stat.lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock escalations" userparameter=db2stat.excl_lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "exclusive lock escalations" userparameter=db2stat.agts_waiting_on_locks[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "agents currently waiting on locks" userparameter=db2stat.lock_timeouts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock timeouts" userparameter=db2stat.log_space_used[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "log space used by the database (bytes)" userparameter=db2stat.package_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache inserts" userparameter=db2stat.package_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache overflows" userparameter=db2stat.catalog_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache inserts" userparameter=db2stat.catalog_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache overflows" userparameter=db2stat.commit_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "commit statements attempted" userparameter=db2stat.rollback_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rollback statements attempted" userparameter=db2stat.dynamic_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "dynamic statements attempted" userparameter=db2stat.static_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "static statements attempted" userparameter=db2stat.failed_statement_operations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "failed statement operations" userparameter=db2stat.select_sql_statements_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "select sql statements executed" userparameter=db2stat.xquery_statements_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "xquery statements executed" userparameter=db2stat.updates_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "update/insert/delete statements executed" userparameter=db2stat.rows_deleted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rows deleted" userparameter=db2stat.rows_inserted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rows inserted" userparameter=db2stat.rows_updated[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rows updated" userparameter=db2stat.rows_selected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rows selected" userparameter=db2stat.rows_read[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rows read" userparameter=db2stat.direct_reads[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "direct reads" userparameter=db2stat.direct_writes[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "direct writes" userparameter=db2stat.direct_reads_time[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "direct reads elapsed time (ms)" userparameter=db2stat.direct_writes_time[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "direct write elapsed time (ms)" userparameter=db2stat.log_space_available[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "log space available to the database (bytes)" userparameter=db2stat.lock_wait[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock waits" userparameter=db2stat.total_sort[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "total sorts" userparameter=db2stat.sort_overfows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "sort overflows" # file system statistics userparameter=db2stat.storage_path_free_space[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "storage path free space (bytes)" userparameter=db2stat.file_system_used_space[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "file system used space (bytes)" userparameter=db2stat.file_system_total_space[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "file system total space (bytes)" # memory heap statistics userparameter=db2stat.package_cache_heap_size[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "node number" "$3" "memory pool type" "package cache heap" "current size (bytes)" userparameter=db2stat.catalog_cache_heap_size[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "node number" "$3" "memory pool type" "catalog cache heap" "current size (bytes)" # buffer poll statistics userparameter=db2stat.buffer_pool_data_logical_reads[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "buffer pool data logical reads" userparameter=db2stat.buffer_pool_index_logical_reads[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "buffer pool index logical reads" userparameter=db2stat.buffer_pool_index_physical_reads[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "buffer pool index physical reads" userparameter=db2stat.buffer_pool_data_physical_reads[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "buffer pool data physical reads"
# user parameters for db2 snapshot statistics # simple statistics userparameter=db2stat.database_status[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "database status" userparameter=db2stat.apps_connected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "applications connected currently" userparameter=db2stat.apps_executing[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "appls. executing in db manager currently" userparameter=db2stat.locks_held[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "locks held currently" userparameter=db2stat.deadlocks_detected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "deadlocks detected" userparameter=db2stat.lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock escalations" userparameter=db2stat.excl_lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "exclusive lock escalations" userparameter=db2stat.agts_waiting_on_locks[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "agents currently waiting on locks" userparameter=db2stat.lock_timeouts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock timeouts" userparameter=db2stat.log_space_used[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "log space used by the database (bytes)" userparameter=db2stat.package_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache inserts" userparameter=db2stat.package_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache overflows" userparameter=db2stat.catalog_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache inserts" userparameter=db2stat.catalog_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache overflows" userparameter=db2stat.commit_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "commit statements attempted" userparameter=db2stat.rollback_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rollback statements attempted" userparameter=db2stat.dynamic_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "dynamic statements attempted" userparameter=db2stat.static_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "static statements attempted" userparameter=db2stat.failed_statement_operations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "failed statement operations" userparameter=db2stat.select_sql_statements_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "select sql statements executed" userparameter=db2stat.xquery_statements_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "xquery statements executed" userparameter=db2stat.updates_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "update/insert/delete statements executed" "db2stat.conf" 56 lines, 5523 characters # user parameters for db2 snapshot statistics # simple statistics userparameter=db2stat.database_status[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "database status" userparameter=db2stat.apps_connected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "applications connected currently" userparameter=db2stat.apps_executing[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "appls. executing in db manager currently" userparameter=db2stat.locks_held[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "locks held currently" userparameter=db2stat.deadlocks_detected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "deadlocks detected" userparameter=db2stat.lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock escalations" userparameter=db2stat.excl_lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "exclusive lock escalations" userparameter=db2stat.agts_waiting_on_locks[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "agents currently waiting on locks" userparameter=db2stat.lock_timeouts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock timeouts" userparameter=db2stat.log_space_used[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "log space used by the database (bytes)" userparameter=db2stat.package_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache inserts" userparameter=db2stat.package_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache overflows" userparameter=db2stat.catalog_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache inserts" userparameter=db2stat.catalog_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache overflows" userparameter=db2stat.commit_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "commit statements attempted" userparameter=db2stat.rollback_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rollback statements attempted" userparameter=db2stat.dynamic_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "dynamic statements attempted" userparameter=db2stat.static_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "static statements attempted" userparameter=db2stat.failed_statement_operations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "failed statement operations" # user parameters for db2 snapshot statistics # simple statistics userparameter=db2stat.database_status[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "database status" userparameter=db2stat.apps_connected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "applications connected currently" userparameter=db2stat.apps_executing[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "appls. executing in db manager currently" userparameter=db2stat.locks_held[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "locks held currently" userparameter=db2stat.deadlocks_detected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "deadlocks detected" userparameter=db2stat.lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock escalations" userparameter=db2stat.excl_lock_escalations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "exclusive lock escalations" userparameter=db2stat.agts_waiting_on_locks[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "agents currently waiting on locks" userparameter=db2stat.lock_timeouts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock timeouts" userparameter=db2stat.log_space_used[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "log space used by the database (bytes)" userparameter=db2stat.package_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache inserts" userparameter=db2stat.package_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "package cache overflows" userparameter=db2stat.catalog_cache_inserts[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache inserts" userparameter=db2stat.catalog_cache_overflows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "catalog cache overflows" userparameter=db2stat.commit_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "commit statements attempted" userparameter=db2stat.rollback_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rollback statements attempted" userparameter=db2stat.dynamic_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "dynamic statements attempted" userparameter=db2stat.static_statements_attempted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "static statements attempted" userparameter=db2stat.failed_statement_operations[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "failed statement operations" userparameter=db2stat.select_sql_statements_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "select sql statements executed" userparameter=db2stat.xquery_statements_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "xquery statements executed" userparameter=db2stat.updates_executed[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "update/insert/delete statements executed" userparameter=db2stat.rows_deleted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rows deleted" userparameter=db2stat.rows_inserted[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rows inserted" userparameter=db2stat.rows_updated[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rows updated" userparameter=db2stat.rows_selected[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rows selected" userparameter=db2stat.rows_read[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "rows read" userparameter=db2stat.direct_reads[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "direct reads" userparameter=db2stat.direct_writes[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "direct writes" userparameter=db2stat.direct_reads_time[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "direct reads elapsed time (ms)" userparameter=db2stat.direct_writes_time[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "direct write elapsed time (ms)" userparameter=db2stat.log_space_available[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "log space available to the database (bytes)" userparameter=db2stat.lock_wait[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "lock waits" userparameter=db2stat.total_sort[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "total sorts" userparameter=db2stat.sort_overfows[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "sort overflows" # file system statistics userparameter=db2stat.storage_path_free_space[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "storage path free space (bytes)" userparameter=db2stat.file_system_used_space[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "file system used space (bytes)" userparameter=db2stat.file_system_total_space[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "file system total space (bytes)" # memory heap statistics userparameter=db2stat.package_cache_heap_size[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "node number" "$3" "memory pool type" "package cache heap" "current size (bytes)" userparameter=db2stat.catalog_cache_heap_size[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "node number" "$3" "memory pool type" "catalog cache heap" "current size (bytes)" # buffer poll statistics userparameter=db2stat.buffer_pool_data_logical_reads[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "buffer pool data logical reads" userparameter=db2stat.buffer_pool_index_logical_reads[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "buffer pool index logical reads" userparameter=db2stat.buffer_pool_index_physical_reads[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "buffer pool index physical reads" userparameter=db2stat.buffer_pool_data_physical_reads[*],/usr/local/zabbix/scripts/db2stat.pl "$1" "$2" "buffer pool data physical reads"
3.在zabbix web端添加监控项,由于工作环境加密的原因,无法添加图片,以下面键值为例
db2stat.rows_updated[{$refresh_interval},{$database_name}]
在主机宏中添加对应的数据库的名字,指定数据的刷新间隔时间,
等待几分钟,查看有无监控数据
如果有不对的地方,请帮忙指点一下
下一篇: SQL Server排名或排序的函数
推荐阅读
-
Percona监控MySQL数据库,配置zabbix-agent和配置MySQL连接教程
-
zabbix监控AIX DB2数据库
-
Zabbix3.4监控mongodb数据库状态的方法
-
zabbix agent2 监控oracle数据库的方法
-
使用zabbix监控oracle数据库的方法详解
-
监控服务zabbix数据库监控配置详解
-
zabbix监控oracle数据库
-
Zabbix--)客户端安装以及如何添加数据库的动态监控视图
-
借助zabbix和mysql performance monitor模板实现mysql数据库的监控
-
Percona监控MySQL数据库,配置zabbix-agent和配置MySQL连接教程