c#实现服务器性能监控并发送邮件保存日志

客户端代码

代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Management;
using System.Configuration;
using System.Net;
using System.IO;

namespace MON.WS
{
    public partial class Service : ServiceBase
    {
        //post 11.9
        //卸载服务
        //installutil /u F:\XLFX-2\XLFX\MON.WS\bin\debug\MON.WS.EXE
        //安装服务
        //installutil F:\XLFX-2\XLFX\MON.WS\bin\debug\MON.WS.EXE
        object threadObj;
        Thread jobThread;
        Dictionary<string, PerformanceCounter> dicCounter;
        Dictionary<string, ManagementObject> dicDisk;

public Service()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 服务启动
        /// </summary>
        /// <param name="args"></param>
        protected override void OnStart(string[] args)
        {
            threadObj = new object();
            dicCounter = new Dictionary<string, PerformanceCounter>();
            dicDisk = new Dictionary<string, ManagementObject>();
            jobThread = new Thread(new ThreadStart(Job));
            jobThread.IsBackground = true;
            jobThread.Start();
        }
        /// <summary>
        /// 服务停止
        /// </summary>
        protected override void OnStop()
        {
            if (jobThread.IsAlive)
            {
                jobThread.Abort();
                jobThread.Join();
            }
            foreach (var obj in dicCounter.Values)
            {
                obj.Dispose();
            }
            foreach (var obj in dicDisk.Values)
            {
                obj.Dispose();
            }
            dicDisk.Clear();
            dicCounter.Clear();
        }

/// <summary>
        /// 监控线程
        /// </summary>
        void Job()
        {
            while (true)
            {
                lock (threadObj)
                {
                    //监控开始
                    try
                    {
                        var obj = new MONServiceClient.MONService();
                        var hn = Dns.GetHostName();
                        var ips = GetIpv4Address(hn);                       
                        if (ips.Count < 1)
                        {
                            obj.Dispose();
                            Thread.Sleep(60000);//如果服务器出错,那么就每分钟去检查一次
                            WriteLog("一个IPV4的地址也没有得到");
                            continue;
                        }
                        DataSet ds = GetConfigDS(hn,ips,obj);
                        if (ds == null)
                        {
                            obj.Dispose();
                            Thread.Sleep(60000);
                            WriteLog("请检查WEBService和全局变量设置");
                            continue;
                        }
                        int sleepTime;
                        try
                        {
                            sleepTime = Convert.ToInt32(ds.Tables[0].Rows[0]["LOG_CIRC"]) * 1000;//毫秒
                        }
                        catch
                        {
                            sleepTime = 60000;
                        }
                        if (sleepTime < 1)
                        {
                            sleepTime = 60000;
                        }
                        Thread.Sleep(sleepTime);
                        if (ds.Tables[1].Rows[0]["S_ISWATCH"].ToString() == "0")
                        {
                            //监控开关->关闭
                            obj.Dispose();
                            continue;
                        }
                        var arr = getWatchValue(ds).ToArray();
                        obj.UpdateServerStatus(arr);
                        obj.Dispose();
                    }
                    catch (Exception ex)
                    {
                        WriteLog(ex.Message);
                    }
                    //监控结束
                }
            }
        }
        /// <summary>
        /// 获取配置信息
        /// </summary>
        /// <param name="ips"></param>
        /// <returns></returns>
        DataSet GetConfigDS(string hn,List<IPAddress> ips,MONServiceClient.MONService obj)
        {
            DataSet ds;
            try
            {
                if (ips.Count > 1)
                {
                    ds = obj.GetMachineConfig(hn, ips[0].ToString(), ips[1].ToString());
                }
                else
                {
                    ds = obj.GetMachineConfig(hn, ips[0].ToString(), "");
                }
            }
            catch
            {
                ds = null;
            }
            return ds;
        }
        /// <summary>
        /// 获取性能数组
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        List<string> getWatchValue(DataSet ds)
        {
            var result = new List<string>();
            result.Add(ds.Tables[1].Rows[0]["LIST_ID"].ToString());
            result.Add(GetValue(ds.Tables[1].Rows[0]["S_CPU"].ToString()).ToString("F2"));
            result.Add(GetDiskValue(ds.Tables[1].Rows[0]["S_DISK_APP"].ToString()).ToString("F2"));
            result.Add(GetDiskValue(System.Environment.SystemDirectory.Substring(0, 2)).ToString("F2"));
            result.Add(GetValue(ds.Tables[1].Rows[0]["S_MEMORY"].ToString()).ToString("F2"));
            result.Add(GetValue(ds.Tables[1].Rows[0]["S_FLOW_IN"].ToString()).ToString("F2"));
            result.Add(GetValue(ds.Tables[1].Rows[0]["S_FLOW_OUT"].ToString()).ToString("F2"));
            result.Add(GetValue(ds.Tables[1].Rows[0]["S_WEB_PORT"].ToString()).ToString("F2"));
            result.Add(GetValue(ds.Tables[1].Rows[0]["S_SQL_CONNECT"].ToString()).ToString("F2"));
            result.Add(ds.Tables[1].Rows[0]["CAMP_ID"].ToString());
            result.Add(ds.Tables[1].Rows[0]["CICODE"].ToString());
            result.Add(ds.Tables[1].Rows[0]["S_KIND"].ToString());
            return result;
        }
        /// <summary>
        /// 获取IPV4的地址
        /// </summary>
        /// <param name="hn"></param>
        /// <returns></returns>
        List<IPAddress> GetIpv4Address(string hn)
        {
            var result = new List<IPAddress>();
            var ips = Dns.GetHostAddresses(hn);
            foreach (var ip in ips)
            {
                if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    result.Add(ip);
                }
            }
            return result;
        }
        /// <summary>
        /// 获取性能计数器的值
        /// </summary>
        /// <param name="configStr"></param>
        /// <returns></returns>
        double GetValue(string configStr)
        {
            try
            {
                if (!dicCounter.ContainsKey(configStr))
                {
                    var arr = configStr.Split('#');
                    var pc = new PerformanceCounter();
                    pc.CategoryName = arr[0];
                    pc.CounterName = arr[1];
                    pc.InstanceName = arr[2];
                    dicCounter.Add(configStr, pc);
                }
                return dicCounter[configStr].NextValue();
            }
            catch (Exception ex)
            {
                WriteLog(string.Format("计数器取值错误:{0}{1}{2}", configStr, Environment.NewLine, ex.Message));
                return -1;
            }
        }
        /// <summary>
        /// 获取磁盘信息的值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        double GetDiskValue(string key)
        {
            try
            {
                if (!dicDisk.ContainsKey(key))
                {
                    ManagementObject DiskInfo = new ManagementObject(string.Format("win32_logicaldisk.deviceid=\"{0}\"", key));
                    dicDisk.Add(key, DiskInfo);
                }
                dicDisk[key].Get();
                var s = Convert.ToDouble(dicDisk[key]["Size"]);
                var l = Convert.ToDouble(dicDisk[key]["FreeSpace"]);
                var d = (s - l) / s * 100;
                return d;
            }
            catch (Exception ex)
            {
                WriteLog(string.Format("获取磁盘信息值错误:{0}{1}{2}", key, Environment.NewLine, ex.Message));
                return -1;
            }
        }
        /// <summary>
        /// 写本地日志
        /// </summary>
        /// <param name="text"></param>
        void WriteLog(string text)
        {
            try
            {
                var logDic = ConfigurationManager.AppSettings["LogDic"];
                int logDays;
                try
                {
                    logDays = Convert.ToInt32(ConfigurationManager.AppSettings["LogDays"]);
                }
                catch
                {
                    logDays = 7;
                }
                if (logDays < 1)
                {
                    logDays = 7;
                }
                var fs = LogFileMon(logDic, logDays);
                StreamWriter writer = new StreamWriter(fs);
                writer.WriteLine(DateTime.Now.ToString());
                writer.WriteLine(text);
                writer.WriteLine("-----------------------------------------------------------");
                writer.Flush();
                writer.Close();
                fs.Close();
            }
            catch
            {
                //写日志出错就没办法了
            }
        }
        /// <summary>
        /// 维护日志文件
        /// </summary>
        /// <param name="logDic"></param>
        /// <param name="days"></param>
        FileStream LogFileMon(string logDic, int dayCount)
        {
            DirectoryInfo di = new DirectoryInfo(logDic);
            //如果日志文件夹不存在则创建日志文件夹;
            if (!di.Exists)
            {
                di.Create();
            }
            //当前应保存的日志数据
            List<string> days = new List<string>();
            for (var i = 0; i < dayCount; i++)
            {
                var d = DateTime.Now.AddDays(0 - i).ToString("yyyy-MM-dd");
                days.Add(string.Format("{0}.log", d));
            }
            //删除没用的历史数据
            foreach (var f in di.GetFiles())
            {
                if (!days.Contains(f.Name))
                {
                    f.Delete();
                }
            }
            //返回当前日志文件的数据流
            var fileName = Path.Combine(logDic, days[0]);
            var fs = File.Open(fileName, FileMode.Append,FileAccess.Write);
            return fs;
        }
    }
}

