在 Azure 中构建 App Insight 以监控 Linux 服务器中的 Inotify 服务

Build App Insight in Azure for monitoring Inotify Services in Linux servers

您能否为 Azure 中的 Build App Insight 提供有价值的 suggestion/procedure 以监控 Linux 服务器中的 Inotify 服务

使用 Python 的 Application Insights,并编写 python 脚本,以便在您的文件系统发生变化时将数据发送到您的应用程序 Insights。

有用的链接:

https://pypi.org/project/inotify/

https://github.com/microsoft/ApplicationInsights-Python

您能否继续简要说明我如何为具有 inotify 工具的 Azure VM linux 构建它,以及基于步骤的应用洞察力,因为非常新

pip 安装 applicationinsights pip 安装 inotify

然后是这样的:

import inotify.adapters
import sys
from applicationinsights import TelemetryClient

def _main():
    tc = TelemetryClient('<YOUR INSTRUMENTATION KEY GOES HERE>')
    i = inotify.adapters.Inotify()

    i.add_watch('/tmp')

    with open('/tmp/test_file', 'w'):
        pass

    for event in i.event_gen(yield_nones=False):
        (_, type_names, path, filename) = event

        print("PATH=[{}] FILENAME=[{}] EVENT_TYPES={}".format(
              path, filename, type_names))

        tc.track_trace({ 'path': path, 'filename': filename })
        tc.flush()            

if __name__ == '__main__':
    _main()

否则指导我如何使用 App Insights 记录任何 Azure 服务的任何会话?分享此日志的程序出路。