Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 30534

Re: PHP Based NOC Dashboard with Sourcecode

$
0
0

For those having issues with getalarms.php, here is the latest code, in full. This version fixes the timezone issues and also colours open alarms red, which i think I missed previously.

<?php

$pageContent = null;

ob_start();

include 'dblogin.php';

$tsql = "select top ".$resultcount." al.alertSubject as Message, eventDateTime as evdate, active = CASE when monitoralarmstateid=1 then 'Open' else 'Closed' end, mc.description as name

 from Users

 join vAgentLabel vl on vl.agentGuid = users.agentGuid

 right join monitoralarm al on al.agentguid = users.agentguid

 join monitorCollection mc on mc.monitorCollectionId = al.monitorCollectionId

 where (users.suspendAgent is null or users.suspendAgent = 0)

 order by eventDateTime DESC";

$stmt = sqlsrv_query( $conn, $tsql);

if( $stmt === false )

{

    echo "Error in executing query.</br>";

    die( print_r( sqlsrv_errors(), true));

}

echo "<div class=\"heading\">";

echo "Recent Alarms</br>";

echo "</div>";

echo "<table id=\"alarmlist\">";

echo "<tr><th class=\"colL\">Date & Time</th><th class=\"colM\">Status</th><th class=\"colM\">Name</th><th class=\"colL\">Alarm Detail</th></tr>";

while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC))

{

    $offset = date('Z');

    echo "<tr><td class=\"colL\">".date('d/m/Y h:i:s A',$row['evdate']->getTimestamp()+$offset)."</td>";

    echo "<td class=\"colM\">";

    if ($row['active']=='Open') {

      echo "<font color=red>".$row['active']."</font></td>";

    } else {

      echo $row['active']."</td>";

    }

    echo "<td class=\"colM\">".$row['name']."</td>";

    echo "<td class=\"colL\">".substr($row['Message'],0,200)."</td></tr>";

}

echo "</table>";

$pageContent = ob_get_contents(); // collect above content and store in variable

ob_end_clean();

echo $pageContent;

?>


Viewing all articles
Browse latest Browse all 30534

Trending Articles