Skip to content

Commit

Permalink
Quick : add json format for openseachest_SMART utility.
Browse files Browse the repository at this point in the history
  • Loading branch information
sharma-nidhi committed Dec 23, 2024
1 parent 4f00aa9 commit 2b44112
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 134 deletions.
1 change: 1 addition & 0 deletions Make/VS.2017/OpenSeaChest.sln
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenSeaChest_SMART", "OpenSeaChest_SMART\OpenSeaChest_SMART.vcxproj", "{1C6E7DEA-F554-46BA-85F8-CDEA738CD1B1}"
ProjectSection(ProjectDependencies) = postProject
{7DAC7F63-E808-47FD-BEEB-33E4A870008B} = {7DAC7F63-E808-47FD-BEEB-33E4A870008B}
{A319438D-D2E5-4CA2-91C4-12769AA9A2EB} = {A319438D-D2E5-4CA2-91C4-12769AA9A2EB}
{A0771494-8717-48AB-A0E5-49191252FF2C} = {A0771494-8717-48AB-A0E5-49191252FF2C}
{621B44CE-B314-4E05-B214-5DC70F2B4798} = {621B44CE-B314-4E05-B214-5DC70F2B4798}
{FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF} = {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}
Expand Down
128 changes: 64 additions & 64 deletions Make/VS.2017/OpenSeaChest_SMART/OpenSeaChest_SMART.vcxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Make/VS.2019/OpenSeaChest.sln
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenSeaChest_SMART", "OpenSeaChest_SMART\OpenSeaChest_SMART.vcxproj", "{1C6E7DEA-F554-46BA-85F8-CDEA738CD1B1}"
ProjectSection(ProjectDependencies) = postProject
{7DAC7F63-E808-47FD-BEEB-33E4A870008B} = {7DAC7F63-E808-47FD-BEEB-33E4A870008B}
{A319438D-D2E5-4CA2-91C4-12769AA9A2EB} = {A319438D-D2E5-4CA2-91C4-12769AA9A2EB}
{A0771494-8717-48AB-A0E5-49191252FF2C} = {A0771494-8717-48AB-A0E5-49191252FF2C}
{621B44CE-B314-4E05-B214-5DC70F2B4798} = {621B44CE-B314-4E05-B214-5DC70F2B4798}
{FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF} = {FBCBA2F1-3BF8-4A25-B815-E228E1AEDCFF}
Expand Down
128 changes: 64 additions & 64 deletions Make/VS.2019/OpenSeaChest_SMART/OpenSeaChest_SMART.vcxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Make/gcc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ seajsonformat:
$(MAKE) $(MAKEFLAG) -C ../../subprojects/opensea-jsonformat/Make/gcc

$(SMARTOUTFILE): $(SMARTOBJS)
$(CC) $(SMARTOBJS) $(LFLAGS) -o $(FILE_OUTPUT_DIR)/$(SMARTOUTFILE)
$(CC) $(SMARTOBJS) $(LIBJSONFORMATLFLAGS) $(LFLAGS) -o $(FILE_OUTPUT_DIR)/$(SMARTOUTFILE)
# $(STRIP) $(STRIPOPTS) $(FILE_OUTPUT_DIR)/$(SMARTOUTFILE)

$(GENERICTESTSOUTFILE) : $(GENERICTESTSOBJS)
Expand Down
2 changes: 1 addition & 1 deletion utils/C/openSeaChest/openSeaChest_Info.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// Global Variables //
////////////////////////
const char *util_name = "openSeaChest_Info";
const char *buildVersion = "2.7.0";
const char *buildVersion = "2.7.1";

////////////////////////////
// functions to declare //
Expand Down
67 changes: 63 additions & 4 deletions utils/C/openSeaChest/openSeaChest_SMART.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
#include "seagate_operations.h"
#include "defect.h"
#include "device_statistics.h"
#include "device_statistics_json.h"

////////////////////////
// Global Variables //
////////////////////////
const char *util_name = "openSeaChest_SMART";
const char *buildVersion = "2.5.1";
const char *buildVersion = "2.5.2";

////////////////////////////
// functions to declare //
Expand Down Expand Up @@ -122,6 +124,7 @@ int main(int argc, char *argv[])
NVME_HEALTH_VAR
LOWLEVEL_INFO_VAR
SMART_OFFLINE_SCAN_VAR
OUTPUT_MODE_VAR

