Skip to content

Commit

Permalink
Merge pull request #93 from intrajp/dev
Browse files Browse the repository at this point in the history
Fix to skip file which is over the size 50 Mbytes.
  • Loading branch information
intrajp authored Mar 30, 2019
2 parents 940bd4f + f312dfa commit b766741
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ install-sosreport_analyzer_data:
$(INSTALL) -m 644 $(srcdir)/sosreport-analyzer-mcinfo.conf.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer-mcinfo.conf.example; \
$(INSTALL) -m 644 $(srcdir)/conf/sosreport-analyzer.conf.CentOS7.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer.conf.CentOS7.example; \
$(INSTALL) -m 644 $(srcdir)/conf/sosreport-analyzer.conf.CentOS6.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer.conf.CentOS6.example; \
$(INSTALL) -m 644 $(srcdir)/conf/sosreport-analyzer-mcinfo.conf.AXS6.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer-mcinfo.conf.AXS6.example; \
$(INSTALL) -m 644 $(srcdir)/conf/sosreport-analyzer-mcinfo.conf.AXS4.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer-mcinfo.conf.AXS4.example; \
else \
$(MKDIR_P) $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH); \
$(INSTALL) -m 644 $(srcdir)/sosreport-analyzer.conf.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer.conf.example; \
$(INSTALL) -m 644 $(srcdir)/sosreport-analyzer-mcinfo.conf.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer-mcinfo.conf.example; \
$(INSTALL) -m 644 $(srcdir)/conf/sosreport-analyzer.conf.CentOS7.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer.conf.CentOS7.example; \
$(INSTALL) -m 644 $(srcdir)/conf/sosreport-analyzer.conf.CentOS6.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer.conf.CentOS6.example; \
$(INSTALL) -m 644 $(srcdir)/conf/sosreport-analyzer-mcinfo.conf.AXS6.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer-mcinfo.conf.AXS6.example; \
$(INSTALL) -m 644 $(srcdir)/conf/sosreport-analyzer-mcinfo.conf.AXS4.example $(DESTDIR)$(SOSREPORT_ANALYZER_DATA_PATH)/sosreport-analyzer-mcinfo.conf.AXS4.example; \
fi

uninstall-sosreport_analyzer_data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# If you have installed this program before, new version will not override.
#
# Please check /usr/share/sosreport-analyzer/sosreport-analyzer-mcinfo.conf.AXS6.example, and
# Please check /usr/share/sosreport-analyzer/sosreport-analyzer-mcinfo.conf.AXS4.example, and
# copy it as /etc/sosreport-analyzer-mcinfo.conf.
#
#
Expand Down
2 changes: 1 addition & 1 deletion conf/sosreport-analyzer.conf.CentOS6.example
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ ps=all
## You can set arbitrary item-name including 'all' up to 12
## ex. lsof=bash

lsof=all
lsof=bash

## netstat
##
Expand Down
2 changes: 1 addition & 1 deletion conf/sosreport-analyzer.conf.CentOS7.example
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ ps=all
## You can set arbitrary item-name including 'all' up to 12
## ex. lsof=bash

lsof=all
lsof=bash

## netstat
##
Expand Down
22 changes: 21 additions & 1 deletion libsosreport-analyzer/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,13 @@ int read_analyze_dir ( const char *member, const char *dname, int recursive )

if ( dname_full != NULL )
{
/* if open directory fails, exit with error message */
/* if open directory fails, exit with error message,
* and print that the member should be set to 'skip'.
*/
if ( ( dir = opendir ( dname_full ) ) == NULL )
{
printf("can't open directory (%s): %s\n",dname_full,strerror(errno));
printf("You should set 'skip' to %s in conf file.\n",member);
if ( strcmp ( member, "var/crash/" ) == 0 )
{
var_crash_exists = 0;
Expand All @@ -772,7 +775,9 @@ int read_analyze_dir ( const char *member, const char *dname, int recursive )
for ( dp = readdir ( dir ),i = 0; dp != NULL; dp = readdir ( dir ) )
{
char full_path_plus_str [ MAX_LINE_LENGTH ];
char filename [ MAX_LINE_LENGTH ];
memset ( full_path_plus_str, '\0', sizeof ( full_path_plus_str ) );
memset ( filename, '\0', sizeof ( filename ) );

if ( ( dp->d_type != DT_REG ) && ( dp->d_type != DT_DIR ) )
continue;
Expand All @@ -786,8 +791,23 @@ int read_analyze_dir ( const char *member, const char *dname, int recursive )
* others have big one, compressed or selinux modules.
* in proc/ there are some files which have only write permissions and couldn't be read.
* file sos_commands/networking/ethtool_-d* is sometimes too big.
*
* we should check file with a function and if the file is too big, skip it.
* Now, if file size is over 50Mbytes, skip the file.
*/
snprintf (filename, MAX_LINE_LENGTH, "%s%s", dname_full, str );
struct stat st;
stat(filename, &st);
int size = 0;
size = st.st_size;

if ( size > 51200000 )
{
printf("Skipping %s (size:%d)\n",filename,size);
continue;
}
if ( ( strcmp ( str, "." ) == 0 ) || ( strcmp ( str, ".." ) == 0 ) ||
( ( strcmp ( member, "cmdlog/" ) == 0 ) && ( strstr ( str, "verbose" ) != NULL ) ) ||
( ( strcmp ( member, "etc/" ) == 0 ) && ( ( strstr ( str, "cil" ) != NULL ) || ( strstr ( str, "hll" ) != NULL ) ) ) ||
( ( strcmp ( member, "etc/" ) == 0 ) && ( ( strstr ( str, ".bin" ) != NULL ) || ( strstr ( str, ".kern" ) != NULL ) ) ) ||
( ( strcmp ( member, "etc/" ) == 0 ) && ( ( strstr ( str, ".db" ) != NULL ) || ( strstr ( str, "policy." ) != NULL ) ) ) ||
Expand Down
2 changes: 1 addition & 1 deletion sosreport-analyzer-mcinfo.conf.example

0 comments on commit b766741

Please sign in to comment.