Skip to content

Commit 467583a

Browse files
authored
Merge pull request pucherot#235 from leiweibau/next_update
Next update
2 parents 7538ebf + fab2e1a commit 467583a

File tree

14 files changed

+95
-73
lines changed

14 files changed

+95
-73
lines changed

back/pialert-cli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ EOM
633633
echo "${PIA_USER} ALL=(ALL) NOPASSWD: /usr/sbin/arp-scan" | sudo tee -a /etc/sudoers.d/pialert-backend
634634
echo "${PIA_USER} ALL=(ALL) NOPASSWD: /usr/bin/nmap" | sudo tee -a /etc/sudoers.d/pialert-backend
635635
echo "${PIA_USER} ALL=(ALL) NOPASSWD: ${SCRIPTPATH}/speedtest/speedtest" | sudo tee -a /etc/sudoers.d/pialert-backend
636+
echo "${PIA_USER} ALL=(ALL) NOPASSWD: /usr/bin/ping" | sudo tee -a /etc/sudoers.d/pialert-backend
636637
;;
637638

638639
unset_sudoers)

back/pialert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,7 @@ def get_icmphost_list():
20622062
# -----------------------------------------------------------------------------
20632063
def ping(host):
20642064

2065-
command = ['ping', '-c', '1', host]
2065+
command = ['sudo', 'ping', '-c' , '1', host]
20662066
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
20672067
output = result.stdout.decode('utf8')
20682068
if "Request timed out." in output or "100% packet loss" in output:
@@ -2077,7 +2077,7 @@ def ping_avg(host):
20772077
except NameError: # variable not defined, use a default
20782078
ping_count = str(2) # 1
20792079

2080-
command = ['ping', '-c', ping_count, host]
2080+
command = ['sudo', 'ping', '-c', ping_count, host]
20812081
ping_process = subprocess.Popen(command, stdout=subprocess.PIPE)
20822082
tail_process = subprocess.Popen(['tail', '-1'], stdin=ping_process.stdout, stdout=subprocess.PIPE)
20832083
awk_process = subprocess.Popen(['awk', '-F/', '{print $5}'], stdin=tail_process.stdout, stdout=subprocess.PIPE)

config/version.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
VERSION = ''
2-
VERSION_YEAR = '2023'
3-
VERSION_DATE = '2023-12-31'
2+
VERSION_YEAR = '2024'
3+
VERSION_DATE = '2024-01-14'