服务端代码

代码如下:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Threading
Imports System.Collections.Generic
Imports System.Text

' 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class MONService
    Inherits System.Web.Services.WebService

<WebMethod()> _
    Public Function GetMachineConfig(ByVal HostName As String, ByVal IP1 As String, ByVal IP2 As String) As DataSet
        Dim sqlda As New data_source.WebTao.Public.SqlServerData
        Try
            Dim sSQL As String = "select *  from mon_server_list " & _
                " where S_HOSTNAME ='" & HostName & "' and IP1 = '" & IP1 & "'  and IP2 = '" & IP2 & "'"
            Dim dt As DataTable = sqlda.GetMytable(sSQL)
            If dt.Rows.Count < 1 Then
                sqlda.runSql("insert into mon_server_list (S_HOSTNAME,IP1,IP2,S_ISWATCH,CICODE,S_NAME,CAMP_ID,S_KIND,STATUS) values ('" & HostName & "','" & IP1 & "','" & IP2 & "',0,'待确定','待确定',-1,0,0)")
                dt = sqlda.GetMytable(sSQL)
                sqlda.runSql("INSERT INTO [MON_INFO] ([LIST_ID],[S_CPU],[S_DISK_APP],[S_DISK_SYS],[S_MEMORY],[S_FLOW_IN],[S_FLOW_OUT],[S_WEB_PORT],[S_SQL_CONNECT],[IN_TIME]) VALUES (" & dt.Rows(0)("LIST_ID").ToString() & ",-1,-1,-1,-1,-1,-1,-1,-1,'" & Now.ToString() & "') ")
            End If
            Dim result As DataSet = sqlda.GetMyDataSet("select * from MON_PARAMETER")
            result.Tables.Add(dt)
            Return result
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
    <WebMethod()> _
    Public Function UpdateServerStatus(ByVal ParamArray ValueArr() As String)
        Dim sqlda As New data_source.WebTao.Public.SqlServerData
        Try
            Dim sSQL As String = "UPDATE [MON_INFO] " & _
                  " SET " & _
                  " [S_CPU] = " & ValueArr(1) & _
                  " ,[S_DISK_APP] = " & ValueArr(2) & _
                  " ,[S_DISK_SYS] = " & ValueArr(3) & _
                  " ,[S_MEMORY] = " & ValueArr(4) & _
                  " ,[S_FLOW_IN] = " & ValueArr(5) & _
                  " ,[S_FLOW_OUT] = " & ValueArr(6) & _
                  " ,[S_WEB_PORT] = " & ValueArr(7) & _
                  " ,[S_SQL_CONNECT] = " & ValueArr(8) & _
                  " ,[IN_TIME] = '" & Now.ToString() & "'" & _
                  " WHERE LIST_ID = " & ValueArr(0)
            sqlda.runSql(sSQL)
            '没有策略
            If ValueArr(9).Trim() = "-1" Or String.IsNullOrEmpty(ValueArr(9).Trim()) Then
                Return 0
            End If
            '找到策略
            sSQL = "select * from MON_CAMPAIGN_LIST where CAMP_ID = " & ValueArr(9)
            Dim dt As DataTable = sqlda.GetMytable(sSQL)
            Dim Dic As New Dictionary(Of String, String)
            Dic.Add("S_PRIORITY", dt.Rows(0)("S_PRIORITY").ToString())
            Dic.Add("S_ACTION", dt.Rows(0)("S_ACTION").ToString())

