SUS Reports is a collection of PHP scripts which contain a logfile parser for MicroSoft Software Update Services (SUS) and a couple of reports. For example one report contains patches downloaded/installed by which pc and when. Data will be stored in a MySql Database.
<?php
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
set_time_limit(0);
$startTotalTimer = mktime();
$startTimer = $startTotalTimer;
if (isset($HTTP_SERVER_VARS["REMOTE_ADDR"])) {
if ($HTTP_SERVER_VARS["REMOTE_ADDR"] || $_SERVER["REMOTE_ADDR"] || $REMOTE_ADDR) { die ("This file can only be executed locally.<br />\n"); }
}
# read config file
if (!$cfg = @file("config.php")) { die ("Config file missing.\n"); }
$n = 0;
$lines = count($cfg);
while($n < $lines) {
# list($ln, $junk) = preg_split("/##/", $cfg[$n], 2);
$parts = preg_split("/##/", $cfg[$n], 2);
$ln = $parts[0];
if (preg_match("/=/", $ln)) {
list($name, $value) = preg_split("/=/", $ln, 2);
$conf[trim($name)] = trim($value);
}
$n++;
}
include_once("library.inc");
# default connect
ConnectDB($conf["SQL_Server"],
$conf["SQL_User"],
$conf["SQL_Password"],
$conf["SQL_Database"],
$conf["SQL_Type"]);
# version 0.30
# change column name from File into Filename
if ($conf["SQL_Type"] == "mysql") {
# only for mysql installations needed.
# mssql script alrady has this
$result = SqlSelectQuery("DESC Last_log_file", __FILE__, __LINE__);
$number = SqlNumRows($result);
$n = 0;
while ($n < $number) {
if (SqlGetRow($result, $n, "Field") == "File") {
print " Altering table Last_log_file\n";
SqlQuery("alter table Last_log_file change File Filename Varchar(30)", __FILE__, __LINE__);
$n = $number;
}
$n++;
}
}
# version 0.31
# Add new table SUS_Error
$result = SqlSelectQuery("SHOW TABLES like 'SUS_Errors'", __FILE__, __LINE__);
$number = SqlNumRows($result);
if ($number == 0) {
print " Creating SUS Error table.\n";
SqlQuery("CREATE TABLE SUS_Errors (
Error varchar(10) NOT NULL default '',
Description text,
Details text,
INDEX (Error))", __FILE__, __LINE__);
print " Inserting error codes into table.\n";
SqlQuery("INSERT INTO SUS_Errors (`Error`, `Description`, `Details`) VALUES
('0x0', 'Success', ''),
('0x3', 'iuctl.dll and iuengine.dll are not the correct version', 'iuctl.dll.dll and iuengine.dll are not the correct version and are unable to be updated.'),
('0x1', 'iuctl.dll is not the correct version', 'iuctl.dll is not the correct version and is unable to be updated.'),
('80000007', 'Operation aborted', ''),
('80004004', 'E_ABORT', 'Operation aborted error'),
('80004005', 'E_Fail', 'General error or Unknown Error')", __FILE__, __LINE__);
SqlQuery("INSERT INTO SUS_Errors (`Error`, `Description`, `Details`) VALUES
('80070001', 'An error occurred during transmission: A network connection with the remote server could not be established.', ''),
('80070002', 'INSTALL_FAILURE', 'Error_File_Not_Found: The system cannot find the file Specified.'),
('80070003', 'The system cannot find the path specified. ', 'Windows Update folder does not exist or the V4 folder within Windows Update is missing. (The correct code path is something like this: %Program Files%WindowsUpdateV4)'),
('80070004', 'The set of folders could not be opened. You do not have sufficient privileges to access the file. Personal Folders', ''),
('80070005', 'ERROR_ACCESS_DENIED', 'Access is denied. The authentication method is not supported.'),
('80070006', 'E_Handle', 'Handle not valid error'),
('80070008', 'ERROR_NOT_ENOUGH_MEMORY', 'The system is out of memory.'),
('8007000b', 'FALSE_ERROR', 'attempts to make a request to the SUS Servers website for the default webpage, please ignore'),
('8007000d', 'The Data is invalid. Cannot open', ''),
('80070015', 'Cannot open please verify the path and file are correct or The_device_is_not_ready', ''),
('80070017', 'Data error (cyclic redundancy check).', 'Data error (cyclic redundancy check).'),
('8007001e', 'AN ERROR OCCURED CALLING DLLREGISTER SERVER', ''),
('80070020', 'The process cannot access the file because it is being used by another process', ''),
('80070052', 'Unpack Error', 'Unpack error due to: Low Disk Space, Access Permissions or an Exchange 2000 IFS Drive'),
('80070057', 'E_INVALIDARG', 'One or more arguments are not valid error.'),
('80070070', 'Method \'~\' of object \'~\' failed Not enough Hard Drive Space', ''),
('8007007e', 'The specified module could not be found', ''),
('80070080', 'ERROR_WAIT_NO_CHILDREN', 'There are no child processes to wait for.'),
('800700c1', 'is not a valid Win32 application', 'not a valid Win32 application.'),
('800700e7', 'ERROR_PIPE_BUSY', '')", __FILE__, __LINE__);
SqlQuery("INSERT INTO SUS_Errors (`Error`, `Description`, `Details`) VALUES
('800700ff', 'ERROR_EA_LIST_INCONSISTENT', 'The extended attributes are inconsistent.'),
('80070103', 'Error_No_More_Items:', 'Windows has determined that the selected driver is not the best driver for your machine.'),
('80070190', 'HTTP_STATUS_BAD_REQUEST (400)', '400 invalid syntax. The request could not be processed by the server due to invalid syntax.'),
('80070193', 'HTTP_STATUS_FORBIDDEN (403)', '403 Server is too busy to process request. The server understood the request, but is refusing to fulfill it.'),
('80070194', 'HTTP_STATUS_NOT_FOUND (404)', '404 Cabs or page is not found. The server has not found anything matching the requested URI (Uniform Resource Identifier).'),
('80070197', 'HTTP_STATUS_PROXY_AUTH_REQ (407)', '407 error (proxy authentication required) - need specific password/user to access. Proxy authentication required.'),
('80070198', 'HTTP_STATUS_REQUEST_TIMEOUT (408)', 'The server timed out waiting for the request.'),
('8007019b', 'HTTP_STATUS_LENGTH_REQUIRED (411)', 'This is a known issue. Possibly relating to proxy servers that don\'t support http1.1. The server refuses to accept the request without a defined content length.'),
('800701a9', 'ERROR_INVALID_FUNCTION', ''),
('800701f4', 'HTTP_STATUS_SERVER_ERROR (500)', 'The server encountered an unexpected condition that prevented it from fulfilling the request.'),
('800701f6', 'Proxy was unable to forward the request to the destination server', ''),
('800701f7', 'HTTP_STATUS_SERVICE_UNAVAIL (503)', '503 Server is to busy to process request. The service is temporarily overloaded.'),
('800701f8', 'HTTP_STATUS_GATEWAY_TIMEOUT (504)', ' 504 timed out waiting for gateway. The request was timed out waiting for a gateway.'),
('800703e3', 'ERROR_OPERATION_ABORTED', 'The I/O operation has been aborted because of either a thread exit or an application request.'),
('800703e5', 'ERROR_IO_PENDING', ''),
('800703e6', 'Invalid access to memory location', ''),
('800703f5', 'ERROR_CANTWIRTE', 'The configuration registry key could not be written.'),
('800703fb', 'ERROR_NO_LOG_SPACE', 'System could not allocate the required space in a registry log.'),
('800703fd', 'Cannot create a stable subkey under a volatile parent key.', 'Cannot create a stable subkey under a volatile parent key.')", __FILE__, __LINE__);
SqlQuery("INSERT INTO SUS_Errors (`Error`, `Description`, `Details`) VALUES
('8007041f', 'The service database is locked', ''),
('80070426', 'The service has not been started', ''),
('8007042b', 'ERROR_PROCESS_ABORTED', 'The process terminated unexpectedly.'),
('80070430', 'The specified service has been marked for deletion', ''),
('8007045a', 'ERROR_DLL_INIT_FAILED', ''),
('8007045d', 'ERROR_IO_DEVICE', 'The request could not be performed because of an I/O device error.'),
('8007048f', 'The device is not connected.', ''),
('80070490', 'Permission denied / [Problem initializing or using session variables] or Element not found', ''),
('800704c7', 'Cancelled by user', ''),
('8007051b', 'ERROR_INVALID_OWNER', 'This security ID may not be assigned as the owner of this object.'),
('80070570', 'Cannot open file', ''),
('800705aa', 'Error loading resources', ''),
('800705af', 'The paging file is too small for this operation to complete', ''),
('80070643', 'Fatal error during installation', ''),
('80070714', 'Version unavailable or Invalid', 'The specified image file did not contain a resource section.'),
('80070715', 'ERROR_RESOURCE_TYPE_NOT_FOUND', 'The specified resource type cannot be found in the image file.')", __FILE__, __LINE__);
SqlQuery("INSERT INTO SUS_Errors (`Error`, `Description`, `Details`) VALUES
('80072733', 'DLOAD_FAILURE', 'A non-blocking socket operation could not be completed immediately.'),
('800727E7', 'DLOAD_FAILURE', 'The requested lookup key was not found in any active activation context.'),
('80072ee2', 'ERROR_INTERNET_TIMEOUT', 'The request has timed out. The connection to this Internet site took longer than the allotted time.'),
('80072ee4', 'ERROR_INTERNET_INTERNAL_ERROR', 'An internal error has occurred.'),
('80072ee7', 'ERROR_INTERNET_NAME_NOT_RESOLVED', 'The server name could not be resolved. DNS Error. Please try a different root DNS (Like UUNET)'),
('80072efd', 'ERROR_INTERNET_CANNOT_CONNECT ', 'Cannot connect to the Internet server'),
('80072efe', 'ERROR_INTERNET_CONNECTION_ABORTED', 'The connection with the server has been terminated.'),
('80072eff', 'ERROR_INTERNET_CONNECTION_RESET', 'The connection with the server has been reset.'),
('80072f76', 'ERROR_HTTP_HEADER_NOT_FOUND', 'The requested http header could not be located'),
('80072f78', 'ERROR_HTTP_INVALID_SERVER_RESPONSE', 'The server response could not be parsed.'),
('80072f7c', 'ERROR_HTTP_REDIRECT_FAILED', '')", __FILE__, __LINE__);
SqlQuery("INSERT INTO SUS_Errors (`Error`, `Description`, `Details`) VALUES
('800a0005', 'Microsoft VBScript runtime error Invalid procedure call or argument: \'fs.OpenTextFile\'', ''),
('800a01b6', 'Microsoft VBScript runtime error Object doesn\'t support this property or method:', ''),
('800a1391', 'Microsoft Jscript runtime \'Recordset1\' is undefined', 'Jscript error undefined identifier'),
('800b0003', 'TRUST_E_SUBJECT_FORM_UNKNOWN', ''),
('800b0004', 'Trust_E_Subject_Not_Trusted', ' The subject is not trusted for the specified action.'),
('800b0100', 'TRUST_E_NOSIGNATURE', ''),
('800c0002', 'http can not find the file specified', 'http can not find the file specified'),
('800c0008', 'Cannot download the information you requested.', ''),
('80190191', 'HTTP 401', 'Translates in a HTTP 401 error'),
('80190192', 'HTTP 402', 'Translates in a HTTP 402 error'),
('80190193', 'HTTP 403', 'is produced when the SUS Servers IIS website has no default webpage'),
('80190194', 'HTTP 404', 'Translates in a HTTP 404 error'),
('801901F4', 'Invalid interface string', 'Invalid interface string')", __FILE__, __LINE__);
SqlQuery("INSERT INTO SUS_Errors (`Error`, `Description`, `Details`) VALUES
('c0000005', 'STATUS_ACCESS_VIOLATION', ''),
('c0000006', 'STATUS_IN_PAGE_ERROR', ''),
('c000001d', 'STATUS_ILLEGAL_INSTRUCTION', ''),
('c000013a', 'STATUS_CONTROL_C_EXIT', ''),
('c0000142', 'STATUS_DLL_INIT_FAILED', ''),
('e0000101', 'ERROR_SECTION_NOT_FOUND', ''),
('e000020b', 'ERROR_NO_SUCH_DEVINST', ''),
('e000020d', 'ERROR_INVALID_CLASS_INSTALLER', ''),
('e0000219', 'ERROR_NO_ASSOCIATED_SERVICE', ''),
('e000022b', 'ERROR_DI_DONT_INSTALL', ''),
('e0000234', 'ERROR_DRIVER_NONNATIVE', ''),
('fffffb4a', 'JET_errDatabaseCorrupted', ''),
('fffffbf8', 'JET_errFileAccessDenied', ''),
('fffffc0d', 'JET_errOutOfMemory', ''),
('ffffff99', 'JET_errOutOfThreads', ''),
('ffffffff', 'Cancel', 'The user canceled the transaction')", __FILE__, __LINE__);
}
$endTotalTimer = mktime();
$runTime = date("i:s", ($endTotalTimer - $startTotalTimer));
print "\n\nScript runtime: " . $runTime . ".\n\n";
?>
&nbsp;