front/icmpmonitorDetails.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ function get_host_statistic($hostip) {
115115

116116
$statistic = array();
117117

118-
$query = "SELECT AVG(icmpeve_avgrtt) FROM ICMP_Mon_Events WHERE icmpeve_avgrtt != 99999 AND icmpeve_avgrtt IS NOT NULL AND icmpeve_ip=\"$hostip\"";
118+
$query = "SELECT AVG(icmpeve_avgrtt) FROM ICMP_Mon_Events WHERE icmpeve_avgrtt != 99999 AND icmpeve_avgrtt != '' AND icmpeve_ip='$hostip'";
119119
$result = $db->querySingle($query);
120120
$statistic['avg_rtt_all'] = round($result, 3) . ' ms';
121121

122-
$query_max = "SELECT MAX(icmpeve_avgrtt) FROM ICMP_Mon_Events WHERE icmpeve_avgrtt != 99999 AND icmpeve_avgrtt IS NOT NULL AND icmpeve_ip=\"$hostip\"";
122+
$query_max = "SELECT MAX(icmpeve_avgrtt) FROM ICMP_Mon_Events WHERE icmpeve_avgrtt != 99999 AND icmpeve_avgrtt != '' AND icmpeve_ip='$hostip'";
123123
$result_max = $db->querySingle($query_max);
124124
$statistic['rtt_max_all'] = '<i class="bi bi-speedometer2 flip-horizontal text-red"></i> ' . round($result_max, 3) . ' ms';
125125

126-
$query_min = "SELECT MIN(icmpeve_avgrtt) FROM ICMP_Mon_Events WHERE icmpeve_avgrtt != 99999 AND icmpeve_avgrtt IS NOT NULL AND icmpeve_ip=\"$hostip\"";
126+
$query_min = "SELECT MIN(icmpeve_avgrtt) FROM ICMP_Mon_Events WHERE icmpeve_avgrtt != 99999 AND icmpeve_avgrtt != '' AND icmpeve_ip='$hostip'";
127127
$result_min = $db->querySingle($query_min);
128128
$statistic['rtt_min_all'] = '<i class="bi bi-speedometer2 text-green"></i> ' . round($result_min, 3) . ' ms';
129129

front/maintenance.php

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -173,39 +173,6 @@ function set_column_checkboxes($table_config) {
173173
return $col_checkbox;
174174
}
175175

176-
// Read logfiles --------------------------------------------------------------
177-
function read_logfile($logfile, $logmessage) {
178-
$file = file_get_contents('./php/server/' . $logfile, true);
179-
if ($file == "") {echo $logmessage;}
180-
if ($logfile == "pialert.webservices.log") {
181-
$file = str_replace("Start Services Monitoring\n\n", "Start Services Monitoring\n\n<pre style=\"border: solid 1px #666; background-color: transparent;\">", $file);
182-
$file = str_replace("\nServices Monitoring Changes:", "\n</pre>Services Monitoring Changes:", $file);
183-
}
184-
echo str_replace("\n", '<br>', str_replace(" ", '&nbsp;&nbsp;&nbsp;&nbsp;', str_replace(" ", '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', $file)));
185-
}
186-
187-
// Read Vendor logfiles -------------------------------------------------------
188-
function read_logfile_vendor() {
189-
global $pia_lang;
190-
191-
$file = file_get_contents('./php/server/pialert.vendors.log');
192-
if ($file == "") {echo $pia_lang['Maintenance_Tools_Logviewer_Vendor_empty'];} else {
193-
$temp_log = explode("\n", $file);
194-
$x = 0;
195-
while ($x < sizeof($temp_log)) {
196-
if (strlen($temp_log[$x]) == 0) {
197-
$y = $x;
198-
while ($y < sizeof($temp_log)) {
199-
echo $temp_log[$y] . '<br>';
200-
$y++;
201-
}
202-
break;
203-
}
204-
$x++;
205-
}
206-
}
207-
}
208-
209176
// Top Modal Block ------------------------------------------------------------
210177
function print_logviewer_modal_head($id, $title) {
211178
echo '<div class="modal fade" id="modal-logviewer-' . $id . '">
@@ -217,7 +184,7 @@ function print_logviewer_modal_head($id, $title) {
217184
<h4 class="modal-title">Viewer: ' . $title . '</h4>
218185
</div>
219186
<div class="modal-body main_logviwer_text_layout">
220-
<div class="main_logviwer_log" style="max-height: 70vh;">';
187+
<div class="main_logviwer_log" style="max-height: 70vh;" id="modal_'.$id.'_content">';
221188
}
222189

223190
// Bottom Modal Block ---------------------------------------------------------
@@ -362,29 +329,24 @@ function print_logviewer_modal_foot() {
362329
// Log Viewer - Modals
363330
// Scan
364331
print_logviewer_modal_head('scan', 'pialert.1.log (File)');
365-
read_logfile('pialert.1.log', $pia_lang['Maintenance_Tools_Logviewer_Scan_empty']);
366332
print_logviewer_modal_foot();
367-
// Internet IP
333+
// // Internet IP
368334
print_logviewer_modal_head('iplog', 'pialert.IP.log (File)');
369-
read_logfile('pialert.IP.log', $pia_lang['Maintenance_Tools_Logviewer_IPLog_empty']);
370335
print_logviewer_modal_foot();
371-
// Vendor Update
336+
// // Vendor Update
372337
print_logviewer_modal_head('vendor', 'pialert.vendors.log (File)');
373-
read_logfile_vendor();
374338
print_logviewer_modal_foot();
375-
// Cleanup
339+
// // Cleanup
376340
print_logviewer_modal_head('cleanup', 'pialert.cleanup.log (File)');
377-
read_logfile('pialert.cleanup.log', $pia_lang['Maintenance_Tools_Logviewer_Cleanup_empty']);
378341
print_logviewer_modal_foot();
379-
// Nmap
342+
// // Nmap
380343
print_logviewer_modal_head('nmap', 'last Nmap Scan (Memory)');
381344
if (!isset($_SESSION['ScanShortMem_NMAP'])) {echo $pia_lang['Maintenance_Tools_Logviewer_Nmap_empty'];} else {echo $_SESSION['ScanShortMem_NMAP'];}
382345
print_logviewer_modal_foot();
383-
// WebServices
346+
// // WebServices
384347
if ($_SESSION['Scan_WebServices'] == True) {
385-
print_logviewer_modal_head('webservices', 'pialert.webservices.log (File)');
386-
read_logfile('pialert.webservices.log', $pia_lang['Maintenance_Tools_Logviewer_WebServices_empty']);
387-
print_logviewer_modal_foot();
348+
print_logviewer_modal_head('webservices', 'pialert.webservices.log (File)');
349+
print_logviewer_modal_foot();
388350
}
389351
?>
390352

@@ -1221,6 +1183,7 @@ function startCountdown() {
12211183
// Reset countdown for the next 5-minute interval
12221184
countdownMinutes = 4;
12231185
countdownSeconds = 59;
1186+
GetARPStatus();
12241187
}
12251188
}
12261189
displayCountdown(countdownMinutes, countdownSeconds);
@@ -1236,6 +1199,33 @@ function formatTime(time) {
12361199
return time < 10 ? '0' + time : time;
12371200
}
12381201

1202+
function GetARPStatus() {
1203+
$.get('php/server/devices.php?action=GetARPStatus', function(data) {
1204+
var arpproccount = JSON.parse(data);
1205+
1206+
$('#arpproccounter').html(arpproccount[0].toLocaleString());
1207+
} );
1208+
}
1209+
1210+
function GetModalLogContent() {
1211+
$.get('php/server/files.php?action=GetLogfiles', function(data) {
1212+
var logcollection = JSON.parse(data);
1213+
1214+
$('#modal_scan_content').html(logcollection[0].toLocaleString());
1215+
$('#modal_iplog_content').html(logcollection[1].toLocaleString());
1216+
$('#modal_vendor_content').html(logcollection[2].toLocaleString());
1217+
$('#modal_cleanup_content').html(logcollection[3].toLocaleString());
1218+
$('#modal_webservices_content').html(logcollection[4].toLocaleString());
1219+
} );
1220+
}
1221+
1222+
function UpdateStatusBox() {
1223+
GetModalLogContent();
1224+
GetARPStatus();
1225+
}
1226+
1227+
setInterval(UpdateStatusBox, 15000);
1228+
GetModalLogContent();
12391229
startCountdown();
12401230
</script>
12411231

front/php/server/devices.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,20 @@
8282
break;
8383
case 'EnableMainScan':EnableMainScan();
8484
break;
85+
case 'GetARPStatus':GetARPStatus();
86+
break;
8587
default:logServerConsole('Action: ' . $action);
8688
break;
8789
}
8890
}
91+
function GetARPStatus() {
92+
$execstring = 'ps -aux | grep "/pialert/back/pialert.py 1" | grep -v grep | sed \'/>~\/pialert\/log\/pialert.1.log/d\'';
93+
$pia_arpscans = "";
94+
exec($execstring, $pia_arpscans);
95+
$result = array(sizeof($pia_arpscans));
96+
echo (json_encode($result));
97+
}
98+
8999

