Exemplo n.º 1
0
function less_stable_services()
{
    global $NUM_HOSTS;
    /* opennms db connect */
    $opennms_db = new ossim_db();
    $opennms_conn = $opennms_db->opennms_connect();
    $query = OssimQuery("SELECT servicename, count(servicename) \n            FROM ifservices ifs, service s \n            WHERE ifs.serviceid = s.serviceid AND ifs.status = 'D' \n            GROUP BY servicename ORDER BY count(servicename) DESC \n            LIMIT {$NUM_HOSTS}");
    $rs =& $opennms_conn->Execute($query);
    if (!$rs) {
        print $opennms_conn->ErrorMsg();
    } else {
        ?>
        <h2><?php 
        echo _("Top");
        ?>
 <?php 
        echo "{$NUM_HOSTS}";
        ?>
 <?php 
        echo _("less stable services");
        ?>
</h2>
        <table align="center">
          <tr>
            <th> <?php 
        echo gettext("Service");
        ?>
 </th>
            <th> <?php 
        echo gettext("Ocurrences");
        ?>
 </th>
          </tr>
<?php 
        while (!$rs->EOF) {
            $service = $rs->fields["servicename"];
            $occurrences = number_format($rs->fields["count"], 0, ",", ".");
            ?>
          <tr>
            <td><?php 
            echo $service;
            ?>
</td>
            <td><?php 
            echo $occurrences;
            ?>
</td>
          </tr>
<?php 
            $rs->MoveNext();
        }
    }
    $opennms_db->close($opennms_conn);
    echo "</table><br/>\n";
}