processes: Fix zombie process procfs panic

fixes #822
This commit is contained in:
Cameron Sparr 2016-03-09 22:55:26 +01:00 committed by Michele Fadda
parent 2cf5685519
commit 3fcadc3e09
2 changed files with 9 additions and 4 deletions

View File

@ -65,7 +65,7 @@ func (p *Processes) Gather(acc telegraf.Accumulator) error {
func getEmptyFields() map[string]interface{} {
fields := map[string]interface{}{
"blocked": int64(0),
"zombie": int64(0),
"zombies": int64(0),
"stopped": int64(0),
"running": int64(0),
"sleeping": int64(0),
@ -105,7 +105,7 @@ func (p *Processes) gatherFromPS(fields map[string]interface{}) error {
// Also known as uninterruptible sleep or disk sleep
fields["blocked"] = fields["blocked"].(int64) + int64(1)
case 'Z':
fields["zombie"] = fields["zombie"].(int64) + int64(1)
fields["zombies"] = fields["zombies"].(int64) + int64(1)
case 'T':
fields["stopped"] = fields["stopped"].(int64) + int64(1)
case 'R':

View File

@ -40,10 +40,11 @@ func TestFromPS(t *testing.T) {
require.NoError(t, err)
fields := getEmptyFields()
fields["blocked"] = int64(1)
fields["blocked"] = int64(4)
fields["zombies"] = int64(1)
fields["running"] = int64(4)
fields["sleeping"] = int64(34)
fields["total"] = int64(39)
fields["total"] = int64(43)
acc.AssertContainsTaggedFields(t, "processes", fields, map[string]string{})
}
@ -139,6 +140,10 @@ S
S+
S+
Ss
L
U
Z
D
S+
`