瀏覽代碼

fixed some bugs. added new...

rajven 4 年之前
父節點
當前提交
1585cdcbb6

+ 3 - 0
docs/wiki/foswiki/ShowStatPlugin.pm

@@ -96,6 +96,9 @@ my $SQL = "SELECT A.id, A.ip, A.mac, L.login, A.nagios, A.dhcp_hostname, A.enabl
 A.last_found, A.comments FROM User_auth as A, User_list as L, Group_list as G, Queue_list As Q
 WHERE A.user_id = L.id and A.filter_group_id = G.id and Q.id = A.queue_id AND A.deleted =0 and A.ip_int=".$host_aton." LIMIT 1";
 
+#wait for statsync
+sleep(2);
+
 my $dbh = DBI->connect("dbi:$dbstat->{driver}:database=$dbstat->{database};host=$dbstat->{hostname}","$dbstat->{username}","$dbstat->{password}");
 my $status = '';
 eval {

+ 13 - 3
docs/wiki/foswiki/StatSyncPlugin.pm

@@ -94,11 +94,17 @@ my $dnsname = $params->{dnsname};
 my $comment = $params->{comment};
 my $wikiname = $params->{wikiname};
 
-return "" if (!$host);
+#my $result="Runned: $host $dnsname $comment $wikiname<br>";
+
+my $result="";
+
+return $result if (!$host);
 
 my $host_aton=StrToIp($host);
-my $SQL = "SELECT id,dns_name,WikName,comments FROM User_auth WHERE ip_int=".$host_aton." and deleted=0 LIMIT 1";
+my $SQL = "SELECT * FROM User_auth WHERE ip_int=".$host_aton." and deleted=0 LIMIT 1";
+
 my $dbh = DBI->connect("dbi:$dbstat->{driver}:database=$dbstat->{database};host=$dbstat->{hostname}","$dbstat->{username}","$dbstat->{password}");
+
 eval {
 if ( !defined $dbh ) { return "Cannot connect to mySQL server: $DBI::errstr\n"; }
 $dbh->do('SET NAMES utf8');
@@ -106,23 +112,27 @@ $dbh->{'mysql_enable_utf8'} = 1;
 my $sth = $dbh->prepare($SQL);
 $sth->execute;
 my $res = $sth->fetchrow_hashref();
+
 if ($res) {
     if ($dnsname and $res->{dns_name} ne $dnsname) {
         $sth = $dbh->prepare("UPDATE User_auth SET dns_name='".$dnsname."' WHERE id=".$res->{id});
         $sth->execute;
+#        $result .= "fixed dns_name!<br>";
         }
     if ($comment and $res->{comments} ne $comment) {
         $sth = $dbh->prepare("UPDATE User_auth SET comments='".$comment."' WHERE id=".$res->{id});
         $sth->execute;
+#        $result .= "fixed comments!<br>";
         }
     if ($wikiname and $res->{WikiName} ne $wikiname) {
         $sth = $dbh->prepare("UPDATE User_auth SET WikiName='".$wikiname."' WHERE id=".$res->{id});
         $sth->execute;
+#        $result .= "fixed wiki name!<br>";
         }
     }
 };
 if ($@) { return "DBI error: $@"; }
-return "";
+return $result;
 }
 
 1;

+ 66 - 28
docs/wiki/foswiki/UpsInfoPlugin.pm

