zoukankan      html  css  js  c++  java
  • [服务器]脚本:批处理带参数ping命令 发送邮件脚本

    1、批处理带参数ping命令

    @echo off
    echo Input you IP address ......
    set /p IP=
    echo Your IP number is %IP%.
    ping %IP%
    set IP=
    pause

    2、发送告警脚本

    For counter = 1 To 3 Step 1
    SendMail
    Next

    Public Sub SendMail
    NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
    Set Email = CreateObject("CDO.Message")
    Email.From = "Server" '发件人名称
    Email.To = "test@test.com.cn" '收件人邮件地址
    Email.Subject = GetIP&" 温度告警!" '邮件主题
    MsgBox(email.subject) 调试用
    Email.Textbody="Test" '邮件内容
    With Email.Configuration.Fields
    .Item(NameSpace&"sendusing") = 2
    .Item(NameSpace&"smtpserver") = "test.com.cn" 'SMTP服务器地址
    .Item(NameSpace&"smtpserverport") = 25 'SMTP服务器端口
    .Item(NameSpace&"smtpauthenticate") = 1 'SMTP身份验证
    .Item(NameSpace&"sendusername") = "test" '发件帐号
    .Item(NameSpace&"sendpassword") = "test" '发件密码
    .Update
    End With
    Email.Send
    End Sub

    Public Function GetIP
    ComputerName="."
    Dim objWMIService,colItems,objItem,objAddress
    Set objWMIService = GetObject("winmgmts:\" & ComputerName & " ootcimv2")
    Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    For Each objItem in colItems
    For Each objAddress in objItem.IPAddress
    If objAddress <> "" then
    GetIP = objAddress
    Exit Function
    End If
    Next
    Next
    End Function

  • 相关阅读:
    【bzoj1191】 HNOI2006—超级英雄Hero
    【poj3020】 Antenna Placement
    【poj1274】 The Perfect Stall
    【poj2724】 Purifying Machine
    【poj2226】 Muddy Fields
    【codevs1257】 打砖块
    【poj2186】 Popular Cows
    【poj1236】 Network of Schools
    【poj1144】 Network
    【poj3177】 Redundant Paths
  • 原文地址:https://www.cnblogs.com/viphhs/p/4380151.html
Copyright © 2011-2022 走看看