// alarms.serviceid // FROM // public.alarms // WHERE // alarms.severity >= 3 // ORDER BY // alarms.lasteventtime, // alarms.severity) // TO 'C:/rapidnms/data.csv' With CSV HEADER; // "; $query = "SELECT \n node.nodesysoid, \n ipinterface.ipaddr, \n alarms.severity, \n alarms.lasteventtime, \n alarms.description\nFROM \n public.alarms, \n public.ipinterface, \n public.node\nWHERE \n ipinterface.nodeid = node.nodeid AND\n alarms.nodeid = ipinterface.nodeid\nORDER BY\n alarms.lasteventtime DESC;"; $result = pg_query($query) or die('Query failed: ' . pg_last_error()); while ($row = pg_fetch_object($result)) { $time[] = $row->lasteventtime; $ip[] = $row->ipaddr; $device[] = deviceCat($row->nodesysoid); $sev[] = severe($row->severity); $des[] = $row->description; } $subject = $name . ", you have new alarms from Electroline Vanguard-HE " . date('Y-m-d H:i:s'); $body = $device[0] . " (" . $ip[0] . "): " . $des[0] . " (" . $time[0] . "). "; //$attachment = "for_downloading/email_alert_data.csv"; sendEmail($to_email, $subject, $body); function severe($severe) { if ($severe == "6") { return "High-High"; } if ($severe == "5") { return "High"; }
$query = "SELECT \n\t\t\tevents.nodeid, \n\t\t\tevents.eventtime, \n\t\t\tevents.ipaddr, \n\t\t\tevents.serviceid, \n\t\t\tevents.eventseverity, \n\t\t\tevents.eventlogmsg, \n\t\t\tnode.nodesysoid\n\t\t\tFROM \n\t\t\tpublic.events, \n\t\t\tpublic.node\n\t\t\tWHERE \n\t\t\tevents.nodeid = node.nodeid AND\n\t\t\tevents.ipaddr = {$newipaddress}\n\t\t\tORDER BY\n\t\t\tevents.eventtime DESC;"; $result = pg_query($query) or die('Query failed: ' . pg_last_error()); $total_alarm_number = pg_num_rows($result); echo "<thead>"; echo "<tr class=headings>"; echo "<th align=left class=table-filterable table-sortable:default><b>Device Category</b></th>"; echo "<th align=left class=table-filterable table-sortable:default><b>Alarm Severity</b></th>"; echo "<th align=left class=table-filterable table-sortable:default><b>Service</b></th>"; echo "<th align=left class=table-sortable:alphanumeric><b>Time</b></th>"; echo "<th align=left class=table-sortable:text><b>Log Message</b></th>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; while ($row = pg_fetch_object($result)) { echo "\t<tr class=even pointer>\n"; $deviceCategory = deviceCat($row->nodesysoid); echo "\t\t<td align=left>{$deviceCategory}</td>"; $seve = visulize_severe($row->eventseverity); echo "\t\t<td align=left>{$seve}</td>"; $service = service_id($row->serviceid); echo "\t\t<td align=left>{$service}</td>"; echo "\t\t<td align=left>{$row->eventtime}</td>"; echo "\t\t<td align=left>{$row->eventlogmsg}</td>"; echo "\t</tr>\n"; } pg_free_result($result); pg_close($dbconn); ?> </tr></table>
echo "<th align=left class=table-sortable:alphanumeric><b>Discovered Time</b><img src=images/sorticon.png width=30 height=20></th>"; echo "<th align=left><b>Device Metrics</b></th>"; echo "<th align=left><b>Alarm Setup</b></th>"; echo "<th align=left><b>Delete</b></th>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; // <a href=php_scripts/snmpSpecificIp_Inventory.php?ip=$row->ipaddr target=_blank > // <a href=php_scripts/snmpinfo_from_snmpinterface.php?nodeid=$row->nodeid target=_blank > while ($row = pg_fetch_object($result)) { $criteria = trim($row->mib); if ($criteria == ".1.3.6.1.4.1.3222.14.2.1.1" || $criteria == ".1.3.6.1.4.1.5591.29317.1.11.1.3.1.1" || $criteria == ".1.3.6.1.4.1.17409.1.11" || $criteria == "SNMPv2-SMI::enterprises.3222.14.2.1.1" || $criteria == "SNMPv2-SMI::enterprises.5591.29317.1.11.1.3.1.1" || $criteria == "SNMPv2-SMI::enterprises.17409.1.11" || $criteria == "SNMPv2-SMI::enterprises.5802.1.3.1.2" || $criteria == ".1.3.6.1.4.1.5802.1.3.1.2") { # code... echo "\t<tr class=even pointer>\n"; echo "\t\t<td align=left>{$row->id}</td>"; $deviceCategory = deviceCat(trim($row->mib)); echo "\t\t<td align=left>{$deviceCategory}</td>"; echo "\t\t<td align=left>{$row->ip} </td>"; echo "\t\t<td align=left>{$row->mac} </td>"; echo "\t\t<td align=left>{$row->sn} </td>"; $profile = assigned_profile($row->provision); echo "\t\t<td align=left>{$profile}</td>"; $alarmStatus = getAlarmStatus($row->ip); echo "\t\t<td align=left>{$alarmStatus}</td>"; $onlineStatus = is_online_for_inventory($row->ip); echo "\t\t<td align=left>{$onlineStatus}</td>"; $time = displayTime($row->time); echo "\t\t<td align=left>{$time}</td>"; $trimedIp = trim($row->ip); switch (trim($row->mib)) { case ".1.3.6.1.4.1.3222.14.2.1.1":