90100
// Query Device Data
91101
function getDeviceData() {

front/php/server/files.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,39 @@
7474
break;
7575
case 'setFavIconURL':setFavIconURL();
7676
break;
77+
case 'GetLogfiles':GetLogfiles();
78+
break;
7779
default:logServerConsole('Action: ' . $action);
7880
break;
7981
}
8082
}
8183

84+
// Read logfiles --------------------------------------------------------------
85+
function GetLogfiles() {
86+
global $pia_lang;
87+
88+
$logfiles = ["pialert.1.log", "pialert.IP.log", "pialert.vendors.log", "pialert.cleanup.log", "pialert.webservices.log"];
89+
$logmessage = [$pia_lang['Maintenance_Tools_Logviewer_Scan_empty'], $pia_lang['Maintenance_Tools_Logviewer_IPLog_empty'], '', $pia_lang['Maintenance_Tools_Logviewer_Cleanup_empty'], $pia_lang['Maintenance_Tools_Logviewer_WebServices_empty']];
90+
91+
$i = 0;
92+
$logs = array();
93+
while($i < count($logfiles)) {
94+
$file = file_get_contents($logfiles[$i], true);
95+
if ($file == "") {
96+
array_push($logs, $logmessage[$i]);
97+
} else {
98+
if ($logfile[$i] == "pialert.webservices.log") {
99+
$file = str_replace("Start Services Monitoring\n\n", "Start Services Monitoring\n\n<pre style=\"border: solid 1px #666; background-color: transparent;\">", $file);
100+
$file = str_replace("\nServices Monitoring Changes:", "\n</pre>Services Monitoring Changes:", $file);
101+
}
102+
$templog = str_replace("\n", '<br>', str_replace(" ", '&nbsp;&nbsp;&nbsp;&nbsp;', str_replace(" ", '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', $file)));
103+
array_push($logs, $templog);
104+
}
105+
$i++;
106+
}
107+
echo (json_encode($logs));
108+
}
109+
82110
function convert_bool($var) {
83111
if ($var == 1) {return "True";} else {return "False";}
84112
}

