Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
openSUSE:Leap:15.0:Staging:E
net-snmp
net-snmp-5.7.3-snmpstatus-suppress-output.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File net-snmp-5.7.3-snmpstatus-suppress-output.patch of Package net-snmp
diff -Nurp net-snmp-5.7.3.orig/apps/snmpstatus.c net-snmp-5.7.3/apps/snmpstatus.c --- net-snmp-5.7.3.orig/apps/snmpstatus.c 2015-07-14 22:06:08.938851077 +0200 +++ net-snmp-5.7.3/apps/snmpstatus.c 2015-07-14 22:06:23.905980889 +0200 @@ -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"); } @@ -152,7 +183,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: exit(1); 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 @@ -278,6 +311,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 */ @@ -375,11 +412,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); SOCK_CLEANUP; return exitval; diff -Nurp net-snmp-5.7.3.orig/man/snmpstatus.1.def net-snmp-5.7.3/man/snmpstatus.1.def --- net-snmp-5.7.3.orig/man/snmpstatus.1.def 2015-07-14 22:06:08.838850210 +0200 +++ net-snmp-5.7.3/man/snmpstatus.1.def 2015-07-14 22:13:19.891588792 +0200 @@ -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)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor