9.5.6. plugins/plugin_sccm.pyΒΆ

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
from collections import OrderedDict

VERSION = "1.1.0"
"""Version of this set of plugin definitions."""

MINIMUM_THAT_VERSION = "1.1.0"
"""Minimum THAT version required to run these plugin definitions."""

NAME = "sccm"
PRIORITY = 4
ANALYZE_DATA = OrderedDict()
GET_TANIUM_DATA = OrderedDict()

GET_INTERNET_DATA = [
]

# ask the question 'Get SCCM Client Communication Days Old from all machines'
# and store results in "sccmcomm.csv"
GET_TANIUM_DATA["sccmcomm.csv"] = {
    "filters": [],
    "sensors": ["SCCM Client Communication Days Old"],
}

# ask the question 'Get SCCM Client Installed from all machines'
# and store results in "sccminstalled.csv"
GET_TANIUM_DATA["sccminstalled.csv"] = {
    "filters": [],
    "sensors": ["SCCM Client Installed"],
}

# ask the question 'Get SCCM Client Running from all machines'
# and store results in "sccmrunning.csv"
GET_TANIUM_DATA["sccmrunning.csv"] = {
    "filters": [],
    "sensors": ["SCCM Client Running"],
}

# ask the question 'Get SCCM Client Version from all machines'
# and store results in "sccmversion.csv"
GET_TANIUM_DATA["sccmversion.csv"] = {
    "filters": [],
    "sensors": ["SCCM Client Version"],
}

# ask the question 'Get SCCM WMI Health from all machines'
# and store results in "sccmwmi.csv"
GET_TANIUM_DATA["sccmwmi.csv"] = {
    "filters": [],
    "sensors": ["SCCM WMI Health"],
}

# ask the question 'Get Online from all machines'
# and store results in "isonline.csv"
GET_TANIUM_DATA["isonline.csv"] = {
    "filters": ["Is Windows, that contains:True"],
    "sensors": ["Online"],
}


ANALYZE_DATA["extra_clean_values"] = """
# set extra clean values to be used for df cleaning

result = ["[no RESULTS]", "::SCCM Not Installed::", "None", "SCCM or WMI error"]
"""

ANALYZE_DATA["cleaned_isonline_df"] = """
# clean out noise from isonline.csv

csv = "isonline.csv"
df = self.load_csv_as_df(csv)
extra_clean_values = self.get_result("extra_clean_values")

result = self.clean_df(df, columns=["Online"], add_values=extra_clean_values)
"""

ANALYZE_DATA["cleaned_sccmwmi_df"] = """
# clean out noise from sccmwmi.csv

csv = "sccmwmi.csv"
df = self.load_csv_as_df(csv)
extra_clean_values = self.get_result("extra_clean_values")

result = self.clean_df(df, columns=["SCCM WMI Health"], add_values=extra_clean_values)
"""

ANALYZE_DATA["cleaned_sccmversion_df"] = """
# clean out noise from sccmversion.csv

csv = "sccmversion.csv"
df = self.load_csv_as_df(csv)
extra_clean_values = self.get_result("extra_clean_values")

result = self.clean_df(df, columns=["Version"], add_values=extra_clean_values)
"""

ANALYZE_DATA["cleaned_sccmrunning_df"] = """
# clean out noise from sccmrunning.csv

csv = "sccmrunning.csv"
df = self.load_csv_as_df(csv)
extra_clean_values = self.get_result("extra_clean_values")

result = self.clean_df(df, columns=["SCCM Client Running"], add_values=extra_clean_values)
"""

ANALYZE_DATA["cleaned_sccminstalled_df"] = """
# clean out noise from sccminstalled.csv

csv = "sccminstalled.csv"
df = self.load_csv_as_df(csv)
extra_clean_values = self.get_result("extra_clean_values")

result = self.clean_df(df, columns=["SCCM Client Installed"], add_values=extra_clean_values)
"""

ANALYZE_DATA["cleaned_sccmcomm_df"] = """
# clean out noise from sccmcomm.csv

csv = "sccmcomm.csv"
df = self.load_csv_as_df(csv)
extra_clean_values = self.get_result("extra_clean_values")

result = self.clean_df(df, columns=["SCCM Client Communication Days Old"], add_values=extra_clean_values)
"""

ANALYZE_DATA["total_targets"] = """
# SCCM Targets

df = self.get_result("cleaned_isonline_df")

result = df['Count'].sum()
"""

ANALYZE_DATA["max_days_old"] = """
# max days old comm
# remove all non numeric values and get max days old

df = self.get_result("cleaned_sccmcomm_df")
col = 'SCCM Client Communication Days Old'

df = df.drop(col, axis=1).join(df[col].apply(pandas.to_numeric, errors='coerce'))
df = df[~df[col].isnull().apply(numpy.any, axis=0)]

if (len(df) > 0):
    result = int(df[col].max())
else:
    result = 0
"""

ANALYZE_DATA["comm_ep"] = """
# Number of Endpoints with Comm Problems

df = self.get_result("cleaned_sccmcomm_df")
col = 'SCCM Client Communication Days Old'

result = self.force_int(df.loc[df[col] != '0', 'Count'].sum(), 0)
"""

ANALYZE_DATA["sccm_not_installed"] = """
# Number of Endpoints SCCM Not Installed

df = self.get_result("cleaned_sccminstalled_df")
col = 'SCCM Client Installed'

result = df.loc[df[col] != 'Yes', 'Count'].sum()
"""

ANALYZE_DATA["not_run_ep"] = """
# Number of Endpoints Not Running SCCM

df = self.get_result("cleaned_sccmrunning_df")
col = 'SCCM Client Running'

result = df.loc[df[col] != 'Yes', 'Count'].sum()
"""

ANALYZE_DATA["distinct_versions"] = """
# Number of Distinct SCCM Versions

df = self.get_result("cleaned_sccmversion_df")
col = 'Version'

result = len(df[col])
"""

ANALYZE_DATA["latest_version"] = """
# Latest SCCM Version

df = self.get_result("cleaned_sccmversion_df")
col = 'Version'

result = df[col].max()
"""

ANALYZE_DATA["old_versions_ep"] = """
#number of endpoints running an old version of SCCM

df = self.get_result("cleaned_sccmversion_df")
max_ver = self.get_result("latest_version")
col = 'Version'

result = df.loc[df[col] != max_ver, 'Count'].sum()
"""

ANALYZE_DATA["wmi_err"] = """
# WMI Errors

df = self.get_result("cleaned_sccmwmi_df")
col = 'SCCM WMI Health'

result = self.force_int(df.loc[df[col] != 'OK', 'Count'].sum(), 0)
"""

ANALYZE_DATA["total_remediation"] = """
# Total SCCM Remediation

items = [
    self.force_int(self.get_result("wmi_err")),
    self.force_int(self.get_result("old_versions_ep")),
    self.force_int(self.get_result("not_run_ep")),
    self.force_int(self.get_result("sccm_not_installed")),
    self.force_int(self.get_result("comm_ep")),
]

result = sum(items)
"""