int args = 0;
int argIndex = 0;
Expand Down Expand Up @@ -185,6 +188,7 @@ int main(int argc, char *argv[])
DEVICE_STATISTICS_LONG_OPT,
NVME_HEALTH_LONG_OPT,
SMART_OFFLINE_SCAN_LONG_OPT,
OUTPUT_MODE_LONG_OPT,
LONG_OPT_TERMINATOR
};

Expand Down Expand Up @@ -237,6 +241,18 @@ int main(int argc, char *argv[])
exit(UTIL_EXIT_ERROR_IN_COMMAND_LINE);
}
}
else if (strcmp(longopts[optionIndex].name, OUTPUT_MODE_LONG_OPT_STRING) == 0)
{
if (strcmp(optarg, "json") == 0)
{
OUTPUT_MODE_IDENTIFIER = UTIL_OUTPUT_MODE_JSON;
}
else
{
print_Error_In_Cmd_Line_Args(OUTPUT_MODE_LONG_OPT_STRING, optarg);
exit(UTIL_EXIT_ERROR_IN_COMMAND_LINE);
}
}
else if (strcmp(longopts[optionIndex].name, IDD_TEST_LONG_OPT_STRING) == 0)
{
RUN_IDD_FLAG = true;
Expand Down Expand Up @@ -878,7 +894,7 @@ int main(int argc, char *argv[])

if (RUN_ON_ALL_DRIVES && !USER_PROVIDED_HANDLE)
{

for (uint32_t devi = 0; devi < DEVICE_LIST_COUNT; ++devi)
{
DEVICE_LIST[devi].deviceVerbosity = toolVerbosity;
Expand Down Expand Up @@ -2057,8 +2073,50 @@ int main(int argc, char *argv[])
switch (get_DeviceStatistics(&deviceList[deviceIter], &deviceStats))
{
case SUCCESS:
print_DeviceStatistics(&deviceList[deviceIter], &deviceStats);
break;
{
if (OUTPUT_MODE_IDENTIFIER == UTIL_OUTPUT_MODE_HUMAN)
{
print_DeviceStatistics(&deviceList[deviceIter], &deviceStats);
}

//if supported then print Seagate Device Statistics also
bool seagateDeviceStatisticsAvailable = false;
seagateDeviceStatistics seagateDeviceStats;
memset(&seagateDeviceStats, 0, sizeof(seagateDeviceStatistics));
if (is_Seagate_DeviceStatistics_Supported(&deviceList[deviceIter]))
{
if (SUCCESS == get_Seagate_DeviceStatistics(&deviceList[deviceIter], &seagateDeviceStats))
{
seagateDeviceStatisticsAvailable = true;
if (OUTPUT_MODE_IDENTIFIER == UTIL_OUTPUT_MODE_HUMAN)
{
print_Seagate_DeviceStatistics(&deviceList[deviceIter], &seagateDeviceStats);
}
}
}

if (OUTPUT_MODE_IDENTIFIER == UTIL_OUTPUT_MODE_JSON)
{
char* jsonFormatOutput = M_NULLPTR;
ret = create_JSON_File_For_Device_Statistics(&deviceList[deviceIter], &deviceStats, &seagateDeviceStats, seagateDeviceStatisticsAvailable, &jsonFormatOutput);
if (ret != SUCCESS)
{
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("A failure occured while trying to create JSON format for Device Statistics\n");
}
exitCode = UTIL_EXIT_OPERATION_FAILURE;
}
else
{
//write the data on console
printf("%s\n\n", jsonFormatOutput);
}

safe_free(&jsonFormatOutput);
}
}
break;
case NOT_SUPPORTED:
if (VERBOSITY_QUIET < toolVerbosity)
{
Expand Down Expand Up @@ -2237,6 +2295,7 @@ void utility_Usage(bool shortUsage)
print_Device_Statistics_Help(shortUsage);
print_Error_Limit_Help(shortUsage);
print_IDD_Help(shortUsage);
print_Output_Mode_Help(shortUsage);
print_Long_DST_Help(shortUsage, commandWindowType);
print_Short_DST_Help(shortUsage);
print_Show_DST_Log_Help(shortUsage);
Expand Down

0 comments on commit 2b44112

Please sign in to comment.