Ad Widget

Collapse

Additional column in availability report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jacek
    Member
    • Nov 2008
    • 45

    #1

    Additional column in availability report

    Hi,

    I would like to add additional column to availability report results, between columns 'Name' and 'Problem'. That new column would be entitled Comments and there would be shown data from 'comments' field from triggers table.

    Unfortunately, I'm a really poor programmer and I cannot find all places in report2.php that I'd have to change to achieve that.

    Have anybody done something similar and can share a solution? I would be very grateful for a diff file or some tips how to this.

    Thanks
    Jacek
  • jacek
    Member
    • Nov 2008
    • 45

    #2
    Ok, I've managed to do this.

    I've added:
    1. $triggerOptions = array(
    'output' => array('triggerid', 'description', 'comments', 'expression', 'value'),
    'expandDescription' => true,
    'expandData' => true,
    'monitored' => true,
    'selectHosts' => API_OUTPUT_EXTEND, // rquired for getting visible host name
    'filter' => array(),
    'hostids' => null

    2. 'SELECT DISTINCT t.triggerid,t.description,t.comments,h.name'.
    ' FROM triggers t,hosts h,items i,functions f'.
    ' WHERE f.itemid=i.itemid'.
    ' AND h.hostid=i.hostid'.
    ' AND t.status='.TRIGGER_STATUS_ENABLED.
    ' AND t.triggerid=f.triggerid'.
    ' AND h.status='.HOST_STATUS_TEMPLATE.
    ' AND i.status='.ITEM_STATUS_ACTIVE.
    $sqlCondition.
    andDbNode('t.triggerid').
    ' ORDER BY t.description';

    3. $triggerTable->setHeader(array(
    is_show_all_nodes() ? _('Node') : null,
    ($_REQUEST['filter_hostid'] == 0 || $availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE) ? _('Host') : null,
    _('Name'),
    _('Comments'),
    _('Problems'),
    _('Ok'),
    _('Graph')
    ));

    4. $triggerTable->addRow(array(
    get_node_name_by_elid($trigger['hostid']),
    ($_REQUEST['filter_hostid'] == 0 || $availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE)
    ? $trigger['hosts'][0]['name'] : null,
    new CLink($trigger['description'], 'events.php?triggerid='.$trigger['triggerid'].
    '&source='.EVENT_SOURCE_TRIGGERS
    ),
    new CSpan($trigger['comments']),
    new CSpan(sprintf('%.4f%%', $availability['true']), 'on'),
    new CSpan(sprintf('%.4f%%', $availability['false']), 'off'),
    new CLink(_('Show'), 'report2.php?filter_groupid='.$_REQUEST['filter_groupid'].
    '&filter_hostid='.$_REQUEST['filter_hostid'].'&triggerid='.$trigger['triggerid'])
    ));

    Comment

    Working...