如果预期的计划报告电子邮件未到达,则会收到警告

发布于 2024-10-12 10:10:24 字数 1539 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泡沫很甜 2024-10-19 10:10:24

拥有像 Nagios 这样的集中监控解决方案,您将其配置为仅在服务错过其心跳、达到高水位线、耗尽燃料时才发送通知,这不是更好的选择吗?然后,第二个监控解决方案监控主监控解决方案......

http://www.nagios。 org/documentation

我不知道您描述的任何服务,但手动例程可能是这样的:

有一个像这样的文件夹/标签结构:

Services\Hourly-[NumberOfServices] (or add a folder per service)
Services\Daily-[NumberOfServicves]
Services\Weekly-[NumberOfServicves]
Services\Monthly-[NumberOfServicves]

有传入邮件的规则来过滤每个特定的服务通知并将其移动到根据预期时间选择正确的文件夹。

每小时醒来并检查每小时文件夹中是否有未读消息。未读数应与文件夹中提到的 NumberOfServices 相同。阅读/处理它们并确保将它们全部标记为已读。任何不通过电子邮件发送的服务都很容易被发现。

0:00 唤醒并检查每日文件夹中是否有未读消息。等等等等..

周六 0:00 醒来,检查每周文件夹中是否有未读消息。等等......

每月一号0:00 唤醒,检查每周文件夹中是否有未读消息。等等等等...

我的建议是减少服务产生的噪音。

如果你仍然觉得你需要服务,我只能提供一个非常非常基本的.Net实现,大致基于上述过程并与gmail一起使用......
这也可以移植到 powershell...

static void Main(string[] args)
        {
            var resolver = new XmlUrlResolver
            {
                Credentials = new NetworkCredential("yourgoolgeaccount", "yourpassword")
            };

            var settings = new XmlReaderSettings();

            settings.XmlResolver = resolver;

            var xr = XmlReader
                .Create("https://mail.google.com/mail/feed/atom/[name of your filter]"
                , settings);

            var navigator = new XPathDocument(xr).CreateNavigator();

            var ns = new XmlNamespaceManager(new NameTable());
            ns.AddNamespace("fd", "http://purl.org/atom/ns#");

            var fullcountNode =  navigator.SelectSingleNode(
                "/fd:feed/fd:fullcount"
                , ns);

            Console.WriteLine(fullcountNode.Value);

            int fullcount = Int32.Parse(fullcountNode.Value);
            int expectCount = 10;

            if (expectCount > fullcount)
            {
                Console.WriteLine("*** NOT EVERY ONE REPORTED BACK");
            }
}

Wouldn't it be a better option to have a centralized monitoring solution like Nagios that you configure in such way that it only send out notifications when a service misses its heartbeat, reaches highwatermarks, run out of fuel? And then off course of a second monitoring solution that monitors the main monitoring solution....

http://www.nagios.org/documentation

I'm not aware of any service you describe but a manual routine might go like this:

Have a folder/tag structure like this:

Services\Hourly-[NumberOfServices] (or add a folder per service)
Services\Daily-[NumberOfServicves]
Services\Weekly-[NumberOfServicves]
Services\Monthly-[NumberOfServicves]

Have rules for incoming mail to filter each specific service notification and move it to the right folder based on its expected timing.

Wakeup every hour and check if there are unread messages in your Hourly folder. The number of unread should be the same as the NumberOfServices mentioned in the folder. Read/Process them and make sure to all mark them as Read. Any service that didn't e-mailed get's spotted easily.

Wakeup at 0:00 and check if there are unread messages in your Daily folder. etc etc..

Wakeup at 0:00 and Saturday and check if there are unread messages in your Weekly folder. etc.....

Wakeup at 0:00 on the first of the month and check if there are unread messages in your Weekly folder. etc etc etc...

My advice would be to cut down the noise generated by the services.

If you still feel you need a service I can only provide a very very basic .Net implementation roughly based on the above process and works with gmail...
This is also portable to powershell...

