FortiNAC-F
FortiNAC-F is a zero-trust network access solution that provides users with enhanced visibility into the Internet of Things (IoT) devices on their enterprise networks. For legacy FortiNAC articles prior to FortiNAC-F 7.2, see FortiNAC.
ebilcari
Staff
Staff
Article Id 403824
Description

 

This article describes how to create and use a Custom Script to send customizable event content via Email.

 

Scope

 

FortiNAC.

 

Solution

 

The scripts are located in the '/home/cm/scripts' directory and can be reached after entering the shell.

 

execute enter-shell

cd /home/cm/scripts

touch Event2Email.sh

chmod +x Event2Email.sh

vi -N Event2Email.sh

 

The content of the script can be pasted into the editor and then saved (:wq). This is an example of a Bash script:

 

######################## Event2Email.sh ######################
# Get the Event content and send a personalized email
##############################################################

#!/bin/bash

## Set up the details of the email
subject="This is a FNAC notification"
destination="gimi@eb.eu"
event=$1

# Event example:  'type="User" name="admin, Admin" user="admin" msg="Alarm Admin User Login Success asserted on admin, Admin Wed Apr 02 15:37:23 CEST 2025.  The following Events caused the Alarm.     Admin user admin logged in.  "'

##############################################################
## Customize the content

user=$(echo "$event" | awk -F'user="' '{print $2}' | awk -F'"' '{print $1}')
msg=$(echo "$event" | awk -F'msg="' '{print $2}' | awk -F'"' '{print $1}')

content="There is a new event generated for *$user*. The message is: - $msg -"

##############################################################
## Send the e-mail to the service connector

/bsc/campusMgr/bin/RunClient SendEMail.class -message="$content" -subject="$subject" -to=$destination

 

Note:

This script provides a basic example of how to parse the event content and generate a new email message to be sent. This part of the script can be customized to meet specific requirements.

 

The script can be configured to be called as a response to an Event Mapping:

 

event2email.PNG

A valid email server must be configured in FortiNAC beforehand. The server needs to be added in Network -> Service Connectors.

Contributors