'验证策略
            sSQL = "select count(*) from MON_INFO where 1=1 and " & dt.Rows(0)("S_NAME").ToString & " and LIST_ID = " & ValueArr(0)
            Dim FLAG = CType(sqlda.myExecuteScalar(sSQL), Integer)
            '没有超标
            If FLAG < 1 Then
                Return 0
            End If

'是否到了下一个轮训间隔
            sSQL = "select TOP 1 * from [MON_MAIL]   WHERE list_id = " & ValueArr(0) & "  ORDER BY S_SENDTIME DESC "
            dt = sqlda.GetMytable(sSQL)
            Dim ts As TimeSpan = TimeSpan.MaxValue
            If dt.Rows.Count > 0 Then
                Dim thatTime As DateTime = CType(dt.Rows(0)("S_SENDTIME"), DateTime)
                ts = DateTime.Now.Subtract(thatTime)
            End If
            sSQL = "select * from MON_PARAMETER"
            dt = sqlda.GetMytable(sSQL)
            Dim circ As Integer = CType(dt.Rows(0)("MAIL_CIRC"), Integer)
            If ts.TotalSeconds < circ Then
                Return 0
            End If

'异步发信
            Dic.Add("S_TITLE", dt.Rows(0)("S_TITLE").ToString())
            Dic.Add("MAIL_SMTP_SERVER", dt.Rows(0)("MAIL_SMTP_SERVER").ToString())
            Dic.Add("MAIL_ACCOUNT", dt.Rows(0)("MAIL_ACCOUNT").ToString())
            Dic.Add("MAIL_PASSWORD", dt.Rows(0)("MAIL_PASSWORD").ToString())
            Dic.Add("MAIL_FROM", dt.Rows(0)("MAIL_FROM").ToString())
            Dic.Add("MAIL_ADDRESS", dt.Rows(0)("MAIL_ADDRESS").ToString())
            Dim sout As Double
            Dim sin As Double
            Try
                sin = Convert.ToDouble(ValueArr(5)) / 1024.0
                sout = Convert.ToDouble(ValueArr(6)) / 1024.0
            Catch ex As Exception
                sin = -1
                sout = -1
            End Try
            Dim sb As New StringBuilder()
            sb.AppendFormat("CPU使用率:{0}%<br />", ValueArr(1))
            sb.AppendFormat("内存使用率:{0}%<br />", ValueArr(4))
            sb.AppendFormat("系统磁盘使用率:{0}%<br />", ValueArr(3))
            sb.AppendFormat("文件磁盘使用率:{0}%<br />", ValueArr(2))
            sb.AppendFormat("网络下行流量IN:{0}KB/S<br />", sin.ToString())
            sb.AppendFormat("网络上行流量OUT:{0}KB/S<br />", sout.ToString())
            sb.AppendFormat("网站连接数:{0}<br />", ValueArr(7))
            sb.AppendFormat("数据库连接数:{0}<br />", ValueArr(8))
            Dim subject As String = String.Format("人力运营管理系统监控告警:{0}{1}", ValueArr(10), IIf(ValueArr(11) = "0", "WEB服务器", "数据库服务器"))
            Dim body As String = String.Format("{0}<br />{1}<br />{2}<br />{3}<br />{4}", DateTime.Now.ToString(), Dic("S_PRIORITY"), Dic("S_TITLE"), sb.ToString(), Dic("S_ACTION"))
            'TODO:oracle不支持~select @@identity
            sSQL = "INSERT INTO [MON_MAIL] ([LIST_ID] ,[S_SOURCE] ,[S_CONTENT] ,[S_ACTION] ,[S_PRIORITY] ,[S_ADDRESS] ,[STATUS] ,[S_SENDTIME]) VALUES " & _
            "(" & ValueArr(0) & ",'" & Dic("S_TITLE") & "','" & sb.ToString() & "','" & Dic("S_ACTION") & "','" & Dic("S_PRIORITY") & "','" & dt.Rows(0)("MAIL_ADDRESS").ToString() & "',0,'" & DateTime.Now.ToString() & "');select @@identity"
            Dim index As Integer = CType(sqlda.myExecuteScalar(sSQL), Integer)

