summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-09-07 17:40:44 +0200
committerZdenek Prikryl <zprikryl@redhat.com>2009-09-07 17:40:44 +0200
commit58d9dfde6ce788c5ffdfe5160d19aaeb8ac7b3a2 (patch)
tree127415f41f4461d5cf1af8ef2232a5b5c04402e4 /lib
parentcaef0b615fc0cc11de65fae634bd9674b0c634d2 (diff)
downloadabrt-58d9dfde6ce788c5ffdfe5160d19aaeb8ac7b3a2.tar.gz
abrt-58d9dfde6ce788c5ffdfe5160d19aaeb8ac7b3a2.tar.xz
abrt-58d9dfde6ce788c5ffdfe5160d19aaeb8ac7b3a2.zip
Some simple changes to SOSreport plugin. (gavin@redhat.com)
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/SOSreport.cpp60
-rw-r--r--lib/Plugins/SOSreport.h5
2 files changed, 60 insertions, 5 deletions
diff --git a/lib/Plugins/SOSreport.cpp b/lib/Plugins/SOSreport.cpp
index 4d22028f..c92b4fee 100644
--- a/lib/Plugins/SOSreport.cpp
+++ b/lib/Plugins/SOSreport.cpp
@@ -31,7 +31,6 @@
#include "ABRTException.h"
#include "CommLayerInner.h"
-
void CActionSOSreport::CopyFile(const std::string& pSourceName, const std::string& pDestName)
{
std::ifstream source(pSourceName.c_str(), std::fstream::binary);
@@ -84,14 +83,61 @@ std::string CActionSOSreport::ParseFilename(const std::string& pOutput)
return pOutput.substr(filename_start,(filename_end-filename_start)+1);
}
+void CActionSOSreport::ParseArgs(const std::string& psArgs, vector_args_t& pArgs)
+{
+ unsigned int ii;
+ bool is_quote = false;
+ std::string item = "";
+ for (ii = 0; ii < psArgs.length(); ii++)
+ {
+ if (psArgs[ii] == '\"')
+ {
+ is_quote = is_quote == true ? false : true;
+ }
+ else if (psArgs[ii] == ',' && !is_quote)
+ {
+ pArgs.push_back(item);
+ item = "";
+ }
+ else
+ {
+ item += psArgs[ii];
+ }
+ }
+ if (item != "")
+ {
+ pArgs.push_back(item);
+ }
+}
+
void CActionSOSreport::Run(const std::string& pActionDir,
const std::string& pArgs)
{
- update_client(_("Executing SOSreportAction plugin..."));
+ update_client(_("Executing SOSreport plugin..."));
- const char command[] = "sosreport --batch --no-progressbar -k rpm.rpmva=off 2>&1";
+ const char command_default[] = "sosreport --batch --no-progressbar --only=anaconda --only=bootloader"
+ " --only=devicemapper --only=filesys --only=hardware --only=kernel"
+ " --only=libraries --only=memory --only=networking --only=nfsserver"
+ " --only=pam --only=process --only=rpm -k rpm.rpmva=off --only=ssh"
+ " --only=startup --only=yum 2>&1";
+ const char command_prefix[] = "sosreport --batch --no-progressbar";
+ std::string command;
+
+ vector_args_t args;
+ ParseArgs(pArgs, args);
+
+ if (args.size() == 0 || args[0] == "")
+ {
+ command = std::string(command_default);
+ }
+ else
+ {
+ command = std::string(command_prefix) + ' ' + args[0] + " 2>&1";
+ }
+
+ update_client(_("running sosreport: ") + command);
+ FILE *fp = popen(command.c_str(), "r");
- FILE *fp = popen(command, "r");
if (fp == NULL)
{
throw CABRTException(EXCEP_PLUGIN, std::string("CActionSOSreport::Run(): cannot execute ") + command);
@@ -100,17 +146,21 @@ void CActionSOSreport::Run(const std::string& pActionDir,
std::ostringstream output_stream;
__gnu_cxx::stdio_filebuf<char> command_output_buffer(fp, std::ios_base::in);
- output_stream << std::string(command) << std::endl;
+ output_stream << command << std::endl;
output_stream << &command_output_buffer;
pclose(fp);
+ update_client(_("done running sosreport"));
std::string output = output_stream.str();
+
std::string sosreport_filename = ParseFilename(output);
std::string sosreport_dd_filename = pActionDir + "/sosreport.tar.bz2";
CDebugDump dd;
dd.Open(pActionDir);
+ //Not usefull
+ //dd.SaveText("sosreportoutput", output);
CopyFile(sosreport_filename,sosreport_dd_filename);
dd.Close();
}
diff --git a/lib/Plugins/SOSreport.h b/lib/Plugins/SOSreport.h
index 2b2c99a3..1a352876 100644
--- a/lib/Plugins/SOSreport.h
+++ b/lib/Plugins/SOSreport.h
@@ -22,6 +22,8 @@
#define SOSREPORT_H_
#include "Action.h"
+#include <string>
+#include <vector>
class CActionSOSreport : public CAction
{
@@ -32,6 +34,9 @@ class CActionSOSreport : public CAction
void ErrorCheck(const index_type pI);
std::string ParseFilename(const std::string& pOutput);
+ typedef std::vector<std::string> vector_args_t;
+ void ParseArgs(const std::string& psArgs, vector_args_t& pArgs);
+
public:
virtual void Run(const std::string& pActionDir,
const std::string& pArgs);