• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    E-mail Notification

    Scheduled Pinned Locked Moved
    Feature Request
    7
    20
    8.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Lee RowlettL
      Lee Rowlett Developer
      last edited by

      Hi Guys,

      is there anyway to get FOG to send an e-mail once an image task has started/completed? i’m sure i saw someone do this on the old forum but didn’t need the facility at the time. wondered if anyone else already has this setup? going to use it as a call logging system can automatically create calls from e-mails.

      could anyone point me in the right direction?

      P.s didn’t post it into the general support as (i believe) it’s not in FOG so it’s also a feature request… 🙂

      1 Reply Last reply Reply Quote 0
      • Lee RowlettL
        Lee Rowlett Developer
        last edited by

        anyone?? 🙂

        1 Reply Last reply Reply Quote 0
        • F
          Fernando Gietz Developer
          last edited by

          I think that develope it is really easy.

          There are tree web service (they are located in WEBROOT_DIRECTORY/fog/service):

          [LIST]
          []Pre_Stage1.php . This web service is called when a task begins.
          [
          ]Post_Stage2.php . This web service is called when an upload task ends .
          [*]Post_Stage3.php . This web service is called when an download task ends .
          [/LIST]

          Those web services are called by fog script either when you upload either when you download an image. Those web services responde with an echo (##), if the proccess finishes well. You can call to the [I][B]mail[/B][/I] php function (you can see the sintaxis [URL=‘http://php.net/manual/en/function.mail.php’]here*[/URL] ) to send an email. You must call it before the echo.

          ===============================

          • [url]http://php.net/manual/en/function.mail.php[/url]
          1 Reply Last reply Reply Quote 0
          • Lee RowlettL
            Lee Rowlett Developer
            last edited by

            hi, got this working perfectly now thanks for pointing me in the right direction! 😄 the only thing i need to do in Post_Stage3.php is get the hostname to put into the mail function as Post_Stage3.php only pulls hostid and i’m having a complete mental block on how to get hostname without creating a new function or mysql connection. i know the functions there but cannot remember! lol

            1 Reply Last reply Reply Quote 0
            • F
              Fernando Gietz Developer
              last edited by

              You don’t need create a new query to know the hostname. Probably, the fog script knows the hostname, it is necesary to change it when you download an image. Check the PXE file to know it.

              Then, you can change the web service call:

              [CODE]wget -q -O /tmp/co.txt “http://${web}service/Post_Stage3.php?mac=$mac&imgid=$imgid&hostname=$hostname” &>/dev/null[/CODE]

              Capture the hostname in the Post_Stage3.php file:
              [PHP]$hostname = $_GET[“hostname”];[/PHP]

              1 Reply Last reply Reply Quote 0
              • Lee RowlettL
                Lee Rowlett Developer
                last edited by

                of course!! thank you, as I say stupid mental block! lol

                1 Reply Last reply Reply Quote 0
                • Lee RowlettL
                  Lee Rowlett Developer
                  last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • Lee RowlettL
                    Lee Rowlett Developer
                    last edited by

                    this didn’t work 😞 hostname is blank

                    1 Reply Last reply Reply Quote 0
                    • Lee RowlettL
                      Lee Rowlett Developer
                      last edited by

                      want to try and avoid writing a new query but unless you got any other idea?.. thanks for the help btw

                      1 Reply Last reply Reply Quote 0
                      • F
                        Fernando Gietz Developer
                        last edited by

                        [quote=“Lee Rowlett, post: 12364, member: 28”]this didn’t work 😞 hostname is blank[/quote]

                        What is the reason to be blank? The PXE file hasn’t the hostname, the fog script not get the $hostname or the $_GET variable is empty?

                        1 Reply Last reply Reply Quote 0
                        • Lee RowlettL
                          Lee Rowlett Developer
                          last edited by

                          The PXE file hasn’t the hostname

                          1 Reply Last reply Reply Quote 0
                          • F
                            Fernando Gietz Developer
                            last edited by

                            There is the problem 🙂 You can solve it easily.

                            When you create a task, the webUI calls to tasks.confirm.include.php ( you can locete it in WEBROOT_DIRECTORY/fog/management/includes/ ). This php file creates the PXE file depending the tasks type. For example, to create a multicast download task, the tasks.confirm.include.php calls to :

                            [PHP]$taskid = createImagePackageMulticast($conn, $imageMembers[$i], $taskName, $port, $tmp, (!empty($_GET[“debug”]) && $_GET[“debug”] == “true” ), true, $shutdown, $imageMembers[$i]->getKernel(), $other , (empty($bashscript)? “”:$bashscript), $type, $taskPCT);[/PHP]

                            This function uses the [B][I]$other[/I][/B] variable to setup the hostname, check if this variable has setup the hostname.

                            1 Reply Last reply Reply Quote 0
                            • x23piracyX
                              x23piracy
                              last edited by

                              Hi,

                              nice thread very interesting, @Lee do you have it working now?
                              Can you post a little overview of what u’ve done please?

                              Greetz X23

                              ║▌║█║▌│║▌║▌█

                              1 Reply Last reply Reply Quote 0
                              • falkoF
                                falko Moderator
                                last edited by

                                [quote=“x23piracy, post: 12383, member: 3982”]Hi,

                                nice thread very interesting, @Lee do you have it working now?
                                Can you post a little overview of what u’ve done please?

                                Greetz X23[/quote]

                                yes this would be very useful if you could share an overview, maybe if you could post it in the tutorial section?

                                1 Reply Last reply Reply Quote 0
                                • Lee RowlettL
                                  Lee Rowlett Developer
                                  last edited by

                                  Hi,

                                  i have got it working but had to write a seperate query to get hostname. it is hard to write a step by step as you can customize it to however you want and use any mail protocol, i am using sendmail/mailutils - below is what i did.

                                  edit the file …/fog/service/Post_Stage3.php

                                  just before line: echo “##”; write you’re mail function i.e.

                                  if ( checkOut( $conn, $jobid ) )
                                  {
                                  [B]mail(“emailaddress@tosendto”,“$hostname - Image Task Completed”, “$hostname has been successfully imaged”);[/B]
                                  echo “##”;

                                  // Now update the imaging log.
                                  @logImageTask( $conn, “e”, $hostid );

                                  if you would like to get the hostname in the email - you have to include this, it is another query and there may be a cleaner way to do this but for now put this anywhere before the if statement put…

                                  $hst = “SELECT hostName FROM hosts WHERE hostID like '”.$hostid.“'”;
                                  $res1 = mysql_query( $hst, $conn ) or die( mysql_error() );
                                  $ar1 = mysql_fetch_object($res1);
                                  $hostname = $ar1->hostName;

                                  optional:
                                  on the server install sendmail/mailutils
                                  apt-get install sendmail
                                  apt-get install mailutils

                                  recommend stopping sendmail running a daemon.

                                  hope this helps

                                  …thanks for the guidance Fernando

                                  1 Reply Last reply Reply Quote 0
                                  • x23piracyX
                                    x23piracy
                                    last edited by

                                    Hi,

                                    @Lee thank you for sharing this information i will try this out and report back.

                                    Greetz X23

                                    ║▌║█║▌│║▌║▌█

                                    1 Reply Last reply Reply Quote 0
                                    • R
                                      raymondub
                                      last edited by

                                      Hi,
                                      something about this ? Is it in the last version of fog ?
                                      thx

                                      1 Reply Last reply Reply Quote 0
                                      • Tom ElliottT
                                        Tom Elliott
                                        last edited by

                                        It’s added.

                                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                        1 Reply Last reply Reply Quote 0
                                        • R
                                          raymondub
                                          last edited by

                                          hi,
                                          I was searching for that option and I realised that I was not in the same last version… I was in the 1.2.0 and not in the svn version. I m now in 1.2.0 version 3118 and I see a section “Fog Email Settings”. I think it s that but how does it work ?
                                          The package has been installed but i m not receiving mails…
                                          apt-get install sendmail
                                          apt-get install mailutils

                                          thx

                                          1 Reply Last reply Reply Quote 0
                                          • S
                                            Sebastian Roth Moderator
                                            last edited by

                                            Do you see any errors in your apache log files when mail is being sent? I guess you need to configure smart host with sendmail… [url]https://www.dnsexit.com/support/mailrelay/sendmail.html[/url]

                                            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                            1 Reply Last reply Reply Quote 0
                                            • 1 / 1
                                            • First post
                                              Last post

                                            170

                                            Online

                                            12.0k

                                            Users

                                            17.3k

                                            Topics

                                            155.2k

                                            Posts
                                            Copyright © 2012-2024 FOG Project