前言:监控web网站方法有很多种,这篇文章说一下对windows服务器 asp.net网站的监控

采用的方案,Powershell + Influxdb + Grafana

1、PowerShell + Influxdb

PowerShell用来收集IIS指标,10秒采集一次,然后写入Influxdb,主要代码如下:需要注意PowerShell需要升级到5.0才能支持influxdb

标签分别是:Server主机名 ,AppName是网站名称

 function waitsec{
$step= #设置间隔
$add= #设置延时
$t=(get-date)
$step-(($t.Hour*+$t.Minute*+$t.Second)%$step)+$add
}
function GetData($cluster,$dept,$group,$project,$type)
{
$commandSet=@(
"\Web Service(*)\Current Anonymous Users",
"\Web Service(*)\Current Connections",
"\Web Service(*)\Current NonAnonymous Users",
"\Web Service(*)\Current Blocked Async I/O Requests",
"\Web Service(*)\Maximum Anonymous Users",
"\Web Service(*)\Measured Async I/O Bandwidth Usage",
"\Web Service(*)\Total Blocked Async I/O Requests",
"\Web Service(*)\Total Get Requests",
"\Web Service(*)\Total Method Requests",
"\Web Service(*)\Total Method Requests/sec",
"\Web Service(*)\Total Post Requests",
"\Web Service(*)\Total Put Requests",
"\Web Service(*)\Delete Requests/sec",
"\Web Service(*)\Get Requests/sec",
"\Web Service(*)\Options Requests/sec",
"\Web Service(*)\Post Requests/sec",
"\Web Service(*)\Put Requests/sec",
"\Web Service(*)\Other Request Methods/sec",
"\HTTP Service Request Queues(*)\CurrentQueueSize",
"\HTTP Service Request Queues(*)\RejectedRequests",
"\.NET CLR Exceptions(*)\# of Exceps Thrown / sec",
"\Process(w3wp*)\Thread Count",
"\Process(w3wp*)\% Processor Time",
"\Process(w3wp*)\Working Set - Private",
"\Process(w3wp*)\Working Set",
"\Process(w3wp*)\Private Bytes"
)
$res= get-counter -counter $commandSet
$index=
$metricAppName=""
$timestamp=[int] (Get-Date (Get-Date).ToUniversalTime() -uformat "%s")
$host_name = hostname
$table_name=""
while($res.countersamples[$index])
{
$Metrics1=@{}
$value= $res.countersamples[$index].cookedvalue
$metric=$res.countersamples[$index].path
$metricAppName=$res.countersamples[$index].InstanceName
$tempArray=$metric.replace("\\","").split("\")
$metric=$tempArray[]
$Metrics1.$metric = $value
if($tempArray[].startswith('web service'))
{
$table_name = "iis_web_service"
}
Elseif($tempArray[].startswith('http service'))
{
$table_name = "iis_http_service"
}
Elseif($tempArray[].startswith('.net clr exceptions'))
{
$table_name = "iis_net_clr_exceptions"
}
Elseif($tempArray[].startswith('process(w3wp'))
{
$table_name = "iis_process"
}
Write-Influx -Measure $table_name -Tags @{Server = $host_name; AppName = $metricAppName;} -Metrics $Metrics1 -Database monitor -Server http://influxdb:9096
$index = $index +
}
}
write-host "running...... please wait" (waitsec)"S"
Start-Sleep -s (waitsec)
while(){
#执行代码
get-date
(GetData)
#……
Start-Sleep -s (waitsec)
}

写入influxdb后的iis_http_service表的数据格式:

2、Grafana 配置展示

这里主要对webapi展示了当前连接数,当前排队数,和请求速率。

整体效果:

还可以在grafana告警里面设置一个WebHook,进行处理告警后的逻辑,比如:当这台机器压力比较大时可以对其进行从负载均衡移除 等等。

asp.net 网站监控方案的更多相关文章

  1. 前端性能监控方案window.performance 调研(转)

    1. 业界案例 目前前端性能监控系统大致为分两类:以GA为代表的代码监控和以webpagetest为代表的工具监控. 代码监控依托于js代码并部署到需监控的页面,手动计算时间差或者使用浏览器的的API ...

  2. ASP.NET MVC 监控诊断、本地化和缓存

    这篇博客主要是针对asp.net mvc项目的一些常用的东东做一个讲解,他们分别是监控诊断.本地化和缓存.虽然前两者跟asp.net mvc看上去好像是没什么关联. 但其实如果真正需要做asp.net ...

  3. 记一次ASP.NET网站的入侵和如何避免被入侵

    ASP.NET网站入侵第二波(LeaRun.信息化快速开发框架 已被笔者拿下) 详细介绍请看第二波 首先我要申明的是不是什么语言写出来的程序就不安全,而是得看写代码的人如何去写这个程序 前些日子我去客 ...

  4. 如何真正提高ASP.NET网站的性能

    摘要:前言 怎么才能让asp.net网站飞得更快,有更好的性能?这是很多开发者常常思考的一个问题.我有时候会做大量的测试,或请求别人帮忙采集一些数据,希望能够验证网上一些专家的建议或证明 前言 怎么才 ...

  5. 构建ASP.NET网站十大必备工具(2)

    正常运行时间 当一个网站发布以后,你肯定希望你的网站不会遇到任何问题,一直处在正常运行状态之中.现在,我使用下面这些工具来监控“Superexpert.com”网站,确保它一直处在正常运行状态之中. ...

  6. 26种提高ASP.NET网站访问性能的优化方法 .

    1. 数据库访问性能优化 数据库的连接和关闭 访问数据库资源需要创建连接.打开连接和关闭连接几个操作.这些过程需要多次与数据库交换信息以通过身份验证,比较耗费服务器资源. ASP.NET中提供了连接池 ...

  7. ASP.NET 网站管理工具

    ylbtech-Miscellaneos:ASP.NET 网站管理工具 1. 网站管理工具概述返回顶部 网站管理工具概述 介绍 使用网站管理工具,可以通过一个简单的 Web 界面来查看和管理网站配置. ...

  8. 构建ASP.NET网站十大必备工具

    最近使用ASP.NET为公司构建了一个简单的公共网站(该网站的地址:http://superexpert.com/).在这个过程中,我们使用了数量很多的免费工具,如果把构建ASP.NET网站的必备工具 ...

  9. C# -- HttpWebRequest 和 HttpWebResponse 的使用 C#编写扫雷游戏 使用IIS调试ASP.NET网站程序 WCF入门教程 ASP.Net Core开发(踩坑)指南 ASP.Net Core Razor+AdminLTE 小试牛刀 webservice创建、部署和调用 .net接收post请求并把数据转为字典格式

    C# -- HttpWebRequest 和 HttpWebResponse 的使用 C# -- HttpWebRequest 和 HttpWebResponse 的使用 结合使用HttpWebReq ...

随机推荐

  1. 关于"undefined reference"错误

    这个错误换句话说: 链接的时候找不到实现的文件(谨记从这个入手!). 可能导致的原因有: 1. 没有链接库文件,包括静态库或动态库. 2. 链接文件的顺序问题,先后依赖问题,把被依赖的放后面. 3. ...

  2. 【校招面试 之 剑指offer】第9-1题 用两个栈实现一个队列

    #include<iostream> #include<stack> using namespace std; template <typename T> void ...

  3. OC 线程操作2 - NSThread

        方法1 :直接创建 alloc init - (void)createNSThread111{ /* 参数1: (nonnull id) 目标对象 self 参数2:(nonnull SEL) ...

  4. handler通信机制

    package com.example.gp08_day26_handler3; import android.os.Bundle; import android.os.Handler; import ...

  5. ef linq 访问视图返回结果重复

    根据检测到的语句查询和linq查询出来的结果不一致,linq查询出重复的数据,原因不明,已改用ef直接查询视图,也许以后某一天突然就解决了,先mark下.

  6. 原型工具之团队协作: Axure VS Mockplus

    一款软件产品的诞生,必然会经历一个过程:需求分析.设计.开发.测试.上线.如此反复迭代.而设计阶段中,原型设计.制作.交流.审核.迭代,是软件设计和开发的重要保障. 简单的一段话,我们可以解读出很多隐 ...

  7. centos 6.5 安装mysql

    步骤1: yum -y install mysql-server 步骤2: chkconfig mysqld on 步骤3: service mysqld start mysql -u root se ...

  8. Django入门与实践-第14章:用户注册(完结)

    http://127.0.0.1:8000/signup/ django-admin startapp accounts INSTALLED_APPS = [ 'accounts', ] # mypr ...

  9. org.eclipse.ui.PartInitException: Unable to open editor, unknown editor ID: org.xmen.ui.text.XMLTextEditor

    无法打开struts模式的编译xml的编译器,然后打开.project文件,编辑最后一行,找到<natures>结点,增加一条<nature>com.genuitec.ecli ...

  10. HDU 5957 Query on a graph (拓扑 + bfs序 + 树剖 + 线段树)

    题意:一个图有n个点,n条边,定义D(u,v)为u到v的距离,S(u,k)为所有D(u,v)<=k的节点v的集合 有m次询问(0<=k<=2): 1 u k d:将集合S(u,k)的 ...