1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
/*
* hp.c -- scli hp mode implementation
*
* Copyright (C) 2006 Juergen Schoenwaelder
*
* 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, 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.
*
* @(#) $Id: cisco.c 1632 2005-06-28 09:45:21Z strauss $
*/
#include "scli.h"
#include "snmpv2-mib.h"
#include "snmpv2-mib.h"
#include "hp-icf-fault-finder-mib.h"
static void
fmt_hp_fault_finder_log_entry(GString *s,
snmpv2_mib_system_t *system,
hp_icf_fault_finder_mib_hpicfFfLogEntry_t *logEntry)
{
char const *e;
g_string_sprintfa(s, "%d", logEntry->hpicfFfLogIndex);
if (logEntry->hpicfFfLogCreateTime && system && system->sysUpTime) {
guint32 dsecs = *(system->sysUpTime)
- *(logEntry->hpicfFfLogCreateTime);
g_string_sprintfa(s, " %s", fmt_timeticks(dsecs));
} else {
g_string_sprintfa(s, " %5s", "-");
}
if (logEntry->hpicfFfLogPhysEntity) {
g_string_sprintfa(s, " %5d", *logEntry->hpicfFfLogPhysEntity);
} else {
g_string_sprintfa(s, " %5s", "-");
}
e = fmt_enum(hp_icf_fault_finder_mib_enums_HpicfFaultType,
logEntry->hpicfFfLogFaultType);
g_string_sprintfa(s, " %s", e ? e : "");
e = fmt_enum(hp_icf_fault_finder_mib_enums_HpicfFaultAction,
logEntry->hpicfFfLogAction);
g_string_sprintfa(s, " %s", e ? e : "");
e = fmt_enum(hp_icf_fault_finder_mib_enums_hpicfFfLogSeverity,
logEntry->hpicfFfLogSeverity);
g_string_sprintfa(s, " %s", e ? e : "");
e = fmt_enum(hp_icf_fault_finder_mib_enums_hpicfFfLogStatus,
logEntry->hpicfFfLogStatus);
g_string_sprintfa(s, " %s", e ? e : "");
g_string_append(s, "\n");
}
static int
show_hp_fault_finder_log(scli_interp_t *interp, int argc, char **argv)
{
snmpv2_mib_system_t *system = NULL;
hp_icf_fault_finder_mib_hpicfFfLogEntry_t **logTable = NULL;
int i, j, n;
g_return_val_if_fail(interp, SCLI_ERROR);
if (argc > 1) {
return SCLI_SYNTAX_NUMARGS;
}
if (scli_interp_dry(interp)) {
return SCLI_OK;
}
hp_icf_fault_finder_mib_get_hpicfFfLogTable(interp->peer,
&logTable, 0);
if (interp->peer->error_status) {
return SCLI_SNMP;
}
if (logTable) {
snmpv2_mib_get_system(interp->peer, &system, SNMPV2_MIB_SYSUPTIME);
#if 0
g_string_sprintfa(interp->header,
"SOURCE DESTINATION "
" PKTS > BYTS PKTS < BYTS TPKTS TBYTS");
#endif
for (i = 0; logTable[i]; i++) {
fmt_hp_fault_finder_log_entry(interp->result, system, logTable[i]);
}
}
if (logTable)
hp_icf_fault_finder_mib_free_hpicfFfLogTable(logTable);
return SCLI_OK;
}
void
scli_init_hp_mode(scli_interp_t *interp)
{
static scli_cmd_t cmds[] = {
{ "show hp fault log", NULL,
"XXX",
SCLI_CMD_FLAG_NEED_PEER | SCLI_CMD_FLAG_DRY,
NULL, NULL,
show_hp_fault_finder_log },
{ NULL, NULL, NULL, 0, NULL, NULL, NULL }
};
static scli_mode_t hp_mode = {
"hp",
"The hp scli mode is used to display and configure hp\n"
"parameters.",
cmds
};
scli_register_mode(interp, &hp_mode);
}
|