Dic.Add("SUBJECT", subject)
            Dic.Add("BODY", body)
            Dic.Add("INDEX", index)
            Dic.Add("CONSTR", sqlda.GetMyConnStr())

ThreadPool.QueueUserWorkItem(AddressOf SendMail, Dic)
        Catch ex As Exception

End Try
    End Function
    Function SendMail(ByVal setting As Object) As Integer
        Try
            Dim Dic As Dictionary(Of String, String) = CType(setting, Dictionary(Of String, String))
            Dim iSmtpSetting As New PublicFunction.SmtpSetting
            iSmtpSetting.SmtpServer = Dic("MAIL_SMTP_SERVER")
            iSmtpSetting.SystemEmailAccount = Dic("MAIL_ACCOUNT")
            iSmtpSetting.SystemEmailAccountPassword = Dic("MAIL_PASSWORD")
            iSmtpSetting.SmtpAuthenticationType = 1
            Dim result As Boolean = PublicFunction.Mail.SendMail(iSmtpSetting, Dic("MAIL_FROM"), Dic("MAIL_ADDRESS"), Dic("SUBJECT"), Dic("BODY"), True, System.Web.Mail.MailPriority.High, System.Text.Encoding.UTF8, New String() {})
            Dim val As Integer = IIf(result, 1, 2)
            Dim sqlda As New data_source.WebTao.Public.SqlServerData(Dic("CONSTR"))
            sqlda.runSql("update MON_MAIL set STATUS = " & val & " where MAIL_ID = " & Dic("INDEX"))
        Catch ex As Exception