front/php/templates/header_func.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ function delete_single_webgui_report() {
2222
function arpscanstatus() {
2323
global $pia_lang;
2424
if (!file_exists('../db/setting_stoppialert')) {
25-
$execstring = 'ps aux | grep "~/pialert/back/pialert.py 1" 2>&1';
25+
$execstring = 'ps -aux | grep "/pialert/back/pialert.py 1" | grep -v grep | sed \'/>~\/pialert\/log\/pialert.1.log/d\'';
2626
$pia_arpscans = "";
2727
exec($execstring, $pia_arpscans);
28+
$arp_proc_count = sizeof($pia_arpscans);
2829
unset($_SESSION['arpscan_timerstart']);
29-
$_SESSION['arpscan_result'] = sizeof($pia_arpscans) - 2 . ' ' . $pia_lang['Maintenance_arp_status_on'] . ' <div id="nextscancountdown" style="display: inline-block;"></div>';
30+
$_SESSION['arpscan_result'] = '<span id="arpproccounter">' . $arp_proc_count . '</span> ' . $pia_lang['Maintenance_arp_status_on'] . ' <div id="nextscancountdown" style="display: inline-block;"></div>';
3031
$_SESSION['arpscan_sidebarstate'] = 'Active';
3132
$_SESSION['arpscan_sidebarstate_light'] = 'green-light fa-gradient-green';
3233
} else {
@@ -143,14 +144,6 @@ function toggle_webservices_menu($section) {
143144
</a>
144145
</li>';
145146
}
146-
147-
// if (($_SESSION['Scan_WebServices'] == True) && ($section == "Event")) {
148-
// echo '<li class="';
149-
// if (in_array(basename($_SERVER['SCRIPT_NAME']), array('servicesEvents.php'))) {echo 'active';}
150-
// echo '">
151-
// <a href="servicesEvents.php"><i class="fa fa-globe"></i><span>' . $pia_lang['Navigation_Events_Serv'] . '</span></a>
152-
// </li>';
153-
// }
154147
}
155148
// ICPMScan Menu Items
156149
function toggle_icmpscan_menu($section) {

front/php/templates/language/help_de_de.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@
247247
<table class="help_table_gen">
248248
<tr><td class="help_table_gen_section" colspan="2">Automatic Speedtest</td></tr>
249249
<tr><td class="help_table_gen_a">SPEEDTEST_TASK_ACTIVE</td>
250-
<td class="help_table_gen_b">Automatischen Speedtest aktivieren/deaktivieren</td></tr>
250+
<td class="help_table_gen_b">Automatischen Speedtest aktivieren/deaktivieren. Hierfür ist die Installation des Ookla Speedtests im Tab "Tools" des Gerätes "Internet" erforderlich. Beachte die Hinweise bei der Installation.</td></tr>
251251
<tr><td class="help_table_gen_a">SPEEDTEST_TASK_HOUR</td>
252-
<td class="help_table_gen_b">Volle Stunde(n) zu denen der Speedtest gestartet werden soll.</td></tr>
252+
<td class="help_table_gen_b">Volle Stunde, oder durch Komma getrennte Stunden, zu denen der Speedtest gestartet werden soll.</td></tr>
253253
</table>
254254
<table class="help_table_gen">
255255
<tr><td class="help_table_gen_section" colspan="2">Arp-scan Options & Samples</td></tr>

front/php/templates/language/help_en_us.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@
245245
<table class="help_table_gen">
246246
<tr><td class="help_table_gen_section" colspan="2">Automatic Speedtest</td></tr>
247247
<tr><td class="help_table_gen_a">SPEEDTEST_TASK_ACTIVE</td>
248-
<td class="help_table_gen_b"></td></tr>
248+
<td class="help_table_gen_b">Activate/deactivate the automatic speed test. This requires the installation of the Ookla speed test in the "Tools" tab of the "Internet" device. Follow the instructions during installation.</td></tr>
249249
<tr><td class="help_table_gen_a">SPEEDTEST_TASK_HOUR</td>
250-
<td class="help_table_gen_b"></td></tr>
250+
<td class="help_table_gen_b">Full hour, or comma-separated hours, at which the speed test is to be started.</td></tr>
251251
</table>
252252
<table class="help_table_gen">
253253
<tr><td class="help_table_gen_section" colspan="2">Arp-scan Options & Samples</td></tr>

front/php/templates/language/help_es_es.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@
240240
<table class="help_table_gen">
241241
<tr><td class="help_table_gen_section" colspan="2">Automatic Speedtest</td></tr>
242242
<tr><td class="help_table_gen_a">SPEEDTEST_TASK_ACTIVE</td>
243-
<td class="help_table_gen_b"></td></tr>
243+
<td class="help_table_gen_b">Activar/desactivar el test de velocidad automático. Para ello, instale el test de velocidad Ookla en la pestaña "Herramientas" del dispositivo "Internet". Siga las instrucciones durante la instalación.</td></tr>
244244
<tr><td class="help_table_gen_a">SPEEDTEST_TASK_HOUR</td>
245-
<td class="help_table_gen_b"></td></tr>
245+
<td class="help_table_gen_b">Hora completa, u horas separadas por comas, a la que debe iniciarse la prueba de velocidad.</td></tr>
246246
</table>
247247
<table class="help_table_gen">
248248
<tr><td class="help_table_gen_section" colspan="2">Arp-scan Options & Samples</td></tr>

front/php/templates/language/help_fr_fr.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@
236236
<table class="help_table_gen">
237237
<tr><td class="help_table_gen_section" colspan="2">Automatic Speedtest</td></tr>
238238
<tr><td class="help_table_gen_a">SPEEDTEST_TASK_ACTIVE</td>
239-
<td class="help_table_gen_b"></td></tr>
239+
<td class="help_table_gen_b">Activer/désactiver le test de vitesse automatique. Pour cela, il faut installer le Speedtest Ookla dans l&apos;onglet "Outils" de l&apos;appareil "Internet". Observe les instructions lors de l&apos;installation.</td></tr>
240240
<tr><td class="help_table_gen_a">SPEEDTEST_TASK_HOUR</td>
241-
<td class="help_table_gen_b"></td></tr>
241+
<td class="help_table_gen_b">Heure complète, ou heures séparées par une virgule, à laquelle le test de vitesse doit être lancé.</td></tr>
242242
</table>
243243
<table class="help_table_gen">
244244
<tr><td class="help_table_gen_section" colspan="2">Arp-scan Options & Samples</td></tr>

front/php/templates/language/help_it_it.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@
240240
<table class="help_table_gen">
241241
<tr><td class="help_table_gen_section" colspan="2">Automatic Speedtest</td></tr>
242242
<tr><td class="help_table_gen_a">SPEEDTEST_TASK_ACTIVE</td>
243-
<td class="help_table_gen_b"></td></tr>
243+
<td class="help_table_gen_b">Attivare/disattivare il test di velocità automatico. Ciò richiede l&apos;installazione dello speed test di Ookla nella scheda "Strumenti" del dispositivo "Internet". Seguire le istruzioni durante l&apos;installazione.</td></tr>
244244
<tr><td class="help_table_gen_a">SPEEDTEST_TASK_HOUR</td>
245-
<td class="help_table_gen_b"></td></tr>
245+
<td class="help_table_gen_b">Ora intera, o ore separate da virgole, in cui deve essere avviato il test di velocità.</td></tr>
246246
</table>
247247
<table class="help_table_gen">
248248
<tr><td class="help_table_gen_section" colspan="2">Opzioni e campioni di arp-scan</td></tr>

tar/pialert_latest.tar

17.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)