

If failed port 53 protocol dns with timeout 5 seconds then alert If failed icmp type echo count 3 with timeout 3 seconds then alert In this example we will configure Monit to check different ports on a certain machine: # vim /etc/monit.d/host1Ĭheck host dns1 with address 111.111.111.111 Create and edit the corresponding file as follows: # vim /etc/monit.d/file_checkĬheck file important with path "/root/packages/test" The configuration is pretty straightforward, and it goes as follows: # vim /etc/monit.d/cert_checkĬheck file certificate with path "/root/ssl/"Īnother example where Monit can do a file size check. We will setup an SSL certificate’s permissions check. Monit can also do various checks for a certain file. # if space usage > 80% for 5 times within 15 cycles then alert # if failed permission 660 then unmonitor You can also name the file to your liking, it does not have to be the same as the example.Ĭreate and edit the file using your favorite text editor as follows: # vim /etc/monit.d/fs_check As we are using include /etc/monit.d/* (it’s just another way of configuring Monit, you can put all of this in /etc/nf too), we need to first create the appropriate file for the check we are about to configure. With Monit, you can check a certain filesystem. Use the following examples to create your own checks and your own conditions that will suit your need. It’s one of the essential tools a sysadmin must have.
#Monit file free#
More home server specific Monit examples to follow, so keep checking back.Monit is a free and open source monitoring system for Linux. As you can see Monit allows for automatic file server status monitoring, which can be a big help for system administrators. That is it to monitor file server status with Monit. You should see Samba and NFS file server statuses as shown in the picture below (See Samba and NFS).


If Monit is running, reload configurations using the following command to monitor file server status with Monit: Then, check to see if Monit is already running using the following command: You should see the following message: Control File Syntax OK. Once you make any changes you have to test Monit configuration: If restart fails twice in 3 cycles then Monit stops monitoring NFS server.
#Monit file code#
The above code monitor file and if does not exist, Monit will try to restart NFS server. If failed host 127.0.0.1 port 2049 type tcp for 2 cycles then restart Stop program = "/etc/init.d/nfs-kernel-server stop" Start program = "/etc/init.d/nfs-kernel-server start" Monit System Monitoring Email Alert Example Monitor NFS Server with Monitįor NFS server monitoring with Monit, create a Monit configuration file using the following command:Ĭheck process NFS with pidfile /var/run/ A restart will trigger an email alert as shown in the example below. If restart fails twice in 3 cycles then Monit stops monitoring Samba server. The above code monitor smbd.pid file and if does not exist, Monit will try to restart Samba. Samba file server process creates smbd.pid. If 2 restarts within 3 cycles then unmonitor If failed host 127.0.0.1 port 139 type tcp for 2 cycles then restart Monitor Samba Server with Monitįor Samba server monitoring with Monit, create a Monit configuration file using the following command:Ĭopy the following contents to it, save, and exit.Ĭheck process Samba with pidfile "/var/run/samba/smbd.pid" Monit configurations for various services are loaded from /etc/monit/conf.d folder.
#Monit file how to#
So let us see how to automatically manage file server using Monit server monitor software.īefore enabling network share monitoring, it is required that you have a working Monit instance with a proper /etc/monit/monitrc file.
#Monit file windows#
Since setting it up I have never had one backup failure due to my Samba drives not being available on Windows or Kodi streaming problems.

On my Ubuntu home server, I run SMB file server and NFS server to share drives with Windows systems and Kodi boxes, respectively.
