code beautifying
This commit is contained in:
parent
26ed056cff
commit
18943d6137
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
|||||||
PROG= subagent_ntpd
|
PROG= subagent_ntpd
|
||||||
SRCS= subagent_ntpd.c log.c
|
SRCS= subagent_ntpd.c mib.c log.c
|
||||||
MAN=
|
MAN=
|
||||||
|
|
||||||
CFLAGS+= -Wall -I${.CURDIR}
|
CFLAGS+= -Wall -I${.CURDIR}
|
||||||
|
22
mib.c
Normal file
22
mib.c
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "mib.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void mib_hottisntpdcounter(struct agentx_varbind *vb) {
|
||||||
|
long long ticks = 200169;
|
||||||
|
|
||||||
|
agentx_varbind_counter64(vb, ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mib_register(struct agentx_context *sac) {
|
||||||
|
struct agentx_region *hottis;
|
||||||
|
struct agentx_object *hottisNtpdCounter;
|
||||||
|
|
||||||
|
if ((hottis = agentx_region(sac, AGENTX_OID(HOTTIS_MIB), 0)) == NULL)
|
||||||
|
fatal("agentx_region");
|
||||||
|
|
||||||
|
if ((hottisNtpdCounter = agentx_object(hottis, AGENTX_OID(HOTTIS_NTPD_COUNTER),
|
||||||
|
NULL, 0, 0, mib_hottisntpdcounter)) == NULL)
|
||||||
|
fatal("agentx_object");
|
||||||
|
}
|
||||||
|
|
8
mib.h
8
mib.h
@ -17,9 +17,17 @@
|
|||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _MIB_H_
|
||||||
|
#define _MIB_H_
|
||||||
|
|
||||||
#include <agentx.h>
|
#include <agentx.h>
|
||||||
|
|
||||||
|
void mib_register(struct agentx_context *sac);
|
||||||
|
|
||||||
#define ENTERPRISE_MIB 1,3,6,1,4,1
|
#define ENTERPRISE_MIB 1,3,6,1,4,1
|
||||||
#define HOTTIS_MIB ENTERPRISE_MIB, 9676
|
#define HOTTIS_MIB ENTERPRISE_MIB, 9676
|
||||||
#define HOTTIS_NTPD HOTTIS_MIB, 1
|
#define HOTTIS_NTPD HOTTIS_MIB, 1
|
||||||
#define HOTTIS_NTPD_COUNTER HOTTIS_NTPD, 1
|
#define HOTTIS_NTPD_COUNTER HOTTIS_NTPD, 1
|
||||||
|
|
||||||
|
#endif // _MIB_H_
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
// #include <agentx.h> MUST BE INCLUDED ONLY ONCE, WILL BE INCLUDED IN mib.h
|
||||||
#include "mib.h"
|
#include "mib.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
@ -45,24 +46,6 @@ void snmp_tryconnect(int, short, void *);
|
|||||||
void snmp_read(int, short, void *);
|
void snmp_read(int, short, void *);
|
||||||
|
|
||||||
|
|
||||||
static void mib_hottisntpdcounter(struct agentx_varbind *vb) {
|
|
||||||
long long ticks = 200169;
|
|
||||||
|
|
||||||
agentx_varbind_counter64(vb, ticks);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mib_register(struct agentx_context *sac) {
|
|
||||||
struct agentx_region *hottis;
|
|
||||||
struct agentx_object *hottisNtpdCounter;
|
|
||||||
|
|
||||||
if ((hottis = agentx_region(sac, AGENTX_OID(HOTTIS_MIB), 0)) == NULL)
|
|
||||||
fatal("agentx_region");
|
|
||||||
|
|
||||||
if ((hottisNtpdCounter = agentx_object(hottis, AGENTX_OID(HOTTIS_NTPD_COUNTER),
|
|
||||||
NULL, 0, 0, mib_hottisntpdcounter)) == NULL)
|
|
||||||
fatal("agentx_object");
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user