就讲讲监控那些值,基线抓的是那些值。如何做告警

环境:windows 2008r2,sql server 2008r2 sp1

性能基线:

  cpu:

    \Processor(_Total)\% Processor Time
    \Processor(_Total)\% Privileged Time

    \SQLServer:SQL Statistics\Batch Requests/sec
    \SQLServer:SQL Statistics\SQL Compilations/sec
    \SQLServer:SQL Statistics\SQL Re-Compilations/sec
    \System\Processor Queue Length
    \System\Context Switches/sec

  Memory:

    \Memory\Available Bytes
    \Memory\Pages/sec
    \Memory\Page Faults/sec
    \Memory\Pages Input/sec
    \Memory\Pages Output/sec
    \Process(sqlservr)\Private Bytes
    \SQLServer:Buffer Manager\Buffer cache hit ratio
    \SQLServer:Buffer Manager\Page life expectancy
    \SQLServer:Buffer Manager\Lazy writes/sec
    \SQLServer:Memory Manager\Memory Grants Pending
    \SQLServer:Memory Manager\Target Server Memory (KB)
    \SQLServer:Memory Manager\Total Server Memory (KB)

  Disk:

    \PhysicalDisk(_Total)\% Disk Time
    \PhysicalDisk(_Total)\Current Disk Queue Length
    \PhysicalDisk(_Total)\Avg. Disk Queue Length
    \PhysicalDisk(_Total)\Disk Transfers/sec
    \PhysicalDisk(_Total)\Disk Bytes/sec
    \PhysicalDisk(_Total)\Avg. Disk sec/Read
    \PhysicalDisk(_Total)\Avg. Disk sec/Write

  SQL Server:

    \SQLServer:Access Methods\FreeSpace Scans/sec
    \SQLServer:Access Methods\Full Scans/sec
    \SQLServer:Access Methods\Table Lock Escalations/sec
    \SQLServer:Access Methods\Worktables Created/sec
    \SQLServer:General Statistics\Processes blocked
    \SQLServer:General Statistics\User Connections
    \SQLServer:Latches\Total Latch Wait Time (ms)
    \SQLServer:Locks(_Total)\Lock Timeouts (timeout > 0)/sec
    \SQLServer:Locks(_Total)\Lock Wait Time (ms)
    \SQLServer:Locks(_Total)\Number of Deadlocks/sec
    \SQLServer:SQL Statistics\Batch Requests/sec
    \SQLServer:SQL Statistics\SQL Re-Compilations/sec

以上是性能基线监控的信息,当然性能警告也是监控这些信息,其中的阀值是根据基线抓取后体现。

关于性能警告我是使用powershell 写了一个脚本,运行在SQL Agent 中。如果出现警告,就通过dbmail 发送邮件

关于powershell 脚本和一些配置信息看如下:

