Ejemplo n.º 1
0
        protected void heartBeat()
        {
            Process execProcess = Process.GetCurrentProcess();
            string  tempstr     = string.Format("HEARTBEAT {0}: XBotID={1}; Up={2}sec; Int={3}; Current={4}; Peak={5}; WSS={6}; TotProc={7};", AssemblyInfo.buildEnv, xBotID, Convert.ToInt32((serviceLife + 500) / 1000), (int)(aTimer.Interval / 1000), execProcess.VirtualMemorySize64, execProcess.PeakVirtualMemorySize64, execProcess.WorkingSet64, execProcess.TotalProcessorTime);

            myFileAgentCore.XLogger(0, tempstr, 9999);
            eventLog1.WriteEntry(tempstr);
            if (XTRMObject.getDictionaryEntry("ShowTimingSummary", "Y").Equals("Y"))
            {
                // Report Timing Metrics.
                tempstr = string.Format("HEARTBEAT {0}: Timing=({1}:CT={2};TOT={3}ms;AVG={4};MIN={5};MAX={6};LAST={7})", AssemblyInfo.buildEnv, myMetrics[99].description, myMetrics[99].count, myMetrics[99].totTime, myMetrics[99].avgTime, myMetrics[99].minTime, myMetrics[99].maxTime, myMetrics[99].lastTime);
                myFileAgentCore.XLogger(0, tempstr, 9979);
                eventLog1.WriteEntry(tempstr);
            }
            if (XTRMObject.getDictionaryEntry("ShowTimingDetail", "Y").Equals("Y"))
            {
                for (int i = 0; i < 2; i++)
                {
                    tempstr = string.Format("HEARTBEAT {0}: Timing=({1}:CT={2};TOT={3}ms;AVG={4};MIN={5};MAX={6};LAST={7})", AssemblyInfo.buildEnv, myMetrics[i].description, myMetrics[i].count, myMetrics[i].totTime, myMetrics[i].avgTime, myMetrics[i].minTime, myMetrics[i].maxTime, myMetrics[i].lastTime);
                    myFileAgentCore.XLogger(0, tempstr, 9980 + i);
                    eventLog1.WriteEntry(tempstr);
                }
            }
            if (!XTRMObject.getDictionaryEntry("ProcessJobs", "Y").Equals("Y"))
            {
                tempstr = string.Format("{0} Job Processing Suspended", AssemblyInfo.buildEnv);
                myFileAgentCore.XLogger(0, tempstr, 9910);
                eventLog1.WriteEntry(tempstr);
            }
            return;
        }
Ejemplo n.º 2
0
        protected void Alert(string subject, string text)
        {
            // Send email to XBot Admin.
            string contact = XTRMObject.getDictionaryEntry("AdminMail", "*****@*****.**");

            XTRMObject.Notify(contact, null, subject, text);
        }
Ejemplo n.º 3
0
        static AssemblyInfo()
        {
            string env = XTRMObject.getDictionaryEntry("ConfigID", "?");

            buildName = Assembly.GetExecutingAssembly().GetName().Name;
            Version vers = Assembly.GetExecutingAssembly().GetName().Version;

            buildVersion = vers.ToString();
            buildTime    = new DateTime(2000, 1, 1).AddDays(vers.Build).AddSeconds(vers.MinorRevision * 2).ToString();
            buildEnv     = string.Format("{0}/{1}", buildName, env);
        }
Ejemplo n.º 4
0
        protected int checkParms()
        {
            int     rc          = 0;
            Process execProcess = Process.GetCurrentProcess();

            if (XTRMObject.getDictionaryEntry("ReloadDictionary", "Y").Equals("Y"))
            {
                XTRMObject.XDictionary = XTRMObject.createDictionary();
            }
            int heartbeatFrequency = Convert.ToInt32(XTRMObject.getDictionaryEntry("HeartbeatFrequency", "60"));

            if (beats % heartbeatFrequency == 0)
            {
                rc = 1; // Time for a heart beat!
            }
            xBotID = XTRMObject.getXTRMID();
            //int interval = Convert.ToInt32(XObject.getDictionaryEntry("DefaultInterval", "60"));
            int interval = Convert.ToInt32(XTRMObject.getDictionaryEntry("FileAgentInterval", "60"));

            agentHoldTime = Convert.ToInt32(XTRMObject.getDictionaryEntry("FileAgentHoldTime", "10"));
            int restartAfterSeconds = Convert.ToInt32(XTRMObject.getDictionaryEntry("RestartAfterSeconds", "82400"));
            int restartOverMemory   = Convert.ToInt32(XTRMObject.getDictionaryEntry("RestartOverMemory", "500000000"));

            memorySize = execProcess.VirtualMemorySize64;
            if (!aTimer.Interval.Equals(interval * 1000))
            {
                // Make Change, log message.
                string tempstr = string.Format("{0} Interval = {1} Seconds.", AssemblyInfo.buildEnv, interval);
                myFileAgentCore.XLogger(0, tempstr, 9907);
                eventLog1.WriteEntry(tempstr);
                aTimer.Interval = interval * 1000;
            }
            if (pendingStop == 1)
            {
                string tempstr = string.Format("{0} Pending Shutdown Due to Initialization Exception.", AssemblyInfo.buildEnv);
                eventLog1.WriteEntry(tempstr);
                myFileAgentCore.XLogger(0, tempstr, 9913);
                rc = -5;
            }
            else if (pendingStop == 2)
            {
                string tempstr = string.Format("{0} Pending Shutdown Due to Missing XBotID.", AssemblyInfo.buildEnv);
                eventLog1.WriteEntry(tempstr);
                myFileAgentCore.XLogger(0, tempstr, 9914);
                rc = -6;
            }
            else if (xBotID.Equals(""))
            {
                string tempstr = string.Format("{0} XBotID Not Set.", AssemblyInfo.buildEnv);
                myFileAgentCore.XLogger(0, tempstr, 9911);
                eventLog1.WriteEntry(tempstr);
                Alert(string.Format("{0} Stopping - No Version", AssemblyInfo.buildEnv), tempstr);
                rc = -4;
            }
            else if (Convert.ToInt32(serviceLife / 1000) >= restartAfterSeconds)
            {
                // Time to re-start!
                string tempstr = string.Format("Restarting {0} Service; Uptime = {1} Seconds.", AssemblyInfo.buildEnv, Convert.ToInt32(serviceLife / 1000));
                myFileAgentCore.XLogger(0, tempstr, 9908);
                eventLog1.WriteEntry(tempstr);
                Alert(string.Format("{0} Stopping - Uptime", AssemblyInfo.buildEnv), tempstr);
                rc = -2;
            }
            else if (memorySize > restartOverMemory)
            {
                // Time to re-start!
                string tempstr = string.Format("Restarting {0} Service; Memory = {1} Bytes.", AssemblyInfo.buildEnv, execProcess.VirtualMemorySize64);
                myFileAgentCore.XLogger(0, tempstr, 9909);
                eventLog1.WriteEntry(tempstr);
                Alert(string.Format("{0} Stopping - Memory", AssemblyInfo.buildEnv), tempstr);
                rc = -3;
            }
            return(rc);
        }