@@ -104,6 +104,7 @@ sub _UpsINFO {
 
 my $OIDModel       = '.1.3.6.1.2.1.33.1.1.1.0';
 my $SchneiderModel = '.1.3.6.1.2.1.1.1.0';
+my $OIDidentBasicModel    = '1.3.6.1.4.1.318.1.1.1.1.1.1.0';
 
 # APC OIDs
 my $OIDAPC                = '1.3.6.1.4.1.318.';
@@ -111,7 +112,6 @@ my $OIDhardware           = '1.3.6.1.4.1.318.1.1.';
 my $OIDups                = '1.3.6.1.4.1.318.1.1.1.';
 my $OIDident              = '1.3.6.1.4.1.318.1.1.1.1.';
 my $OIDidentBasic         = '1.3.6.1.4.1.318.1.1.1.1.1.';
-my $OIDidentBasicModel    = '1.3.6.1.4.1.318.1.1.1.1.1.1.0';
 my $OIDidentBasicName     = '1.3.6.1.4.1.318.1.1.1.1.1.2.0';
 my $OIDidentAdv           = '1.3.6.1.4.1.318.1.1.1.1.2.';
 my $OIDidentAdvFW         = '1.3.6.1.4.1.318.1.1.1.1.2.1.0';
@@ -138,6 +138,15 @@ my $apcUpsAdvOutputCurrent              ='1.3.6.1.4.1.318.1.1.1.4.2.4.0';
 my $apcUpsAdvInputLineVoltage           ='1.3.6.1.4.1.318.1.1.1.3.2.1.0';
 my $apcUpsAdvInputFrequency             ='1.3.6.1.4.1.318.1.1.1.3.2.4.0';
 
+my $apcUpsAdvInputLine3Voltage           ='1.3.6.1.4.1.318.1.1.1.3.2.3.0';
+my $apcUpsAdvInputLine2Voltage           ='1.3.6.1.4.1.318.1.1.1.3.2.2.0';
+my $apcUpsAdvInputLine1Voltage           ='1.3.6.1.4.1.318.1.1.1.3.2.1.0';
+
+#EATON
+my $EatonBatteryTemp =' 1.3.6.1.4.1.534.1.6.1.0';
+
+#default UPS mib
+
 my $BATTERYREPLACE = '2';
 
 my $defaultModel          = '.1.3.6.1.2.1.33.1.1.2.0';
@@ -189,14 +198,19 @@ my $TEMPWARN = 50;
 
     my $vendor;
     my $vendor_string = GetSNMPkeyValue($snmp_session,$OIDModel);
+
+    if (!$vendor_string) { $vendor_string = GetSNMPkeyValue($snmp_session,$OIDidentBasicModel); }
     if (!$vendor_string) { $vendor_string = GetSNMPkeyValue($snmp_session,$SchneiderModel); $vendor = 'Schneider'; }
+
     return "Ups model unknown!<BR>"  if (!defined($vendor_string));
 
     if (!$vendor and $vendor_string=~/Eaton/i) { $vendor='EATON'; }
     if (!$vendor and $vendor_string=~/APC/i) { $vendor='APC'; }
+    if (!$vendor and $vendor_string=~/Symmetra/i) { $vendor='Symmetra'; }
 
-    my $upsModel = GetSNMPkeyValue($snmp_session,$defaultModel);
+    my $upsModel = GetSNMPkeyValue($snmp_session,$defaultModel) || GetSNMPkeyValue($snmp_session,$OIDidentBasicModel);
 
+#    my $ret = "UPS Model: ".$upsModel." Vendor: ".$vendor." [ $vendor_string ]\n\n";
     my $ret = "UPS Model: ".$upsModel."\n\n";
 
     my $battery_status = GetSNMPkeyValue($snmp_session,$defaultBatteryStatus);
@@ -215,7 +229,7 @@ my $TEMPWARN = 50;
     $status = "%RED%Sleeping until power return%ENDCOLOR%" if ($battery_status eq 11);
     $ret .= "| UPS Status | ".$status." |\n";
 
-    if ($vendor eq 'APC') {
+    if ($vendor eq 'APC' or $vendor eq 'Symmetra') {
         my $batteryAdvReplace = $snmp_session->get_request(-varbindlist => [$OIDbatteryAdvReplace])->{$OIDbatteryAdvReplace};
         if ($batteryAdvReplace && ($batteryAdvReplace eq $BATTERYREPLACE)) { $ret .= "| Battery Status | %RED%Battery requires replacement!%ENDCOLOR%|\n"; };
         $ret .= "| Battery Capacity | ".$snmp_session->get_request(-varbindlist => [$apcUpsAdvBatteryCapacity])->{$apcUpsAdvBatteryCapacity}."% |\n";
@@ -223,43 +237,67 @@ my $TEMPWARN = 50;
 
     my $inputHz = GetSNMPkeyValue($snmp_session,$defaultInputHz);
     if ($inputHz) { $inputHz = int($inputHz/10); }
-    my $outputHz = GetSNMPkeyValue($snmp_session,$defaultOutputHz);
-    if ($outputHz) { $outputHz = int($outputHz/10); }
-    my $runtime;
 
-    if ($vendor eq 'APC') {
+
+    my $runtime;
+    if ($vendor eq 'APC' or $vendor eq 'Symmetra') {
         $runtime = GetSNMPkeyValue($snmp_session,$OIDbatteryAdvRuntime);
         $runtime=int($runtime/6000);
-        } else {
-        if ($vendor eq 'EATON') {
-            $runtime = GetSNMPkeyValue($snmp_session,'.1.3.6.1.4.1.534.1.2.1');
-            } else {
-            $runtime = GetSNMPkeyValue($snmp_session,$defaultLiveTime);
-            }
         }
+
+    if ($vendor eq 'EATON') { $runtime = GetSNMPkeyValue($snmp_session,'.1.3.6.1.4.1.534.1.2.1'); }
+    if (!$runtime) { $runtime = GetSNMPkeyValue($snmp_session,$defaultLiveTime); }
     if ($vendor eq 'EATON') { $runtime=int($runtime/60); }
-    my $outputCurrent = GetSNMPkeyValue($snmp_session,$defaultOutputCurrent);
+
+    my $outputCurrent;
+    if ($vendor eq 'APC' or $vendor eq 'Symmetra') { $outputCurrent = GetSNMPkeyValue($snmp_session,$apcUpsAdvOutputCurrent); }
+    if (!$outputCurrent) { $outputCurrent = GetSNMPkeyValue($snmp_session,$defaultOutputCurrent); }
     if ($outputCurrent) { $outputCurrent=$outputCurrent/10; }
 
     my $batTemp;
-    if ($vendor eq 'APC') {
-        $batTemp=GetSNMPkeyValue($snmp_session,$OIDbatteryAdvTemp);
-        } else {
-        if ($vendor eq 'EATON') {
-            $batTemp=GetSNMPkeyValue($snmp_session,'.1.3.6.1.4.1.534.1.6.1.0');
-            } else {
-            $batTemp=GetSNMPkeyValue($snmp_session,$defaultbatteryTemp);
-            }
-        }
+    if ($vendor eq 'APC' or $vendor eq 'Symmetra') { $batTemp=GetSNMPkeyValue($snmp_session,$OIDbatteryAdvTemp); }
+    if ($vendor eq 'EATON') { $batTemp=GetSNMPkeyValue($snmp_session,$EatonBatteryTemp); }
+    if (!$batTemp) { $batTemp=GetSNMPkeyValue($snmp_session,$defaultbatteryTemp); }
+
+    my $outputVoltage;
+    if ($vendor eq 'APC' or $vendor eq 'Symmetra') { $outputVoltage=GetSNMPkeyValue($snmp_session,$apcUpsAdvOutputVoltage); }
+    if (!$outputVoltage) { $outputVoltage = GetSNMPkeyValue($snmp_session,$defaultOutputAC); }
+
+    my $outputCurrent;
+    if ($vendor eq 'APC' or $vendor eq 'Symmetra') { $outputCurrent=GetSNMPkeyValue($snmp_session,$apcUpsAdvOutputCurrent); }
+    if (!$outputCurrent) { $outputCurrent = GetSNMPkeyValue($snmp_session,$defaultOutputCurrent); }
+
+    my $outputHz;
+    if ($vendor eq 'APC' or $vendor eq 'Symmetra') { $outputHz=GetSNMPkeyValue($snmp_session,$apcUpsAdvOutputFrequency); }
+    if (!$outputHz) { $outputHz = GetSNMPkeyValue($snmp_session,$defaultOutputHz); }
+    if ($outputHz and $outputHz>100 ) { $outputHz = int($outputHz/10); }
+
+    my $outputLoad;
+    if ($vendor eq 'APC' or $vendor eq 'Symmetra') { $outputLoad=GetSNMPkeyValue($snmp_session,$apcUpsAdvOutputLoad); }
+    if (!$outputLoad) { $outputLoad = GetSNMPkeyValue($snmp_session,$defaultUpsLoad); }
 
     $ret .= "| Runtime Remaining | ". $runtime." min. |\n";
     $ret .= "| Battery Temperature | ".$batTemp." C |\n";
-    $ret .= "| Output Voltage | ".GetSNMPkeyValue($snmp_session,$defaultOutputAC)." |\n";
-    $ret .= "| Output Frequency | ".$outputHz." Hz |\n";
-    $ret .= "| Output Load | ".GetSNMPkeyValue($snmp_session,$defaultUpsLoad)." % |\n";
+
+    if ($vendor eq 'Symmetra') {
+        my $input1=GetSNMPkeyValue($snmp_session,$apcUpsAdvInputLine1Voltage);
+        my $input2=GetSNMPkeyValue($snmp_session,$apcUpsAdvInputLine2Voltage);
+        my $input3=GetSNMPkeyValue($snmp_session,$apcUpsAdvInputLine3Voltage);
+        $ret .= "| Input Line1 Voltage | ".$input1." V |\n";
+        $ret .= "| Input Line2 Voltage | ".$input2." V |\n";
+        $ret .= "| Input Line3 Voltage | ".$input3." V |\n";
+        }
+
+    if ($vendor ne 'Symmetra') {
+        $ret .= "| Input Voltage | ".$input_voltage." V |\n";
+        $ret .= "| Input Frequency | ".$inputHz." Hz |\n";
+        }
+
+    $ret .= "| Output Voltage | ".$outputVoltage." V |\n";
     $ret .= "| Output Current | ".$outputCurrent."  A |\n";
-    $ret .= "| Input Voltage | ".$input_voltage." V |\n";
-    $ret .= "| Input Frequency | ".$inputHz." Hz |\n";
+    $ret .= "| Output Frequency | ".$outputHz." Hz |\n";
+    $ret .= "| Output Load | ".$outputLoad." % |\n";
+
 
     $snmp_session->close;
 

+ 1 - 1
docs/wiki/update_auth_wiki.pl

@@ -54,7 +54,7 @@ exit;
 sub wanted {
 my $filename = $File::Find::name;
 my $dev_name = basename($filename);
-if ($filename =~/\.txt$/ and $dev_name=~/^(Device|Switch|Router|Gateway|Ups|Sensor)/) {
+if ($filename =~/\.txt$/ and $dev_name=~/^(Device|Switch|Router|Gateway|Ups|Sensor|Server)/) {
     $dev_name=~s/\.txt$//;
     $content{$dev_name}=$filename;
     }

+ 67 - 19
docs/wiki/update_wiki.pl

@@ -34,39 +34,87 @@ my @wiki_dev=();
 my $ip;
 
 foreach my $row (@tmp) {
-if ($row=~/\%META\:FIELD\{name\=\"Description\"/) { next; }
-if ($row=~/\%META\:FIELD\{name\=\"Parent\"/) { next; }
-if ($row=~/\%META\:FIELD\{name\=\"ParentPort\"/) { next; }
 if ($row=~/\%META\:FIELD\{name\=\"DeviceIP\"/) {
     if ($row=~/value\=\"([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\"/) { $ip = $1; }
     }
-if ($row=~/\%META\:FIELD\{name\=\"Mac\"/) { next; }
-push(@wiki_dev,$row);
 }
 
 if (!$ip) { next; }
+
+
 my $auth  = get_record_sql($dbh,"SELECT * FROM User_auth WHERE deleted=0 and ip='".$ip."'");
+
 if (!$auth) { next; }
+if (!$auth->{WikiName}) { next; }
+if ($auth->{WikiName} =~/^Gateway/) { next; }
+
 
-my $dSQL = "SELECT D.ip, D.building_id, D.user_id ,DP.port FROM devices AS D, device_ports AS DP, connections AS C WHERE D.deleted=0 and D.id = DP.device_id AND DP.id = C.port_id AND C.auth_id=".$auth->{id};
-my $device = get_record_sql($dbh,$dSQL);
-if (!$device or !$device->{user_id}) { next; }
-$dSQL = "SELECT * FROM User_auth WHERE WikiName IS NOT NULL AND user_id=".$device->{user_id}." AND deleted=0 AND ip='".$device->{ip}."'";
-my $device_auth = get_record_sql($dbh,$dSQL);
-if (!$device_auth) { next; }
-my $device_name = $device_auth->{WikiName};
-my $device_port = $device->{port};
+my $device;
+my $device_name;
+my $device_port;
 
-if ($auth->{comments}) { push(@wiki_dev,'%META:FIELD{name="Description" title="Description" value="'.$auth->{comments}.'"}%'); }
-push(@wiki_dev,'%META:FIELD{name="Parent" title="Parent" value="'.$device_name.'"}%');
-push(@wiki_dev,'%META:FIELD{name="ParentPort" title="Parent Port" value="'.$device_port.'"}%');
-push(@wiki_dev,'%META:FIELD{name="Mac" title="Mac" value="'.$auth->{mac}.'"}%');
+if ($auth->{WikiName} =~/^(Switch|Router)/) {
+    $device = get_record_sql($dbh,"SELECT * FROM devices WHERE IP='".$ip."'");
+    if ($device->{comment}) { $auth->{comments} = $device->{comment}; }
+    my $parent_connect = get_record_sql($dbh,"SELECT * FROM device_ports DP WHERE DP.uplink=1 AND DP.device_id=".$device->{id});
+    my $parent_port =  get_record_sql($dbh,"SELECT * FROM device_ports DP WHERE id=".$parent_connect->{target_port_id});
+    my $device_parent = get_record_sql($dbh,"SELECT * FROM devices WHERE id=".$parent_port->{device_id});
+    my $auth_parent = get_record_sql($dbh,"SELECT * FROM User_auth WHERE deleted=0 AND ip='".$device_parent->{ip}."'");
+    $device_name = $auth_parent->{WikiName};
+    $device_port = $parent_port->{port};
+    } else {
+    my $dSQL = "SELECT D.ip, D.building_id, D.user_id ,DP.port FROM devices AS D, device_ports AS DP, connections AS C WHERE D.deleted=0 and D.id = DP.device_id AND DP.id = C.port_id AND C.auth_id=".$auth->{id};
+    $device = get_record_sql($dbh,$dSQL);
+    if (!$device or !$device->{user_id}) { next; }
+#       if ($ip eq '192.168.13.104') { print Dumper($device),Dumper(\@tmp); die; }
+    $dSQL = "SELECT * FROM User_auth WHERE WikiName IS NOT NULL AND user_id=".$device->{user_id}." AND deleted=0 AND ip='".$device->{ip}."'";
+    my $device_auth = get_record_sql($dbh,$dSQL);
+    if (!$device_auth) { next; }
+    $device_name = $device_auth->{WikiName};
+    $device_port = $device->{port};
+    }
+
+#add non-existent field
+my %empty_fields;
+$empty_fields{descr}=1;
+$empty_fields{parent}=1;
+$empty_fields{parent_port}=1;
+$empty_fields{mac}=1;
+
+#apply patch
+foreach my $row (@tmp) {
+if ($row=~/\%META\:FIELD\{name\=\"Description\"/) {
+    $empty_fields{descr}=0;
+    if ($auth->{comments}) { push(@wiki_dev,'%META:FIELD{name="Description" title="Description" value="'.$auth->{comments}.'"}%'); next; }
+    }
+if ($row=~/\%META\:FIELD\{name\=\"Parent\"/) {
+    $empty_fields{parent}=0;
+    if ($device_name) { push(@wiki_dev,'%META:FIELD{name="Parent" title="Parent" value="'.$device_name.'"}%'); next; }
+    }
+if ($row=~/\%META\:FIELD\{name\=\"ParentPort\"/) { 
+    $empty_fields{parent_port}=0;
+    if ($device_port) { push(@wiki_dev,'%META:FIELD{name="ParentPort" title="Parent Port" value="'.$device_port.'"}%'); next; }
+    }
+if ($row=~/\%META\:FIELD\{name\=\"Mac\"/) { 
+    $empty_fields{mac}=0;
+    if ($auth->{mac}) { push(@wiki_dev,'%META:FIELD{name="Mac" title="Mac" value="'.$auth->{mac}.'"}%'); next; }
+    }
+push(@wiki_dev,$row);
+}
+
+foreach my $field (keys %empty_fields) {
+next if (!$empty_fields{$field});
+if ($field eq 'descr' and $auth->{comments}) { push(@wiki_dev,'%META:FIELD{name="Description" title="Description" value="'.$auth->{comments}.'"}%'); next; }
+if ($field eq 'parent' and $device_name) { push(@wiki_dev,'%META:FIELD{name="Parent" title="Parent" value="'.$device_name.'"}%'); next; }
+if ($field eq 'parent_port' and $device_port) { push(@wiki_dev,'%META:FIELD{name="ParentPort" title="Parent Port" value="'.$device_port.'"}%'); next; }
+if ($field eq 'mac' and $auth->{mac}) { push(@wiki_dev,'%META:FIELD{name="Mac" title="Mac" value="'.$auth->{mac}.'"}%'); next; }
+}
 
 print "Found: $auth->{ip} $auth->{mac} $device_name $device_port \n";
 
 open (LG,">$content{$fname}") || die("Error open file $content{$fname}!!! die...");
 foreach my $row (@wiki_dev) {
-next if (!$row);
+if (!$row) { $row=''; }
 print LG $row."\n";
 }
 close (LG);
@@ -78,7 +126,7 @@ exit;
 sub wanted {
 my $filename = $File::Find::name;
 my $dev_name = basename($filename);
-if ($filename =~/\.txt$/ and $filename=~/^(Device|Switch|Ups|Sensor)/) {
+if ($dev_name =~/\.txt$/ and $dev_name=~/^(Device|Switch|Ups|Sensor|Gateway|Router|Server)/) {
     $dev_name=~s/\.txt$//;
     $content{$dev_name}=$filename;
     }

+ 2 - 2
html/admin/devices/index.php

@@ -77,9 +77,9 @@ foreach ($switches as $row) {
     print "<tr align=center>\n";
     $cl = "data";
     if (isset($row['nagios_status'])) {
-        if ($row['nagios_status'] == 'DOWN') { $cl = 'shutdown'; }
+        $cl = 'shutdown';
         if ($row['nagios_status'] == 'UP') { $cl = 'up'; }
-    }
+        }
     print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";
     print "<td class=\"$cl\"><input type=hidden name=\"id\" value=".$row['id'].">".$row['id']."</td>\n";
     print "<td class=\"$cl\">".get_devtype_name($db_link,$row['device_type'])."</td>\n";

+ 13 - 1
html/admin/users/editauth.php

@@ -191,7 +191,19 @@ print "<b> Адрес доступа пользователя <a href=/admin/use
 <tr>
 <td width=200><?php print $cell_dns_name." &nbsp | &nbsp "; print_url("Альясы","/admin/users/edit_alias.php?id=$id"); ?></td>
 <td width=200><?php print $cell_comment; ?></td>
-<td width=200><?php print $cell_wikiname; ?></td>
+<td width=200><?php 
+if (!empty($auth_info['WikiName'])) {
+    $wiki_url = rtrim(get_option($db_link, 60),'/');
+    if (preg_match('/127.0.0.1/', $wiki_url)) { print $cell_wikiname; } else {
+        $wiki_web = rtrim(get_option($db_link, 63),'/');
+        $wiki_web = ltrim($wiki_web,'/');
+        $wiki_link = $wiki_url.'/'.$wiki_web.'/'.$auth_info['WikiName'];
+        print_url($cell_wikiname,$wiki_link);
+        }
+    } else {
+    print $cell_wikiname;
+    }
+?></td>
 <td width=70><?php print $cell_enabled; ?></td>
 <td width=70><?php print $cell_blocked; ?></td>
 <td width=70><?php print $cell_perday; ?></td>

+ 1 - 1
html/inc/footer.php

@@ -1,4 +1,4 @@
-<div id="copyright">Copyright &copy; 2008-2021 Stat v2.3<a href="https://github.com/rajven/statV2">rnd@rajven.ru</a></div>
+<div id="copyright">Copyright &copy; 2008-2021 Stat v2.3 &nbsp<a href="https://github.com/rajven/statV2">rnd@rajven.ru</a></div>
 
 <?php
 $end_time = microtime();

+ 1 - 1
html/inc/footer.small.php

@@ -1,4 +1,4 @@
-<div id="copyright">Copyright &copy; 2008-2021 Stat v2.3<a href="https://github.com/rajven/statV2">rnd@rajven.ru</a></div>
+<div id="copyright">Copyright &copy; 2008-2021 Stat v2.3 &nbsp<a href="https://github.com/rajven/statV2">rnd@rajven.ru</a></div>
 <?php
 $end_time = microtime();
 $end_array = explode(" ",$end_time);

+ 1 - 1
scripts/Rstat/mysql.pm

@@ -336,7 +336,7 @@ if ($table eq "User_auth") {
 foreach my $field (keys %$record) {
     if (!defined $record->{$field}) { $record->{$field}=''; }
     if (!defined $old_record->{$field}) { $old_record->{$field}=''; }
-    my $old_value = $old_record->{$field};
+    my $old_value = quotemeta($old_record->{$field});
     my $new_value = $record->{$field};
     $new_value=~s/\'//g;
     $new_value=~s/\"//g;