Rename package from http to httpaccess.

This commit is contained in:
Christian P. MOMON 2024-07-13 23:25:21 +02:00
parent cc545c217e
commit 3bc224b779
26 changed files with 84 additions and 67 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2023 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.time.LocalDateTime;
import java.time.ZoneId;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.io.IOException;
import java.util.regex.Matcher;
@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.metrics.IpCounters;
import fr.devinsy.statoolinfos.metrics.PathCounters;
import fr.devinsy.strings.StringList;
/**
* The Class HttpAccessLogProber.
@ -305,9 +306,6 @@ public class HttpAccessLogAnalyzer
this.counters.inc("metrics.http.devices." + device.toString().toLowerCase(), year, yearMonth, yearWeek, date);
// metrics.http.countries.XX =
// metrics.http.errors.* =
// metrics.http.errors.php.* =
}
}
@ -367,13 +365,18 @@ public class HttpAccessLogAnalyzer
HttpAccessLogAnalyzer analyzer = new HttpAccessLogAnalyzer();
for (HttpAccessLog log : logs)
HttpAccessLogIterator logIterator = (HttpAccessLogIterator) logs.iterator();
while (logIterator.hasNext())
{
analyzer.probeLog(log);
analyzer.probeLog(logIterator.next());
}
result = analyzer.getCounters();
StringList timemarks = result.getNowTimeMarks();
analyzer.getCounters().set(logIterator.getLogCount(), "metrics.http.logs.count", timemarks);
analyzer.getCounters().set(logIterator.getIgnoredLogCount(), "metrics.http.logs.ignored", timemarks);
analyzer.getCounters().set(logIterator.getFailedLogCount(), "metrics.http.logs.failed", timemarks);
//
return result;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2022-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.io.IOException;
import java.time.format.DateTimeFormatter;
@ -43,8 +43,9 @@ public class HttpAccessLogIterator implements Iterator<HttpAccessLog>
private DateTimeFormatter dateTimeFormatter;
private Pattern requestFilter;
private HttpAccessLog nextLog;
private int errorCount;
private int ignoredLineCount;
private int logCount;
private int ignoredLogCount;
private int failedLogCount;
/**
* Instantiates a new http access log iterator.
@ -92,8 +93,9 @@ public class HttpAccessLogIterator implements Iterator<HttpAccessLog>
{
this.lineIterator = new FilesLineIterator(source);
this.nextLog = null;
this.errorCount = 0;
this.ignoredLineCount = 0;
this.logCount = 0;
this.ignoredLogCount = 0;
this.failedLogCount = 0;
if (StringUtils.isBlank(linePattern))
{
@ -134,23 +136,33 @@ public class HttpAccessLogIterator implements Iterator<HttpAccessLog>
}
/**
* Gets the error count.
* Gets the failed log count.
*
* @return the error count
* @return the failed log count
*/
public int getErrorCount()
public int getFailedLogCount()
{
return this.errorCount;
return this.failedLogCount;
}
/**
* Gets the ignored line count.
* Gets the ignored log count.
*
* @return the ignored line count
* @return the ignored log count
*/
public int getIgnoredLineCount()
public int getIgnoredLogCount()
{
return this.ignoredLineCount;
return this.ignoredLogCount;
}
/**
* Gets the log count.
*
* @return the log count
*/
public int getLogCount()
{
return this.logCount;
}
/* (non-Javadoc)
@ -206,6 +218,7 @@ public class HttpAccessLogIterator implements Iterator<HttpAccessLog>
if (this.lineIterator.hasNext())
{
String line = this.lineIterator.next();
this.logCount += 1;
try
{
@ -213,7 +226,7 @@ public class HttpAccessLogIterator implements Iterator<HttpAccessLog>
if (log == null)
{
logger.warn("LINE IS NOT MATCHING [{}]", line);
this.errorCount += 1;
this.failedLogCount += 1;
}
else if ((this.requestFilter == null) || (this.requestFilter.matcher(log.getRequest()).matches()))
{
@ -222,13 +235,14 @@ public class HttpAccessLogIterator implements Iterator<HttpAccessLog>
}
else
{
this.ignoredLineCount += 1;
this.ignoredLogCount += 1;
// System.out.println("XX " + log.getRequest());
}
}
catch (Exception exception)
{
logger.warn("Error parsing line [{}][{}]", line, exception.getMessage());
this.failedLogCount += 1;
// exception.printStackTrace();
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2022-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.io.File;
import java.io.IOException;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2022-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
/**
* The Class HttpMethod.

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
/**
* The Enum HttpStatusCategory.

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.util.HashMap;
import java.util.regex.Pattern;
@ -29,15 +29,15 @@ import org.slf4j.LoggerFactory;
*/
public class HttpStatusTable
{
private static Logger logger = LoggerFactory.getLogger(HttpStatusTable.class);
public static final Pattern HTTP_CODE_PATTERN = Pattern.compile("\\d{3}");
private static class SingletonHolder
{
private static final HttpStatusTable instance = new HttpStatusTable();
}
private static Logger logger = LoggerFactory.getLogger(HttpStatusTable.class);
public static final Pattern HTTP_CODE_PATTERN = Pattern.compile("\\d{3}");
private HashMap<Integer, HttpStatus> codes;
/**

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.io.IOException;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
/**
* The Enum UserAgentBrowser.

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
/**
* The Enum UserAgentDevice.

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
/**
* The Enum UserAgentOS.

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
/**
* The Enum UserAgentType.

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.time.Duration;
import java.time.LocalDate;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.time.LocalDate;
import java.time.YearMonth;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.util.HashMap;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.metrics.http;
package fr.devinsy.statoolinfos.metrics.httpaccess;
import java.time.Duration;
import java.time.LocalDate;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2024 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -27,8 +27,8 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.metrics.PathCounters;
import fr.devinsy.statoolinfos.metrics.UserCounters;
import fr.devinsy.statoolinfos.metrics.http.HttpAccessLog;
import fr.devinsy.statoolinfos.metrics.http.HttpAccessLogIterator;
import fr.devinsy.statoolinfos.metrics.httpaccess.HttpAccessLog;
import fr.devinsy.statoolinfos.metrics.httpaccess.HttpAccessLogIterator;
import fr.devinsy.statoolinfos.util.Files;
/**