Search code examples
azureinotifyappinsights

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


Can you Provide valuable suggestion/procedure for Build App Insight in Azure for monitoring Inotify Services in Linux servers


Solution

  • pip install applicationinsights pip install inotify

    then something like this:

    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()