Skip to content

Commit

Permalink
alert on overall cpu usage instead of only user usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Crapworks committed Mar 30, 2017
1 parent dcc0cff commit ea0bf7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/telegraf/cpu/cpu_alert_batch.tick
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var every = 10s

// Dataframe
var data = batch
|query('''SELECT mean(usage_user) AS stat FROM "telegraf"."autogen"."cpu" WHERE cpu = 'cpu-total' ''')
|query('''SELECT 100 - mean(usage_idle) AS stat FROM "telegraf"."autogen"."cpu" WHERE cpu = 'cpu-total' ''')
.period(period)
.every(every)
.groupBy('host')
Expand All @@ -43,4 +43,4 @@ var alert = data

// Alert
alert
.log('/tmp/cpu_alert_log.txt')
.log('/tmp/cpu_alert_log.txt')
4 changes: 3 additions & 1 deletion examples/telegraf/cpu/cpu_alert_stream.tick
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ var data = stream
.measurement('cpu')
.groupBy('host')
.where(lambda: "cpu" == 'cpu-total')
|eval(lambda: 100.0 - "usage_idle")
.as('used')
|window()
.period(period)
.every(every)
|mean('usage_user')
|mean('used')
.as('stat')

// Thresholds
Expand Down

0 comments on commit ea0bf7c

Please sign in to comment.