Пример #1
0
        private static string GetParamsObjectInPowershellFormat(PropertyBag parameters)
        {
            var parametersSerialized = string.Join(
                ";",
                parameters.Select(x => string.Format("{0}={1}", x.Key, QuoteForPowerShell(x.Value.ToString()))));

            return(string.Format("@{{{0}}}", parametersSerialized.ToString()));
        }
Пример #2
0
        public static string GetQueryForCurlCmd(string query, ConnectionInfo connection, PropertyBag parameters)
        {
            string creds = QuoteForCmd($"{connection.UserName}:{connection.Password}");

            if (!parameters.Any())
            {
                return($"curl.exe -k -u {creds} {GetUrlForQuery(query, connection)}");
            }
            else
            {
                var escapedQuery         = CollapseWhitespace(query);
                var postUrl              = $"https://{connection.Server}:17778/SolarWinds/InformationService/v3/Json/Query";
                var parametersSerialized = string.Join(
                    ",",
                    parameters.Select(x => string.Format("\"{0}\" : \"{1}\"", x.Key, x.Value.ToString())));

                var postData = $"{{ \"query\": \"{escapedQuery}\", \"parameters\": {{{parametersSerialized}}}".Replace("\"", "\\\"");

                return($"curl -X POST -d \"{postData}}}\" {postUrl} --insecure -u {creds} --header \"Content-Type:application/json\"");
            }
        }
Пример #3
0
        private static void convertToEvent(List<LogEventProperty> list, PropertyBag props, string groupName)
        {
            if (props == null || props.Count == 0) return;

            list.AddRange(props.Select(prop => new LogEventProperty() { Group = groupName, Name = prop.Key, Value = prop.Value }));
        }