- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Expert
I need to enhance a Linux Server Discovery Pattern using Pre and Post Scripts:
Pre-Script: Before running any discovery steps, check if the host is reachable. If not, log a message and stop further execution.
Post-Script: After the server CI is created/updated, write the current timestamp into a custom field u_discovery_timestamp on the CI.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Add a Pre-Script
Open Discovery Patterns > Linux Server Pattern.
Add a Pre-script step before the identification section.
Script should:
-
Use Snmp or PingProbe utility to check if the host is reachable.
-
If not reachable, log: "Pre-check failed: Host not reachable. Skipping pattern."
-
Exit gracefully without creating any CIs.
Expected Output: Pattern log showing the pre-script execution and skip behavior when the host is down.
Normal Pattern Execution
-
Run the default steps (classification, identification, exploration).
-
Server details are collected as usual when the host is reachable.
Expected Output: CMDB Linux Server CI updated with OS details.
Add a Post-Script
After the Set Attributes step that creates/updates the Linux Server CI, add a Post-script.
Script should:
Capture current date/time with gs.nowDateTime()
Update the current CI context with the field u_discovery_timestamp.
Example :
- var ciSysId = current.sys_id;
if (ciSysId) {
var gr = new GlideRecord('cmdb_ci_linux_server');
if (gr.get(ciSysId)) {
gr.u_discovery_timestamp = gs.nowDateTime();
gr.update();
pattern.log("Post-script: Discovery timestamp updated for " + gr.name);
}
}
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I am super thankful for this @Ravi Gaurav This works and I was working since a week on this .. just added your logic on Mine and worked.. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Don’t take it the wrong way, but I strongly recommend completing the Discovery and other ITOM-related training through Now Learning. This will help clear many of your doubts.
Once your basics and fundamentals are clear, you can then focus on explaining what you have done and where you are stuck. That’s why my recommendation is to first go through the training
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Exactly @SandeepKSingh .. More focus should be on Discovery Fundamental.. and in pattern more focus is required as its consist of pre,post, pre-execuation and on Failure.. its all you need is dedicated knowledge and after that you can post your question
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Sure @Dr Atul G- LNG I am trying was not able to get.. course doesn't have these these Info
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Try to connect with @AJ-TechTrek he is a champ in ITOM and I am sure he will clear your all doubts.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************