I understand how Nagios works in that it periodically polls the status of the system. It can for example check for existence of some files or availability of some web page each minute.
But what about when I want to create alerts straight from my application code? Say user tries to perform some illegal operation and I want to receive an alert from that.
I could for example log this event into a file and configure Nagios to periodically poll this file. This just seems an indirect way of doing this. Why go through writing, polling, and parsing a file in filesystem if I could just call some interface (REST,SOAP) with the alert details?
Is there something available which lets my application call Nagios directly (or would this be a bad design for some reason)?