Package com.cloud.agent.api.to.LoadBalancerTO

Examples of com.cloud.agent.api.to.LoadBalancerTO.CounterTO


            for (AutoScalePolicyTO autoScalePolicyTO : policies) {
                List<ConditionTO> conditions = autoScalePolicyTO.getConditions();
                String policyExpression = "";
                int snmpCounterNumber = 0;
                for (ConditionTO conditionTO : conditions) {
                    CounterTO counterTO = conditionTO.getCounter();
                    String counterName = counterTO.getName();
                    String operator = conditionTO.getRelationalOperator();
                    long threshold = conditionTO.getThreshold();

                    StringBuilder conditionExpression = new StringBuilder();
                    Formatter formatter = new Formatter(conditionExpression, Locale.US);

                    if(counterTO.getSource().equals("snmp"))
                    {
                        counterName = generateSnmpMetricName(counterName);
                        if(snmpMetrics.size() == 0) {
                            // Create Metric Table
                            //add lb metricTable lb_metric_table
                            lbmetrictable metricTable = new lbmetrictable();
                            try {
                                metricTable.set_metrictable(mtName);
                                metricTable.add(_netscalerService, metricTable);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // Create Monitor
                            // add lb monitor lb_metric_table_mon LOAD -destPort 161 -snmpCommunity public -metricTable
                            // lb_metric_table -interval <policy_interval == 80% >
                            lbmonitor monitor = new lbmonitor();
                            try {
                                monitor.set_monitorname(monitorName);
                                monitor.set_type("LOAD");
                                monitor.set_destport(snmpPort);
                                monitor.set_snmpcommunity(snmpCommunity);
                                monitor.set_metrictable(mtName);
                                monitor.set_interval((int)(interval * 0.8));
                                monitor.add(_netscalerService, monitor);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // Bind monitor to servicegroup.
                            // bind lb monitor lb_metric_table_mon lb_autoscaleGroup -passive
                            servicegroup_lbmonitor_binding servicegroup_monitor_binding = new servicegroup_lbmonitor_binding();
                            try {
                                servicegroup_monitor_binding.set_servicegroupname(serviceGroupName);
                                servicegroup_monitor_binding.set_monitor_name(monitorName);

                                // Use the monitor for autoscaling purpose only.
                                // Don't mark service members down when metric breaches threshold
                                servicegroup_monitor_binding.set_passive(true);

                                servicegroup_lbmonitor_binding.add(_netscalerService, servicegroup_monitor_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }
                        }

                        boolean newMetric = !snmpMetrics.containsKey(counterName);
                        if(newMetric) {
                            snmpMetrics.put(counterName, snmpCounterNumber++);
                        }

                        if(newMetric)
                        {
                            // bind lb metricTable lb_metric_table mem 1.3.6.1.4.1.2021.11.9.0
                            String counterOid = counterTO.getValue();
                            lbmetrictable_metric_binding metrictable_metric_binding = new lbmetrictable_metric_binding();
                            try {
                                metrictable_metric_binding.set_metrictable(mtName);
                                metrictable_metric_binding.set_metric(counterName);
                                metrictable_metric_binding.set_Snmpoid(counterOid);
                                metrictable_metric_binding.add(_netscalerService, metrictable_metric_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // bind lb monitor lb_metric_table_mon -metric cpu -metricThreshold 1
                            lbmonitor_metric_binding monitor_metric_binding = new lbmonitor_metric_binding();;
                            try {
                                monitor_metric_binding.set_monitorname(monitorName);
                                monitor_metric_binding.set_metric(counterName);
                                /*
                                 * Setting it to max to make sure traffic is not affected due to 'LOAD' monitoring.
                                 * For Ex. if CPU is tracked and CPU is greater than 80, it is still < than Integer.MAX_VALUE
                                 * so traffic will continue to flow.
                                 */
                                monitor_metric_binding.set_metricthreshold(Integer.MAX_VALUE);
                                monitor_metric_binding.add(_netscalerService, monitor_metric_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }
                        }
                        // SYS.VSERVER("abcd").SNMP_TABLE(0).AVERAGE_VALUE.GT(80)
                        int counterIndex = snmpMetrics.get(counterName); // TODO: temporary fix. later on counter name
                        // will be added as a param to SNMP_TABLE.
                        formatter.format("SYS.VSERVER(\"%s\").SNMP_TABLE(%d).AVERAGE_VALUE.%s(%d)",nsVirtualServerName, counterIndex, operator, threshold);
                    }
                    else if (counterTO.getSource().equals("netscaler"))
                    {
                        //SYS.VSERVER("abcd").RESPTIME.GT(10)
                        formatter.format("SYS.VSERVER(\"%s\").%s.%s(%d)",nsVirtualServerName, counterTO.getValue(), operator, threshold);
                    }
                    if(policyExpression.length() != 0) {
                        policyExpression += " && ";
                    }
                    policyExpression += conditionExpression;
View Full Code Here


            boolean isSnmp = false;
            /* Create Counters */
            for (AutoScalePolicyTO autoScalePolicyTO : policies) {
                List<ConditionTO> conditions = autoScalePolicyTO.getConditions();
                for (ConditionTO conditionTO : conditions) {
                    CounterTO counterTO = conditionTO.getCounter();
                    if(counterTO.getSource().equals("snmp")) {
                        isSnmp = true;
                        break;
                    }
                }
                String policyId = Long.toString(autoScalePolicyTO.getId());
View Full Code Here

            for (AutoScalePolicyTO autoScalePolicyTO : policies) {
                List<ConditionTO> conditions = autoScalePolicyTO.getConditions();
                String policyExpression = "";
                int snmpCounterNumber = 0;
                for (ConditionTO conditionTO : conditions) {
                    CounterTO counterTO = conditionTO.getCounter();
                    String counterName = counterTO.getName();
                    String operator = conditionTO.getRelationalOperator();
                    long threshold = conditionTO.getThreshold();

                    StringBuilder conditionExpression = new StringBuilder();
                    Formatter formatter = new Formatter(conditionExpression, Locale.US);

                    if(counterTO.getSource().equals("snmp"))
                    {
                        counterName = generateSnmpMetricName(counterName);
                        if(snmpMetrics.size() == 0) {
                            // Create Metric Table
                            //add lb metricTable lb_metric_table
                            lbmetrictable metricTable = new lbmetrictable();
                            try {
                                metricTable.set_metrictable(mtName);
                                metricTable.add(_netscalerService, metricTable);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // Create Monitor
                            // add lb monitor lb_metric_table_mon LOAD -destPort 161 -snmpCommunity public -metricTable
                            // lb_metric_table -interval <policy_interval == 80% >
                            lbmonitor monitor = new lbmonitor();
                            try {
                                monitor.set_monitorname(monitorName);
                                monitor.set_type("LOAD");
                                monitor.set_destport(snmpPort);
                                monitor.set_snmpcommunity(snmpCommunity);
                                monitor.set_metrictable(mtName);
                                monitor.set_interval((int)(interval * 0.8));
                                monitor.add(_netscalerService, monitor);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // Bind monitor to servicegroup.
                            // bind lb monitor lb_metric_table_mon lb_autoscaleGroup -passive
                            servicegroup_lbmonitor_binding servicegroup_monitor_binding = new servicegroup_lbmonitor_binding();
                            try {
                                servicegroup_monitor_binding.set_servicegroupname(serviceGroupName);
                                servicegroup_monitor_binding.set_monitor_name(monitorName);

                                // Use the monitor for autoscaling purpose only.
                                // Don't mark service members down when metric breaches threshold
                                servicegroup_monitor_binding.set_passive(true);

                                servicegroup_lbmonitor_binding.add(_netscalerService, servicegroup_monitor_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }
                        }

                        boolean newMetric = !snmpMetrics.containsKey(counterName);
                        if(newMetric) {
                            snmpMetrics.put(counterName, snmpCounterNumber++);
                        }

                        if(newMetric)
                        {
                            // bind lb metricTable lb_metric_table mem 1.3.6.1.4.1.2021.11.9.0
                            String counterOid = counterTO.getValue();
                            lbmetrictable_metric_binding metrictable_metric_binding = new lbmetrictable_metric_binding();
                            try {
                                metrictable_metric_binding.set_metrictable(mtName);
                                metrictable_metric_binding.set_metric(counterName);
                                metrictable_metric_binding.set_Snmpoid(counterOid);
                                metrictable_metric_binding.add(_netscalerService, metrictable_metric_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // bind lb monitor lb_metric_table_mon -metric cpu -metricThreshold 1
                            lbmonitor_metric_binding monitor_metric_binding = new lbmonitor_metric_binding();;
                            try {
                                monitor_metric_binding.set_monitorname(monitorName);
                                monitor_metric_binding.set_metric(counterName);
                                /*
                                 * Setting it to max to make sure traffic is not affected due to 'LOAD' monitoring.
                                 * For Ex. if CPU is tracked and CPU is greater than 80, it is still < than Integer.MAX_VALUE
                                 * so traffic will continue to flow.
                                 */
                                monitor_metric_binding.set_metricthreshold(Integer.MAX_VALUE);
                                monitor_metric_binding.add(_netscalerService, monitor_metric_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }
                        }
                        // SYS.VSERVER("abcd").SNMP_TABLE(0).AVERAGE_VALUE.GT(80)
                        int counterIndex = snmpMetrics.get(counterName); // TODO: temporary fix. later on counter name
                        // will be added as a param to SNMP_TABLE.
                        formatter.format("SYS.VSERVER(\"%s\").SNMP_TABLE(%d).AVERAGE_VALUE.%s(%d)",nsVirtualServerName, counterIndex, operator, threshold);
                    }
                    else if (counterTO.getSource().equals("netscaler"))
                    {
                        //SYS.VSERVER("abcd").RESPTIME.GT(10)
                        formatter.format("SYS.VSERVER(\"%s\").%s.%s(%d)",nsVirtualServerName, counterTO.getValue(), operator, threshold);
                    }
                    if(policyExpression.length() != 0) {
                        policyExpression += " && ";
                    }
                    policyExpression += conditionExpression;
View Full Code Here

            boolean isSnmp = false;
            /* Create Counters */
            for (AutoScalePolicyTO autoScalePolicyTO : policies) {
                List<ConditionTO> conditions = autoScalePolicyTO.getConditions();
                for (ConditionTO conditionTO : conditions) {
                    CounterTO counterTO = conditionTO.getCounter();
                    if(counterTO.getSource().equals("snmp")) {
                        isSnmp = true;
                        break;
                    }
                }
                String policyId = Long.toString(autoScalePolicyTO.getId());
View Full Code Here

            for (AutoScalePolicyTO autoScalePolicyTO : policies) {
                List<ConditionTO> conditions = autoScalePolicyTO.getConditions();
                String policyExpression = "";
                int snmpCounterNumber = 0;
                for (ConditionTO conditionTO : conditions) {
                    CounterTO counterTO = conditionTO.getCounter();
                    String counterName = counterTO.getName();
                    String operator = conditionTO.getRelationalOperator();
                    long threshold = conditionTO.getThreshold();

                    StringBuilder conditionExpression = new StringBuilder();
                    Formatter formatter = new Formatter(conditionExpression, Locale.US);

                    if (counterTO.getSource().equals("snmp")) {
                        counterName = generateSnmpMetricName(counterName);
                        if (snmpMetrics.size() == 0) {
                            // Create Metric Table
                            //add lb metricTable lb_metric_table
                            lbmetrictable metricTable = new lbmetrictable();
                            try {
                                metricTable.set_metrictable(mtName);
                                lbmetrictable.add(_netscalerService, metricTable);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // Create Monitor
                            // add lb monitor lb_metric_table_mon LOAD -destPort 161 -snmpCommunity public -metricTable
                            // lb_metric_table -interval <policy_interval == 80% >
                            lbmonitor monitor = new lbmonitor();
                            try {
                                monitor.set_monitorname(monitorName);
                                monitor.set_type("LOAD");
                                monitor.set_destport(snmpPort);
                                monitor.set_snmpcommunity(snmpCommunity);
                                monitor.set_metrictable(mtName);
                                monitor.set_interval((int)(interval * 0.8));
                                lbmonitor.add(_netscalerService, monitor);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // Bind monitor to servicegroup.
                            // bind lb monitor lb_metric_table_mon lb_autoscaleGroup -passive
                            servicegroup_lbmonitor_binding servicegroup_monitor_binding = new servicegroup_lbmonitor_binding();
                            try {
                                servicegroup_monitor_binding.set_servicegroupname(serviceGroupName);
                                servicegroup_monitor_binding.set_monitor_name(monitorName);

                                // Use the monitor for autoscaling purpose only.
                                // Don't mark service members down when metric breaches threshold
                                servicegroup_monitor_binding.set_passive(true);

                                servicegroup_lbmonitor_binding.add(_netscalerService, servicegroup_monitor_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }
                        }

                        boolean newMetric = !snmpMetrics.containsKey(counterName);
                        if (newMetric) {
                            snmpMetrics.put(counterName, snmpCounterNumber++);
                        }

                        if (newMetric) {
                            // bind lb metricTable lb_metric_table mem 1.3.6.1.4.1.2021.11.9.0
                            String counterOid = counterTO.getValue();
                            lbmetrictable_metric_binding metrictable_metric_binding = new lbmetrictable_metric_binding();
                            try {
                                metrictable_metric_binding.set_metrictable(mtName);
                                metrictable_metric_binding.set_metric(counterName);
                                metrictable_metric_binding.set_Snmpoid(counterOid);
                                lbmetrictable_metric_binding.add(_netscalerService, metrictable_metric_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // bind lb monitor lb_metric_table_mon -metric cpu -metricThreshold 1
                            lbmonitor_metric_binding monitor_metric_binding = new lbmonitor_metric_binding();
                            ;
                            try {
                                monitor_metric_binding.set_monitorname(monitorName);
                                monitor_metric_binding.set_metric(counterName);
                                /*
                                 * Setting it to max to make sure traffic is not affected due to 'LOAD' monitoring.
                                 * For Ex. if CPU is tracked and CPU is greater than 80, it is still < than Integer.MAX_VALUE
                                 * so traffic will continue to flow.
                                 */
                                monitor_metric_binding.set_metricthreshold(Integer.MAX_VALUE);
                                lbmonitor_metric_binding.add(_netscalerService, monitor_metric_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }
                        }
                        // SYS.VSERVER("abcd").SNMP_TABLE(0).AVERAGE_VALUE.GT(80)
                        int counterIndex = snmpMetrics.get(counterName); // TODO: temporary fix. later on counter name
                        // will be added as a param to SNMP_TABLE.
                        formatter.format("SYS.VSERVER(\"%s\").SNMP_TABLE(%d).AVERAGE_VALUE.%s(%d)", nsVirtualServerName, counterIndex, operator, threshold);
                    } else if (counterTO.getSource().equals("netscaler")) {
                        //SYS.VSERVER("abcd").RESPTIME.GT(10)
                        formatter.format("SYS.VSERVER(\"%s\").%s.%s(%d)", nsVirtualServerName, counterTO.getValue(), operator, threshold);
                    }
                    if (policyExpression.length() != 0) {
                        policyExpression += " && ";
                    }
                    policyExpression += conditionExpression;
View Full Code Here

            boolean isSnmp = false;
            /* Create Counters */
            for (AutoScalePolicyTO autoScalePolicyTO : policies) {
                List<ConditionTO> conditions = autoScalePolicyTO.getConditions();
                for (ConditionTO conditionTO : conditions) {
                    CounterTO counterTO = conditionTO.getCounter();
                    if (counterTO.getSource().equals("snmp")) {
                        isSnmp = true;
                        break;
                    }
                }
                String policyId = Long.toString(autoScalePolicyTO.getId());
View Full Code Here

            for (AutoScalePolicyTO autoScalePolicyTO : policies) {
                List<ConditionTO> conditions = autoScalePolicyTO.getConditions();
                String policyExpression = "";
                int snmpCounterNumber = 0;
                for (ConditionTO conditionTO : conditions) {
                    CounterTO counterTO = conditionTO.getCounter();
                    String counterName = counterTO.getName();
                    String operator = conditionTO.getRelationalOperator();
                    long threshold = conditionTO.getThreshold();

                    StringBuilder conditionExpression = new StringBuilder();
                    Formatter formatter = new Formatter(conditionExpression, Locale.US);

                    if(counterTO.getSource().equals("snmp"))
                    {
                        counterName = generateSnmpMetricName(counterName);
                        if(snmpMetrics.size() == 0) {
                            // Create Metric Table
                            //add lb metricTable lb_metric_table
                            lbmetrictable metricTable = new lbmetrictable();
                            try {
                                metricTable.set_metrictable(mtName);
                                metricTable.add(_netscalerService, metricTable);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // Create Monitor
                            // add lb monitor lb_metric_table_mon LOAD -destPort 161 -snmpCommunity public -metricTable
                            // lb_metric_table -interval <policy_interval == 80% >
                            lbmonitor monitor = new lbmonitor();
                            try {
                                monitor.set_monitorname(monitorName);
                                monitor.set_type("LOAD");
                                monitor.set_destport(snmpPort);
                                monitor.set_snmpcommunity(snmpCommunity);
                                monitor.set_metrictable(mtName);
                                monitor.set_interval((int)(interval * 0.8));
                                monitor.add(_netscalerService, monitor);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // Bind monitor to servicegroup.
                            // bind lb monitor lb_metric_table_mon lb_autoscaleGroup -passive
                            servicegroup_lbmonitor_binding servicegroup_monitor_binding = new servicegroup_lbmonitor_binding();
                            try {
                                servicegroup_monitor_binding.set_servicegroupname(serviceGroupName);
                                servicegroup_monitor_binding.set_monitor_name(monitorName);

                                // Use the monitor for autoscaling purpose only.
                                // Don't mark service members down when metric breaches threshold
                                servicegroup_monitor_binding.set_passive(true);

                                servicegroup_lbmonitor_binding.add(_netscalerService, servicegroup_monitor_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }
                        }

                        boolean newMetric = !snmpMetrics.containsKey(counterName);
                        if(newMetric) {
                            snmpMetrics.put(counterName, snmpCounterNumber++);
                        }

                        if(newMetric)
                        {
                            // bind lb metricTable lb_metric_table mem 1.3.6.1.4.1.2021.11.9.0
                            String counterOid = counterTO.getValue();
                            lbmetrictable_metric_binding metrictable_metric_binding = new lbmetrictable_metric_binding();
                            try {
                                metrictable_metric_binding.set_metrictable(mtName);
                                metrictable_metric_binding.set_metric(counterName);
                                metrictable_metric_binding.set_Snmpoid(counterOid);
                                metrictable_metric_binding.add(_netscalerService, metrictable_metric_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // bind lb monitor lb_metric_table_mon -metric cpu -metricThreshold 1
                            lbmonitor_metric_binding monitor_metric_binding = new lbmonitor_metric_binding();;
                            try {
                                monitor_metric_binding.set_monitorname(monitorName);
                                monitor_metric_binding.set_metric(counterName);
                                /*
                                 * Setting it to max to make sure traffic is not affected due to 'LOAD' monitoring.
                                 * For Ex. if CPU is tracked and CPU is greater than 80, it is still < than Integer.MAX_VALUE
                                 * so traffic will continue to flow.
                                 */
                                monitor_metric_binding.set_metricthreshold(Integer.MAX_VALUE);
                                monitor_metric_binding.add(_netscalerService, monitor_metric_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }
                        }
                        // SYS.VSERVER("abcd").SNMP_TABLE(0).AVERAGE_VALUE.GT(80)
                        int counterIndex = snmpMetrics.get(counterName); // TODO: temporary fix. later on counter name
                        // will be added as a param to SNMP_TABLE.
                        formatter.format("SYS.VSERVER(\"%s\").SNMP_TABLE(%d).AVERAGE_VALUE.%s(%d)",nsVirtualServerName, counterIndex, operator, threshold);
                    }
                    else if (counterTO.getSource().equals("netscaler"))
                    {
                        //SYS.VSERVER("abcd").RESPTIME.GT(10)
                        formatter.format("SYS.VSERVER(\"%s\").%s.%s(%d)",nsVirtualServerName, counterTO.getValue(), operator, threshold);
                    }
                    if(policyExpression.length() != 0) {
                        policyExpression += " && ";
                    }
                    policyExpression += conditionExpression;
View Full Code Here

            boolean isSnmp = false;
            /* Create Counters */
            for (AutoScalePolicyTO autoScalePolicyTO : policies) {
                List<ConditionTO> conditions = autoScalePolicyTO.getConditions();
                for (ConditionTO conditionTO : conditions) {
                    CounterTO counterTO = conditionTO.getCounter();
                    if(counterTO.getSource().equals("snmp")) {
                        isSnmp = true;
                        break;
                    }
                }
                String policyId = Long.toString(autoScalePolicyTO.getId());
View Full Code Here

            for (AutoScalePolicyTO autoScalePolicyTO : policies) {
                List<ConditionTO> conditions = autoScalePolicyTO.getConditions();
                String policyExpression = "";
                int snmpCounterNumber = 0;
                for (ConditionTO conditionTO : conditions) {
                    CounterTO counterTO = conditionTO.getCounter();
                    String counterName = counterTO.getName();
                    String operator = conditionTO.getRelationalOperator();
                    long threshold = conditionTO.getThreshold();

                    StringBuilder conditionExpression = new StringBuilder();
                    Formatter formatter = new Formatter(conditionExpression, Locale.US);

                    if(counterTO.getSource().equals("snmp"))
                    {
                        counterName = generateSnmpMetricName(counterName);
                        if(snmpMetrics.size() == 0) {
                            // Create Metric Table
                            //add lb metricTable lb_metric_table
                            lbmetrictable metricTable = new lbmetrictable();
                            try {
                                metricTable.set_metrictable(mtName);
                                metricTable.add(_netscalerService, metricTable);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // Create Monitor
                            // add lb monitor lb_metric_table_mon LOAD -destPort 161 -snmpCommunity public -metricTable
                            // lb_metric_table -interval <policy_interval == 80% >
                            lbmonitor monitor = new lbmonitor();
                            try {
                                monitor.set_monitorname(monitorName);
                                monitor.set_type("LOAD");
                                monitor.set_destport(snmpPort);
                                monitor.set_snmpcommunity(snmpCommunity);
                                monitor.set_metrictable(mtName);
                                monitor.set_interval((int)(interval * 0.8));
                                monitor.add(_netscalerService, monitor);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // Bind monitor to servicegroup.
                            // bind lb monitor lb_metric_table_mon lb_autoscaleGroup -passive
                            servicegroup_lbmonitor_binding servicegroup_monitor_binding = new servicegroup_lbmonitor_binding();
                            try {
                                servicegroup_monitor_binding.set_servicegroupname(serviceGroupName);
                                servicegroup_monitor_binding.set_monitor_name(monitorName);

                                // Use the monitor for autoscaling purpose only.
                                // Don't mark service members down when metric breaches threshold
                                servicegroup_monitor_binding.set_passive(true);

                                servicegroup_lbmonitor_binding.add(_netscalerService, servicegroup_monitor_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }
                        }

                        boolean newMetric = !snmpMetrics.containsKey(counterName);
                        if(newMetric) {
                            snmpMetrics.put(counterName, snmpCounterNumber++);
                        }

                        if(newMetric)
                        {
                            // bind lb metricTable lb_metric_table mem 1.3.6.1.4.1.2021.11.9.0
                            String counterOid = counterTO.getValue();
                            lbmetrictable_metric_binding metrictable_metric_binding = new lbmetrictable_metric_binding();
                            try {
                                metrictable_metric_binding.set_metrictable(mtName);
                                metrictable_metric_binding.set_metric(counterName);
                                metrictable_metric_binding.set_Snmpoid(counterOid);
                                metrictable_metric_binding.add(_netscalerService, metrictable_metric_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }

                            // bind lb monitor lb_metric_table_mon -metric cpu -metricThreshold 1
                            lbmonitor_metric_binding monitor_metric_binding = new lbmonitor_metric_binding();;
                            try {
                                monitor_metric_binding.set_monitorname(monitorName);
                                monitor_metric_binding.set_metric(counterName);
                                /*
                                 * Setting it to max to make sure traffic is not affected due to 'LOAD' monitoring.
                                 * For Ex. if CPU is tracked and CPU is greater than 80, it is still < than Integer.MAX_VALUE
                                 * so traffic will continue to flow.
                                 */
                                monitor_metric_binding.set_metricthreshold(Integer.MAX_VALUE);
                                monitor_metric_binding.add(_netscalerService, monitor_metric_binding);
                            } catch (Exception e) {
                                // Ignore Exception on cleanup
                                if (!isCleanUp)
                                    throw e;
                            }
                        }
                        // SYS.VSERVER("abcd").SNMP_TABLE(0).AVERAGE_VALUE.GT(80)
                        int counterIndex = snmpMetrics.get(counterName); // TODO: temporary fix. later on counter name
                        // will be added as a param to SNMP_TABLE.
                        formatter.format("SYS.VSERVER(\"%s\").SNMP_TABLE(%d).AVERAGE_VALUE.%s(%d)",nsVirtualServerName, counterIndex, operator, threshold);
                    }
                    else if (counterTO.getSource().equals("netscaler"))
                    {
                        //SYS.VSERVER("abcd").RESPTIME.GT(10)
                        formatter.format("SYS.VSERVER(\"%s\").%s.%s(%d)",nsVirtualServerName, counterTO.getValue(), operator, threshold);
                    }
                    if(policyExpression.length() != 0) {
                        policyExpression += " && ";
                    }
                    policyExpression += conditionExpression;
View Full Code Here

            boolean isSnmp = false;
            /* Create Counters */
            for (AutoScalePolicyTO autoScalePolicyTO : policies) {
                List<ConditionTO> conditions = autoScalePolicyTO.getConditions();
                for (ConditionTO conditionTO : conditions) {
                    CounterTO counterTO = conditionTO.getCounter();
                    if(counterTO.getSource().equals("snmp")) {
                        isSnmp = true;
                        break;
                    }
                }
                String policyId = Long.toString(autoScalePolicyTO.getId());
View Full Code Here

TOP

Related Classes of com.cloud.agent.api.to.LoadBalancerTO.CounterTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.