Alexander Bergmann
b2dc2d3287
- Decouple snmp-mibs from net-snmp version to allow major version upgrade (bsc#1196955). - Fix LFH violation during v3 user creation (bsc#1181591). Add net-snmp-5.9.1-fix-create-v3-user-outfile.patch - Fix subagent crash at save_set_var() (bsc#1178021). Add net-snmp-5.9.1-subagent-set-response.patch - Fix missing sysconfig files creation (bsc#1108471). - Rename patches to version number 5.9.1: delete: * net-snmp-5.8-socket-path.patch * net-snmp-5.8-testing-empty-arptable.patch * net-snmp-5.8-pie.patch * net-snmp-5.8-net-snmp-config-headercheck.patch * net-snmp-5.8-perl-tk-warning.patch * net-snmp-5.8-velocity-mib.patch * net-snmp-5.8-snmpstatus-suppress-output.patch * net-snmp-5.8-fix-Makefile.PL.patch * net-snmp-5.8-modern-rpm-api.patch add: * net-snmp-5.9.1-socket-path.patch * net-snmp-5.9.1-testing-empty-arptable.patch * net-snmp-5.9.1-pie.patch * net-snmp-5.9.1-net-snmp-config-headercheck.patch * net-snmp-5.9.1-perl-tk-warning.patch * net-snmp-5.9.1-velocity-mib.patch * net-snmp-5.9.1-snmpstatus-suppress-output.patch * net-snmp-5.9.1-fix-Makefile.PL.patch * net-snmp-5.9.1-modern-rpm-api.patch OBS-URL: https://build.opensuse.org/request/show/966059 OBS-URL: https://build.opensuse.org/package/show/network:utilities/net-snmp?expand=0&rev=42
141 lines
4.8 KiB
Diff
141 lines
4.8 KiB
Diff
diff -Nurp net-snmp-5.8-orig/apps/snmpstatus.c net-snmp-5.8/apps/snmpstatus.c
|
|
--- net-snmp-5.8-orig/apps/snmpstatus.c 2018-10-10 09:45:14.955075516 +0000
|
|
+++ net-snmp-5.8/apps/snmpstatus.c 2018-10-10 10:15:16.131576910 +0000
|
|
@@ -96,6 +96,15 @@ size_t length_ipOutRequests =
|
|
|
|
#define NETSNMP_DS_APP_DONT_FIX_PDUS 0
|
|
|
|
+/* Flags to control which additional information to request and print */
|
|
+#define NETSNMP_STATUS_REQ_NETSTAT 0x0001
|
|
+#define NETSNMP_STATUS_REQ_NETOPER 0x0002
|
|
+#define NETSNMP_STATUS_REQ_ALL 0xffff
|
|
+
|
|
+/* By default request and print everything and let the user decide what
|
|
+ to suppress */
|
|
+static unsigned int rq_status = NETSNMP_STATUS_REQ_ALL;
|
|
+
|
|
static void
|
|
optProc(int argc, char *const *argv, int opt)
|
|
{
|
|
@@ -114,6 +123,22 @@ optProc(int argc, char *const *argv, int
|
|
}
|
|
}
|
|
break;
|
|
+ case 'S': /* 'S' == 'Suppress' */
|
|
+ while (*optarg) {
|
|
+ switch (*optarg++) {
|
|
+ case 'n':
|
|
+ rq_status &= ~NETSNMP_STATUS_REQ_NETSTAT;
|
|
+ break;
|
|
+ case 'i':
|
|
+ rq_status &= ~NETSNMP_STATUS_REQ_NETOPER;
|
|
+ break;
|
|
+ default:
|
|
+ fprintf(stderr, "Unknown flag passed to -S: %c\n",
|
|
+ optarg[-1]);
|
|
+ exit(1);
|
|
+ }
|
|
+ }
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
@@ -128,6 +153,12 @@ usage(void)
|
|
" -C APPOPTS\t\tSet various application specific behaviours:\n");
|
|
fprintf(stderr,
|
|
"\t\t\t f: do not fix errors and retry the request\n");
|
|
+ fprintf(stderr,
|
|
+ " -S REQOPTS\t\tDo not request and print information about:\n");
|
|
+ fprintf(stderr,
|
|
+ "\t\t\t n: network (packets sent/received, operational status)\n");
|
|
+ fprintf(stderr,
|
|
+ "\t\t\t i: interface operational status\n");
|
|
}
|
|
|
|
|
|
@@ -154,7 +185,7 @@ main(int argc, char *argv[])
|
|
/*
|
|
* get the common command line arguments
|
|
*/
|
|
- switch (snmp_parse_args(argc, argv, &session, "C:", &optProc)) {
|
|
+ switch (snmp_parse_args(argc, argv, &session, "C:S:", &optProc)) {
|
|
case NETSNMP_PARSE_ARGS_ERROR:
|
|
goto out;
|
|
case NETSNMP_PARSE_ARGS_SUCCESS_EXIT:
|
|
@@ -185,8 +216,10 @@ main(int argc, char *argv[])
|
|
pdu = snmp_pdu_create(SNMP_MSG_GET);
|
|
snmp_add_null_var(pdu, objid_sysDescr, length_sysDescr);
|
|
snmp_add_null_var(pdu, objid_sysUpTime, length_sysUpTime);
|
|
- snmp_add_null_var(pdu, objid_ipInReceives, length_ipInReceives);
|
|
- snmp_add_null_var(pdu, objid_ipOutRequests, length_ipOutRequests);
|
|
+ if (rq_status & NETSNMP_STATUS_REQ_NETSTAT) {
|
|
+ snmp_add_null_var(pdu, objid_ipInReceives, length_ipInReceives);
|
|
+ snmp_add_null_var(pdu, objid_ipOutRequests, length_ipOutRequests);
|
|
+ }
|
|
|
|
/*
|
|
* do the request
|
|
@@ -279,6 +312,10 @@ main(int argc, char *argv[])
|
|
if (response)
|
|
snmp_free_pdu(response);
|
|
|
|
+ /* Suppress request to retrieve network statistics */
|
|
+ if (!(rq_status & NETSNMP_STATUS_REQ_NETSTAT))
|
|
+ goto done;
|
|
+
|
|
/*
|
|
* create PDU for GET request and add object names to request
|
|
*/
|
|
@@ -386,11 +423,11 @@ main(int argc, char *argv[])
|
|
}
|
|
printf("Interfaces: %d, Recv/Trans packets: %d/%d | IP: %d/%d\n",
|
|
interfaces, ipackets, opackets, ipin, ipout);
|
|
- if (down_interfaces > 0) {
|
|
+ if ((rq_status & NETSNMP_STATUS_REQ_NETOPER) && (down_interfaces > 0)) {
|
|
printf("%d interface%s down!\n",
|
|
down_interfaces, down_interfaces > 1 ? "s are" : " is");
|
|
}
|
|
-
|
|
+ done:
|
|
snmp_close(ss);
|
|
|
|
out:
|
|
diff -Nurp net-snmp-5.8-orig/man/snmpstatus.1.def net-snmp-5.8/man/snmpstatus.1.def
|
|
--- net-snmp-5.8-orig/man/snmpstatus.1.def 2018-10-10 09:45:14.951075479 +0000
|
|
+++ net-snmp-5.8/man/snmpstatus.1.def 2018-10-10 10:15:16.131576910 +0000
|
|
@@ -32,7 +32,7 @@
|
|
snmpstatus - retrieves a fixed set of management information from a network entity
|
|
.SH SYNOPSIS
|
|
.B snmpstatus
|
|
-[COMMON OPTIONS] [\-Cf] AGENT
|
|
+[COMMON OPTIONS] [\-Cf] [\-Sni] AGENT
|
|
.SH DESCRIPTION
|
|
.B snmpstatus
|
|
is an SNMP application that retrieves several important statistics
|
|
@@ -94,6 +94,11 @@ variable (unless the
|
|
option is given, see below), but this variable will then be missing
|
|
from the displayed data.
|
|
.PP
|
|
+It is also possible to suppress parts of the default output by
|
|
+using the option
|
|
+.B \-S
|
|
+(see below).
|
|
+.PP
|
|
.SH OPTIONS
|
|
.TP
|
|
.B COMMON OPTIONS
|
|
@@ -108,5 +113,13 @@ by the agent and retry a request. In thi
|
|
the command will display the data that it can. If the \-Cf option
|
|
is specified, then snmpstatus will not try to fix
|
|
errors, and the error will cause the command to terminate.
|
|
+.TP
|
|
+.B \-Sn
|
|
+Do not retrieve and print network statistics such as packets
|
|
+sent and received and the number of network interfaces that
|
|
+are down.
|
|
+.TP
|
|
+.B \-Si
|
|
+Do not print the number of network interfaces that are down.
|
|
.SH "SEE ALSO"
|
|
snmpcmd(1), snmpget(1)
|