static void Main(string[] args)
        {
            var resolver = new XmlUrlResolver
            {
                Credentials = new NetworkCredential("yourgoolgeaccount", "yourpassword")
            };

            var settings = new XmlReaderSettings();

            settings.XmlResolver = resolver;

            var xr = XmlReader
                .Create("https://mail.google.com/mail/feed/atom/[name of your filter]"
                , settings);

            var navigator = new XPathDocument(xr).CreateNavigator();

            var ns = new XmlNamespaceManager(new NameTable());
            ns.AddNamespace("fd", "http://purl.org/atom/ns#");

            var fullcountNode =  navigator.SelectSingleNode(
                "/fd:feed/fd:fullcount"
                , ns);

            Console.WriteLine(fullcountNode.Value);

            int fullcount = Int32.Parse(fullcountNode.Value);
            int expectCount = 10;

            if (expectCount > fullcount)
            {
                Console.WriteLine("*** NOT EVERY ONE REPORTED BACK");
            }
}
万人眼中万个我 2024-10-19 10:10:24

您提到了 Gmail,因此您可能对 googlecl 感兴趣,它为您提供了对 Google 日历和文档等内容的命令行控件。不幸的是,他们还不支持 Gmail,但如果您的长期偏好是使用 Gmail 帐户作为状态报告的中心,那么 googlecl 可能是您的最佳选择。

从短期来看,您现在可以使用日历、Blogger 或文档的命令来尝试 googlecl,所有这些命令都已受支持。例如,这些命令将事件添加到 Google 日历:

google calendar add --cal server1 "I'm still alive at 13:45 today"
google calendar add "Server 1 is still alive at 2011-02-08 19:43"

...这些命令查询日历:

google calendar list --fields title,when,where --cal "commitments"
google calendar list -q party --cal ".*"

想一想,您甚至可能会发现日历、Blogger 或文档是比 Gmail 更适合跟踪状态更新的地方。例如,电子表格或日历格式应该更容易生成给定服务何时启动或关闭的图形表示。

您仍然需要编写一个使用 googlecl 来查询日历(或博客、文档或其他内容)的小程序,但是一旦您掌握了简单的命令行,其余的事情就应该非常简单了。以下是有关 googlecl 的更多信息的链接:

http://code.google.com/p/googlecl/< /a>

如果您确实想使用 Gmail,并且现在就使用它,他们会提供 IMAP 界面。使用 IMAP,您可以执行许多简单的操作,例如确定是否存在包含指定主题行的邮件。这是一个了解详细信息的好地方:

http:// /mail.google.com/support/bin/answer.py?hl=zh-CN&answer=75725

下面是一个简单示例,它使用 IMAP 和 Python 列出具有给定 Gmail“标签”的最近 10 封电子邮件":



import getpass, imaplib
# These gmail_* utilties are from https://github.com/drewbuschhorn/gmail_imap                                                                                                   
import gmail_mailboxes, gmail_messages, gmail_message

# Update these next lines manually, or turn them into parms or somesuch.                                                                                                        
gmail_account_name = "[email protected]" # Your full gmail address.                                                                                                      
mailbox_name = "StatusReports" # Use Gmail "labels" to tag the relevant msgs.                                                                                                   

class gmail_imap:
    def __init__ (self, username, password):
        self.imap_server = imaplib.IMAP4_SSL("imap.gmail.com",993)
        self.username = username
        self.password = password
        self.loggedIn = False
        self.mailboxes = gmail_mailboxes.gmail_mailboxes(self)
        self.messages = gmail_messages.gmail_messages(self)
    def login (self):
        self.imap_server.login(self.username,self.password)
        self.loggedIn = True
    def logout (self):
        self.imap_server.close()
        self.imap_server.logout()
        self.loggedIn = False

# Right now this prints a summary of the most-recent ten (or so) messages                                                                                                       
# which have been labelled in Gmail with the string found in mailbox_name.                                                                                                      
# It won't work unless you've used Gmail settings to allow IMAP access.                                                                                                         
if __name__ == '__main__':
    gmail = gmail_imap(gmail_account_name,getpass.getpass())
    gmail.messages.process(mailbox_name)
    for next in gmail.messages: 
      message = gmail.messages.getMessage(next.uid)
      # This is a good point in the code to insert some kind of search                                                                                                          
      # of gmail.messages.  Instead of unconditionally printing every                                                                                                           
      # entry (which is what the code below does), issue some sort of                                                                                                           
      # warning if the expected email (message.From and message.Subject)                                                                                                        
      # did not arrive within the expected time frame (message.date).                                                                                                           
      print message.date, message.From, message.Subject
    gmail.logout()

