Skip to content

Commit

Permalink
Merge pull request pucherot#211 from leiweibau/next_update
Browse files Browse the repository at this point in the history
Update 2023-11-28
  • Loading branch information
leiweibau authored Nov 28, 2023
2 parents c9e71c7 + 3482459 commit a72f9e2
Show file tree
Hide file tree
Showing 32 changed files with 3,391 additions and 2,272 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
* [Installation](#installation)
* [Update](#update)
* Additional information
* [Uninstall Pi.Alert](docs/UNINSTALL.md)
* [Screenshots](docs/SCREENSHOTS.md)
* [Device Management](docs/DEVICE_MANAGEMENT.md)
* [Bulk Editor](docs/BULKEDITOR.md)
* [Network Relationship](docs/NETWORK_RELATIONSHIP.md)
* [Web service monitoring](docs/WEBSERVICES.md)
* [Screenshots](docs/SCREENSHOTS.md)
* [Uninstall Pi.Alert](docs/UNINSTALL.md)
* [Closing words](#closing-words)


Expand Down
5 changes: 4 additions & 1 deletion back/pialert-cli
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ EOM
echo "# takes place during the update to avoid possible database errors afterwards! #"
echo "# #"
echo "# This can be done by pausing the Arp scan via the settings page. However, #"
echo "# scans that are already running will not be terminated. (STRG+C to Abort) #"
echo "# scans that are already running will not be terminated. For more information, #"
echo "# check the Help/FAQ section in Pi.Alert #"
echo "# #"
echo "# Press STRG+C to Abort #"
echo "################################################################################"
echo ""
echo ""
Expand Down
44 changes: 35 additions & 9 deletions back/pialert.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ def cleanup_database ():
sql.execute ("DELETE FROM Events WHERE eve_DateTime <= date('now', '-"+strdaystokeepEV+" day')")
print (' Services_Events, up to the lastest '+strdaystokeepOH+' days...')
sql.execute ("DELETE FROM Services_Events WHERE moneve_DateTime <= date('now', '-"+strdaystokeepOH+" day')")
print (' ICMP_Mon_Events, up to the lastest '+strdaystokeepEV+' days...')
sql.execute ("DELETE FROM ICMP_Mon_Events WHERE icmpeve_DateTime <= date('now', '-"+strdaystokeepEV+" day')")
print (' ICMP_Mon_Events, up to the lastest '+strdaystokeepOH+' days...')
sql.execute ("DELETE FROM ICMP_Mon_Events WHERE icmpeve_DateTime <= date('now', '-"+strdaystokeepOH+" day')")
print (' Trim Journal to the lastest 1000 entries')
sql.execute ("DELETE FROM pialert_journal WHERE journal_id NOT IN (SELECT journal_id FROM pialert_journal ORDER BY journal_id DESC LIMIT 1000) AND (SELECT COUNT(*) FROM pialert_journal) > 1000")
print (' Speedtest_History, up to the lastest '+strdaystokeepOH+' days...')
Expand Down Expand Up @@ -2009,8 +2009,11 @@ def icmp_monitoring():
flush_icmphost_current_scan()
print(" Ping Hosts...")

closeDB()
scantime = startTime.strftime("%Y-%m-%d %H:%M")

icmp_scan_results = {}

icmphosts_all = len(icmphosts)
icmphosts_online = 0
icmphosts_offline = 0
Expand All @@ -2020,8 +2023,11 @@ def icmp_monitoring():
except NameError: # variable not defined, use a default
ping_retries = 1 # 1

while icmphosts:
for host_ip in icmphosts:
icmphosts_index = 0

if icmphosts_all > 0 :
while icmphosts_index < icmphosts_all:
host_ip = icmphosts[icmphosts_index]
for i in range(ping_retries):
# print("Host %s retry %s" % (host_ip, str(i+1)))
icmp_status = ping(host_ip)
Expand All @@ -2036,22 +2042,42 @@ def icmp_monitoring():
icmp_rtt = "99999"
icmphosts_offline+=1

set_icmphost_events(host_ip, scantime, icmp_status, icmp_rtt)
set_icmphost_current_scan(host_ip, scantime, icmp_status, icmp_rtt)
current_data = {
"host_ip": host_ip,
"scantime": scantime,
"icmp_status": icmp_status,
"icmp_rtt": icmp_rtt
}

icmp_scan_results[host_ip] = current_data
sys.stdout.flush()
set_icmphost_update(host_ip, scantime, icmp_status, icmp_rtt)

icmphosts_index += 1

print(" Online Host(s) : " + str(icmphosts_online))
print(" Offline Host(s) : " + str(icmphosts_offline))

openDB()
# Save Scan Results
icmp_save_scandata(icmp_scan_results)

print(" Calculate Activity History...")
calc_activity_history_icmp(icmphosts_online, icmphosts_offline)

break

else:
openDB()
print(" No Hosts(s) to monitor!")

# -----------------------------------------------------------------------------
def icmp_save_scandata(data):
print(" Save scan results...")
for host_ip, scan_data in data.items():
#print(f"Host IP: {host_ip}")
#print(f"ICMP Status: {scan_data['icmp_status']}")
set_icmphost_events(host_ip, scan_data['scantime'], scan_data['icmp_status'], scan_data['icmp_rtt'])
set_icmphost_current_scan(host_ip, scan_data['scantime'], scan_data['icmp_status'], scan_data['icmp_rtt'])
set_icmphost_update(host_ip, scan_data['scantime'], scan_data['icmp_status'], scan_data['icmp_rtt'])

# -----------------------------------------------------------------------------
def get_icmphost_list():

Expand Down
2 changes: 1 addition & 1 deletion config/version.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = ''
VERSION_YEAR = '2023'
VERSION_DATE = '2023-11-14'
VERSION_DATE = '2023-11-28'
22 changes: 12 additions & 10 deletions front/css/pialert.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
.box-body { padding-top: 0px; padding-bottom: 0px; }
.main-footer { padding: 5px; color: gray; }
/* ----------------- Customized Main Menu ---------------------------------- */
.main-header .logo { width: 170px;}
.main-header>.navbar { margin-left: 170px; }
.main-sidebar, .left-side { width: 170px; }
.content-wrapper, .right-side, .main-footer { margin-left: 170px; }
.main-header .logo { width: 210px;}
.main-header>.navbar { margin-left: 210px; }
.main-sidebar, .left-side { width: 210px; }
.content-wrapper, .right-side, .main-footer { margin-left: 210px; }

@media (max-width: 767px) {
.main-header .logo {
Expand All @@ -63,10 +63,10 @@
-ms-transform: translate(150px, 0);
-o-transform: translate(150px, 0);
transform: translate(150px, 0) */
-webkit-transform: translate(170px, 0);
-ms-transform: translate(170px, 0);
-o-transform: translate(170px, 0);
transform: translate(170px, 0)
-webkit-transform: translate(210px, 0);
-ms-transform: translate(210px, 0);
-o-transform: translate(210px, 0);
transform: translate(210px, 0)
}
.skin-yellow-light .sidebar-menu>li>a:hover {
background: #f0f0f0;
Expand Down Expand Up @@ -204,7 +204,7 @@
}
/* ----------------- Customized Menu dropdown ------------------------------- */
.dropdown-menu {
max-height: 300px;
max-height: 350px;
overflow-x: hidden;
box-shadow: 0px 3px 20px rgba(0, 0, 0, 0.2);
}
Expand Down Expand Up @@ -417,6 +417,7 @@ body.modal-open {
#navbar-back-button {position: relative; left:0px; width: 42px; height: 50px; display: inline-block; padding-top: 15px; text-align: center;}
#navbar-back-button:hover {background-color: rgba(0, 0, 0, 0.1);}
/* ----------------- System Info -------------------------------------------- */
.user-panel {padding-left: 0px;}
.sysinfo_headline {color: #00c0ef;}
.sysinfo_gerneral_a {font-weight: bold; padding-top: 2px; padding-bottom: 2px;}
.sysinfo_gerneral_b {padding-left: 30px; padding-top: 2px; padding-bottom: 2px;}
Expand Down Expand Up @@ -473,6 +474,7 @@ body.modal-open {
.help_table_gen_section {font-weight: 600; text-align: center; border: solid 1px #aaa; text-transform: uppercase; padding-top: 3px; padding-bottom: 3px;}
.help_table_gen_a {vertical-align: top; padding-left:5px; padding-right:5px; border: solid 1px #aaa; padding-top: 5px; padding-bottom: 5px;}
.help_table_gen_b {padding-left:5px; border: solid 1px #aaa; padding-top: 5px; padding-bottom: 5px;}
.help_question {font-size: 16px;}
/* ----------------- Bulk Editor -------------------------------------------- */
.bulked_checkbox_label_alldown {
background-image:linear-gradient(90deg,#5196d5,#dd7768);
Expand All @@ -487,4 +489,4 @@ body.modal-open {
/* ----------------- Network ------------------------------------------------ */
.network_tab_icon {font-size: 16px; position: relative;}
.flip-horizontal { transform: scaleX(-1); display: inline-block;}

/* ----------------- Network ------------------------------------------------ */
4 changes: 1 addition & 3 deletions front/download/config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

$ARCHIVE_PATH = str_replace('download', '', str_replace('front', 'config', getcwd()));
$DOWN_CONF_FILE = $ARCHIVE_PATH . "pialert.conf";

Expand All @@ -12,5 +11,4 @@
header('Content-Length: ' . filesize($DOWN_CONF_FILE));
readfile($DOWN_CONF_FILE);
exit;

?>
?>
19 changes: 8 additions & 11 deletions front/download/database.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<?php

$ARCHIVE_PATH = str_replace('download', '', str_replace('front', 'db', getcwd()));
$LATEST_FILES = glob($ARCHIVE_PATH."pialertdb_*.zip");
$LATEST_FILES = glob($ARCHIVE_PATH . "pialertdb_*.zip");
if (sizeof($LATEST_FILES) == 0) {
exit;
exit;
} else {
natsort($LATEST_FILES);
$LATEST_FILES = array_reverse($LATEST_FILES,False);
$LATEST_BACKUP = $LATEST_FILES[0];
}
natsort($LATEST_FILES);
$LATEST_FILES = array_reverse($LATEST_FILES, False);
$LATEST_BACKUP = $LATEST_FILES[0];
}

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($LATEST_BACKUP).'"');
header('Content-Disposition: attachment; filename="' . basename($LATEST_BACKUP) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($LATEST_BACKUP));
readfile($LATEST_BACKUP);
exit;


?>
?>
14 changes: 14 additions & 0 deletions front/download/databasecsv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
$ARCHIVE_PATH = str_replace('download', '', str_replace('front', 'db', getcwd()));
$CSVFILE = $ARCHIVE_PATH . "pialertcsv.zip";

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($CSVFILE) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($CSVFILE));
readfile($CSVFILE);
exit;
?>
Loading

0 comments on commit a72f9e2

Please sign in to comment.