示例#1
0
    function display_tree()
    {
        global $objects;
        //global BpObjects array
        global $unique;
        //display a list of children in html
        $children = $this->get_memberlist();
        //print_r($children);
        print "<ul>";
        $tr_count = 0;
        foreach ($children as $child) {
            $tr_count++;
            //two-colored tables
            if ($tr_count % 2 == 1) {
                $class = 'even';
            } else {
                $class = 'odd';
            }
            $state = return_state($child['current_state'], $child['type']);
            $optmarker = $child['option'] == '|' ? '**' : '';
            if ($child['type'] == 'service') {
                if (NAGV == 'XI') {
                    $hostlink = HOSTDETAIL . $child['host_name'];
                    //url for host
                    $servicelink = SERVICEDETAIL . $child['host_name'] . '&service=' . $child['service_description'] . '&dest=auto';
                } else {
                    $host = preg_replace('/ /', '+', trim($child['host_name']));
                    $hostlink = HOSTDETAIL . $host;
                    $service = preg_replace('/ /', '+', trim($child['service_description']));
                    $servicelink = SERVICEDETAIL . $host . '&service=' . $service;
                    //http://localhost/nagios/cgi-bin/extinfo.cgi?type=2&host=XI+Demo&service=HTTP
                }
                //BEGIN hereroc string
                $listitem = <<<LISTITEM
\t\t\t\t\t\t <li class='servicelisting'>
\t\t\t\t         <table class='servicedata'>
\t\t\t\t         \t<tr class='{$class}'>
\t\t\t\t         \t\t<td class='{$state}'>{$state}{$optmarker}</td>
\t\t\t\t         \t\t<td><a href='{$hostlink}' target='_blank'>{$child['host_name']}</a></td>
\t\t\t\t         \t\t<td><a href='{$servicelink}' target='_blank'>{$child['service_description']}</a></td>
\t\t\t\t         \t\t<td>{$child['plugin_output']}</td>
\t\t\t\t         \t</tr>
\t\t\t\t         </table>
\t\t\t\t       </li>\t\t\t\t       
LISTITEM;
                //print heredoc string
                print $listitem;
            } elseif ($child['type'] == 'host') {
                if (NAGV == 'XI') {
                    $hostlink = HOSTDETAIL . $child['host_name'];
                    //url for host
                } else {
                    $host = preg_replace('/ /', '+', trim($child['host_name']));
                    $hostlink = HOSTDETAIL . $host;
                    //http://localhost/nagios/cgi-bin/extinfo.cgi?type=2&host=XI+Demo&service=HTTP
                }
                //BEGIN hereroc string
                $listitem = <<<LISTITEM
\t\t\t\t\t\t <li class='servicelisting'>
\t\t\t\t         <table class='servicedata'>
\t\t\t\t         \t<tr class='{$class}'>
\t\t\t\t         \t\t<td class='{$state}'>{$state}{$optmarker}</td>
\t\t\t\t         \t\t<td><strong><a href='{$hostlink}' target='_blank'>{$child['host_name']}</a></strong></td>
\t\t\t\t         <!--\t\t<td></td> -->
\t\t\t\t         \t\t<td>{$child['plugin_output']}</td>
\t\t\t\t         \t</tr>
\t\t\t\t         </table>
\t\t\t\t       </li>\t\t\t\t       
LISTITEM;
                //print heredoc string
                print $listitem;
            } elseif ($child['type'] == 'group') {
                $unique++;
                //used for jquery ID
                $id = $child['index'] . $unique;
                //creates a unique id for the <ul>
                $td_id = 'td' . $unique;
                //creates unique td id for changing style
                $obj = $objects[$child['index']];
                //call appropriate object
                $info = $obj->get_info_html();
                //returns either an info URL or empty string
                $group_desc = $child['desc'] != '' ? '<td>' . $child['desc'] . '</td>' : '';
                $optmarker = $child['option'] == '|' ? '**' : '';
                if ($obj->has_group_children == true) {
                    $gpc_icon = "<td><img src='images/children.png' title='Contains Child Groups' height='8' width='13' alt='C' /></td>";
                } else {
                    $gpc_icon = '';
                }
                $tableitem = <<<TABLEITEM
\t\t\t\t\t <li class='grouplisting'>
\t\t\t\t\t\t\t<table class='groupdata'>
\t\t\t\t\t\t\t\t<tr class='{$class}'>
\t\t\t\t\t\t\t\t\t<td class='{$state}'>{$state}{$optmarker}</td>
\t\t\t\t\t\t\t\t\t<td class='group'><strong>
\t\t\t\t\t\t\t\t\t\t<a id='{$td_id}' class='grouphide' title="Group ID: {$child['index']}" href='javascript:void(0)' onclick='showHide("{$id}","{$td_id}")'>{$child['title']}</strong></a></td>
\t\t\t\t\t\t\t\t\t\t
\t\t\t\t\t\t\t\t\t{$gpc_icon}
\t\t\t\t\t\t\t\t\t{$info} 
\t\t\t\t\t\t\t\t\t<td>{$child['problems']} problem(s)</td>\t\t\t\t\t\t\t\t\t  
\t\t\t\t\t\t\t\t\t{$group_desc}
\t\t\t\t\t\t\t\t\t<td><a href="index.php?cmd=edit&arg={$child['index']}">Edit</a></td>
\t\t\t\t\t\t\t\t\t<td><a href="javascript:deleteGroup('index.php?cmd=delete&arg={$child['index']}')">Delete</a></td>
\t\t\t\t\t\t\t\t</tr>
\t\t\t\t\t\t\t</table>
\t\t\t\t\t\t\t
TABLEITEM;
                //end heredoc string
                print $tableitem;
                //child group creates a nested list
                print "<ul class='hidden' id='{$id}'>\n";
                $obj->display_tree();
                //recursively call child object until all are displayed
                print "</ul>\n";
                print "</li>\n";
                //close list
            } else {
                print "<li>Missing index 'type' for Group: {$child}</li>";
            }
        }
        print "</ul>";
        //close list
    }
