From 1ffa1399482188e8d85b2fd6a4ab980e7f1fb43e Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 4 Dec 2025 13:35:58 +0000 Subject: [PATCH] Added server_live_partitions inserts/updates to update_AMI2 script Added partition display to admin.php git-svn-id: svn://192.168.202.10@3956 3d104415-ff17-0410-8863-d5cf3c621b8a --- bin/AST_update_AMI2.pl | 19 ++++ www/vicidial/admin.php | 148 +++++++++++++++++++++++++++- www/vicidial/help_documentation.txt | 4 +- 3 files changed, 164 insertions(+), 7 deletions(-) diff --git a/bin/AST_update_AMI2.pl b/bin/AST_update_AMI2.pl index c28e60ed..17f8a54b 100644 --- a/bin/AST_update_AMI2.pl +++ b/bin/AST_update_AMI2.pl @@ -20,6 +20,7 @@ # 210827-0930 - Added PJSIP compatibility # 220310-1136 - Fix for issue dealing with bad carrier 'P-Asserted-Identity' input # 251008-2114 - Added code for recording_dtmf_detection and recording_dtmf_muting +# 251203-2218 - Added server_live_partitions inserts/updates # # constants @@ -1758,6 +1759,7 @@ sub get_disk_space @serverDISK = `$dfbin -B 1048576 -x nfs -x cifs -x sshfs -x ftpfs`; $ct=0; $ct_PCT=0; + $part_order=0; $disk_usage = ''; foreach(@serverDISK) { @@ -1767,6 +1769,23 @@ sub get_disk_space $usage = $1; $usage =~ s/\%//gi; $disk_usage .= "$ct_PCT $usage|"; + $partition_path = $serverDISK[$ct]; + $partition_path =~ s/.*\% |\r|\n|\t//gi; + $partition_filesystem = $serverDISK[$ct]; + $partition_filesystem =~ s/ .*|\r|\n|\t//gi; + $disk_data = $serverDISK[$ct]; + $disk_data =~ s/\s+/ /gi; + @disk_dataARY = split(/ /,$disk_data); + $mb_used = $disk_dataARY[2]; + $mb_available = $disk_dataARY[3]; + + # insert/update server_live_drives record in the DB + $stmtA = "INSERT INTO server_live_partitions set server_ip='$server_ip',partition_path='$partition_path',update_time=NOW(),partition_order='$part_order',partition_filesystem='$partition_filesystem',use_pct='$usage',mb_used='$mb_used',mb_available='$mb_available' ON DUPLICATE KEY UPDATE update_time=NOW(),partition_order='$part_order',partition_filesystem='$partition_filesystem',use_pct='$usage',mb_used='$mb_used',mb_available='$mb_available';"; + if($DB){print STDERR "\n$stmtA\n";} + $dbhA->do($stmtA); + $affected_rows = $dbhA->do($stmtA); + + $part_order++; } $ct++; } diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 11cc2c9c..a274849d 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -6299,12 +6299,13 @@ if ($SSscript_remove_js > 0) # 251019-2024 - Added Recording DTMF Muting # 251025-1924 - Added CRASHED DATABASE TABLES display page, db_crashed_tables_check system settings option # 251112-2201 - Added alter_cid_name DID option +# 251204-0757 - Added SERVER DRIVE PARTITIONS display # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.14-948a'; -$build = '251112-2201'; +$admin_version = '2.14-949a'; +$build = '251204-0757'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -7381,6 +7382,7 @@ if ($ADD==999987) {$hh='reports'; echo _QXZ("PHONE CODES");} if ($ADD==999986) {$hh='reports'; echo _QXZ("POSTAL CODES");} if ($ADD==999985) {$hh='reports'; echo _QXZ("POSTAL CODES CITIES");} if ($ADD==999984) {$hh='reports'; echo _QXZ("CRASHED DATABASE TABLES");} +if ($ADD==999983) {$hh='reports'; echo _QXZ("SERVER DRIVE PARTITIONS");} echo "\n"; @@ -41826,6 +41828,23 @@ if ($ADD==311111111111) $live_agents = $row[0]; if ($DB > 0) {echo "|$live_agents|$stmt|\n";} + # look for server_live_partitions entries for this server + $stmt="SELECT partition_order,use_pct from server_live_partitions where server_ip='$server_ip' and (mb_used + mb_available) >= 1000;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $parts_to_print = mysqli_num_rows($rslt); + $pp=0; + $temp_disk_usage=''; + while ($parts_to_print > $pp) + { + $row=mysqli_fetch_row($rslt); + $part_order = ($row[0] + 1); + $temp_disk_usage .= "$part_order $row[1]|"; + $pp++; + } + if (strlen($temp_disk_usage) > 3) + {$disk_usage = $temp_disk_usage;} + $cpu = (100 - $cpu_idle_percent); $disk_usage = preg_replace("/ /"," - ",$disk_usage); $disk_usage = preg_replace("/\|/","%     ",$disk_usage); @@ -41843,7 +41862,15 @@ if ($ADD==311111111111) echo ""._QXZ("System Load").": $sysload - $cpu%   $NWB#servers-sysload$NWE\n"; echo ""._QXZ("Live Channels").": $channels_total     "._QXZ("Agents").": $live_agents   $NWB#servers-channels_total$NWE\n"; - echo ""._QXZ("Disk Usage").": $disk_usage   $NWB#servers-disk_usage$NWE\n"; + + if ($pp > 0) + { + echo ""._QXZ("Disk Usage").": $disk_usage   $NWB#servers-disk_usage$NWE\n"; + } + else + { + echo ""._QXZ("Disk Usage").": $disk_usage   $NWB#servers-disk_usage$NWE\n"; + } echo ""._QXZ("System Uptime").": $system_uptime   $NWB#servers-system_uptime$NWE\n"; echo ""._QXZ("Admin User Group").":