File tree Expand file tree Collapse file tree
Specialized Areas/CMDB/Detect Configuration Drift Compare to Baseline Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ( function executeRule ( current , previous ) {
2+ var baseline = new GlideRecord ( 'cmdb_baseline' ) ;
3+ baseline . addQuery ( 'ci' , current . sys_id ) ;
4+ baseline . orderByDesc ( 'sys_created_on' ) ;
5+ baseline . query ( ) ;
6+
7+ if ( baseline . next ( ) ) {
8+ var drift = false ;
9+ var changes = [ ] ;
10+
11+ if ( baseline . ram != current . ram ) {
12+ drift = true ; changes . push ( 'RAM' ) ;
13+ }
14+
15+ if ( baseline . cpu_count != current . cpu_count ) {
16+ drift = true ; changes . push ( 'CPU' ) ;
17+ }
18+
19+ if ( baseline . os != current . os ) {
20+ drift = true ; changes . push ( 'OS' ) ;
21+ }
22+
23+ if ( drift ) {
24+ var log = new GlideRecord ( 'u_drift_log' ) ;
25+ log . initialize ( ) ;
26+ log . u_ci = current . sys_id ;
27+ log . u_detected_on = new GlideDateTime ( ) ;
28+ log . u_drift_fields = changes . join ( ', ' ) ;
29+ log . insert ( ) ;
30+
31+ gs . eventQueue ( 'ci.drift_detected' , current , changes . join ( ', ' ) ) ;
32+ }
33+ }
34+ } ) ( current , previous ) ;
You can’t perform that action at this time.
0 commit comments