示例#2
0
function bpi_view($arg)
{
    global $objects;
    global $unique;
    foreach ($objects as $object) {
        $prime = $object->get_primary();
        $priority = $object->priority;
        //echo "<p>$disp</p>";
        if ($prime > 0 && $priority == $arg) {
            $title = $object->get_title();
            $state = return_state($object->state);
            if ($object->has_group_children == true) {
                $gpc_icon = "<th><img src='images/children.png' title='Contains Child Groups' height='8' width='13' alt='C' /></th>";
            } else {
                $gpc_icon = '';
            }
            $id = $object->name;
            $desc = $object->desc;
            $td_id = 'td' . $unique;
            $info_th = $object->get_info_html();
            $problems = $object->problems;
            //display for only primary groups.  See the $object->display_tree() for subgroup displays
            //begin heredoc string
            $table = <<<TABLE
\t\t\t\t <table class='primary'>
\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t<th class='{$state}'>{$state}</th>
\t\t\t\t\t\t\t<th class='group' >
\t\t\t\t\t\t\t<a id='{$td_id}' href='javascript:void(0)' title="Group ID: {$id}" onclick='showHide("{$id}","{$td_id}")' class='grouphide'>{$title}</a></th>
\t\t\t\t\t\t\t{$gpc_icon}
\t\t\t\t\t\t\t{$info_th}
\t\t\t\t\t\t\t<th>{$problems} problem(s)</th>\t\t\t\t\t\t\t
\t\t\t\t\t\t\t<th>{$desc}</th>
\t\t\t\t\t\t\t<td><a href='index.php?cmd=edit&arg={$id}'>Edit</a></td>
\t\t\t\t\t\t\t<td><a href="javascript:deleteGroup('index.php?cmd=delete&arg={$id}')">Delete</a></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t</table>
\t\t\t\t\t
TABLE;
            print $table;
            //end heredoc string
            //recursively display groups
            print "<div class='hidden' id='{$id}'>";
            $object->display_tree();
            print "</div>\n";
            $unique++;
        }
    }
}