Ejemplo n.º 1
0
        private static void doZabbix(string zbxServer, string ourHostname, hypervisor_iLo_HTTP hyp)
        {
            bool powerStatus           = hyp.getPowerStatus();
            int  powerUse              = hyp.getCurrentPowerUseW();
            ilo_resp_healthfans  fans  = hyp.getHealthOfFans();
            ilo_resp_healthPSUs  psus  = hyp.getHealthOfPSUs();
            ilo_resp_healthtemps temps = hyp.getHealthOfTemps();

            Sender sender = new Ysq.Zabbix.Sender(zbxServer);

            // Send the discovery item a list of the data we have..
            sender.Send(ourHostname, "fanList", makeFanListJSON(fans), 2500);
            sender.Send(ourHostname, "psuList", makePSUListJSON(psus), 2500);
            sender.Send(ourHostname, "tempList", makeTempListJSON(temps), 2500);

            // and then send the data.
            sender.Send(ourHostname, "powerState", powerStatus ? "1" : "0");
            sender.Send(ourHostname, "powerUse", powerUse.ToString());
            foreach (ilo_resp_healthfan fan in fans.fans)
            {
                sender.Send(ourHostname, "fanspeed[" + fan.label + "]", fan.speed);
            }
            foreach (ilo_resp_healthPSU psu in psus.power_supplies)
            {
                sender.Send(ourHostname, "psustatus[" + psu.label + "]", psu.status);
            }
            foreach (ilo_resp_healthtemp temp in temps.temperature)
            {
                sender.Send(ourHostname, "cautionTemp[" + temp.label + "]", temp.caution.ToString());
                sender.Send(ourHostname, "currentTemp[" + temp.label + "]", temp.currentreading.ToString());
                sender.Send(ourHostname, "criticalTemp[" + temp.label + "]", temp.critical.ToString());
            }
        }
Ejemplo n.º 2
0
        private static string makePSUListJSON(ilo_resp_healthPSUs psus)
        {
            StringBuilder toSend = new StringBuilder("{ \"data\" :[ ");
            int           n      = 0;

            foreach (ilo_resp_healthPSU psu in psus.power_supplies)
            {
                if (n++ > 0)
                {
                    toSend.Append(",");
                }
                toSend.Append(String.Format("{{ \"{{#PSUNAME}}\": \"{0}\"}}", psu.label));
            }
            toSend.Append("]}");

            return(toSend.ToString());
        }