如代码注释中所述,如果该邮箱中的最新消息不包含预期消息,您可以对其进行调整以发出某种警告。然后每天(或您需要的任何时间段)运行一次 Python 程序,看看是否从未收到预期的电子邮件。

You mentioned Gmail, so you may be interested in googlecl, which gives you command-line controls for things like Google Calendar and Docs. Unfortunately they do not yet support Gmail, but if your long-term preference is to use a Gmail account as the hub of your status reports, then googlecl may be your best option.

In the short run, you can try out googlecl right now using the commands for Calendar, Blogger, or Docs, all of which are already supported. For example, these commands add events to Google Calendar:

google calendar add --cal server1 "I'm still alive at 13:45 today"
google calendar add "Server 1 is still alive at 2011-02-08 19:43"

...and these commands query the calendar:

google calendar list --fields title,when,where --cal "commitments"
google calendar list -q party --cal ".*"

Come to think of it, you may even find that Calendar, Blogger, or Docs are a more appropriate place than Gmail for tracking status updates. For example, a spreadsheet or calendar format should make it easier to generate a graphical representation of when a given service was up or down.

You still need to write a little program which uses googlecl to query the calendar (or blog, or docs, or whatever), but once you have simple command lines at your disposal, the rest should be pretty straightforward. Here's a link to further information about googlecl:

http://code.google.com/p/googlecl/

If you really want to use Gmail, and use it right now, they offer an IMAP interface. Using IMAP, you can perform numerous simple operations, such as determining if a message exists which contains a specified subject line. Here's one good place to learn about the details:

http://mail.google.com/support/bin/answer.py?hl=en&answer=75725

Here's a quick example that uses IMAP and Python to list the ten most-recent emails which have a given Gmail "Label":



import getpass, imaplib
# These gmail_* utilties are from https://github.com/drewbuschhorn/gmail_imap                                                                                                   
import gmail_mailboxes, gmail_messages, gmail_message

# Update these next lines manually, or turn them into parms or somesuch.                                                                                                        
gmail_account_name = "[email protected]" # Your full gmail address.                                                                                                      
mailbox_name = "StatusReports" # Use Gmail "labels" to tag the relevant msgs.                                                                                                   

class gmail_imap:
    def __init__ (self, username, password):
        self.imap_server = imaplib.IMAP4_SSL("imap.gmail.com",993)
        self.username = username
        self.password = password
        self.loggedIn = False
        self.mailboxes = gmail_mailboxes.gmail_mailboxes(self)
        self.messages = gmail_messages.gmail_messages(self)
    def login (self):
        self.imap_server.login(self.username,self.password)
        self.loggedIn = True
    def logout (self):
        self.imap_server.close()
        self.imap_server.logout()
        self.loggedIn = False

# Right now this prints a summary of the most-recent ten (or so) messages                                                                                                       
# which have been labelled in Gmail with the string found in mailbox_name.                                                                                                      
# It won't work unless you've used Gmail settings to allow IMAP access.                                                                                                         
if __name__ == '__main__':
    gmail = gmail_imap(gmail_account_name,getpass.getpass())
    gmail.messages.process(mailbox_name)
    for next in gmail.messages: 
      message = gmail.messages.getMessage(next.uid)
      # This is a good point in the code to insert some kind of search                                                                                                          
      # of gmail.messages.  Instead of unconditionally printing every                                                                                                           
      # entry (which is what the code below does), issue some sort of                                                                                                           
      # warning if the expected email (message.From and message.Subject)                                                                                                        
      # did not arrive within the expected time frame (message.date).                                                                                                           
      print message.date, message.From, message.Subject
    gmail.logout()

As noted in the code comments, you could adapt it to issue some sort of warning if the most-recent messages in that mailbox do not contain an expected message. Then just run the Python program once per day (or whatever time period you require) to see if the expected email message was never received.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文