Integration Nagios3 withServiceNow
-
Alex_galych
- Posts: 9
- Joined: Wed Aug 02, 2017 3:01 am
Integration Nagios3 withServiceNow
Hello.
I'm trying setup automatically sending notifications to ServiceNow.
I have used this guide: https://support.nagios.com/kb/article.php?id=552
All steps, before "Create Notification Commands" successfully, have been made successfully
But when I run command:
./sn_ticketer.pl --page="incident.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$HOSTNAME$ is $SERVICESTATE$" --description="Host: $HOSTNAME$\nState: $HOSTSTATE$\nTime: $LONGDATETIME$\nDescription: $HOSTOUTPUT$\n\n"
I get following error:
Cleaning up archived DB entries older than TTL
Config loaded.
Message hash for this alert is: 942d6adecde04c7f2656aa33c6ffb25c
Can't call method "rows" on an undefined value at ./sn_ticketer.pl line 54.
Somebody knows how can I resolve this error?
I'm trying setup automatically sending notifications to ServiceNow.
I have used this guide: https://support.nagios.com/kb/article.php?id=552
All steps, before "Create Notification Commands" successfully, have been made successfully
But when I run command:
./sn_ticketer.pl --page="incident.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$HOSTNAME$ is $SERVICESTATE$" --description="Host: $HOSTNAME$\nState: $HOSTSTATE$\nTime: $LONGDATETIME$\nDescription: $HOSTOUTPUT$\n\n"
I get following error:
Cleaning up archived DB entries older than TTL
Config loaded.
Message hash for this alert is: 942d6adecde04c7f2656aa33c6ffb25c
Can't call method "rows" on an undefined value at ./sn_ticketer.pl line 54.
Somebody knows how can I resolve this error?
-
bolson
Re: Integration Nagios3 withServiceNow
Hello Alex,
The error message suggests that the query:
Is not returning any rows of data. Can you re-check your configuration?
The error message suggests that the query:
Code: Select all
"SELECT id FROM tbl_sn_ticket_tracker WHERE hostname = ? AND servicename = ? AND date_modified > DATE_SUB(NOW(), INTERVAL ? MINUTE)"-
Alex_galych
- Posts: 9
- Joined: Wed Aug 02, 2017 3:01 am
Re: Integration Nagios3 withServiceNow
Hello!
Thank you for replay.
"Is not returning any rows of data. Can you re-check your configuration? " -- how can I check it?
The only result is "Can't call method "rows""
But for testing I have commented the following lines:
And now script is working:
root@nagios3:/etc/nagios-plugins/config# ./sn_ticketer.pl --page="incident.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$HOSTNAME$ is $SERVICESTATE$" --description="Host: $HOSTNAME$\nState: $HOSTSTATE$\nTime: $LONGDATETIME$\nDescription: $HOSTOUTPUT$\n\n"
I didn't learn Perl language. Do this action can resolve the issue?
############################
Then I added lines to the file /etc/nagios3/commands.cfg:
When test service is down Nagios3 sends email notification but doesn't send event notification to the ServiceNow Instance.
Thank you for replay.
"Is not returning any rows of data. Can you re-check your configuration? " -- how can I check it?
The only result is "Can't call method "rows""
But for testing I have commented the following lines:
Code: Select all
if ($dbResults->rows >= $hrMainConf->{'storm_watch'}->{'sw_service_tickets'}) {
snt_log("Service: $ARGV{'service'} has tried to log too many tickets");
$dbResults->finish();
$bWriteHoldDown = 1;
}root@nagios3:/etc/nagios-plugins/config# ./sn_ticketer.pl --page="incident.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$HOSTNAME$ is $SERVICESTATE$" --description="Host: $HOSTNAME$\nState: $HOSTSTATE$\nTime: $LONGDATETIME$\nDescription: $HOSTOUTPUT$\n\n"
Code: Select all
Cleaning up archived DB entries older than TTL
Config loaded.
Message hash for this alert is: a1c6b279e8b544cf22de56ef85f05835
Ticket track enabled using database.
Existing ticket found, updating.
Ticket related to SN ID: c279cfcadb984300da15d5f0cf9619b2 has been updated.
Completed succesfully.############################
Then I added lines to the file /etc/nagios3/commands.cfg:
Code: Select all
# 'notify-host-by-snt_service_now' command definition
define command{
command_name notify-host-by-snt
command_line /etc/nagios-plugins/config/sn_ticketer.pl --page="incident.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$HOSTNAME$ is $SERVICESTATE$" --description="Host: $HOSTNAME$\nSta$
}
# 'notify-service-by-snt_service_now' command definition
define command{
command_name notify-service-by-snt
command_line /etc/nagios-plugins/config/sn_ticketer.pl --page="incident.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$SERVICEDESC$ on $HOSTNAME$ is $SERVICESTATE$" --description="Ho$
}
-
bolson
Re: Integration Nagios3 withServiceNow
Run the following command with the password you created when you installed the service now integration package:
Then run the following commands from the mysql prompt:
And post your results.
Code: Select all
mysql -u servicenow -p your_password -h localhostCode: Select all
mysql>use nagsnt
mysql>select * from tbl_sn_ticket_tracker;-
Alex_galych
- Posts: 9
- Joined: Wed Aug 02, 2017 3:01 am
Re: Integration Nagios3 withServiceNow
Code: Select all
mysql> use nagsntYou can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from tbl_sn_ticket_tracker;
+----+-----------+-------------+---------------------+---------------------+---- ------------------------------+----------+----------------------------------+
| id | hostname | servicename | date_created | date_modified | sys _id | archived | message_hash |
+----+-----------+-------------+---------------------+---------------------+---- ------------------------------+----------+----------------------------------+
| 1 | GFL-1495$ | NULL | 2017-08-02 11:17:38 | 2017-08-03 11:52:25 | c27 9cfcadb984300da15d5f0cf9619b2 | false | 2977d27d346ce7e9332c7a2237d36d08 |
+----+-----------+-------------+---------------------+---------------------+---- ------------------------------+----------+----------------------------------+
1 row in set (0,00 sec)
-
bolson
Re: Integration Nagios3 withServiceNow
When you run the command:
Are you populating the argument variables $HOSTNAME$, $HOSTSTATE$, $SERVICESTATE$, $LONGDATETIME$, and $HOSTOUTPUT$ with actual data?
Can you copy and paste the command exactly as you're running it?
Code: Select all
./sn_ticketer.pl --page="incident.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$HOSTNAME$ is $SERVICESTATE$" --description="Host: $HOSTNAME$\nState: $HOSTSTATE$\nTime: $LONGDATETIME$\nDescription: $HOSTOUTPUT$\n\n" Can you copy and paste the command exactly as you're running it?
-
Alex_galych
- Posts: 9
- Joined: Wed Aug 02, 2017 3:01 am
Re: Integration Nagios3 withServiceNow
Hello!
Nagios:/etc/nagios-plugins/config# ./sn_ticketer.pl --page="incident.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$HOSTNAME$ is $SERVICESTATE$" --description="Host: $HOSTNAME$\nState: $HOSTSTATE$\nTime: $LONGDATETIME$\nDescription: $HOSTOUTPUT$\n\n"
Cleaning up archived DB entries older than TTL
Config loaded.
Message hash for this alert is: 35c08880b511e773104996136e161478
Ticket track enabled using database.
Existing ticket found, updating.
Ticket related to SN ID: c279cfcadb984300da15d5f0cf9619b2 has been updated.
Completed succesfully.
In attachment there is my field_map.ini file which contains parameters using by sn_ticketer.pl script
Nagios:/etc/nagios-plugins/config# ./sn_ticketer.pl --page="incident.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$HOSTNAME$ is $SERVICESTATE$" --description="Host: $HOSTNAME$\nState: $HOSTSTATE$\nTime: $LONGDATETIME$\nDescription: $HOSTOUTPUT$\n\n"
Cleaning up archived DB entries older than TTL
Config loaded.
Message hash for this alert is: 35c08880b511e773104996136e161478
Ticket track enabled using database.
Existing ticket found, updating.
Ticket related to SN ID: c279cfcadb984300da15d5f0cf9619b2 has been updated.
Completed succesfully.
In attachment there is my field_map.ini file which contains parameters using by sn_ticketer.pl script
- Attachments
-
field_map.ini- field_map.ini
- (3.42 KiB) Downloaded 264 times
-
Alex_galych
- Posts: 9
- Joined: Wed Aug 02, 2017 3:01 am
Re: Integration Nagios3 withServiceNow
Hello!
I have found a new incident in the ServiceNow instance from Nagios. I expected to see them on All Events of Event management.
https://gyazo.com/c37c67f4cb95d5ea740cdc5a18914f90
Also I have error if run manualy:
SOAP-ENV:Server com.glide.processors.soap.SOAPProcessingException: Web service update called for a missing record: c279cfcadb984300da15d5f0cf9619b2 com.glide.processors.soap.SOAPProcessingException: Web service update called for a missing record: c279cfcadb984300da15d5f0cf9619b2
Most of fields don't populate. How can I fix it?
I have found a new incident in the ServiceNow instance from Nagios. I expected to see them on All Events of Event management.
https://gyazo.com/c37c67f4cb95d5ea740cdc5a18914f90
Also I have error if run manualy:
SOAP-ENV:Server com.glide.processors.soap.SOAPProcessingException: Web service update called for a missing record: c279cfcadb984300da15d5f0cf9619b2 com.glide.processors.soap.SOAPProcessingException: Web service update called for a missing record: c279cfcadb984300da15d5f0cf9619b2
Most of fields don't populate. How can I fix it?
-
Alex_galych
- Posts: 9
- Joined: Wed Aug 02, 2017 3:01 am
Re: Integration Nagios3 withServiceNow
So, I rebuld config_file using this command:
Then, I run command:
./sn_ticketer.pl --page="em_event.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$HOSTNAME$ is $SERVICESTATE$" --description="Host: $HOSTNAME$\nState: $HOSTSTATE$\nTime: $LONGDATETIME$\nDescription: $HOSTOUTPUT$\n\n"
Now all new events appear in the "All events".
But still the most fields are empty. What is a reason of this problem?
Code: Select all
sn_ticketer.pl --page='[b]em_event.do[/b]' --buildmap./sn_ticketer.pl --page="em_event.do" --host="$HOSTNAME$" --state="$HOSTSTATE$" --category="Nagios" --short_description="$HOSTNAME$ is $SERVICESTATE$" --description="Host: $HOSTNAME$\nState: $HOSTSTATE$\nTime: $LONGDATETIME$\nDescription: $HOSTOUTPUT$\n\n"
Now all new events appear in the "All events".
But still the most fields are empty. What is a reason of this problem?
Re: Integration Nagios3 withServiceNow
The fields might be empty because those macros (like $HOSTNAME$ and $HOSTSTATE$) are evaluated within Nagios Core at run-time. They are not present as proper Linux environment variables unless you have enable_environment_macros enabled. Even then, since there is no context under which a $HOSTNAME$ exists when you're running it as a one-off from the CLI, you might still have empty fields.
Try plugging in simple plain-text values to see if the fields are properly populated.
Try plugging in simple plain-text values to see if the fields are properly populated.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/