$server = "(local)"
$uid = "sa"
$db="master"
$pwd="pwd"
$mailprfname = "sina"
$recipients = "xxxxx@qq.com"
$subject = "Proformance Alter"
$computernamexml = "f:\computername.xml"
$alter_cpuxml = "f:\alter_cpu.xml"
function GetServerName($xmlpath)
{$xml = [xml] (Get-Content $xmlpath)$return = New-Object Collections.Generic.List[string]for($i = 0;$i -lt $xml.computernames.ChildNodes.Count;$i++){if ( $xml.computernames.ChildNodes.Count -eq 1){$cp = [string]$xml.computernames.computername}else{$cp = [string]$xml.computernames.computername[$i]}$return.Add($cp.Trim())}$return
}function GetAlterCounter($xmlpath)
{$xml = [xml] (Get-Content $xmlpath)$return = New-Object Collections.Generic.List[string]$list = $xml.counters.Counter$list
}function CreateAlter($message)
{$SqlConnection = New-Object System.Data.SqlClient.SqlConnection $CnnString ="Server = $server; Database = $db;User Id = $uid; Password = $pwd" $SqlConnection.ConnectionString = $CnnString $CC = $SqlConnection.CreateCommand(); if (-not ($SqlConnection.State -like "Open")) { $SqlConnection.Open() } $cc.CommandText=" EXEC msdb..sp_send_dbmail @profile_name  = '$mailprfname',@recipients = '$recipients',@body = '$message',@subject = '$subject'
" $cc.ExecuteNonQuery()|out-null $SqlConnection.Close();
}$names = GetServerName($computernamexml)
$pfcounters = GetAlterCounter($alter_cpuxml)
foreach($cp in $names)
{$p = New-Object Collections.Generic.List[string]$report = ""foreach ($pfc in $pfcounters){$b = ""$counter ="\\"+$cp+$pfc.get_InnerText().Trim()$p.Add($counter)}$count = Get-Counter $pfor ($i = 0; $i -lt $count.CounterSamples.Count; $i++){$v = $count.CounterSamples.Get($i).CookedValue$pfc = $pfcounters[$i]#$pfc.get_InnerText()$b = ""$lg = ""if($pfc.operator -eq "lt"){if ($v -ge [double]$pfc.alter){$b = "alter"$lg = "Greater Than"}}elseif ($pfc.operator -eq "gt"){if( $v -le [double]$pfc.alter){$b = "alter"$lg = "Less Than"}}if($b -eq "alter"){$path = "\\"+$cp+$pfc.get_InnerText()$item = "{0}:{1};{2} Threshold:{3}" -f $path,$v.ToString(),$lg,$pfc.alter.Trim()$report += $item + "`n"}}if($report -ne ""){#生产警告 参数 计数器,阀值,当前值CreateAlter $report}
}

其中涉及到2个配置文件:computernamexml,alter_cpuxml分别如下:

<computernames><computername>fanr-pc</computername>
</computernames>

<Counters><Counter alter = "10" operator = "gt" >\Processor(_Total)\% Processor Time</Counter><Counter alter = "10" operator = "gt" >\Processor(_Total)\% Privileged Time</Counter><Counter alter = "10" operator = "gt" >\SQLServer:SQL Statistics\Batch Requests/sec</Counter><Counter alter = "10" operator = "gt" >\SQLServer:SQL Statistics\SQL Compilations/sec</Counter><Counter alter = "10" operator = "gt" >\SQLServer:SQL Statistics\SQL Re-Compilations/sec</Counter><Counter alter = "10" operator=  "lt" >\System\Processor Queue Length</Counter><Counter alter = "10" operator=  "lt" >\System\Context Switches/sec</Counter>
</Counters>

其中 alter 就是阀值,如第一条,如果 阀值 > 性能计数器值,就会发出警告。

    

SQL Server 性能基线和监控相关推荐

  1. sql server 性能_SQL Server性能基础

    sql server 性能 "The goal of monitoring databases is to assess how a server is performing. Effect ...

  2. SQL Server性能调优之执行计划深度剖析 第二节 执行计划第一次实践

    SQL Server性能调优之执行计划深度剖析 第二节 执行计划第一次实践 前言:自从上一篇文章发出之后,收到了很朋友的关注.很多朋友要求多多实践,而不是纯粹的理论.确实,从打算出这个系列开始,我就本 ...

  3. SQL Server 性能调优(cpu)

    SQL Server 性能调优(cpu) 研究cpu压力工具 perfom SQL跟踪 性能视图 cpu相关的waitevent Signal wait time SOS_SCHEDULER_YIEL ...

  4. sql server 性能_SQL Server硬件性能调整

    sql server 性能 SQL Server Performance Tuning can be a difficult assignment, especially when working w ...

  5. sql server 性能_如何在SQL Server中收集性能和系统信息

    sql server 性能 介绍 (Introduction) In this article, we're going through many of the tools we can use fo ...

  6. 使用Windows Performance Monitor进行SQL Server性能调整

    Windows Performance Monitor basics article, we described the most important Windows Performance Moni ...

  7. 收集的SQL Server性能相关资料

    这是本人在工作中整理的关于SQL Server性能相关资料,便于随时查阅 目录 性能监视器指标 内存问题诊断 侦测 CPU 压力 磁盘相关 内存 Memory Clerks Buffer Pool P ...

  8. 初涉SQL Server性能问题(3/4):列出阻塞的会话

    原文:初涉SQL Server性能问题(3/4):列出阻塞的会话 在 初涉SQL Server性能问题(2/4)里,我们讨论了列出等待资源或正运行的会话脚本.这篇文章我们会看看如何列出包含具体信息的话 ...

  9. 初涉SQL Server性能问题(1/4):服务器概况

    原文:初涉SQL Server性能问题(1/4):服务器概况 当你作为DBA时,很多人会向你抱怨:"这个程序数据加载和蜗牛一样,你看看是不是服务器出问题了?"造成这个问题的原因有很 ...

最新文章

  1. 彻底理解HashMap及LinkedHashMap
  2. 嬴彻与东风商用车完成L3重卡A样车验收,加速自动驾驶产品化
  3. Linux netstat查看网络连接状态
  4. linux redis release.c:37:10: fatal error: release.h: No such file or directory
  5. 室内主题元素分析图_2020届室内设计专业优秀毕业设计作品展(五)
  6. Dream City(01背包+小贪心)acm寒假集训日记21/12/30
  7. 《A Point Set Generation Network for 3D Object Reconstruction from a Single Image》论文笔记_2D图像生成3D点云
  8. 【CF】304 E. Soldier and Traveling
  9. numpy.ndarray.flat/flatten 与 Spark 下的 flatMap
  10. mysql表空间预估_MYSQL实战优化——数据页、表空间
  11. 微信dat文件用什么软件打开方式_2020微信dat文件解密工具怎么获取软件
  12. matlab中norm函数的用法
  13. h5php大转盘抽奖,html5转盘抽奖 完整代码下载(网页版)
  14. 「面向对象程序设计-C++」学习笔记(下半部分)
  15. Maven项目右边依赖好多红色波浪线处理办法
  16. 小学生怎样学习英语,ProudKids少儿英语推荐几首适合学英语的三年级英语歌曲
  17. S.M.A.R.T 参数详解及推荐指标
  18. cad能整体比例缩小吗_cad比例缩放 cad如何整体缩小尺寸
  19. 从截图里面识别数字_【答疑解惑】还没成功入驻数字工坊的同学看过来!!!
  20. ava中volatile关键字

热门文章

  1. .NET2.0隐形的翅膀,正则表达式搜魂者【月儿原创】
  2. CDMA模块上网设置的过程
  3. 判断输入是否为中文的函数
  4. JavaScript去除字符串首尾空格
  5. PE文件和COFF文件格式分析——导出表的应用——一种摘掉Inline钩子(Unhook)的方法
  6. TensorRT Samples: MNIST(Plugin, add a custom layer)
  7. 卷积神经网络(CNN)的简单实现(MNIST)
  8. 【leetcode】力扣刷题(3):无重复字符的最长子串(go语言)
  9. 八年级计算机网络公开课,计算机网络公开课教案.doc
  10. axure中图表背影_Axure 教程:动态图表——排名图