Skip to content

Instantly share code, notes, and snippets.

import sys
import json
import os
def old_functin():
import urllib2
subscription_id = "5320918a-f859-451d-86ab-c965dcaf589c"
amrurl = "https://management.azure.com/subscriptions/" + subscription_id + "?api-version=2014-04-01"
import json
import os
import time
def old_function():
print("old_function()")
import urllib2
imdsurl = "http://169.254.169.254/metadata/instance?api-version=2019-03-11"
print("imdsurl=", imdsurl)
import sys
# if sys.version_info[0] < 3:
# from future import standard_library
# standard_library.install_aliases()
# from builtins import str
import urllib.request, urllib.error, urllib.parse
import json
import os
def test_setup_me():
#!/usr/bin/env python
import os
import os.path
import platform
def is_vm_supported_for_extension():
"""
Checks if the VM this extension is running on is supported by OMSAgent
Returns for platform.linux_distribution() vary widely in format, such as
'7.3.1611' returned for a VM with CentOS 7, so the first provided
#! /usr/bin/env python
import sys
import os
import re
import json
import time
import socket
import logging
import string
# This configuration enables rsyslog to send logs to mdsd output module: omazuremds.
# Configuration parameters:
# - mdsdsocketfile: mdsd socket file full path.
# - filter: The filter is for all facility and all severity. Change this accordingly.
# Example, to only log kernel messages, replace *.* with kern.* .
# - log_level <0|1> disable/enable logging (also you need to run rsyslog with -d to see logs)
$ModLoad omazuremds
$template fmt,"\"%syslogfacility-text:::json%\",\"%syslogseverity%\",\"%timereported:::date-rfc3339%\",\"%fromhost-ip%\",\"%msg:::json%\",\"%syslogtag:R,ERE,1,BLANK:\[([0-9]{1,5})\]--end%\",\"%syslogseverity-text:::json%\",\"%fromhost%\",\"%programname%\""
*.* action( type="omazuremds"
template="fmt"
#! /usr/bin/env python
import sys
import os
import re
import json
import time
import socket
import logging
import string
@abenbachir
abenbachir / service_control
Created February 10, 2021 00:47
omsagent service_control with debug statements
#! /bin/bash
#
# Helper functions for omsagent service control
#
# This script can be "sourced" (if sourcing with the "functions" qualifer),
# which is used by the service control scripts. This allows for deeper control
# of the process at a low level.
#
# NOTE: Sourcing through Bourne Shell and Dash does not allow ANY qualifier,
# encoding: utf-8
require "logstash/outputs/base"
require "logstash/namespace"
require "date"
require "logstash/codecs/plain"
# Send events to a syslog server.
#
# You can send messages compliant with RFC3164 or RFC5424
#
# Fluentd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software