z

Commercial Support Clients: Clients with support contracts can get escalated support assistance by visiting Nagios Answer Hub. These forums are for community support services. Although we at Nagios try our best to help out on the forums here, we always give priority support to our support clients.

How to utilise macros "HOSTADDRESS" in my code

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.

How to utilise macros "HOSTADDRESS" in my code

Postby dhlao » Mon Jan 03, 2022 10:36 pm

I'm going to create a check command that is written in C. Like those built-in ones that come with Nagios Core, I want to make it able to get the argument such as hostaddress, warning and critical threshold.
I've checked check_ping and check_snmp, then I found that they all rely on an unknown variable "optarg". It's not declared in the codes so I assume it's included in one of those headers (common.h, utils.h, etc.).
The problem is those headers have dependency with the other headers that make it impossible to include all of them.
If I know where and how that "optarg" is declared, I can just simply skip those unnecessary library/header. My problem is, I've no idea where it is.
dhlao
 
Posts: 14
Joined: Thu Apr 29, 2021 10:23 am

Re: How to utilise macros "HOSTADDRESS" in my code

Postby mcapra » Tue Jan 04, 2022 11:00 am

I think this is what you're looking for:
https://github.com/nagios-plugins/nagio ... l/getopt.c

But there's a variety of ways to handle command-line arguments in C.
Former Nagios employee
https://www.mcapra.com/
User avatar
mcapra
 
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm


Return to Open Source Nagios Projects

Who is online

Users browsing this forum: No registered users and 28 guests