| Server IP : 68.178.202.69 / Your IP : 216.73.216.122 Web Server : Apache System : Linux 69.202.178.68.host.secureserver.net 3.10.0-1160.139.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Nov 3 13:30:41 UTC 2025 x86_64 User : ikioworld ( 1005) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/fm-agent/plugins/ |
Upload File : |
import agent_util
class SendmailPlugin(agent_util.Plugin):
textkey = "sendmail"
label = "Sendmail"
@classmethod
def get_metadata(self, config):
status = agent_util.SUPPORTED
msg = None
sendmail_bin = agent_util.which("sendmail")
# in case sendmail is not in default path for the agent
if not sendmail_bin:
sendmail_bin = agent_util.which("/usr/sbin/sendmail")
if not sendmail_bin:
self.log.info("couldn't find sendmail binary")
status = agent_util.UNSUPPORTED
msg = "Couldn't find sendmail binary"
# if they have configured sudo, try it first
if sendmail_bin and config.get("use_sudo", 0):
if not agent_util.execute_command("sudo -n %s -bp" % sendmail_bin)[0] == 0:
self.log.error(
"Insufficient permission - Enable sudo access for agent user on sendmail."
)
status = agent_util.UNSUPPORTED
msg = "SUDO access not configured for fm-agent user"
data = {
"queue_depth": {
"label": "Sendmail queue depth",
"options": None,
"status": status,
"error_message": msg,
}
}
return data
def check(self, textkey, data, config={}):
sendmail_bin = agent_util.which("sendmail", exc=True)
# in case sendmail is not in default path for the agent
if not sendmail_bin:
sendmail_bin = agent_util.which("/usr/sbin/sendmail", exc=True)
if config.get("use_sudo", 0):
sudo_string = "sudo -n "
else:
sudo_string = ""
retcode, output = agent_util.execute_command(
"%s%s -bp" % (sudo_string, sendmail_bin)
)
self.log.debug("sendmail -bp output: %s" % str(output))
# sample output
# dev@wlocalhost:/# sendmail -bpc
# /var/spool/mqueue is empty
# Total requests: 0
output = output.splitlines()
for line in output:
if line.strip().startswith("Total requests:"):
try:
return int(line.strip().split("Total requests:")[1].strip())
except:
self.log.debug("Failed parsing line: '%s'" % line)
return None
self.log.debug("No lines matched Total requests string")
return None