Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a380df3
Showing
88 changed files
with
25,379 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
config.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<IfModule mod_rewrite.c> | ||
|
||
RewriteEngine on | ||
|
||
# passthroughs | ||
RewriteRule ^index.php$ - [L] | ||
RewriteRule ^(css|js|app|test)/.*$ - [L] | ||
RewriteRule ^(css|js|app|test)/.*$ - [L] | ||
|
||
# redirect errors | ||
ErrorDocument 400 /error/400/ | ||
ErrorDocument 401 /error/401/ | ||
ErrorDocument 403 /error/403/ | ||
ErrorDocument 404 /error/404/ | ||
ErrorDocument 500 /error/500/ | ||
|
||
# Rewrites | ||
RewriteRule ^(.*)/(.*)/(.*)/$ index.php?app=$1&page=$2&id1=$3 [L] | ||
RewriteRule ^(.*)/(.*)/$ index.php?app=$1&page=$2 [L] | ||
RewriteRule ^(.*)/$ index.php?app=$1 [L] | ||
|
||
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## php-snmptraps | ||
|
||
###### php snmptrap handler and web UI for management | ||
|
||
php-snmptraps is an php trpahandler that processes snmp traps, writes them to database and/or file and sends | ||
notifications via sms/email/pushover to users, based on web settings. | ||
|
||
It comes with nice HMTL5 UI: | ||
..* Dashboard that shows overview of last messages | ||
..* Displays messages sent by specific host | ||
..* Displays messages per severity | ||
..* Displays specific messages received | ||
..* Live update of received traps | ||
|
||
and more. | ||
|
||
You can set severity level for each received message, ignore specific message types, create maintaneance periods | ||
for hosts, set per-user quiet hours and more. | ||
|
||
|
||
Notifications are set per-user/severity, by default aupported are: | ||
..* Email notification | ||
..* Pushover notification | ||
..* SMS notification | ||
|
||
The can be easily extended to any other custom notification type. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* By severity | ||
* | ||
**/ | ||
|
||
# verify that user is logged in | ||
$User->check_user_session(); | ||
|
||
# set limit | ||
$Trap->reset_print_limit (30); | ||
# fetch all traps for each | ||
$all_error_traps = $Trap->fetch_traps (array("emergency", "alert", "critical")); | ||
|
||
$Trap->reset_print_limit (13); | ||
$all_warning_traps = $Trap->fetch_traps (array("error", "warning")); | ||
$all_info_traps = $Trap->fetch_traps (array("notice", "informational", "debug")); | ||
$all_unknown_traps = $Trap->fetch_traps (array("unknown")); | ||
|
||
# set fields | ||
$tfields = array( "id"=>"", | ||
"hostname"=>"Hostname", | ||
"ip"=>"IP address", | ||
"date"=>"Date", | ||
"message"=>"Message", | ||
"severity"=>"Severity" | ||
); | ||
$Table_print->set_snmp_table_fields ($tfields); | ||
|
||
# structure | ||
print "<div class='container-fluid row' id='dashboard'>"; | ||
|
||
# critical | ||
print "<div class='col-xs-12 col-md-6 widget-dash'>"; | ||
print "<div class='inner'>"; | ||
print "<h4><a href='severity/major/'>Emergency, Critical and Alert events</a></h4>"; | ||
print "<div class='hContent'>"; | ||
print "<table class='table snmp table-striped table-condensed table-hover'>"; | ||
if ($all_error_traps!==false) { $Table_print->print_snmp_table ($all_error_traps); } | ||
else { print "<tr><td>".$Result->show("info", "No messages found", false, false, true)."<td></tr>"; } | ||
print "</table>"; | ||
print "</div>"; | ||
print "</div>"; | ||
print "</div>"; | ||
|
||
# warning, info | ||
print "<div class='col-xs-12 col-md-6 widget-dash'>"; | ||
print "<div class='inner'>"; | ||
print "<h4><a href='severity/minor/'>Error and Warning events</a></h4>"; | ||
print "<div class='hContent'>"; | ||
print "<table class='table snmp table-striped table-condensed table-hover'>"; | ||
if ($all_warning_traps!==false) { $Table_print->print_snmp_table ($all_warning_traps); } | ||
else { print "<tr><td>".$Result->show("info", "No messages found", false, false, true)."<td></tr>"; } | ||
print "</table>"; | ||
print "</div>"; | ||
print "</div>"; | ||
print "</div>"; | ||
|
||
print "<div class='col-xs-12 col-md-6 widget-dash'>"; | ||
print "<div class='inner'>"; | ||
print "<h4><a href='severity/informational/'>Informational, Notice and Debug events</a></h4>"; | ||
print "<div class='hContent'>"; | ||
print "<table class='table snmp table-striped table-condensed table-hover'>"; | ||
if ($all_info_traps!==false) { $Table_print->print_snmp_table ($all_info_traps); } | ||
else { print "<tr><td>".$Result->show("info", "No messages found", false, false, true)."<td></tr>"; } | ||
print "</table>"; | ||
print "</div>"; | ||
print "</div>"; | ||
print "</div>"; | ||
|
||
# unknown | ||
print "<div class='col-xs-12 widget-dash'>"; | ||
print "<div class='inner'>"; | ||
print "<h4><a href='severity/unknown/'>Unknown severity events</a></h4>"; | ||
print "<div class='hContent'>"; | ||
print "<table class='table snmp table-striped table-condensed table-hover'>"; | ||
if ($all_unknown_traps!==false) { $Table_print->print_snmp_table ($all_unknown_traps); } | ||
else { print "<tr><td>".$Result->show("info", "No messages found", false, false, true)."<td></tr>"; } | ||
print "</table>"; | ||
print "</div>"; | ||
print "</div>"; | ||
print "</div>"; | ||
|
||
print "</div>"; | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
php-snmptrap management |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* Fetch all traps and display them | ||
* | ||
**/ | ||
|
||
# verify that user is logged in | ||
$User->check_user_session(); | ||
|
||
# set limit to 10 | ||
$Trap->reset_print_limit (200); | ||
|
||
# fetch all traps | ||
if(isset($_GET['page'])) { | ||
$all_traps = $Trap->fetch_traps_host ($_GET['page']); | ||
} | ||
|
||
# fetch all unique hosts | ||
$unique_hosts = $Trap->fetch_unique_hosts (); | ||
|
||
# print badges if page set | ||
if (isset($_GET['page'])) { | ||
# print title | ||
print "<h4>Traps for host $_GET[page]</h4>"; | ||
|
||
# badges | ||
print "<div class='container-fluid text-right row'>"; | ||
print "<div class='col-lg-6 col-sm-12'></div>"; | ||
print "<div class='col-lg-6 col-sm-12'>"; | ||
foreach ($unique_hosts as $h) { | ||
// ignore unknown | ||
if ($h->hostname!="<UNKNOWN>") { | ||
// active | ||
$active = $h->hostname==$_GET['page'] ? "badge-active" : ""; | ||
print "<span class='badge badge1 badge5 marged $active'><a href='host/$h->hostname/'>$h->hostname</a></span>"; | ||
} | ||
} | ||
print "</div>"; | ||
print "</div>"; | ||
print "<hr><br>"; | ||
|
||
|
||
# set fields | ||
$tfields = array( "id"=>"", | ||
"hostname"=>"Hostname", | ||
"ip"=>"IP address", | ||
"date"=>"Date", | ||
"message"=>"Message", | ||
"severity"=>"Severity", | ||
"content"=>"Content" | ||
); | ||
$Table_print->set_snmp_table_fields ($tfields); | ||
|
||
|
||
# print table | ||
print "<table class='table snmp sorted table-noborder table-condensed table-hover'>"; | ||
$Table_print->print_snmp_table ($all_traps); | ||
print "</table>"; | ||
} | ||
else { | ||
# print title | ||
print "<h4>Select host</h4>"; | ||
|
||
foreach ($unique_hosts as $h) { | ||
// ignore unknown | ||
if ($h->hostname!="<UNKNOWN>") { | ||
// active | ||
$active = $h->hostname==$_GET['page'] ? "badge-active" : ""; | ||
print "<span class='badge badge1 badge5 marged $active'><a href='host/$h->hostname/'>$h->hostname</a></span>"; | ||
} | ||
} | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* By severity | ||
* | ||
**/ | ||
|
||
# verify that user is logged in | ||
$User->check_user_session(); | ||
|
||
# set limit to 10 | ||
$Trap->reset_print_limit (200); | ||
|
||
# fetch all traps | ||
$traps = $Trap->fetch_traps ("all"); | ||
|
||
|
||
# set fields | ||
$tfields = array( "id"=>"", | ||
"hostname"=>"Hostname", | ||
"ip"=>"IP address", | ||
"date"=>"Date", | ||
"message"=>"Message", | ||
"severity"=>"Severity", | ||
"content"=>"Content" | ||
); | ||
$Table_print->set_snmp_table_fields ($tfields); | ||
|
||
# structure | ||
print "<div class='container-fluid row'>"; | ||
|
||
# critical | ||
print "<h4>Live message update</h4><hr>"; | ||
print "<div class='container pull-left'>Messages will be updated each 15 seconds</div>"; | ||
print "<table class='table snmp live sorted table-noborder table-condensed table-hover'>"; | ||
$Table_print->print_snmp_table ($traps); | ||
print "</table>"; | ||
|
||
print "</div>"; | ||
|
||
?> | ||
|
||
|
||
<script type="text/javascript"> | ||
$(document).ready(function() { | ||
//update messages each 15 seconds | ||
var t = setInterval(update_table,15000); | ||
|
||
// stop | ||
//clearInterval(t); | ||
|
||
// update function | ||
function update_table () { | ||
// get last id | ||
var id = $('table.table.snmp.live').children('tbody').children('tr:first').attr('data-id'); | ||
// remove updated class | ||
$('table.table.snmp tr').removeClass('new'); | ||
// get updated tr items | ||
$.ajax({ | ||
type: "POST", | ||
url: "app/live/update.php", | ||
data: "id="+ id, | ||
cache: false, | ||
success: function(html){ | ||
if(html!=="False") | ||
$('table.table.snmp.live tbody').prepend(html); | ||
} | ||
}); | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* Updates new items based on provided trap id | ||
* | ||
**/ | ||
|
||
|
||
# functions | ||
require('../../functions/functions.php'); | ||
|
||
# Objects | ||
$Database = new Database_PDO; | ||
$Result = new Result; | ||
$User = new User ($Database); | ||
# snmp class | ||
$Trap = new Trap_read ($Database); | ||
$Table_print= new Table_print (); | ||
|
||
# verify that user is logged in | ||
$User->check_user_session(); | ||
|
||
# fetch all traps | ||
$traps = $Trap->get_new_traps ($_POST['id']); | ||
|
||
# false - no new items | ||
if ($traps!==false) { | ||
|
||
# set fields | ||
$tfields = array( "id"=>"", | ||
"hostname"=>"Hostname", | ||
"ip"=>"IP address", | ||
"date"=>"Date", | ||
"message"=>"Message", | ||
"severity"=>"Severity", | ||
"content"=>"Content" | ||
); | ||
$Table_print->set_snmp_table_fields ($tfields); | ||
|
||
# Print new items | ||
$Table_print->print_snmp_table ($traps, false, false); | ||
|
||
} | ||
else { | ||
print "False"; | ||
} | ||
?> |
Oops, something went wrong.