├── .github
└── workflows
│ ├── build-release-latest.yml
│ └── build-release-stable.yml
├── .gitignore
├── LICENSE
├── README.md
├── agents
└── plugins
│ └── yum
├── build
├── Dockerfile
├── build-entrypoint.sh
└── build-modify-extension.py
└── lib
└── python3
├── cmk
└── base
│ └── cee
│ └── plugins
│ └── bakery
│ └── yum.py
└── cmk_addons
└── plugins
└── yum
├── agent_based
└── yum.py
├── checkman
└── yum
└── rulesets
├── yum_cee.py
└── yum_check_parameters.py
/.github/workflows/build-release-latest.yml:
--------------------------------------------------------------------------------
1 | name: build-release-latest
2 | on:
3 | push:
4 | tags-ignore: 'v*'
5 | branches: '*'
6 |
7 | jobs:
8 | build-package:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v4
12 | # build container image for package creation
13 | - run: /usr/bin/docker build -t ${{ github.job }} -f build/Dockerfile .
14 | # actually build .mkp file
15 | - run: /usr/bin/docker run --volume $PWD:/source ${{ github.job }}
16 | # upload results
17 | - uses: actions/upload-artifact@v4
18 | with:
19 | path: ./*.mkp
20 | retention-days: 1
21 |
22 | github-release:
23 | runs-on: ubuntu-latest
24 | needs: build-package
25 | steps:
26 | - uses: actions/download-artifact@v4
27 | - run: cd artifact && md5sum *.mkp > md5sums.txt
28 | - run: cd artifact && sha256sum *.mkp > sha256sums.txt
29 | - uses: marvinpinto/action-automatic-releases@latest
30 | with:
31 | repo_token: "${{ secrets.GITHUB_TOKEN }}"
32 | automatic_release_tag: "latest"
33 | prerelease: true
34 | files: |
35 | artifact/*
--------------------------------------------------------------------------------
/.github/workflows/build-release-stable.yml:
--------------------------------------------------------------------------------
1 | name: build-release-stable
2 | on:
3 | push:
4 | tags: 'v*'
5 |
6 | jobs:
7 | build-package:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - uses: actions/checkout@v4
11 | # build container image for package creation
12 | - run: /usr/bin/docker build -t ${{ github.job }} -f build/Dockerfile .
13 | # actually build .mkp file
14 | - run: /usr/bin/docker run --volume $PWD:/source ${{ github.job }}
15 | # upload results
16 | - uses: actions/upload-artifact@v4
17 | with:
18 | path: ./*.mkp
19 | retention-days: 1
20 |
21 | github-release:
22 | runs-on: ubuntu-latest
23 | needs: build-package
24 | steps:
25 | - uses: actions/download-artifact@v4
26 | - run: cd artifact && md5sum *.mkp > md5sums.txt
27 | - run: cd artifact && sha256sum *.mkp > sha256sums.txt
28 | - uses: marvinpinto/action-automatic-releases@latest
29 | with:
30 | repo_token: "${{ secrets.GITHUB_TOKEN }}"
31 | prerelease: false
32 | draft: true
33 | files: |
34 | artifact/*
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gitignore
2 | .idea
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # checkmk-agent-plugin-yum
2 |
3 | Checks for updates on RPM-based distributions via yum.
4 |
5 | Inspired by https://github.com/lgbff/lgb_check_mk_plugins/tree/master/aptng.
6 |
7 | See [https://docs.checkmk.com/latest/de/mkps.html#H1:Installation,%20Update%20and%20Removal](https://docs.checkmk.com/latest/de/mkps.html#H1:Installation,%20Update%20and%20Removal) for details on Check_MK package management.
8 |
9 | Now built by GitHub Actions.
--------------------------------------------------------------------------------
/agents/plugins/yum:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Set the version to be captured in newer versions of CheckMK Inventory
3 | CMK_VERSION="0.0.0"
4 |
5 | if [ -z $MK_VARDIR ]; then
6 | echo "ERROR: Unable to load ENV variables"
7 | exit 2
8 | fi
9 |
10 | BOOT_REQUIRED=no
11 | UPDATES=0
12 | SECURITY_UPDATES=0
13 | CACHE_RESULT_CHECK=$MK_VARDIR/cache/yum_result.cache
14 | CACHE_YUM_UPDATE=$MK_VARDIR/cache/yum_update.cache
15 | CACHE_PREV_UPTIME=$MK_VARDIR/cache/yum_uptime.cache
16 | LAST_UPDATE_TIMESTAMP=-1
17 |
18 | # Check which major version we are running so we can run appropriate commands
19 | if [ -f "/etc/os-release" ]; then
20 | MAJOR_VERSION=$(grep -oP '(?<=^VERSION_ID=").*(?=")' /etc/os-release | cut -d '.' -f 1)
21 | else
22 | MAJOR_VERSION=0
23 | fi
24 |
25 | # get current yum state - use cache directory contents as fingerprint
26 | YUM_CURRENT="$(ls -lR /var/cache/{yum,dnf}/ 2>/dev/null)"
27 |
28 | # check if cached listing of /var/cache/yum already exists - create empty one otherwise
29 | if [ ! -e $CACHE_YUM_UPDATE ]
30 | then
31 | touch $CACHE_YUM_UPDATE
32 | elif [ ! -f $CACHE_YUM_UPDATE ] || [ -L $CACHE_YUM_UPDATE ]
33 | then
34 | # something is wrong here...
35 | echo "ERROR: invalid cache file"
36 | exit 2
37 | else
38 | # get cached information
39 | YUM_CACHED=$(cat "$CACHE_YUM_UPDATE")
40 | fi
41 |
42 | # check if cached check result already exists and is nothing but a file
43 | if [ ! -e $CACHE_RESULT_CHECK ]
44 | then
45 | touch $CACHE_RESULT_CHECK
46 | elif [ ! -f $CACHE_RESULT_CHECK ] || [ -L $CACHE_RESULT_CHECK ]
47 | then
48 | # something is wrong here...
49 | echo "ERROR: invalid cache file"
50 | exit 2
51 | fi
52 |
53 | # check if system has rebooted - if so, remove cached check file to avoid wrong "reboot required"-state
54 | RUNNING_SECS=$(cat /proc/uptime | cut -d" " -f1 | cut -d"." -f1)
55 |
56 | # check if cache file with previously seen uptime is existing - create one otherwise
57 | if [ ! -e $CACHE_PREV_UPTIME ]
58 | then
59 | echo 0 > $CACHE_PREV_UPTIME
60 | PREV_UPTIME=0
61 | elif [ ! -f $CACHE_PREV_UPTIME ] || [ -L $CACHE_PREV_UPTIME ]
62 | then
63 | # something is wrong here...
64 | echo "ERROR: invalid cache file"
65 | exit 2
66 | else
67 | # get cached information
68 | PREV_UPTIME=$(cat "$CACHE_PREV_UPTIME")
69 | # save current uptime
70 | echo $RUNNING_SECS > $CACHE_PREV_UPTIME
71 | fi
72 |
73 | # check if current uptime is lower than cached last seen uptime to detect reboot
74 | if (( RUNNING_SECS < PREV_UPTIME ))
75 | then
76 | # remove pre-reboot cache which requires reboot
77 | rm -f $CACHE_RESULT_CHECK
78 | # create empty check cache
79 | touch $CACHE_RESULT_CHECK
80 | fi
81 |
82 | echo "<<>>"
83 |
84 | # compare current and cached yum information
85 | # Update cached data if YUM fingerprint has changed OR machine has recently rebooted.
86 | if [ "$YUM_CURRENT" != "$YUM_CACHED" ] || [ ! -s $CACHE_RESULT_CHECK ]
87 | then
88 | count=0
89 | while [ -n "$(pgrep -f "python (/usr|)/bin/(yum|dnf)")" ]; do
90 | if [ $count -eq 3 ]; then
91 | echo "ERROR: Tried to run yum for 30 secs but another yum instance was running"
92 | exit 2
93 | else
94 | ((count++))
95 | sleep 10
96 | fi
97 | done
98 | LATEST_KERNEL=$(yum -q -C --noplugins --debuglevel 0 list installed | egrep "^(vz)?kernel(|-(uek|ml|lt))\." | grep "\." | tail -n1 | awk '{print $2};')
99 | RUNNING_KERNEL=$(cat /proc/version | awk '{print $3}' | sed 's/.x86_64//g')
100 | if [[ "$RUNNING_KERNEL" == "$LATEST_KERNEL"* ]]
101 | then
102 | BOOT_REQUIRED="no"
103 | else
104 | BOOT_REQUIRED="yes"
105 | fi
106 | UPDATES=$(waitmax 25 /usr/bin/yum -C --noplugins --quiet list updates | grep "\." | cut -d' ' -f1 | wc -l || echo "-1")
107 | # check if --security is available
108 | # Updated the timeout for the initial security list validation because it takes longer than 10 seconds on many machines
109 | waitmax 25 /usr/bin/yum -C --noplugins --quiet --security list updates > /dev/null 2>&1
110 | if [ $? -eq 0 ]
111 | then
112 | SECURITY_UPDATES=$(waitmax 25 /usr/bin/yum -C --noplugins --quiet --security list updates | grep "\." | cut -d' ' -f1 | wc -l || echo "-1")
113 | else
114 | # --security not supported with this yum version
115 | # maybe the yum-plugin-security package is needed (RH 6)
116 | SECURITY_UPDATES="-2"
117 | fi
118 |
119 | # Check last time of installed Updates from yum history
120 | # Added "list all" to the history command as in situations where 20 or more RPM installs have been completed (non updates
121 | # yum commands) have been run, the script will incorrectly report that the server has never updated
122 | # Yum only lists 20 of the last actions when using only the "history" command.
123 |
124 | # Switch command based on which Major version we are running
125 | if [ "$MAJOR_VERSION" -ge 8 ]; then
126 |
127 | LAST_UPDATE_TIMESTAMP=$(/usr/bin/yum -C --quiet --noplugins history list | awk '{if(NR>2)print}' | grep ' U \|Upgrade\|Update' | cut -d '|' -f3 | head -n 1 | date -f - +"%s" || echo "-1")
128 | else
129 | LAST_UPDATE_TIMESTAMP=$(/usr/bin/yum -C --quiet --noplugins history list all| awk '{if(NR>2)print}' | grep ' U \|Upgrade\|Update' | cut -d '|' -f3 | head -n 1 | date -f - +"%s" || echo "-1")
130 | fi
131 | # Add check in case this is a brand new built machine that has had
132 | # up to date pacakges installed during build. In this case, neither
133 | # command above will have yielded a value and LAST_UPDATE_TIMESTAMP
134 | # will be empty
135 |
136 | if [ "$LAST_UPDATE_TIMESTAMP" == "" ]; then LAST_UPDATE_TIMESTAMP=-1; fi
137 |
138 |
139 | echo $BOOT_REQUIRED
140 | echo $UPDATES
141 | echo $SECURITY_UPDATES
142 | echo $LAST_UPDATE_TIMESTAMP
143 |
144 | # cache check yum
145 | # check if cached check already exists and is nothing but a file
146 | if [ -f $CACHE_YUM_UPDATE ] || [ ! -L $CACHE_YUM_UPDATE ]; then
147 | echo "$YUM_CURRENT" > $CACHE_YUM_UPDATE
148 | else
149 | # something is wrong here...
150 | echo "ERROR: invalid check cache file"
151 | exit 2
152 | fi
153 | # cache check results
154 | # check if cached check result already exists and is nothing but a file
155 | if [ -f $CACHE_RESULT_CHECK ] || [ ! -L $CACHE_RESULT_CHECK ]
156 | then
157 | echo $BOOT_REQUIRED > $CACHE_RESULT_CHECK
158 | echo $UPDATES >> $CACHE_RESULT_CHECK
159 | echo $SECURITY_UPDATES >> $CACHE_RESULT_CHECK
160 | echo $LAST_UPDATE_TIMESTAMP >> $CACHE_RESULT_CHECK
161 | else
162 | # something is wrong here...
163 | echo "ERROR: invalid check result cache file"
164 | exit 2
165 | fi
166 | else
167 | # use cache file
168 | cat $CACHE_RESULT_CHECK
169 | fi
170 |
--------------------------------------------------------------------------------
/build/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM checkmk/check-mk-raw:2.3.0-latest
2 | LABEL maintainer=henri@nagstamon.de
3 |
4 | ARG DEBIAN_FRONTEND=noninteractive
5 |
6 | # python3 and git needed for build-modify-extension.py
7 | RUN apt -y update && \
8 | apt -y install git \
9 | python3 \
10 | python3-git
11 |
12 | # scripts used need to be executable
13 | COPY build/build-entrypoint.sh build/build-modify-extension.py /
14 | RUN chmod +x /build-entrypoint.sh /build-modify-extension.py
15 |
16 | # run after original docker-entrypoint.sh
17 | CMD /build-entrypoint.sh
18 |
--------------------------------------------------------------------------------
/build/build-entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # CLI steps done like described in https://docs.checkmk.com/latest/en/mkps.html
3 |
4 | set -e
5 |
6 | SOURCE=/source
7 | CMK=/omd/sites/cmk
8 |
9 | cd $CMK/local
10 |
11 | # copy lib
12 | cp -R $SOURCE/lib/* ./lib/
13 |
14 | cd share/check_mk
15 | # copy non-lib
16 | cp -R $SOURCE/agents .
17 | # No longer needed as all in lib
18 | # cp -R $SOURCE/checkman .
19 | # cp -R $SOURCE/web .
20 |
21 | # needed for package config file creation
22 | # has to be done by site user
23 | su - cmk -c "/omd/sites/cmk/bin/mkp template yum"
24 |
25 | # otherwise /source is not accepted
26 | git config --global --add safe.directory $SOURCE
27 |
28 | # modify extension config file with correct version number, author etc.
29 | /build-modify-extension.py $SOURCE $CMK/tmp/check_mk/yum.manifest.temp
30 |
31 | # avoid error:
32 | # Error removing file /omd/sites/cmk/local/lib/python3/cmk/base/cee/plugins/bakery/yum.py: [Errno 13] Permission denied: '/omd/sites/cmk/local/lib/python3/cmk/base/cee/plugins/bakery/yum.py'
33 | chmod go+rw $CMK/local/lib/python3/cmk/base/cee/plugins/bakery
34 | chmod go+rw $CMK/local/lib/python3/cmk_addons/plugins/yum/agent_based
35 | chmod go+rw $CMK/local/lib/python3/cmk_addons/plugins/yum/checkman
36 | chmod go+rw $CMK/local/lib/python3/cmk_addons/plugins/yum/rulesets
37 |
38 | # also to be done by site user is packaging the mkp file
39 | su - cmk -c "/omd/sites/cmk/bin/mkp package $CMK/tmp/check_mk/yum.manifest.temp"
40 |
41 | # copy created extension package back into volume
42 | cp $CMK/var/check_mk/packages_local/*.mkp $SOURCE
43 |
44 | # let runner user access the created mkp file which is owned by root now
45 | chmod go+r $SOURCE/*.mkp
46 |
--------------------------------------------------------------------------------
/build/build-modify-extension.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # modify extension configuration
4 |
5 | # Include "os" to check for correct copy of the yum agent before changing lines in it below
6 | import os
7 |
8 | from pathlib import Path
9 | from pprint import pformat
10 | from sys import argv, \
11 | exit
12 |
13 | from git import (Commit,
14 | Repo,
15 | TagReference)
16 | version="0.0.0"
17 | # only do stuff if git repo path and config file path are given
18 | if len(argv) > 2:
19 | git_repo_path = argv[1]
20 | package_file_path = argv[2]
21 | if Path(package_file_path).exists() and Path(package_file_path).is_file():
22 | # get version information from git repo
23 | repo = Repo(path=git_repo_path, search_parent_directories=True)
24 |
25 | print(repo.head.commit)
26 |
27 | # if no tag is latest take repo head
28 | version_repo = next((tag for tag in repo.tags if tag.commit == repo.head.commit), repo.head.commit)
29 | if type(version_repo) == Commit:
30 | # first 8 characters of commit added to '0.0.' to get a SemVer version number
31 | version = f'0.0.{int(version_repo.hexsha[0:8], 16)}'
32 | elif type(version_repo) == TagReference:
33 | # Tag
34 | version = version_repo.name
35 | if version.startswith('v'):
36 | version = version.split('v')[1]
37 |
38 | # open package config file
39 | with open(package_file_path, 'r') as package_file:
40 | package_config = eval(package_file.read())
41 |
42 | # modify package config
43 | package_config['author'] = 'Henri Wahl'
44 | package_config['description'] = 'Checks for updates on RPM-based distributions via yum.'
45 | package_config['download_url'] = 'https://github.com/HenriWahl/checkmk-agent-plugin-yum/releases'
46 | package_config['title'] = 'YUM Update Check'
47 | package_config['version'] = version
48 | package_config['version.min_required'] = '2.0.0'
49 |
50 | # write package config file
51 | bla = pformat(package_config, indent=4)
52 | with open(package_file_path, 'w') as package_file:
53 | # nicely format config file with pformat
54 | package_file.write(pformat(package_config, indent=4))
55 | else:
56 | print(f'Package configuration file path {package_file_path} does not exist. :-(')
57 | exit(1)
58 |
59 | # New code to update version number inside the yum script itself
60 | yum_agent_path = "/omd/sites/cmk/local/share/check_mk/agents/plugins/yum"
61 | if os.path.exists(yum_agent_path):
62 | with open(yum_agent_path, "r+") as file:
63 | content = file.read().replace('CMK_VERSION="0.0.0"', f'CMK_VERSION="{version}"')
64 | file.seek(0)
65 | file.write(content)
66 | file.truncate()
67 | else:
68 | print(f"File not found: {yum_agent_path}")
69 | # End of new code
70 |
71 | else:
72 | print('Git repository or package configuration file path is missing at all. :-(')
73 | exit(1)
74 |
--------------------------------------------------------------------------------
/lib/python3/cmk/base/cee/plugins/bakery/yum.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 |
4 | from pathlib import Path
5 | from typing import Any
6 |
7 | from cmk.base.cee.plugins.bakery.bakery_api.v1 import FileGenerator, OS, Plugin, register
8 |
9 |
10 | def get_yum_files(conf: Any) -> FileGenerator:
11 | # if conf.get('deploy', 'nointerval') == 'nointerval':
12 | # return
13 | if conf.get('interval') is not None:
14 | interval=conf.get('interval')
15 | elif conf.get('deploy', 'interval')[1] is not None:
16 | interval=conf.get('deploy', 'interval')[1]
17 |
18 | yield Plugin(base_os=OS.LINUX,
19 | source=Path('yum'),
20 | interval=int(interval)
21 | )
22 |
23 | register.bakery_plugin(
24 | name='yum',
25 | files_function=get_yum_files,
26 | )
27 |
--------------------------------------------------------------------------------
/lib/python3/cmk_addons/plugins/yum/agent_based/yum.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # Check_MK YUM Plugin - Check for upgradeable packages.
4 | #
5 | # Copyright 2015, Henri Wahl
6 | # Copyright 2018, Moritz Schlarb
7 | # Copyright 2021, Marco Lenhardt
8 | # Copyright 2021, Henrik Gießel
9 | # Copyright 2023, Timo Klecker
10 | # Based on:
11 | #
12 | # Check_MK APT-NG Plugin - Check for upgradeable packages.
13 | #
14 | # Copyright 2012, Stefan Schlesinger
15 | # Copyright 2015, Karsten Schoeke
16 | #
17 | # This program is free software: you can redistribute it and/or modify
18 | # it under the terms of the GNU General Public License as published by
19 | # the Free Software Foundation, either version 3 of the License, or
20 | # (at your option) any later version.
21 | #
22 | # This program is distributed in the hope that it will be useful,
23 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | # GNU General Public License for more details.
26 | #
27 | # You should have received a copy of the GNU General Public License
28 | # along with this program. If not, see
29 | #
30 | #
31 | # Example Agent Output:
32 | #
33 | # <<>>
34 | # yes
35 | # 32
36 | # 4
37 | # 1626252300
38 |
39 | # Import the ability to manipulate and handle times in python
40 | from time import time
41 |
42 | # Import the ability to set certain types of variable/object
43 | from typing import Dict, List, NamedTuple, Optional
44 |
45 | # Import CheckMK specific libraries
46 | from cmk.gui.i18n import _
47 | #from cmk.agent_based.v2.type_defs import (
48 | # StringTable,
49 | #)
50 | from cmk.agent_based.v2 import (
51 | # register,
52 | CheckResult,
53 | CheckPlugin,
54 | Service,
55 | State,
56 | Metric,
57 | render,
58 | AgentSection,
59 | Result,
60 | )
61 |
62 |
63 |
64 |
65 |
66 | # Set some default values for the plugin
67 | class Section(NamedTuple):
68 | reboot_required: Optional[bool]
69 | packages: int = -1
70 | security_packages: int = -1
71 | last_update_timestamp: int = -1
72 | error_message: Optional[str] = None
73 |
74 | #### Define the section that processes the output received from the
75 | #### agent within the
76 | # <<>> section. This is called because we register the "yum"
77 | # agent section using the API "register" namespace
78 | def yum_parse(string_table: List[List[str]]) -> Section:
79 | # If no results are determined to have been parsed from the agent
80 | # <<>> section, flag it
81 | if string_table[0][0] == 'ERROR:':
82 | return Section(error_message=" ".join(string_table[0][1:]))
83 |
84 | # Assess the validity of the "reboot_required" section - default to
85 | # "None" if there is an error
86 | reboot_required = None
87 | try:
88 | if string_table[0][0] in ('yes', 'no'):
89 | reboot_required = string_table[0][0] == 'yes'
90 | except KeyError:
91 | pass
92 |
93 | packages = None
94 | security_packages = None
95 | last_update_timestamp = None
96 | try:
97 | packages = int(string_table[1][0])
98 | security_packages = int(string_table[2][0])
99 | last_update_timestamp = int(string_table[3][0])
100 | except KeyError:
101 | pass
102 |
103 | # Return the processesed values if there has not been an error
104 | return Section(
105 | reboot_required,
106 | packages,
107 | security_packages,
108 | last_update_timestamp)
109 |
110 | #### Register the agent section we want to be referring to
111 | agent_section_yum=AgentSection(
112 | # Using the apiv1 "register" namespace we register the "yum" agent
113 | # section and it's subsequent processing within this python script
114 | # by defining the "parse_funtcion" as "yum_parse"
115 | name="yum",
116 | parse_function=yum_parse,
117 | )
118 |
119 | #### Define what we do when discovery is run
120 | def discovery_yum(section: Section):
121 | yield Service()
122 |
123 |
124 | #### Define the check function that is called by the registered
125 | #### register.check_plugin section
126 | def check_yum(params: Dict[str, int], section: Section):
127 | # Handle error message from agent which is set if the agent output
128 | # is not a correct format
129 | if section.error_message:
130 | yield Result(state=State.UNKNOWN, summary=section.error_message)
131 | return
132 | # Check the status returned from the agent script
133 | # Added additional checks to cover off a broader range of
134 | # possibilities and ensure that a value is returned (for
135 | # the perf-o-meter) even when no updates are available
136 |
137 | #### Check the status of "packages" (which is the "total updates
138 | #### available")
139 | # First check if there was an error returned (-1) where the yum
140 | # command failed
141 | if section.packages < 0:
142 | yield Result(state=State.UNKNOWN, summary='No package information available')
143 | # Then check if there are "no updates of which none are security
144 | # updates" but DO return a metric value of zero instead of not
145 | # having a metric value at all
146 | elif section.packages == 0 and section.security_packages == 0:
147 | yield Result(state=State.OK, summary='All packages are up to date')
148 | yield Metric(name="normal_updates", value=section.packages)
149 | # If there are "any" updates available report the number of updates
150 | elif section.packages > 0:
151 | yield Result(state=State(params.get("normal", 0)), summary=f"{section.packages} updates available")
152 | yield Metric(name="normal_updates", value=section.packages)
153 | # If there are no updates available, but we haven't been able to
154 | # check security updates, still return a metric value of zero
155 | elif section.packages == 0:
156 | yield Result(state=State.OK, summary=f"{section.packages} updates available")
157 | yield Metric(name="normal_updates", value=section.packages)
158 |
159 | # Check the status of the returned number of updates that are security updates including
160 | # error condition and if there are no updates or the security updates check is not possible
161 | # First check if ANY updates were flagged as security updates and report the metric
162 | if section.security_packages > 0:
163 | yield Result(state=State(params.get("security", 0)), summary=f"{section.security_packages} security updates available")
164 | yield Metric(name="security_updates", value=section.security_packages)
165 | # If there are no updates available, report this
166 | elif section.security_packages == 0:
167 | yield Result(state=State.OK, summary=f"{section.security_packages} security updates available")
168 | yield Metric(name="security_updates", value=section.security_packages)
169 | # If the agent reported that security update was not available,
170 | # return this with a report of 0 updates
171 | elif section.security_packages == -2:
172 | yield Result(state=State.OK, summary='Security update check not available')
173 | yield Metric(name="security_updates", value=0)
174 | # If the security update check failed with an error,
175 | # report this AND a value of zero
176 | elif section.security_packages == -1:
177 | yield Metric(name="security_updates", value=0)
178 | yield Result(state=State.OK, summary='Security update failed')
179 |
180 |
181 | #### Interpret the timestamp that is returned for when the host was
182 | #### last updated
183 | # If the timestamp is less than zero, report that there is no
184 | # valid time stamp
185 | if section.last_update_timestamp < 0:
186 | yield Result(
187 | state=State(params.get("last_update_state", 0)),
188 | summary=f"{section.last_update_timestamp} Time of last update could not be found")
189 | yield Metric(name="last_update_timestamp", value=section.last_update_timestamp)
190 | # If not a value less than 0, assess the timestamp by first
191 | # grabbing all the relevant parameters
192 | elif section.last_update_timestamp > 0:
193 | # Get the default or WATO config state from within CheckMK api
194 | level = params.get("last_update_state", 0)
195 | # Get the threshold for the time we are allowed to be out by
196 | # from default or WATO
197 | last_update_time_diff = params.get("last_update_time_diff", (60*24*60*60))
198 | # Get current time so we can assess the age of OUR timestamp
199 | current_timestamp = int(time())
200 | # Delta the supplied timestamp and compare it to the target
201 | # from the default or WATO. If the last update delta is less
202 | # than the configured threshold, report OK
203 | if current_timestamp - section.last_update_timestamp < last_update_time_diff:
204 | yield Result(
205 | state=State.OK,
206 | summary=f"Last Update was run at {render.datetime(section.last_update_timestamp)}")
207 | # If the last update delta is outside of the configured
208 | # threshold but the number of configured packages is 0 then
209 | # still report all is OK, is there is nothing we could possibly
210 | # have updated
211 | elif current_timestamp - section.last_update_timestamp > last_update_time_diff and section.packages == 0:
212 | yield Result(
213 | state=State.OK,
214 | summary=f"Last Update was too long ago at {render.datetime(section.last_update_timestamp)} but there are no pending updates")
215 | # Otherwise, report the level that is configured in default or
216 | # WATO for being outside of the required delta time
217 | else:
218 | yield Result(
219 | state=State(level),
220 | summary=f"Last Update was too long ago at {render.datetime(section.last_update_timestamp)} and there are pending updates")
221 |
222 | #### Assess the "reboot_required" parameters
223 | if section.reboot_required:
224 | # fallback for < 2.0.6
225 | # If the reported value has been anything other than yes or no
226 | # then the value will be "None" as defined in the yum_parse
227 | # section if it is then report an error
228 | if params is None:
229 | level = 2
230 | else:
231 | level = params["reboot_req"]
232 | yield Result(state=State(level), summary="reboot required")
233 |
234 |
235 | #### Use the API v1 "register" namspace to assign the various
236 | #### processing sections of this python file to handle that various
237 | #### data,
238 | # set default parameters and the general details of the service.
239 | check_plugin_yum=CheckPlugin(
240 | # Set the unique name of the plugin
241 | name='yum',
242 | # Set the service name that is created on a host
243 | service_name=_('YUM Updates'),
244 | # Set what should be called when discovery is run - in this case,
245 | # call "discovery_yum" that simply creates a new service
246 | discovery_function=discovery_yum,
247 | # Set what the "check" function is - in this case, to check the
248 | # output from the agent once it has been processed by
249 | # "yum_parse" we will run "check_yum"
250 | check_function=check_yum,
251 | # Specify which agent section we need to read
252 | sections=["yum"],
253 | # specify which ruleset to grab parameters from
254 | check_ruleset_name="yum",
255 | # Set the default parameters (which match the ones defined in the
256 | # WATO ruleset in yum_check_parameters.py)
257 | check_default_parameters={
258 | "reboot_req": 2,
259 | "normal": 1,
260 | "security": 2,
261 | "last_update_state": 0,
262 | "last_update_time_diff": (60*24*60*60),
263 | },
264 | )
265 |
--------------------------------------------------------------------------------
/lib/python3/cmk_addons/plugins/yum/checkman/yum:
--------------------------------------------------------------------------------
1 | title: Check for updates via yum
2 | agents: linux
3 | author: Henri Wahl , based on work of Karsten Scgoeke , Stefan Schlesinger
4 | catalog: generic
5 | license: GPL
6 | distribution: check_mk
7 | description:
8 | This check checks for available updates via {yum} on RedHat and
9 | this derivates. You need to install the plugin {yum}
10 | into the {plugins} directory of your agent.
11 |
12 | The check gets critical if kernel updates require a reboot.
13 | This state can be overriden via a WATO rule.
14 | It gets warning state if there are any updates available.
15 |
16 | inventory:
17 | One service will be created for each system where the {yum}
18 | plugin produces a non-empty output.
19 |
20 |
--------------------------------------------------------------------------------
/lib/python3/cmk_addons/plugins/yum/rulesets/yum_cee.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 | from collections.abc import Mapping
4 |
5 | from cmk.rulesets.v1.form_specs import (
6 | DictElement,
7 | Dictionary,
8 | # DefaultValue,
9 | # SingleChoice,
10 | # SingleChoiceElement,
11 | # Integer,
12 | # InputHint,
13 | CascadingSingleChoice,
14 | CascadingSingleChoiceElement,
15 | FixedValue,
16 | TimeSpan,
17 | TimeMagnitude,
18 | # SimpleLevels,
19 | )
20 | from cmk.rulesets.v1.rule_specs import AgentConfig, Topic, Title, Help
21 |
22 | def _migrateInt(value: object) -> Mapping[str, object]:
23 | if value is not None:
24 | if 'interval' in value:
25 | match value["interval"]:
26 | case _ if value["interval"] >= 0:
27 | return {'deploy': ('interval', float(value["interval"]))}
28 | case None:
29 | return {'deploy': ('interval', 77.0)}
30 | else:
31 | return value
32 | else:
33 | return {'deploy': 'nointerval'}
34 |
35 |
36 | def _parameter_form_yum_bakery() -> Dictionary:
37 | return Dictionary(
38 | migrate=_migrateInt,
39 | title=Title('Deploy the Yum plugin'),
40 | help_text=Help('This will deploy the agent plugin Yum. This will activate the '
41 | 'check Yum on redHat based hosts and monitor pending normal and security updates.'
42 | ),
43 | elements={
44 | "deploy": DictElement(
45 | required=True,
46 | parameter_form=CascadingSingleChoice(
47 | title=Title('Deployment options for the Yum plugin.'),
48 | #prefill=DefaultValue("interval"),
49 | help_text=Help('Determines how the the Yum plugin will run on a deployed agent or disables it on an deployed agent'),
50 | elements=[
51 | CascadingSingleChoiceElement(
52 | name="interval",
53 | title=Title("Deploy the Yum plugin"),
54 | parameter_form=TimeSpan(
55 | title=Title('Interval that the plugin runs at on the client'),
56 | help_text=Help('Determines how often that the Yum plugin will run on a deployed agent.'),
57 | displayed_magnitudes=[TimeMagnitude.SECOND, TimeMagnitude.MINUTE, TimeMagnitude.HOUR, TimeMagnitude.DAY],
58 | #prefill=DefaultValue(129600.0),
59 | ),
60 | ),
61 | CascadingSingleChoiceElement(
62 | name="nointerval",
63 | title=Title("Do not deploy the Yum plugin"),
64 | parameter_form=FixedValue(value=None),
65 | )
66 | ]
67 | ),
68 | ),
69 | },
70 | )
71 |
72 |
73 | rule_spec_yum_bakery = AgentConfig(
74 | title=Title('YUM plugin'),
75 | name='yum',
76 | parameter_form=_parameter_form_yum_bakery,
77 | topic=Topic.APPLICATIONS,
78 | help_text=Help('This will deploy the agent plugin Yum '
79 | 'for checking patch status.'),
80 | )
81 |
--------------------------------------------------------------------------------
/lib/python3/cmk_addons/plugins/yum/rulesets/yum_check_parameters.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 | #
4 | # 2021 Henrik Gießel
5 | # 2018 Moritz Schlarb
6 | # 2015 Henri Wahl
7 | # 2013 Karsten Schoeke karsten.schoeke@geobasis-bb.de
8 |
9 | from cmk.gui.i18n import _
10 | from cmk.gui.valuespec import (
11 | Dictionary,
12 | MonitoringState,
13 | Age,
14 | )
15 |
16 | from cmk.gui.plugins.wato.utils import (
17 | rulespec_registry,
18 | CheckParameterRulespecWithoutItem,
19 | RulespecGroupCheckParametersOperatingSystem,
20 | )
21 |
22 |
23 | def _parameter_valuespec_yum():
24 | return Dictionary(
25 | elements=[
26 | (
27 | "reboot_req",
28 | MonitoringState(
29 | title=_("State when a reboot is required"),
30 | default_value=2,
31 | )
32 | ),
33 | (
34 | "normal",
35 | MonitoringState(
36 | title=_("State when normal updates are available"),
37 | default_value=1,
38 | )
39 | ),
40 | (
41 | "security",
42 | MonitoringState(
43 | title=_("State when security updates are available"),
44 | default_value=2,
45 | )
46 | ),
47 | (
48 | "last_update_time_diff",
49 | Age(
50 | title=_("Max Time since last last run update (Default 60 Days)"),
51 | default_value=(60*24*60*60),
52 | )
53 | ),
54 | (
55 | "last_update_state",
56 | MonitoringState(
57 | title=_("Change State based on last run update (default OK)"),
58 | default_value=0,
59 | )
60 | ),
61 | ],
62 | )
63 |
64 |
65 | rulespec_registry.register(
66 | CheckParameterRulespecWithoutItem(
67 | check_group_name="yum",
68 | group=RulespecGroupCheckParametersOperatingSystem,
69 | parameter_valuespec=_parameter_valuespec_yum,
70 | title=lambda: _("YUM Update check"),
71 | ))
72 |
--------------------------------------------------------------------------------