Find the answer to your Linux question:
Results 1 to 6 of 6
Good day everyone, I installed nagios on centreon platform, now I wrote a perl script that fetches data from specif date from an sql table,to make it run when needed ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2012
    Posts
    12

    Running a Perl script on nagios


    Good day everyone,

    I installed nagios on centreon platform, now I wrote a perl script that fetches data from specif date from an sql table,to make it run when needed ,my question is , where should i write ,implement this file? Any ideas on this guys?

    Thanks

  2. #2
    Just Joined!
    Join Date
    May 2011
    Location
    Malaysia
    Posts
    15
    Hi Waelkd,

    Let's assume you installed your nagios at /usr/local/nagios.
    Your plugin scripts will be located at /usr/local/nagios/libexec/. Just copy it there and configure your nagios configuration files to trigger it.

  3. #3
    Just Joined!
    Join Date
    May 2012
    Posts
    12
    Quote Originally Posted by fabbie View Post
    Hi Waelkd,

    Let's assume you installed your nagios at /usr/local/nagios.
    Your plugin scripts will be located at /usr/local/nagios/libexec/. Just copy it there and configure your nagios configuration files to trigger it.

    ok, i copied the file there, should i rename the file with a .pl extension ? and what do you mean when you say configure you nagios conf files to trigger it?

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    May 2011
    Location
    Malaysia
    Posts
    15
    It's fine to rename the file without the .pl extension, just as long as you've tested that the script can be executed successfully.

    Once you've placed your file in libexec, go to your /usr/local/nagios/etc/objects/linuxservers.cfg (or whichever file your host and services configuration is located at).

    Add in your service. Eg.
    lets say your perl script name is check_mysql.

    define service{
    use local-service ; Name of service template to use
    host_name localhost
    service_description SQL-Query (whatever name)
    check_command check_mysql! xxx! xxx!
    }

    The 'xxx' here are your variables passed to your perl script.

    Remember to have the check_mysql configured in your /usr/local/nagios/etc/objects/command.cfg as well.
    Eg.
    define command{
    command_name check_mysql
    command_line $USER1$/check_mysql -H $ARG1$ -t $ARG2$ <-- check mysql is your perl script. -H,-t is an example used. It depends how u wrote your script or whether u plan to pass are values to it. $ARG1$, $ARG2$ are arguments from the linuxservice.cfg file.
    }


    Once you've done all that, check for errors. /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    And then, restart your nagios.

  6. #5
    Just Joined!
    Join Date
    May 2012
    Posts
    12
    Sorry for the late reply

    Quote Originally Posted by fabbie View Post
    It's fine to rename the file without the .pl extension, just as long as you've tested that the script can be executed successfully.

    Once you've placed your file in libexec, go to your /usr/local/nagios/etc/objects/linuxservers.cfg (or whichever file your host and services configuration is located at)
    i went to the above directory and i cant find linuxservers.cfg file, i searched for it , its no where to be found. Why is this file important ?

    Add in your service. Eg.
    lets say your perl script name is check_mysql.

    define service{
    use local-service ; Name of service template to use
    host_name localhost
    service_description SQL-Query (whatever name)
    check_command check_mysql! xxx! xxx!
    }

    The 'xxx' here are your variables passed to your perl script.

    you say add in your services, where should i add the above code, in what directoy? what path


    Remember to have the check_mysql configured in your /usr/local/nagios/etc/objects/command.cfg as well.
    Eg.
    define command{
    command_name check_mysql
    command_line $USER1$/check_mysql -H $ARG1$ -t $ARG2$ <-- check mysql is your perl script. -H,-t is an example used. It depends how u wrote your script or whether u plan to pass are values to it. $ARG1$, $ARG2$ are arguments from the linuxservice.cfg file.

    }
    this step i think i understand, after i have created the file above in both "directories" , itll be automade in " /usr/local/nagios/etc/objects/command.cfg" and i just have to auto check it?

    Once you've done all that, check for errors. /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    And then, restart your nagios
    .
    this i understand

  7. #6
    Just Joined!
    Join Date
    May 2012
    Posts
    12
    never mind mate , found services.cfg and commands.cfg


    i think i understand now what i have to.

    inorder to create a valid service,

    1st step would be going to libexec, writing it

    then ill have to goto services.cfg and commands.cfg and define there.

    so nagios can track it and relay it back to centreon .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •