中の技術日誌ブログ

C#とC++/CLIと
VBと.NETとWindowsで戯れる
 

目次

Blog 利用状況

ニュース

自己紹介

東京でソフトウェアエンジニアをやっています。
お仕事大募集中です。
記事執筆や、講師依頼とかでも何でもどうぞ(*^_^*)
似顔絵 MSMVPロゴ
MSMVP Visual C# Since 2004/04-2013/03

記事カテゴリ

書庫

日記カテゴリ

00-整理

01-MSMVP

ディスク空き容量監視

サーバのディスク容量がかなりの危機です おもにIISのログが膨張していて・・・(^^;;

なのでもともとはvbsで作ろうと思っていたディスク容量監視プログラムを簡単にC#でこさえてみました。

このSystem.Net.Mailは非常に曲者で便利に使えるのに、日本語処理がダメダメで・・・

おがわさんにソースをもらったのでそいつを改良していいメールクライアントを作りたいですね。(^^

namespace Wankuma.わんくまサーバディスク容量監視
{
  class Program
  {
    static void SendMail( string body)
    {
      MailAddress from = new MailAddress("from");
      MailAddress to = new MailAddress("to");
      MailMessage message = new MailMessage(from, to);
      message.Subject = "わんくまサーバディスク容量監視";
      message.Body = body;
      SmtpClient client = new SmtpClient(Wankuma.わんくまサーバディスク容量監視.Properties.Settings.Default.SMTPサーバ名);
      client.Send(message);
    }
    static void Main(string[] args)
    {
      using (ManagementObjectSearcher Searcher = new ManagementObjectSearcher("Select * from Win32_LogicalDisk where DriveType=3"))
      {
        using (ManagementObjectCollection moc = Searcher.Get())
        {
          StringBuilder MailBody = new StringBuilder();
          foreach (ManagementObject mo in moc)
          {
            string DeviceID = (string)mo.Properties["DeviceID"].Value;
            UInt64 Size = (UInt64)mo.Properties["Size"].Value;
            UInt64 FreeSpace = (UInt64)mo.Properties["FreeSpace"].Value;
            int 利用済みパーセント = 100 - (int)((Decimal)FreeSpace / (Decimal)Size * 100);
            MailBody.Append(string.Format("{0}\t{1:###,###}MB\t{2:###,###}MB\t({3:###}%)\t{4}\r\n", DeviceID, FreeSpace / 1024 / 1024, Size / 1024 / 1024, 利用済みパーセント, 利用済みパーセント > 90 ? "CAUTION!!!" : ""));
          }
          SendMail(MailBody.ToString());
        }
      }
    }
  }
}

投稿日時 : 2006年5月8日 1:10

コメントを追加

# re: ディスク空き容量監視 2006/05/08 1:48 じゃんぬ

> おもにIISのログが膨張していて

おもに私のせいかな... ごめんなさい。(;_ _)

最近、わんくまがたまにもっさりして、
タイムアウトを起こす場合がありますが、原因はコレかいな?

# あ、たいてい blogs がもっさりしてるので、おもに中さんのせいかなw

# ブランド激安市場 2018/02/06 23:58 xomniabszsl@live.jp

特恵中-新作入荷!
当社の商品は絶対の自信が御座います
迅速、確実にお客様の手元にお届け致します
実物写真、付属品を完備しております。
低価格を提供すると共に、品質を絶対保証しております
ご注文を期待しています

# It's an remarkable paragraph in support of all the web users; they will take advantage from it I am sure. 2021/09/05 10:24 It's an remarkable paragraph in support of all the

It's an remarkable paragraph in support of all the web users;
they will take advantage from it I am sure.

# Heya i'm for the first time here. I found this board and I find It really useful & it helped me out a lot. I hope to give something back and help others like you helped me. 2021/12/24 0:01 Heya i'm for the first time here. I found this boa

Heya i'm for the first time here. I found this board and I find It really useful & it helped me
out a lot. I hope to give something back and help others like you helped me.

# doxycycline hydrochloride 100mg https://doxycyline1st.com/
doxycycline order online 2022/02/26 9:45 Jusidkid

doxycycline hydrochloride 100mg https://doxycyline1st.com/
doxycycline order online

# purchase clomid online https://clomiden.fun/ 2022/04/12 13:00 Clomids

purchase clomid online https://clomiden.fun/

# prednisolone prednisone http://prednisonefast.site/ 2022/04/16 22:55 Prednisone

prednisolone prednisone http://prednisonefast.site/

# lasix 20 mg https://buylasix.icu/
furosemide 40 mg 2022/06/24 17:12 LasixRx

lasix 20 mg https://buylasix.icu/
furosemide 40 mg

# order clomid https://clomidonline.icu/ 2022/07/08 13:40 Clomidj

order clomid https://clomidonline.icu/

# treatment of ed https://ed-pills.xyz/
best treatment for ed 2022/09/17 19:58 EdPills

treatment of ed https://ed-pills.xyz/
best treatment for ed

# doxy 200 https://buydoxycycline.icu/ 2022/10/08 11:57 Doxycycline

doxy 200 https://buydoxycycline.icu/

#  https://clomidforsale.site/ 2022/11/13 14:26 ForSale

https://clomidforsale.site/

# prednisone price south africa https://prednisonepills.site/
prednisone nz 2022/11/30 0:57 Prednisone

prednisone price south africa https://prednisonepills.site/
prednisone nz

# the best ed pill https://cheapestedpills.com/
treatments for ed 2022/12/10 16:31 CheapPills

the best ed pill https://cheapestedpills.com/
treatments for ed

# Long-Term Effects. drug information and news for professionals and consumers.
https://canadianfast.com/
Prescription Drug Information, Interactions & Side. All trends of medicament. 2023/02/20 6:00 CanadaBest

Long-Term Effects. drug information and news for professionals and consumers.
https://canadianfast.com/
Prescription Drug Information, Interactions & Side. All trends of medicament.

# generic for doxycycline - https://doxycyclinesale.pro/# 2023/04/21 17:38 Doxycycline

generic for doxycycline - https://doxycyclinesale.pro/#

# buy prednisone online australia - https://prednisonesale.pro/# 2023/04/22 4:56 Prednisone

buy prednisone online australia - https://prednisonesale.pro/#

# over the counter pain meds for dogs https://overthecounter.pro/# 2023/05/08 23:15 OtcJikoliuj

over the counter pain meds for dogs https://overthecounter.pro/#

# cheapest ed pills online: https://edpills.pro/# 2023/05/15 15:42 EdPillsPro

cheapest ed pills online: https://edpills.pro/#

# prednisone 2.5 mg daily https://prednisonepills.pro/# - prednisone purchase canada 2023/06/04 21:35 Prednisone

prednisone 2.5 mg daily https://prednisonepills.pro/# - prednisone purchase canada

# paxlovid covid https://paxlovid.pro/# - paxlovid generic 2023/07/02 17:35 Paxlovid

paxlovid covid https://paxlovid.pro/# - paxlovid generic

# paxlovid for sale https://paxlovid.store/
buy paxlovid online 2023/07/13 13:27 Paxlovid

paxlovid for sale https://paxlovid.store/
buy paxlovid online

# paxlovid price https://paxlovid.life/# Paxlovid buy online 2023/07/25 20:46 Paxlovid

paxlovid price https://paxlovid.life/# Paxlovid buy online

# ï»¿cytotec pills online https://cytotec.ink/# - buy cytotec online fast delivery 2023/07/26 14:44 PillsFree

cytotec pills online https://cytotec.ink/# - buy cytotec online fast delivery

# ed medication https://edpills.ink/# - otc ed pills 2023/07/27 1:16 EdPills

ed medication https://edpills.ink/# - otc ed pills

# erection pills https://edpillsotc.store/# - best erectile dysfunction pills 2023/10/08 1:36 EdPills

erection pills https://edpillsotc.store/# - best erectile dysfunction pills

# paxlovid price https://paxlovid.bid/ buy paxlovid online 2023/10/25 23:21 Paxlovid

paxlovid price https://paxlovid.bid/ buy paxlovid online

# doxycycline hydrochloride 100mg https://doxycycline.forum/ doxycycline monohydrate 2023/11/25 13:34 Doxycycline

doxycycline hydrochloride 100mg https://doxycycline.forum/ doxycycline monohydrate

# farmacie online sicure https://farmaciait.pro/ farmacia online migliore 2023/12/04 10:34 Farmacia

farmacie online sicure https://farmaciait.pro/ farmacia online migliore

タイトル
名前
URL
コメント