End Try
    End Function
End Class

(0)

相关推荐

  • Java Socket编程(四) 重复和并发服务器

    文章来源:aspcn 作者:孙雯 重复和并发服务器 这个应用程序被当作一个重复的服务器.因为它只有在处理完一个进程以后才会接受另一个连接.更多的复杂服务器是并发的.它为每一个请求分配一个线程,而不是来一个处理一个.所以看起来它在同时处理多人请求.所有的商业的服务器都是并发的服务器. Java数据报类 不像面向连接的类,数据报的客户端和服务器端的类在表面上是一样的.下面的程序建立了一个客户和服务器商的数据报sockets: DatagramSocket serverSocket = new Dat

  • Nginx+PHP(FastCGI)搭建高并发WEB服务器(自动安装脚本)第二版

    本文是依照张宴的 Nginx 0.7.x + PHP 5.2.10(FastCGI)搭建胜过Apache十倍的Web服务器(第5版) 编写 原文地址 http://blog.s135.com/nginx_php_v5/ 因为编译过程和等待时间繁琐,于是就自己写了个全自动安装的shell脚本,此脚本可以随意修改,转载请注明出处. 这篇文章为这个系列的第二版,在第一版的基础上加入 1.日志切割 2.智能选择yum或者rpm安装 下载地址 注意:如果不能使用yum源,请放入系统光盘,单张dvd的,如果

  • IIS Web服务器支持高并发设置方法详解

    适用的IIS版本:IIS 7.0, IIS 7.5, IIS 8.0 适用的Windows版本:Windows Server 2008, Windows Server 2008 R2, Windows Server 2012 1.应用程序池(Application Pool)的设置: General->Queue Length设置为65535(队列长度所支持的最大值)Process Model->Idle Time-out设置为0(不让应用程序池因为没有请求而回收)Recycling->

  • 5个并发处理技巧代码示例

    [译者注]在本文中,作者总结出了5个关于处理并发性程序的技巧,并给出代码示例,让读者更好地理解和使用这5种方法. 以下为译文: 1.捕获InterruptedException错误 请检查下面的代码片段: public class Task implements Runnable { private final BlockingQueue queue = ...; @Override public void run() { while (!Thread.currentThread().isInt

  • python高并发异步服务器核心库forkcore使用方法

    1 拷贝下面的代码到一个文件,并命名为forkcore.py 复制代码 代码如下: import osimport threadingimport selectimport socket class ds_forkcore(object): #async IO(epoll)    def ds_epoll(self):        epoll=select.epoll()        epoll.register(self.s.fileno(),select.EPOLLIN|select.E

  • Windows服务器应对高并发和DDOS攻击的配置方法

    windows系统本身就有很多机制可以用来提高性能和安全,其中有不少可以用来应对高并发请求和DDOS攻击的情况. 通过以下配置可以改善windows服务器性能: 一.应对高并发请求: 1.TCP连接延迟等待时间 TcpTimedWaitDelay: 这是设定TCP/IP 可释放已关闭连接并重用其资源前,必须经过的时间.关闭和释放之间的此时间间隔通称 TIME_WAIT状态或两倍最大段生命周期(2MSL)状态.在此时间内,重新打开到客户机和服务器的连接的成本少于建立新连接.减少此条目的值允许 TC

  • c#实现服务器性能监控并发送邮件保存日志

    客户端代码 复制代码 代码如下: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Diagnostics;using System.ServiceProcess;using System.Text;using System.Threading;using System.Management;using System.Configurat

  • 利用windows性能计数器进行服务器性能监控示例分享

    复制代码 代码如下: using System;using System.Collections.Generic;using System.Text;using System.Diagnostics;using System.Threading;using System.Management;using System.Runtime.InteropServices;using System.Data;using System.Data.SqlClient;using System.Directo

  • 值得收藏的20个Linux服务器性能优化技巧

    Linux是一种开源操作系统,它支持各种硬件平台,Linux服务器全球知名,它和Windows之间最主要的差异在于,Linux服务器默认情况下一般不提供GUI(图形用户界面),而是命令行界面,它的主要目的是高效处理非交互式进程,响应时间并不是那么重要,相反,能够长时间处理高负载才是最关键的.Linux高可用服务器集群解决方案让IT系统管理员可以从容应对许多常见的硬件和软件故障,允许多台计算机一起工作,为关键服务正常运行提供保障,系统管理员可以不中断服务执行维护和升级. Linux服务器有各种用途

  • Ubuntu上使用Netdata设置实时性能监控的详细流程

    介绍 Netdata通过可扩展的Web仪表板提供准确的性能监控,可以显示Linux系统上的流程和服务.它监控有关CPU,内存,磁盘,网络,进程等的指标. Netdata一旦安装就不需要额外的配置,但提供了重要的定制.该应用程序的效率和速度旨在与本机控制台管理工具(如vmstat,iostat和htop)相媲美. 本教程中的步骤涵盖了使用其内置Web服务器或可选地使用Nginx成功设置运行Netdata的一台Ubuntu 16.04服务器所需的一切. 准备 要学习本教程,您需要: 一个Ubuntu

  • docker环境搭建JMeter+Grafana+influxdb可视化性能监控平台的教程

    目录 1.安装docker 2.安装及配置influxDB 3.Grafana安装及配置 4.Jmeter配置及压测一个接口 背景: 在用jmeter压测接口的时候发现其原生的监控起来不是很友好,在网上查阅的时候发现结合influxDB和grafana,出来的报告很炫酷,监听结果看起来很舒服很明了. 前言: InfluxDB:是一款用Go语言编写的开源分布式时序数据库.该数据库现在主要用于存储涉及大量的时间戳数据. 小数据量的时候还性能还不错,但是数据量大一点,性能问题就体现出来了.不过只是收集

  • PHP实现服务器状态监控的方法

    本文实例讲述了PHP实现服务器状态监控的方法.分享给大家供大家参考.具体分析如下: PHP服务器状态监控对于很多朋友来讲都没做,只有看到网站挂了才知道,这种半夜网站关了是不知道情况了,对于网站也非常不好,为此这两天抽空写了个网页服务器状态监控,看到有朋友说需要,那我就放出来吧.很简单的东西. 使用方法: 打开压缩包里面的status.php文件.编辑这里的内容为你自己的邮箱信息.代码如下: 复制代码 代码如下: $mail->Host       = 'smtp.exmail.qq.com'; 

  • 优化Apache服务器性能的方法小结

    测试与提高性能 Apache服务器已经被设计得尽可能的快,即使你用一台配置不高的机器,用不着进行太复杂的设置,它的响应内容就足以塞满以前的各种窄带连接.但随网站内容日益复杂和带宽的增加,对Apache进行优化以取得更好的性能变得日益重要起来. 如果优化的结果仅仅是极小的性能提升那真是浪费时间.试想一下,你花了好几个小时甚至几天调整Apache的各种参数但结果仅是几个百分点的性能提升?因此,在优化前你做的第一步应该是测试你目前的服务器的性能水平以便决定如何优化你的服务器并衡量优化的效果. 关于对A

  • LAMP服务器性能优化技巧之Mysql优化

    Apache服务器优化.PHP优化.Mysql优化 对于程序开发人员而言,目前使用最流行的两种后台数据库即为MySQL and SQL Server.这两者最基本的相似之处在于数据存储和属于查询系统.如果你想建立一个.NET服务器体系,这一体系可以从多个不同平台访问数据,参与数据库的管理,那么你可以选用SQL Server服务器.如果你想建立一个第三方动态网站,从这一站点可以从一些客户端读取数据,那么MySQL将是一个不错的选择. 1.编译和安装MySQL 通过你的系统挑选可能最好的编译器,你通

  • 基于JVM性能监控命令介绍

    •jps:JVM Process StatusTool,显示指定系统内所有的HotSpot虚拟机进程 •jstat:JVM Statistics Monitoring Tool,用于手机HotSpot虚拟机各方面的运行数据 •jinfo: Configuration Info for Java 显示虚拟机配置信息 •jmap:Memory Map for Java,生成虚拟机的内存转储快照 •jhat: JVM Heap Dump Browser,用于分析headpdump文件,他会建立一个一个

  • Zabbix 上Windows性能监控的方法

    背景信息 最近在重新看一些关于windows 性能的书籍,对于我这样一个原来使用SCOM监控的懒人来说,Zabbix 上自带的windows OS template 的模板实在是不够用,因为之前SCOM监控包(微软出的,把所有工作都做了,我只需要按需启用规则和告警即可). 默认的Zabbix 性能数据只有Avg Latency,平均的数据也不准,想看下磁盘的Latency以及IOPS要自己动手,看了下zabbix 中windows performance Counter 的语法,我略有退缩了.全

随机推荐