Пример #1
0
        public static UInt32 LSAMgmtQueryLsaMetrics_0(string serverName, out LsaMetricPack_0 metrics)
        {
            UInt32 result       = 0;
            string functionName = "LSAMgmtAPI.LSAMgmtQueryLsaMetrics_0";
            IntPtr pMetrics     = IntPtr.Zero;

            metrics = new LsaMetricPack_0();

            try
            {
                Logger.Log(String.Format(
                               "{0}(serverName={1}) called",
                               functionName, serverName), Logger.LSAMgmtLogLevel);

                result = PrivateLSAMgmtAPI.LWMGMTQueryLsaMetrics_0(
                    serverName,
                    out pMetrics);

                if (result != 0)
                {
                    return(result);
                }

                if (pMetrics.Equals(IntPtr.Zero))
                {
                    throw new Exception("Failed to read metrics; null handle returned");
                }

                metrics = (LsaMetricPack_0)Marshal.PtrToStructure(pMetrics, typeof(LsaMetricPack_0));

                Logger.Log(String.Format(
                               "{0}: result={1} metrics:\n{2}",
                               functionName,
                               result,
                               MetricsToString_0(metrics)),
                           Logger.LSAMgmtLogLevel);

                int freeSuccess = (int)PrivateLSAMgmtAPI.LWMGMTFreeLsaMetrics_0(pMetrics);
                if (freeSuccess != 0)
                {
                    Logger.Log(String.Format(
                                   "WARNING: PrivateLSAMgmtAPI.LWMGMTFreeLsaMetrics_0 reports failure! [code={0}]",
                                   freeSuccess),
                               Logger.LogLevel.Panic);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(functionName, ex);
                if (result == 0)
                {
                    result = 0xFFFFFFFF;
                }
            }
            return(result);
        }